receipt.php 18 KB

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