| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <?php
- Doo::loadCore ( 'db/DooModel' );
- class receipt extends DooModel {
- public $rid;
- public $accountItem;
- public $loanItem;
- public $staff;
- public $sum;
- public $date;
- public $pastDate;
- public $executeDate;
- public $loanDate;
- public $cid;
- public $status;
- public $Rtype;
- public $isBK;
- public $loanSum;
- public $loanRid;
- public $reviseDetail;
- public $revisePrice;
- public $receiptOrder;
- public $verify;
- public $verifyStaff;
- public $executeCopy;
- public $executeStaff;
- public $verifyBreakup;
- public $nowStaff;
- public $explanation;
- public $implementOpinions;
- public $notice;
- public $amount;
- public $remittanceName;
- public $bankName;
- public $bankNumber;
- public $coupletNumber;
- public $remittanceBankType;
- public $trainId;
- public $trainLoanRid;
- public $invoiceTrainId;
-
-
- public $_table = 'CLD_receipt';
- public $_primarykey = 'rid';
- public $_fields = array (
- 'aid',
- 'accountItem',
- 'staff',
- 'sum',
- 'date',
- 'pastDate',
- 'cid',
- 'status',
- 'reviseDetail',
- 'revisePrice',
- 'verify',
- 'verifyStaff',
- 'nowStaff',
- 'receiptOrder',
- 'explanation',
- 'notice',
- 'Rtype',
- 'loanItem',
- 'loanRid',
- 'loanSum',
- 'implementOpinions',
- 'isBK',
- 'executeCopy',
- 'executeStaff',
- 'verifyBreakup',
- 'executeDate',
- 'amount',
- 'loanDate',
- 'remittanceName',
- 'bankName',
- 'bankNumber',
- 'coupletNumber',
- 'remittanceBankType',
- 'trainId',
- 'trainLoanRid',
- 'invoiceTrainId'
- );
- function receiptByYear($dateCondition, $sid) {
- $sql = "select sum(sum) as sum from " . $this->_table . " where staff= '" . $sid . "' " . $dateCondition . " and status=2 ";
- // echo '<div style="display:none">'.$sql.'</div>';
- $query = Doo::db ()->query ( $sql );
- $result = $query->fetch ();
-
- return $result;
- }
- function getReceiptBySid($sid = '', $year = '', $month = '') {
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- if (empty ( $sid ))
- return array ();
- $sql = 'select a.*
- from ' . $this->_table . ' as a left join CLD_receiptDetail as b on b.rid=a.rid
- where b.staff =' . $sid . ' and Month(b.pastDate)=' . $month . ' and Year(b.pastDate)=' . $year . ' and b.status=1
- GROUP BY b.rid';
-
- $query = Doo::db ()->query ( $sql );
- $list = $query->fetchAll ();
-
- foreach ( $list as $key => $value ) {
- $list [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
- }
- return $list;
- }
- function getReceiptByRid($rid = '') {
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- Doo::loadModel ( 'L_category' );
- $Lcategory = new L_category ();
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- if (! is_numeric ( $rid ))
- $rid = $XDeode->decode ( $rid );
-
-
- $rinfo = $this->getOne ( array (
- 'where' => 'rid=' . $rid,
- 'asArray' => true
- ) );
-
- $rinfo['ridKey']=$XDeode->encode ( $rinfo ['rid'] );
- $rinfo['trainLoanRidKey']=$XDeode->encode ( $rinfo ['trainLoanRid'] );
- $rinfo['category']=$Lcategory->getCategoryById($rinfo['cid']);
- $rinfo['staffDetail']=$staff->getStaffBySid($rinfo['staff']);
-
- return $rinfo;
- }
-
- /**
- * 默认获得10条
- * @param unknown $sid
- * @param unknown $cid
- * @param unknown $limit
- */
- function getReceiptLoanByStatus($sid,$cid,$status,$limit=10){
- $sql='';
- if ($sid!==false&&is_numeric($sid)){
- $sql.=' and staff='.$sid;
- }
- if ($cid!==false&&is_numeric($cid)){
- $sql.=' and cid='.$cid;
- }
-
- $list = $this->find ( array (
- 'where' => 'Rtype=1 and status=' . $status.$sql,
- 'asArray' => true
- ) );
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- foreach ($list as $key=>$value){
- $list[$key]['ridKey']=$XDeode->encode ( $list[$key] ['rid'] );
- }
- return $list;
- }
-
- /**
- * 根据参数字段更新相应字段(主键ID必须传)
- * @param array $item 相关需要更新的字段信息
- * @return number 返回发票ID
- */
- public function setReceiptByCondition($item = array(), $rid = "") {
- $lid = 0;
-
- if (is_array ( $item ) && ! empty ( $item )) {
- foreach ( $item as $key => $value ) {
- $this->$key = $value;
- }
-
- if (! empty ( $isid )) {
- $condition = array (
- 'where' => "rid in (" . $rid . ")",
- 'asArray' => TRUE
- );
- $this->update ( $condition );
- } else
- $lid = $this->update ();
- }
- return $lid;
- }
-
- }
- ?>
|