receipt.php 18 KB

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