receipt.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  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 ['cidKey'] = $XDeode->encode ( $rinfo ['cid'] );
  328. //$rinfo ['trainLoanRidKey'] = $XDeode->encode ( $rinfo ['trainLoanRid'] );
  329. $XDeode = new XDeode ( 7 );
  330. $rinfo ['ridKey7'] = $XDeode->encode ( $rinfo ['rid'] );
  331. $rinfo ['category'] = $Lcategory->getCategoryById ( $rinfo ['cid'] );
  332. $rinfo ['staffDetail'] = $staff->getStaffBySid ( $rinfo ['staff'] );
  333. // $rinfo['sum']=number_format ($rinfo['sum'],2);
  334. return $rinfo;
  335. }
  336. function getReceiptInRid($rid = ''){
  337. /*
  338. if (! is_numeric ( $rid )){
  339. $rid = $XDeode->decode ( $rid );
  340. } */
  341. Doo::loadClass ( 'XDeode' );
  342. $XDeode = new XDeode ( 5 );
  343. Doo::loadModel ( 'L_category' );
  344. $Lcategory = new L_category ();
  345. Doo::loadModel ( 'staff' );
  346. $staff = new staff ();
  347. $rinfo = $this->find ( array (
  348. 'where' => 'rid in (' . $rid.')',
  349. 'asArray' => true
  350. ) );
  351. foreach ($rinfo as $key=>$value){
  352. $rinfo [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  353. //$rinfo [$key]['trainLoanRidKey'] = $XDeode->encode ( $value ['trainLoanRid'] );
  354. $XDeode = new XDeode ( 7 );
  355. $rinfo [$key]['ridKey7'] = $XDeode->encode ( $value ['rid'] );
  356. $rinfo[$key] ['category'] = $Lcategory->getCategoryById ( $value ['cid'] );
  357. $rinfo[$key] ['staffDetail'] = $staff->getStaffBySid ( $value ['staff'] );
  358. }
  359. //print_r($rinfo);
  360. return $rinfo;
  361. }
  362. function getReceiptByTrainLoanRid($rid = '') {
  363. Doo::loadClass ( 'XDeode' );
  364. $XDeode = new XDeode ( 5 );
  365. // Doo::loadModel ( 'L_category' );
  366. // $Lcategory = new L_category ();
  367. // Doo::loadModel ( 'staff' );
  368. // $staff = new staff ();
  369. if (! is_numeric ( $rid )){
  370. $rid = $XDeode->decode ( $rid );
  371. }
  372. $rinfo = $this->getOne ( array (
  373. 'where' => 'trainLoanRid=' . $rid,
  374. 'asArray' => true
  375. ) );
  376. if(empty($rinfo)){
  377. $rinfo = $this->getOne ( array (
  378. 'where' => 'trainLoanRid like "' . $rid.',%"',
  379. 'asArray' => true
  380. ) );
  381. }
  382. if(empty($rinfo)){
  383. $rinfo = $this->getOne ( array (
  384. 'where' => 'trainLoanRid like "%,' . $rid.'"',
  385. 'asArray' => true
  386. ) );
  387. }
  388. if(empty($rinfo)){
  389. $rinfo = $this->getOne ( array (
  390. 'where' => 'trainLoanRid like "%,' . $rid.',%"',
  391. 'asArray' => true
  392. ) );
  393. }
  394. $rinfo ['ridKey7']='';
  395. if (!empty($rinfo ['rid'])){
  396. $XDeode = new XDeode ( 7 );
  397. $rinfo ['ridKey7'] = $XDeode->encode ( $rinfo ['rid'] );
  398. }
  399. // $rinfo ['ridKey7'] = $XDeode->encode ( $rinfo ['rid'] );
  400. // $rinfo ['category'] = $Lcategory->getCategoryById ( $rinfo ['cid'] );
  401. // $rinfo ['staffDetail'] = $staff->getStaffBySid ( $rinfo ['staff'] );
  402. // $rinfo['sum']=number_format ($rinfo['sum'],2);
  403. return $rinfo;
  404. }
  405. function getReceiptByinvoiceTrainId($invoiceTrainId = 0) {
  406. Doo::loadClass ( 'XDeode' );
  407. $XDeode = new XDeode ( 5 );
  408. Doo::loadModel ( 'L_category' );
  409. $Lcategory = new L_category ();
  410. Doo::loadModel ( 'staff' );
  411. $staff = new staff ();
  412. if (! is_numeric ( $invoiceTrainId ))
  413. $invoiceTrainId = $XDeode->decode ( $invoiceTrainId );
  414. $rinfo = $this->getOne ( array (
  415. 'where' => 'invoiceTrainId=' . $invoiceTrainId,
  416. 'asArray' => true
  417. ) );
  418. if (empty ( $rinfo )) {
  419. return array ();
  420. }
  421. $rinfo ['ridKey'] = $XDeode->encode ( $rinfo ['rid'] );
  422. $rinfo ['trainLoanRidKey'] = '';//$XDeode->encode ( $rinfo ['trainLoanRid'] );
  423. $XDeode = new XDeode ( 7 );
  424. $rinfo ['ridKey7'] = $XDeode->encode ( $rinfo ['rid'] );
  425. $rinfo ['category'] = $Lcategory->getCategoryById ( $rinfo ['cid'] );
  426. $rinfo ['staffDetail'] = $staff->getStaffBySid ( $rinfo ['staff'] );
  427. return $rinfo;
  428. }
  429. /**
  430. * 默认获得10条
  431. * @param unknown $sid
  432. * @param unknown $cid
  433. * @param unknown $limit
  434. */
  435. function getReceiptLoanByStatus($sid, $cid, $status, $limit = 10) {
  436. $sql = '';
  437. if ($sid !== false && is_numeric ( $sid )) {
  438. $sql .= ' and staff=' . $sid;
  439. }
  440. if ($cid !== false && is_numeric ( $cid )) {
  441. $sql .= ' and cid=' . $cid;
  442. }
  443. $list = $this->find ( array (
  444. 'where' => 'Rtype=1 and status=' . $status . $sql,
  445. 'asArray' => true
  446. ) );
  447. Doo::loadClass ( 'XDeode' );
  448. $XDeode = new XDeode ( 5 );
  449. foreach ( $list as $key => $value ) {
  450. $list [$key] ['ridKey'] = $XDeode->encode ( $list [$key] ['rid'] );
  451. }
  452. return $list;
  453. }
  454. /**
  455. * 获得需要记录流水的费用
  456. * @param unknown $status
  457. * @return string
  458. */
  459. function getReceiptByWaste() {
  460. $list = $this->find ( array (
  461. 'where' => 'status=2 or status=6 or status=1',
  462. 'asArray' => true
  463. ) );
  464. Doo::loadClass ( 'XDeode' );
  465. $XDeode = new XDeode ( 5 );
  466. $XDeode7 = new XDeode ( 7 );
  467. Doo::loadModel ( 'wasteBook' );
  468. $wasteBook = new wasteBook ();
  469. $accountType = 0;
  470. foreach ( $list as $key => $value ) {
  471. $list [$key] ['ridKey7'] = $XDeode7->encode ( $list [$key] ['rid'] );
  472. $list [$key] ['ridKey'] = $XDeode->encode ( $list [$key] ['rid'] );
  473. if ($list [$key] ['Rtype'] == 0) {
  474. $accountType = 3;
  475. } elseif ($list [$key] ['Rtype'] == 1) {
  476. if (! empty ( $list [$key] ['accountItem'] ))
  477. $accountType = 2;
  478. else
  479. $accountType = 1;
  480. } elseif ($list [$key] ['Rtype'] == 2) {
  481. $accountType = 4;
  482. } elseif ($list [$key] ['Rtype'] == 3) {
  483. $accountType = 12;
  484. }
  485. // 是否已经生成流水
  486. $wbDetail = array ();
  487. if (! empty ( $accountType )) {
  488. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $list [$key] ['rid'] );
  489. if (! empty ( $wbDetail )) {
  490. unset ( $list [$key] );
  491. }
  492. } else {
  493. unset ( $list [$key] );
  494. }
  495. }
  496. return $list;
  497. }
  498. /**
  499. * 根据参数字段更新相应字段(主键ID必须传)
  500. * @param array $item 相关需要更新的字段信息
  501. * @return number 返回发票ID
  502. */
  503. public function setReceiptByCondition($item = array(), $rid = "") {
  504. $lid = 0;
  505. if (is_array ( $item ) && ! empty ( $item )) {
  506. foreach ( $item as $key => $value ) {
  507. $this->$key = $value;
  508. }
  509. if (! empty ( $isid )) {
  510. $condition = array (
  511. 'where' => "rid in (" . $rid . ")",
  512. 'asArray' => TRUE
  513. );
  514. $this->update ( $condition );
  515. } else
  516. $lid = $this->update ();
  517. }
  518. return $lid;
  519. }
  520. }
  521. ?>