예제 #1
0
파일: Invoice.php 프로젝트: xindalu/evolve
 public function getData($condition = array(), $invoice_id = null)
 {
     $sql = $this->select()->setIntegrityCheck(false)->from(array('t1' => $this->_name))->joinLeft(array('t2' => $this->_dbprefix . 'user'), "t1.create_user = t2.id", array())->joinLeft(array('t3' => $this->_dbprefix . 'employee'), "t2.employee_id = t3.id", array('creater' => 'cname'))->joinLeft(array('t4' => $this->_dbprefix . 'user'), "t1.update_user = t4.id", array())->joinLeft(array('t5' => $this->_dbprefix . 'employee'), "t4.employee_id = t5.id", array('updater' => 'cname'))->joinLeft(array('t9' => $this->_dbprefix . 'bpartner'), "t1.supplier_id = t9.id", array('supplier_code' => 'code', 'supplier_ename' => new Zend_Db_Expr("case when t9.ename = '' then t9.cname else t9.ename end"), 'supplier_cname' => 'cname', 'supplier_bank_type' => 'bank_type', 'supplier_bank_account' => 'bank_account', 'supplier_tax_id' => 'tax_id', 'supplier_tax_num' => 'tax_num', 'supplier_bank_payment_days' => 'bank_payment_days'));
     if ($invoice_id) {
         $sql->where("t1.id = " . $invoice_id);
         return $this->fetchRow($sql)->toArray();
     } else {
         $sql->where("t1.state = " . $condition['state']);
         if ($condition['date_from']) {
             $sql->where("t1.create_time >= '" . $condition['date_from'] . " 00:00:00'");
         }
         if ($condition['date_to']) {
             $sql->where("t1.create_time <= '" . $condition['date_to'] . " 23:59:59'");
         }
         if ($condition['key']) {
             $sql->where("t9.code like '%" . $condition['key'] . "%' or t9.cname like '%" . $condition['key'] . "%' or t9.ename like '%" . $condition['key'] . "%' or t1.number like '%" . $condition['key'] . "%' or t1.description like '%" . $condition['key'] . "%' or t1.remark like '%" . $condition['key'] . "%'");
             // or t8.name like '%".$condition['key']."%'
         }
         $total = $this->fetchAll($sql)->count();
         $sql->order(array('t1.state', 't1.number desc', 't1.create_time desc'))->limitPage($condition['page'], $condition['limit']);
         $data = $this->fetchAll($sql)->toArray();
         $review = new Dcc_Model_Review();
         $help = new Application_Model_Helpers();
         $user_session = new Zend_Session_Namespace('user');
         $employee_id = $user_session->user_info['employee_id'];
         for ($i = 0; $i < count($data); $i++) {
             $data[$i]['create_time'] = strtotime($data[$i]['create_time']);
             $data[$i]['update_time'] = strtotime($data[$i]['update_time']);
             $data[$i]['release_time'] = strtotime($data[$i]['release_time']);
             $data[$i]['state'] = intval($data[$i]['state']);
             $data[$i]['review_state'] = "";
             $data[$i]['review_info_tip'] = $data[$i]['review_info'];
             $data[$i]['review_info'] = str_replace('<br>', ' > ', $data[$i]['review_info']);
             $data[$i]['reviewer'] = '';
             // 当状态不为拒绝时才能获取,否则会报错
             if ($data[$i]['state'] != 1) {
                 // 获取审核情况
                 $review_state = $help->getReviewState('purchse_invoice_add', $data[$i]['id']);
                 /* echo '<pre>';
                    print_r($review_state);
                    exit; */
                 $data[$i]['reviewer'] = implode(',', $help->getEmployeeNameByIdArr($review_state['reviewer']));
                 $data[$i]['review_state'] = $review_state['info'];
                 $data[$i]['can_review'] = in_array($employee_id, $review_state['reviewer']) && !in_array($employee_id, $review_state['reviewer_finished']) ? 1 : 0;
                 $data[$i]['current_step'] = $review_state['step_chk']['current_step'];
                 $data[$i]['last_step'] = $review_state['step_chk']['last_step'];
                 $data[$i]['to_finish'] = $review_state['step_chk']['to_finish'];
                 $data[$i]['next_step'] = $review_state['step_chk']['next_step'];
             }
             if ($help->chkIsReviewer('purchse_invoice_add', $data[$i]['id'], $employee_id)) {
                 $data[$i]['is_reviewer'] = 1;
             } else {
                 $data[$i]['is_reviewer'] = 0;
             }
         }
         return array('total' => $total, 'rows' => $data);
     }
 }
예제 #2
0
파일: Price.php 프로젝트: xindalu/evolve
 public function getData($conditions, $price_id = null)
 {
     $data = array();
     $sql = $this->select()->setIntegrityCheck(false)->from(array('t1' => $this->_name))->joinLeft(array('t2' => $this->_dbprefix . 'user'), "t1.create_user = t2.id", array())->joinLeft(array('t3' => $this->_dbprefix . 'employee'), "t2.employee_id = t3.id", array('creater' => 'cname'))->joinLeft(array('t4' => $this->_dbprefix . 'user'), "t1.update_user = t4.id", array())->joinLeft(array('t5' => $this->_dbprefix . 'employee'), "t4.employee_id = t5.id", array('updater' => 'cname'))->joinLeft(array('t6' => $this->_dbprefix . 'bpartner'), "t1.customer_id = t6.id", array('customer_name' => new Zend_Db_Expr("case when t6.cname = '' then t6.ename else t6.cname end"), 'customer_code' => 'code'))->joinLeft(array('t7' => $this->_dbprefix . 'erp_setting_tax'), "t1.tax_id = t7.id", array('tax_name' => 'name'))->where("t1.deleted = 0");
     if ($conditions['key']) {
         $sql->where("t1.number LIKE '%" . $conditions['key'] . "%' OR t6.code LIKE '%" . $conditions['key'] . "%' OR t6.cname LIKE '%" . $conditions['key'] . "%' OR t6.ename LIKE '%" . $conditions['key'] . "%' OR t3.cname LIKE '%" . $conditions['key'] . "%' OR t3.ename LIKE '%" . $conditions['key'] . "%'");
     }
     if ($price_id) {
         $sql->where("t1.id = " . $price_id);
         return $this->fetchRow($sql)->toArray();
     } else {
         $sql->where("state = " . $conditions['state']);
         if ($conditions['date_from']) {
             $sql->where("price_date >= '" . $conditions['date_from'] . " 00:00:00'");
         }
         if ($conditions['date_to']) {
             $sql->where("price_date <= '" . $conditions['date_to'] . " 23:59:59'");
         }
         $data = $this->fetchAll($sql)->toArray();
         $review = new Dcc_Model_Review();
         $help = new Application_Model_Helpers();
         $user_session = new Zend_Session_Namespace('user');
         $employee_id = $user_session->user_info['employee_id'];
         for ($i = 0; $i < count($data); $i++) {
             // 当状态不为拒绝时才能获取,否则会报错
             if ($data[$i]['state'] != 1) {
                 // 获取审核情况
                 $review_state = $help->getReviewState('sale_price_add', $data[$i]['id']);
                 $data[$i]['reviewer'] = implode(',', $help->getEmployeeNameByIdArr($review_state['reviewer']));
                 $data[$i]['review_state'] = $review_state['info'];
                 $data[$i]['can_review'] = in_array($employee_id, $review_state['reviewer']) && !in_array($employee_id, $review_state['reviewer_finished']) ? 1 : 0;
                 $data[$i]['current_step'] = $review_state['step_chk']['current_step'];
                 $data[$i]['last_step'] = $review_state['step_chk']['last_step'];
                 $data[$i]['to_finish'] = $review_state['step_chk']['to_finish'];
                 $data[$i]['next_step'] = $review_state['step_chk']['next_step'];
             }
             if ($help->chkIsReviewer('sale_price_add', $data[$i]['id'], $employee_id)) {
                 $data[$i]['is_reviewer'] = 1;
             } else {
                 $data[$i]['is_reviewer'] = 0;
             }
         }
     }
     return $data;
 }
예제 #3
0
파일: Req.php 프로젝트: xindalu/evolve
 public function getData($condition = array(), $req_id = null)
 {
     $sql = $this->select()->setIntegrityCheck(false)->from(array('t1' => $this->_name))->joinLeft(array('t2' => $this->_dbprefix . 'user'), "t1.create_user = t2.id", array())->joinLeft(array('t3' => $this->_dbprefix . 'employee'), "t2.employee_id = t3.id", array('creater' => 'cname'))->joinLeft(array('t4' => $this->_dbprefix . 'user'), "t1.update_user = t4.id", array())->joinLeft(array('t5' => $this->_dbprefix . 'employee'), "t4.employee_id = t5.id", array('updater' => 'cname'))->joinLeft(array('t6' => $this->_dbprefix . 'employee_dept'), "t1.dept_id = t6.id", array('dept' => 'name'))->joinLeft(array('t7' => $this->_dbprefix . 'erp_pur_type'), "t1.type_id = t7.id", array('type' => 'name', 'req_flow_id'))->joinLeft(array('t9' => $this->_dbprefix . 'user'), "t1.apply_user = t9.id", array())->joinLeft(array('t10' => $this->_dbprefix . 'employee'), "t9.employee_id = t10.id", array('apply_user_name' => 'cname'))->joinLeft(array('t11' => $this->_dbprefix . 'erp_pur_transfer'), "t11.id = t1.transfer_id", array('transfer_type', 'transfer_description', 'transfer_state' => 'state'));
     if ($req_id) {
         $sql->where("t1.id = " . $req_id);
         return $this->fetchRow($sql)->toArray();
     } else {
         $sql->where("t1.active = " . $condition['active']);
         if ($condition['state'] !== null) {
             $sql->where("t1.state = " . $condition['state']);
         }
         if ($condition['applier']) {
             $sql->where("t10.cname like '%" . $condition['applier'] . "%' or t10.ename like '%" . $condition['applier'] . "%'");
         }
         if ($condition['date_from']) {
             $sql->where("t1.create_time >= '" . $condition['date_from'] . " 00:00:00'");
         }
         if ($condition['date_to']) {
             $sql->where("t1.create_time <= '" . $condition['date_to'] . " 23:59:59'");
         }
         if ($condition['type']) {
             $type = json_decode($condition['type']);
             if (count($type)) {
                 $type_con = "t1.type_id = " . $type[0];
                 for ($i = 1; $i < count($type); $i++) {
                     $type_con .= " or t1.type_id = " . $type[$i];
                 }
                 $sql->where($type_con);
             }
         }
         if ($condition['dept']) {
             $dept = json_decode($condition['dept']);
             if (count($dept)) {
                 $dept_con = "t1.dept_id = " . $dept[0];
                 for ($i = 1; $i < count($dept); $i++) {
                     $dept_con .= " or t1.dept_id = " . $dept[$i];
                 }
                 $sql->where($dept_con);
             }
         }
         if ($condition['key']) {
             $sql->where("t1.number like '%" . $condition['key'] . "%' or t1.reason like '%" . $condition['key'] . "%' or t1.remark like '%" . $condition['key'] . "%' or t1.approved_user like '%" . $condition['key'] . "%'");
             // or t8.name like '%".$condition['key']."%'
         }
         $total = $this->fetchAll($sql)->count();
         $sql->order(array('t1.state', 't1.number desc', 't1.create_time desc'))->limitPage($condition['page'], $condition['limit']);
         $data = $this->fetchAll($sql)->toArray();
         /* echo '<pre>';
            print_r($data);
            exit; */
         $review = new Dcc_Model_Review();
         $help = new Application_Model_Helpers();
         $user_session = new Zend_Session_Namespace('user');
         $employee_id = $user_session->user_info['employee_id'];
         for ($i = 0; $i < count($data); $i++) {
             $data[$i]['create_time'] = strtotime($data[$i]['create_time']);
             $data[$i]['update_time'] = strtotime($data[$i]['update_time']);
             $data[$i]['release_time'] = strtotime($data[$i]['release_time']);
             $data[$i]['state'] = intval($data[$i]['state']);
             $data[$i]['review_state'] = "";
             $data[$i]['review_info_tip'] = $data[$i]['review_info'];
             $data[$i]['review_info'] = str_replace('<br>', ' > ', $data[$i]['review_info']);
             // 当状态不为拒绝时才能获取,否则会报错
             if ($data[$i]['state'] != 1) {
                 // 获取审核情况
                 $review_state = $help->getReviewState('purchse_req_add', $data[$i]['id']);
                 $data[$i]['reviewer'] = implode(',', $help->getEmployeeNameByIdArr($review_state['reviewer']));
                 $data[$i]['review_state'] = $review_state['info'];
                 $data[$i]['can_review'] = in_array($employee_id, $review_state['reviewer']) && !in_array($employee_id, $review_state['reviewer_finished']) ? 1 : 0;
                 $data[$i]['current_step'] = $review_state['step_chk']['current_step'];
                 $data[$i]['last_step'] = $review_state['step_chk']['last_step'];
                 $data[$i]['to_finish'] = $review_state['step_chk']['to_finish'];
                 $data[$i]['next_step'] = $review_state['step_chk']['next_step'];
             }
             if ($help->chkIsReviewer('purchse_req_add', $data[$i]['id'], $employee_id)) {
                 $data[$i]['is_reviewer'] = 1;
             } else {
                 $data[$i]['is_reviewer'] = 0;
             }
         }
         return array('total' => $total, 'rows' => $data);
     }
 }