receipt.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. <?php
  2. Doo::loadCore ( 'db/DooModel' );
  3. class receipt extends DooModel {
  4. public $rid;
  5. public $accountItem;
  6. public $loanItem;
  7. public $staff;
  8. public $sum;
  9. public $date;
  10. public $pastDate;
  11. public $executeDate;
  12. public $loanDate;
  13. public $cid;
  14. public $status;
  15. public $Rtype;
  16. public $isBK;
  17. public $loanSum;
  18. public $loanRid;
  19. public $reviseDetail;
  20. public $revisePrice;
  21. public $receiptOrder;
  22. public $verify;
  23. public $verifyStaff;
  24. public $executeCopy;
  25. public $executeStaff;
  26. public $verifyBreakup;
  27. public $nowStaff;
  28. public $explanation;
  29. public $implementOpinions;
  30. public $notice;
  31. public $amount;
  32. public $remittanceName;
  33. public $bankName;
  34. public $bankNumber;
  35. public $coupletNumber;
  36. public $remittanceBankType;
  37. public $trainId;
  38. public $trainLoanRid;
  39. public $invoiceTrainId;
  40. public $paidStatus;
  41. public $statusTrain;
  42. public $receiptClass;
  43. public $itinerary;
  44. public $itinerary2;
  45. public $iti2New;
  46. public $_table = 'CLD_receipt';
  47. public $_primarykey = 'rid';
  48. public $_fields = array (
  49. 'aid',
  50. 'accountItem',
  51. 'staff',
  52. 'sum',
  53. 'date',
  54. 'pastDate',
  55. 'cid',
  56. 'status',
  57. 'reviseDetail',
  58. 'revisePrice',
  59. 'verify',
  60. 'verifyStaff',
  61. 'nowStaff',
  62. 'receiptOrder',
  63. 'explanation',
  64. 'notice',
  65. 'Rtype',
  66. 'loanItem',
  67. 'loanRid',
  68. 'loanSum',
  69. 'implementOpinions',
  70. 'isBK',
  71. 'executeCopy',
  72. 'executeStaff',
  73. 'verifyBreakup',
  74. 'executeDate',
  75. 'amount',
  76. 'loanDate',
  77. 'remittanceName',
  78. 'bankName',
  79. 'bankNumber',
  80. 'coupletNumber',
  81. 'remittanceBankType',
  82. 'trainId',
  83. 'trainLoanRid',
  84. 'invoiceTrainId' ,
  85. 'paidStatus',
  86. 'statusTrain',
  87. 'receiptClass',
  88. 'itinerary',
  89. 'itinerary2',
  90. );
  91. /*
  92. $this->query($sql, array_merge( $opt['param'], $where_values));
  93. */
  94. /**
  95. * 获得培训班结算未收款
  96. */
  97. function getReceiptTrainByPaid($un=0,$limit=5,$cid=''){
  98. if (empty($cid)){
  99. return array();
  100. }
  101. $sql = "select b.* ,a.invoiceTrainId,a.rid,a.executeDate
  102. from " . $this->_table . " as a left JOIN CLD_receiptTraining as b on (a.trainId=b.rtid)
  103. where a.status not in (3,4,5) and a.Rtype=3 and a.trainId!=0 and invoiceTrainId!=0 and a.cid in (".$cid.") and paidStatus=".$un." limit ".$limit;
  104. $query = Doo::db ()->query ( $sql );
  105. $result = $query->fetchAll ();
  106. Doo::loadModel ( 'invoiceTraining' );
  107. $invoiceTraining = new invoiceTraining ();
  108. Doo::loadClass ( 'XDeode' );
  109. $XDeode = new XDeode ( 7 );
  110. Doo::loadModel ( 'RItem' );
  111. $RItem = new RItem ();
  112. Doo::loadModel ( 'RILecturer' );
  113. $RILecturer = new RILecturer ();
  114. Doo::loadModel ( 'accountItem' );
  115. $accountItem = new accountItem ();
  116. foreach ($result as $key=>$value){
  117. $result[$key]['ridKey']= $XDeode->encode ( $value ['rid'] );
  118. $result[$key]['iTrain']=$invoiceTraining->getInvoiceTrainingByItid ( $value ['invoiceTrainId'] );
  119. $result[$key]['iTrain']['receivablesAmount']=sprintf ( "%.2f",$result[$key]['iTrain']['invoiceTotalAmount']-$result[$key]['iTrain']['invoiceArriveAmount']);
  120. $RItemList = $RItem->getRItemByRid ( $value ['rid'] );
  121. $RILecturerList = $RILecturer->getRILecturerByRid ( $value ['rid'] );
  122. // 支出项金额详情
  123. $expendList= $accountItem->getTrainingDetail ( $RItemList, $RILecturerList );
  124. $result[$key]['iTrain']['expendAmount']=sprintf ( "%.2f",$expendList['total']);
  125. $result[$key]['iTrain']['profit']= sprintf ( "%.2f",$result[$key]['iTrain']['invoiceTotalAmount']-$expendList['total']);
  126. }
  127. return $result;
  128. }
  129. /**
  130. * 获得所有培训班结算
  131. */
  132. function getReceiptTrainByPaidAll($un='',$cid='',$dateSql='',$limit='0,18',$cidString="",$where=""){
  133. $psSql='';
  134. if(!empty($un)){
  135. $psSql=" and paidStatus=".$un." ";
  136. }
  137. $cidSql="";
  138. if(!empty($cid)){
  139. $cidSql=" and a.cid=".$cid." ";
  140. }elseif(!empty($cidString)){
  141. $cidSql=" and a.cid in (".$cidString.") ";
  142. }else{
  143. return array();
  144. }
  145. $sql = "select b.* ,a.invoiceTrainId,a.rid
  146. from " . $this->_table . " as a left JOIN CLD_receiptTraining as b on (a.trainId=b.rtid)
  147. ".$where.$psSql.$cidSql.$dateSql." limit ".$limit;
  148. $query = Doo::db ()->query ( $sql );
  149. $result = $query->fetchAll ();
  150. Doo::loadModel ( 'invoiceTraining' );
  151. $invoiceTraining = new invoiceTraining ();
  152. Doo::loadClass ( 'XDeode' );
  153. $XDeode = new XDeode ( 7 );
  154. Doo::loadModel ( 'RItem' );
  155. $RItem = new RItem ();
  156. Doo::loadModel ( 'RILecturer' );
  157. $RILecturer = new RILecturer ();
  158. Doo::loadModel ( 'accountItem' );
  159. $accountItem = new accountItem ();
  160. foreach ($result as $key=>$value){
  161. $result[$key]['ridKey']= $XDeode->encode ( $value ['rid'] );
  162. $result[$key]['iTrain']=$invoiceTraining->getInvoiceTrainingByItid ( $value ['invoiceTrainId'] );
  163. $result[$key]['iTrain']['receivablesAmount']=sprintf ( "%.2f",$result[$key]['iTrain']['invoiceTotalAmount']-$result[$key]['iTrain']['invoiceArriveAmount']);
  164. $RItemList = $RItem->getRItemByRid ( $value ['rid'] );
  165. $RILecturerList = $RILecturer->getRILecturerByRid ( $value ['rid'] );
  166. // 支出项金额详情
  167. $expendList= $accountItem->getTrainingDetail ( $RItemList, $RILecturerList );
  168. $result[$key]['iTrain']['expendAmount']=sprintf ( "%.2f",$expendList['total']);
  169. $result[$key]['iTrain']['profit']= sprintf ( "%.2f",$result[$key]['iTrain']['invoiceTotalAmount']-$expendList['total']);
  170. //利润
  171. $result[$key]['iTrain']['companyProfit']=sprintf ( "%.2f",$result[$key]['iTrain']['invoiceTotalAmount']*0.4);
  172. $result[$key]['iTrain']['categoryProfit']=sprintf ( "%.2f",$result[$key]['iTrain']['invoiceTotalAmount']*0.6);
  173. }
  174. return $result;
  175. }
  176. /**
  177. * 获得培训班结算的合计金额
  178. * @param string $itid 发票培训班ID
  179. */
  180. function getReceiptTrainSumByItid($sql=""){
  181. Doo::loadModel ( 'invoice' );
  182. $invoice = new invoice ();
  183. $query = Doo::db ()->query ( $sql );
  184. $result = $query->fetchAll ();
  185. //组合发票培训班ID
  186. $itidList = array ();$ridList=array();
  187. foreach ($result as $key=>$value){
  188. array_push ( $itidList, $value ['invoiceTrainId'] );
  189. array_push ( $ridList, $value ['rid'] );
  190. }
  191. $itidList = array_unique($itidList);
  192. $itidString=implode ( ',', $itidList );
  193. $ridList = array_unique($ridList);
  194. $ridString=implode ( ',', $ridList );
  195. //发票培训班ID-整合出开票金额合计-入账金额合计
  196. $invoiceList = $invoice->sumOfinvoiceTrain ( $itidString );//开票合计-开票收入
  197. $invoiceRecelvablesList = $invoice->sumOfInvoiceRecelvablesTrain ( $itidString );//入账合计-实际收入
  198. $invoiceTotalAmount=0;//开票金额合计
  199. $receivablesTotalAmount=0;//入账金额合计
  200. foreach ( $invoiceList as $k => $v ) {
  201. $invoiceTotalAmount+=$v ['invoicePrice'];
  202. }
  203. foreach ( $invoiceRecelvablesList as $i => $o ) {
  204. $receivablesTotalAmount+=$o ['receivablesPrice'];
  205. }
  206. //未收款
  207. $unReceivablesTotalAmount=sprintf ( "%.2f",$invoiceTotalAmount-$receivablesTotalAmount);
  208. //获得支出金额合计
  209. Doo::loadModel ( 'RItem' );
  210. $RItem = new RItem ();
  211. Doo::loadModel ( 'RILecturer' );
  212. $RILecturer = new RILecturer ();
  213. $RItemPrice=$RItem->getRItemPriceByRids($ridString);
  214. $RILecturerPrice=$RILecturer->getRILecturerPriceByRids($ridString);
  215. $payPrice=$RItemPrice+$RILecturerPrice;//支出金额合计
  216. $profit=$invoiceTotalAmount-$payPrice;
  217. return array('invoiceTotalAmount'=>sprintf ( "%.2f",$invoiceTotalAmount),
  218. 'payPrice'=>sprintf ( "%.2f",$payPrice),
  219. 'profit'=>sprintf ( "%.2f",$profit),
  220. 'unReceivablesTotalAmount'=>$unReceivablesTotalAmount,
  221. );
  222. }
  223. /**
  224. * @param string $sql
  225. */
  226. function initReceiptTrainRevenue($sql=""){
  227. Doo::loadModel ( 'invoice' );
  228. $invoice = new invoice ();
  229. $query = Doo::db ()->query ( $sql );
  230. $result = $query->fetchAll ();
  231. foreach ($result as $key=>$value){
  232. $invoiceList = $invoice->sumOfinvoiceTrain ( $value['invoiceTrainId'] );//开票合计-开票收入
  233. $invoiceRecelvablesList = $invoice->sumOfInvoiceRecelvablesTrain ( $value['invoiceTrainId'] );//入账合计-实际收入
  234. $invoiceTotalAmount=0;//开票金额合计
  235. $receivablesTotalAmount=0;//入账金额合计
  236. foreach ( $invoiceList as $k => $v ) {
  237. $invoiceTotalAmount+=$v ['invoicePrice'];
  238. }
  239. foreach ( $invoiceRecelvablesList as $i => $o ) {
  240. $receivablesTotalAmount+=$o ['receivablesPrice'];
  241. }
  242. //echo $invoiceTotalAmount.'-'.$receivablesTotalAmount.'</br>';
  243. if ($invoiceTotalAmount<=$receivablesTotalAmount){
  244. $itemData = array (
  245. 'rid' => $value['rid'],
  246. 'paidStatus' => 1,
  247. );
  248. $this->setReceiptByCondition($itemData);
  249. }
  250. }
  251. }
  252. /**
  253. * 获得培训班 年营收图表
  254. */
  255. function getReceiptTrainByYearChart($cid='',$year=''){
  256. if (empty($cid)){
  257. return array();
  258. }
  259. if(empty($year)){
  260. $year=date("Y");
  261. }
  262. $sql = "select GROUP_CONCAT(rid) as rid,GROUP_CONCAT(invoiceTrainId) as invoiceTrainId,date_format(date,\"%m\") as month
  263. from " . $this->_table . "
  264. where status not in (3,4,5) and Rtype=3 and trainId!=0 and invoiceTrainId!=0 and cid in (".$cid.") and paidStatus=1 and Year(date) =".$year."
  265. GROUP BY Month(date)";
  266. //
  267. $query = Doo::db ()->query ( $sql );
  268. $result = $query->fetchAll ();
  269. Doo::loadModel ( 'RItem' );
  270. $RItem = new RItem ();
  271. Doo::loadModel ( 'RILecturer' );
  272. $RILecturer = new RILecturer ();
  273. Doo::loadModel ( 'invoice' );
  274. $invoice = new invoice ();
  275. $MonthPriceList=array();
  276. foreach ($result as $key=>$value){
  277. //获得支出金额总和
  278. $RItemPrice=$RItem->getRItemPriceByRids($value['rid']);
  279. $RILecturerPrice=$RILecturer->getRILecturerPriceByRids($value['rid']);
  280. $RIprice=$RItemPrice+$RILecturerPrice;//支出金额合计
  281. //收款金额总和
  282. $ITprice=$invoice->getInvoicePriceByIids($value['invoiceTrainId']);
  283. $MonthPriceList[$value['month']]=array(
  284. 'RIprice'=>$RIprice,
  285. 'ITprice'=>$ITprice
  286. );
  287. }
  288. return $MonthPriceList;
  289. }
  290. function receiptByYear($dateCondition, $sid) {
  291. $sql = "select sum(sum) as sum from " . $this->_table . " where staff= '" . $sid . "' " . $dateCondition . " and status=2 ";
  292. // echo '<div style="display:none">'.$sql.'</div>';
  293. $query = Doo::db ()->query ( $sql );
  294. $result = $query->fetch ();
  295. return $result;
  296. }
  297. function getReceiptBySid($sid = '', $year = '', $month = '') {
  298. Doo::loadClass ( 'XDeode' );
  299. $XDeode = new XDeode ( 5 );
  300. if (empty ( $sid ))
  301. return array ();
  302. $sql = 'select a.*
  303. from ' . $this->_table . ' as a left join CLD_receiptDetail as b on b.rid=a.rid
  304. where b.staff =' . $sid . ' and Month(b.pastDate)=' . $month . ' and Year(b.pastDate)=' . $year . ' and b.status=1
  305. GROUP BY b.rid';
  306. $query = Doo::db ()->query ( $sql );
  307. $list = $query->fetchAll ();
  308. foreach ( $list as $key => $value ) {
  309. $list [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  310. }
  311. return $list;
  312. }
  313. function getReceiptByRid($rid = '') {
  314. Doo::loadClass ( 'XDeode' );
  315. $XDeode = new XDeode ( 5 );
  316. Doo::loadModel ( 'L_category' );
  317. $Lcategory = new L_category ();
  318. Doo::loadModel ( 'staff' );
  319. $staff = new staff ();
  320. if (! is_numeric ( $rid ))
  321. $rid = $XDeode->decode ( $rid );
  322. $rinfo = $this->getOne ( array (
  323. 'where' => 'rid=' . $rid,
  324. 'asArray' => true
  325. ) );
  326. $rinfo ['ridKey'] = $XDeode->encode ( $rinfo ['rid'] );
  327. //$rinfo ['trainLoanRidKey'] = $XDeode->encode ( $rinfo ['trainLoanRid'] );
  328. $XDeode = new XDeode ( 7 );
  329. $rinfo ['ridKey7'] = $XDeode->encode ( $rinfo ['rid'] );
  330. $rinfo ['category'] = $Lcategory->getCategoryById ( $rinfo ['cid'] );
  331. $rinfo ['staffDetail'] = $staff->getStaffBySid ( $rinfo ['staff'] );
  332. // $rinfo['sum']=number_format ($rinfo['sum'],2);
  333. return $rinfo;
  334. }
  335. function getReceiptInRid($rid = ''){
  336. /*
  337. if (! is_numeric ( $rid )){
  338. $rid = $XDeode->decode ( $rid );
  339. } */
  340. Doo::loadClass ( 'XDeode' );
  341. $XDeode = new XDeode ( 5 );
  342. Doo::loadModel ( 'L_category' );
  343. $Lcategory = new L_category ();
  344. Doo::loadModel ( 'staff' );
  345. $staff = new staff ();
  346. $rinfo = $this->find ( array (
  347. 'where' => 'rid in (' . $rid.')',
  348. 'asArray' => true
  349. ) );
  350. foreach ($rinfo as $key=>$value){
  351. $rinfo [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  352. //$rinfo [$key]['trainLoanRidKey'] = $XDeode->encode ( $value ['trainLoanRid'] );
  353. $XDeode = new XDeode ( 7 );
  354. $rinfo [$key]['ridKey7'] = $XDeode->encode ( $value ['rid'] );
  355. $rinfo[$key] ['category'] = $Lcategory->getCategoryById ( $value ['cid'] );
  356. $rinfo[$key] ['staffDetail'] = $staff->getStaffBySid ( $value ['staff'] );
  357. }
  358. //print_r($rinfo);
  359. return $rinfo;
  360. }
  361. function getReceiptByTrainLoanRid($rid = '') {
  362. Doo::loadClass ( 'XDeode' );
  363. $XDeode = new XDeode ( 5 );
  364. // Doo::loadModel ( 'L_category' );
  365. // $Lcategory = new L_category ();
  366. // Doo::loadModel ( 'staff' );
  367. // $staff = new staff ();
  368. if (! is_numeric ( $rid )){
  369. $rid = $XDeode->decode ( $rid );
  370. }
  371. $rinfo = $this->getOne ( array (
  372. 'where' => 'trainLoanRid=' . $rid,
  373. 'asArray' => true
  374. ) );
  375. if(empty($rinfo)){
  376. $rinfo = $this->getOne ( array (
  377. 'where' => 'trainLoanRid like "' . $rid.',%"',
  378. 'asArray' => true
  379. ) );
  380. }
  381. if(empty($rinfo)){
  382. $rinfo = $this->getOne ( array (
  383. 'where' => 'trainLoanRid like "%,' . $rid.'"',
  384. 'asArray' => true
  385. ) );
  386. }
  387. if(empty($rinfo)){
  388. $rinfo = $this->getOne ( array (
  389. 'where' => 'trainLoanRid like "%,' . $rid.',%"',
  390. 'asArray' => true
  391. ) );
  392. }
  393. $rinfo ['ridKey7']='';
  394. if (!empty($rinfo ['rid'])){
  395. $XDeode = new XDeode ( 7 );
  396. $rinfo ['ridKey7'] = $XDeode->encode ( $rinfo ['rid'] );
  397. }
  398. // $rinfo ['ridKey7'] = $XDeode->encode ( $rinfo ['rid'] );
  399. // $rinfo ['category'] = $Lcategory->getCategoryById ( $rinfo ['cid'] );
  400. // $rinfo ['staffDetail'] = $staff->getStaffBySid ( $rinfo ['staff'] );
  401. // $rinfo['sum']=number_format ($rinfo['sum'],2);
  402. return $rinfo;
  403. }
  404. function getReceiptByinvoiceTrainId($invoiceTrainId = 0) {
  405. Doo::loadClass ( 'XDeode' );
  406. $XDeode = new XDeode ( 5 );
  407. Doo::loadModel ( 'L_category' );
  408. $Lcategory = new L_category ();
  409. Doo::loadModel ( 'staff' );
  410. $staff = new staff ();
  411. if (! is_numeric ( $invoiceTrainId ))
  412. $invoiceTrainId = $XDeode->decode ( $invoiceTrainId );
  413. $rinfo = $this->getOne ( array (
  414. 'where' => 'invoiceTrainId=' . $invoiceTrainId,
  415. 'asArray' => true
  416. ) );
  417. if (empty ( $rinfo )) {
  418. return array ();
  419. }
  420. $rinfo ['ridKey'] = $XDeode->encode ( $rinfo ['rid'] );
  421. $rinfo ['trainLoanRidKey'] = '';//$XDeode->encode ( $rinfo ['trainLoanRid'] );
  422. $XDeode = new XDeode ( 7 );
  423. $rinfo ['ridKey7'] = $XDeode->encode ( $rinfo ['rid'] );
  424. $rinfo ['category'] = $Lcategory->getCategoryById ( $rinfo ['cid'] );
  425. $rinfo ['staffDetail'] = $staff->getStaffBySid ( $rinfo ['staff'] );
  426. return $rinfo;
  427. }
  428. /**
  429. * 默认获得10条
  430. * @param unknown $sid
  431. * @param unknown $cid
  432. * @param unknown $limit
  433. */
  434. function getReceiptLoanByStatus($sid, $cid, $status, $limit = 10) {
  435. $sql = '';
  436. if ($sid !== false && is_numeric ( $sid )) {
  437. $sql .= ' and staff=' . $sid;
  438. }
  439. if ($cid !== false && is_numeric ( $cid )) {
  440. $sql .= ' and cid=' . $cid;
  441. }
  442. $list = $this->find ( array (
  443. 'where' => 'Rtype=1 and status=' . $status . $sql,
  444. 'asArray' => true
  445. ) );
  446. Doo::loadClass ( 'XDeode' );
  447. $XDeode = new XDeode ( 5 );
  448. foreach ( $list as $key => $value ) {
  449. $list [$key] ['ridKey'] = $XDeode->encode ( $list [$key] ['rid'] );
  450. }
  451. return $list;
  452. }
  453. /**
  454. * 获得需要记录流水的费用
  455. * @param unknown $status
  456. * @return string
  457. */
  458. function getReceiptByWaste() {
  459. $list = $this->find ( array (
  460. 'where' => 'status=2 or status=6 or status=1',
  461. 'asArray' => true
  462. ) );
  463. Doo::loadClass ( 'XDeode' );
  464. $XDeode = new XDeode ( 5 );
  465. $XDeode7 = new XDeode ( 7 );
  466. Doo::loadModel ( 'wasteBook' );
  467. $wasteBook = new wasteBook ();
  468. $accountType = 0;
  469. foreach ( $list as $key => $value ) {
  470. $list [$key] ['ridKey7'] = $XDeode7->encode ( $list [$key] ['rid'] );
  471. $list [$key] ['ridKey'] = $XDeode->encode ( $list [$key] ['rid'] );
  472. if ($list [$key] ['Rtype'] == 0) {
  473. $accountType = 3;
  474. } elseif ($list [$key] ['Rtype'] == 1) {
  475. if (! empty ( $list [$key] ['accountItem'] ))
  476. $accountType = 2;
  477. else
  478. $accountType = 1;
  479. } elseif ($list [$key] ['Rtype'] == 2) {
  480. $accountType = 4;
  481. } elseif ($list [$key] ['Rtype'] == 3) {
  482. $accountType = 12;
  483. }
  484. // 是否已经生成流水
  485. $wbDetail = array ();
  486. if (! empty ( $accountType )) {
  487. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $list [$key] ['rid'] );
  488. if (! empty ( $wbDetail )) {
  489. unset ( $list [$key] );
  490. }
  491. } else {
  492. unset ( $list [$key] );
  493. }
  494. }
  495. return $list;
  496. }
  497. /**
  498. * 根据参数字段更新相应字段(主键ID必须传)
  499. * @param array $item 相关需要更新的字段信息
  500. * @return number 返回发票ID
  501. */
  502. public function setReceiptByCondition($item = array(), $rid = "") {
  503. $lid = 0;
  504. if (is_array ( $item ) && ! empty ( $item )) {
  505. foreach ( $item as $key => $value ) {
  506. $this->$key = $value;
  507. }
  508. if (! empty ( $isid )) {
  509. $condition = array (
  510. 'where' => "rid in (" . $rid . ")",
  511. 'asArray' => TRUE
  512. );
  513. $this->update ( $condition );
  514. } else
  515. $lid = $this->update ();
  516. }
  517. return $lid;
  518. }
  519. }
  520. ?>