public function __construct() { parent::__construct(); if (in_array($this->uri->rsegments(2, 0), array('edit', 'update', 'destroy'))) { if (!(($id = $this->uri->rsegments(3, 0)) && ($this->tag = InvoiceTag::find_by_id($id)))) { return redirect_message(array('admin', $this->get_class()), array('_flash_message' => '找不到該筆資料。')); } } $this->add_tab('類別列表', array('href' => base_url('admin', $this->get_class()), 'index' => 1))->add_tab('新增類別', array('href' => base_url('admin', $this->get_class(), 'add'), 'index' => 2)); }
private function _validation_posts(&$posts) { if (!(isset($posts['invoice_tag_id']) && is_numeric($posts['invoice_tag_id'] = trim($posts['invoice_tag_id'])) && $posts['invoice_tag_id'] >= 0 && (!$posts['invoice_tag_id'] || InvoiceTag::find_by_id($posts['invoice_tag_id'])))) { return '沒有選擇類別 或 類別錯誤!'; } if (!(isset($posts['user_id']) && is_numeric($posts['user_id'] = trim($posts['user_id'])) && $posts['user_id'] >= 0 && (!$posts['user_id'] || User::find_by_id($posts['user_id'])))) { return '沒有選擇負責人 或 負責人錯誤!'; } if (!(isset($posts['name']) && ($posts['name'] = trim($posts['name'])))) { return '沒有填寫名稱!'; } if (!(isset($posts['contact']) && ($posts['contact'] = trim($posts['contact'])))) { return '沒有填寫窗口!'; } if (!(isset($posts['quantity']) && is_numeric($posts['quantity'] = trim($posts['quantity'])) && $posts['quantity'] > 0 && $posts['quantity'] < 4294967296)) { return '沒有填寫數量 或 數量錯誤!'; } if (!(isset($posts['single_money']) && is_numeric($posts['single_money'] = trim($posts['single_money'])) && $posts['single_money'] > 0 && $posts['single_money'] < 4294967296)) { return '沒有填寫單價 或 單價錯誤!'; } if (!(isset($posts['all_money']) && is_numeric($posts['all_money'] = trim($posts['all_money'])) && $posts['all_money'] > 0 && $posts['all_money'] < 4294967296)) { return '沒有填寫金額 或 金額錯誤!'; } if (!(isset($posts['closing_at']) && ($posts['closing_at'] = trim($posts['closing_at'])) && DateTime::createFromFormat('Y-m-d', $posts['closing_at']) !== false)) { return '沒有選擇結案日期 或 格式錯誤!'; } if (!isset($posts['pic_ids'])) { $posts['pic_ids'] = array(); } if (!(isset($posts['is_finished']) && ($posts['is_finished'] = trim($posts['is_finished'])))) { $posts['is_finished'] = 0; } else { $posts['is_finished'] = 1; } return ''; }