Exemple #1
0
 public function update()
 {
     if (empty($this->input['id'])) {
         $this->errorOutput(NO_ID);
     }
     if (!$this->user['user_id']) {
         $this->errorOutput(NO_LOGIN);
     }
     /*
     if(!$this->input['bill_id'])
     {
     	    	$this->errorOutput(NO_BILLID);
     }
     */
     if (intval($this->input['sort_id']) < 0) {
         $this->errorOutput(NO_SORT);
     }
     $id = intval($this->input['id']);
     $data = array('sort_id' => intval($this->input['sort_id']), 'cost' => intval($this->input['cost']), 'cost_capital' => hg_cny(intval($this->input['cost'])), 'remark' => trim($this->input['remark']), 'is_ticket' => intval($this->input['is_ticket']), 'cost_time' => strtotime(trim($this->input['cost_time'])), 'state' => intval($this->input['state']), 'update_time' => TIMENOW);
     if ($this->input['bill_id']) {
         include_once CUR_CONF_PATH . 'lib/bill.class.php';
         $this->bill = new bill();
         $checkbool = $this->bill->checkLocked($this->input['bill_id']);
         if ($checkbool) {
             $this->errorOutput(THIS_IS_LOCKED);
         }
     }
     $material = array();
     $material = parent::upload_indexpic();
     if ($material) {
         $logo_info = array('host' => $material['host'], 'dir' => $material['dir'], 'filepath' => $material['filepath'], 'filename' => $material['filename']);
         $data['img'] = serialize($logo_info);
         $data['material_id'] = $material['id'];
     }
     $old_info = $this->obj->detail($id);
     if ($old_info['state']) {
         $this->reTotalSort(0, $old_info['sort_id']);
     }
     $ret = $this->obj->update($data, $id);
     if ($ret['state']) {
         $this->reTotalSort($data['sort_id'], 0);
     }
     if (intval($this->input['bill_id'])) {
         $this->retotal(intval($this->input['bill_id']));
     }
     $this->addItem($ret);
     $this->output();
 }
Exemple #2
0
 public function detail($id)
 {
     if ($id) {
         $sql = "SELECT * FROM " . DB_PREFIX . "bill WHERE id=" . $id;
     } else {
         $sql = "SELECT * FROM " . DB_PREFIX . "bill WHERE 1";
     }
     $f = $this->db->query_first($sql);
     $f['cost_capital'] = hg_cny($f['cost']);
     return $f;
 }