public function destroy() { $tag = $this->tag; $delete = InvoiceTag::transaction(function () use($tag) { return $tag->destroy(); }); if (!$delete) { return redirect_message(array('admin', $this->get_class()), array('_flash_message' => '刪除失敗!')); } return redirect_message(array('admin', $this->get_class()), array('_flash_message' => '刪除成功!')); }
?> ' method='post' enctype='multipart/form-data'> <input type='hidden' name='_method' value='put' /> <table class='table-form'> <tbody> <tr> <th>類 別:</th> <td> <select name='invoice_tag_id'> <option value='0'<?php echo (isset($posts['invoice_tag_id']) ? $posts['invoice_tag_id'] : $invoice->invoice_tag_id) == 0 ? ' selected' : ''; ?> >其他</option> <?php if ($tags = InvoiceTag::all()) { foreach ($tags as $tag) { ?> <option value='<?php echo $tag->id; ?> '<?php echo (isset($posts['invoice_tag_id']) ? $posts['invoice_tag_id'] : $invoice->invoice_tag_id) == $tag->id ? ' selected' : ''; ?> ><?php echo $tag->name; ?> </option> <?php } }
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 ''; }