receipt.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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. $XDeode = new XDeode ( 7 );
  119. $rinfo['ridKey7']=$XDeode->encode ( $rinfo ['rid'] );
  120. $rinfo['category']=$Lcategory->getCategoryById($rinfo['cid']);
  121. $rinfo['staffDetail']=$staff->getStaffBySid($rinfo['staff']);
  122. //$rinfo['sum']=number_format ($rinfo['sum'],2);
  123. return $rinfo;
  124. }
  125. function getReceiptByinvoiceTrainId($invoiceTrainId = '') {
  126. Doo::loadClass ( 'XDeode' );
  127. $XDeode = new XDeode ( 5 );
  128. Doo::loadModel ( 'L_category' );
  129. $Lcategory = new L_category ();
  130. Doo::loadModel ( 'staff' );
  131. $staff = new staff ();
  132. if (! is_numeric ( $invoiceTrainId ))
  133. $invoiceTrainId = $XDeode->decode ( $invoiceTrainId );
  134. $rinfo = $this->getOne ( array (
  135. 'where' => 'invoiceTrainId=' . $invoiceTrainId,
  136. 'asArray' => true
  137. ) );
  138. if (empty($rinfo)){
  139. return array();
  140. }
  141. $rinfo['ridKey']=$XDeode->encode ( $rinfo ['rid'] );
  142. $rinfo['trainLoanRidKey']=$XDeode->encode ( $rinfo ['trainLoanRid'] );
  143. $XDeode = new XDeode ( 7 );
  144. $rinfo['ridKey7']=$XDeode->encode ( $rinfo ['rid'] );
  145. $rinfo['category']=$Lcategory->getCategoryById($rinfo['cid']);
  146. $rinfo['staffDetail']=$staff->getStaffBySid($rinfo['staff']);
  147. return $rinfo;
  148. }
  149. /**
  150. * 默认获得10条
  151. * @param unknown $sid
  152. * @param unknown $cid
  153. * @param unknown $limit
  154. */
  155. function getReceiptLoanByStatus($sid,$cid,$status,$limit=10){
  156. $sql='';
  157. if ($sid!==false&&is_numeric($sid)){
  158. $sql.=' and staff='.$sid;
  159. }
  160. if ($cid!==false&&is_numeric($cid)){
  161. $sql.=' and cid='.$cid;
  162. }
  163. $list = $this->find ( array (
  164. 'where' => 'Rtype=1 and status=' . $status.$sql,
  165. 'asArray' => true
  166. ) );
  167. Doo::loadClass ( 'XDeode' );
  168. $XDeode = new XDeode ( 5 );
  169. foreach ($list as $key=>$value){
  170. $list[$key]['ridKey']=$XDeode->encode ( $list[$key] ['rid'] );
  171. }
  172. return $list;
  173. }
  174. /**
  175. * 获得需要记录流水的费用
  176. * @param unknown $status
  177. * @return string
  178. */
  179. function getReceiptByWaste(){
  180. $list = $this->find ( array (
  181. 'where' => 'status=2 or status=6 or status=1',
  182. 'asArray' => true
  183. ) );
  184. Doo::loadClass ( 'XDeode' );
  185. $XDeode = new XDeode ( 5 );
  186. $XDeode7 = new XDeode ( 7 );
  187. Doo::loadModel ( 'wasteBook' );
  188. $wasteBook = new wasteBook ();
  189. $accountType=0;
  190. foreach ($list as $key=>$value){
  191. $list[$key]['ridKey7']=$XDeode7->encode ( $list[$key] ['rid'] );
  192. $list[$key]['ridKey']=$XDeode->encode ( $list[$key] ['rid'] );
  193. if ($list[$key] ['Rtype']==0){
  194. $accountType=3;
  195. }elseif ($list[$key] ['Rtype']==1){
  196. if($list[$key] ['Rtype']==0){
  197. $accountType=1;
  198. }elseif($list[$key] ['Rtype']==1){
  199. $accountType=2;
  200. }
  201. }elseif ($list[$key] ['Rtype']==2){
  202. $accountType=4;
  203. }elseif ($list[$key] ['Rtype']==3){
  204. $accountType=12;
  205. }
  206. //是否已经生成流水
  207. $wbDetail=array();
  208. if (!empty($accountType)){
  209. $wbDetail=$wasteBook->getWateBookByAD($accountType,$list[$key] ['rid']);
  210. if (!empty($wbDetail)){
  211. unset($list[$key]);
  212. }
  213. }else{
  214. unset($list[$key]);
  215. }
  216. }
  217. return $list;
  218. }
  219. /**
  220. * 根据参数字段更新相应字段(主键ID必须传)
  221. * @param array $item 相关需要更新的字段信息
  222. * @return number 返回发票ID
  223. */
  224. public function setReceiptByCondition($item = array(), $rid = "") {
  225. $lid = 0;
  226. if (is_array ( $item ) && ! empty ( $item )) {
  227. foreach ( $item as $key => $value ) {
  228. $this->$key = $value;
  229. }
  230. if (! empty ( $isid )) {
  231. $condition = array (
  232. 'where' => "rid in (" . $rid . ")",
  233. 'asArray' => TRUE
  234. );
  235. $this->update ( $condition );
  236. } else
  237. $lid = $this->update ();
  238. }
  239. return $lid;
  240. }
  241. }
  242. ?>