receipt.php 18 KB

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