receipt.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 $_table = 'CLD_receipt';
  41. public $_primarykey = 'rid';
  42. public $_fields = array (
  43. 'aid',
  44. 'accountItem',
  45. 'staff',
  46. 'sum',
  47. 'date',
  48. 'pastDate',
  49. 'cid',
  50. 'status',
  51. 'reviseDetail',
  52. 'revisePrice',
  53. 'verify',
  54. 'verifyStaff',
  55. 'nowStaff',
  56. 'receiptOrder',
  57. 'explanation',
  58. 'notice',
  59. 'Rtype',
  60. 'loanItem',
  61. 'loanRid',
  62. 'loanSum',
  63. 'implementOpinions',
  64. 'isBK',
  65. 'executeCopy',
  66. 'executeStaff',
  67. 'verifyBreakup',
  68. 'executeDate',
  69. 'amount',
  70. 'loanDate',
  71. 'remittanceName',
  72. 'bankName',
  73. 'bankNumber',
  74. 'coupletNumber',
  75. 'remittanceBankType',
  76. 'trainId',
  77. 'trainLoanRid',
  78. 'invoiceTrainId'
  79. );
  80. function receiptByYear($dateCondition, $sid) {
  81. $sql = "select sum(sum) as sum from " . $this->_table . " where staff= '" . $sid . "' " . $dateCondition . " and status=2 ";
  82. // echo '<div style="display:none">'.$sql.'</div>';
  83. $query = Doo::db ()->query ( $sql );
  84. $result = $query->fetch ();
  85. return $result;
  86. }
  87. function getReceiptBySid($sid = '', $year = '', $month = '') {
  88. Doo::loadClass ( 'XDeode' );
  89. $XDeode = new XDeode ( 5 );
  90. if (empty ( $sid ))
  91. return array ();
  92. $sql = 'select a.*
  93. from ' . $this->_table . ' as a left join CLD_receiptDetail as b on b.rid=a.rid
  94. where b.staff =' . $sid . ' and Month(b.pastDate)=' . $month . ' and Year(b.pastDate)=' . $year . ' and b.status=1
  95. GROUP BY b.rid';
  96. $query = Doo::db ()->query ( $sql );
  97. $list = $query->fetchAll ();
  98. foreach ( $list as $key => $value ) {
  99. $list [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  100. }
  101. return $list;
  102. }
  103. function getReceiptByRid($rid = '') {
  104. Doo::loadClass ( 'XDeode' );
  105. $XDeode = new XDeode ( 5 );
  106. Doo::loadModel ( 'L_category' );
  107. $Lcategory = new L_category ();
  108. Doo::loadModel ( 'staff' );
  109. $staff = new staff ();
  110. if (! is_numeric ( $rid ))
  111. $rid = $XDeode->decode ( $rid );
  112. $rinfo = $this->getOne ( array (
  113. 'where' => 'rid=' . $rid,
  114. 'asArray' => true
  115. ) );
  116. $rinfo['ridKey']=$XDeode->encode ( $rinfo ['rid'] );
  117. $rinfo['trainLoanRidKey']=$XDeode->encode ( $rinfo ['trainLoanRid'] );
  118. $rinfo['category']=$Lcategory->getCategoryById($rinfo['cid']);
  119. $rinfo['staffDetail']=$staff->getStaffBySid($rinfo['staff']);
  120. return $rinfo;
  121. }
  122. /**
  123. * 默认获得10条
  124. * @param unknown $sid
  125. * @param unknown $cid
  126. * @param unknown $limit
  127. */
  128. function getReceiptLoanByStatus($sid,$cid,$status,$limit=10){
  129. $sql='';
  130. if ($sid!==false&&is_numeric($sid)){
  131. $sql.=' and staff='.$sid;
  132. }
  133. if ($cid!==false&&is_numeric($cid)){
  134. $sql.=' and cid='.$cid;
  135. }
  136. $list = $this->find ( array (
  137. 'where' => 'Rtype=1 and status=' . $status.$sql,
  138. 'asArray' => true
  139. ) );
  140. Doo::loadClass ( 'XDeode' );
  141. $XDeode = new XDeode ( 5 );
  142. foreach ($list as $key=>$value){
  143. $list[$key]['ridKey']=$XDeode->encode ( $list[$key] ['rid'] );
  144. }
  145. return $list;
  146. }
  147. /**
  148. * 根据参数字段更新相应字段(主键ID必须传)
  149. * @param array $item 相关需要更新的字段信息
  150. * @return number 返回发票ID
  151. */
  152. public function setReceiptByCondition($item = array(), $rid = "") {
  153. $lid = 0;
  154. if (is_array ( $item ) && ! empty ( $item )) {
  155. foreach ( $item as $key => $value ) {
  156. $this->$key = $value;
  157. }
  158. if (! empty ( $isid )) {
  159. $condition = array (
  160. 'where' => "rid in (" . $rid . ")",
  161. 'asArray' => TRUE
  162. );
  163. $this->update ( $condition );
  164. } else
  165. $lid = $this->update ();
  166. }
  167. return $lid;
  168. }
  169. }
  170. ?>