public function modify_custom($ticket_id, $custom_input) { $ticket_customs = $this->get_all_custom($ticket_id); $ticket_columns = array(); foreach ($ticket_customs as $row) { $ticket_columns[$row['column_name']] = $row; } foreach ($custom_input as $key => $value) { if (!empty($ticket_columns[$key]['detail']) || !empty($value)) { if (is_null($ticket_columns[$key]['detail'])) { $custom_detail = new Model_TicketColumnDetail(); $custom_detail->ticket_id = $ticket_id; $custom_detail->column_id = $ticket_columns[$key]['column_id']; $custom_detail->detail = !empty($value) ? $value : ''; $custom_detail->updated_at = date("Y-m-d H:i:s"); $custom_detail->save(); $c_id = $custom_detail->id; } else { $dao = Model_TicketColumnDetail::data_access(); $custom_detail = $dao->find_by_pk($ticket_columns[$key]['id']); $custom_detail->detail = !empty($value) ? $value : ''; $custom_detail->updated_at = date("Y-m-d H:i:s"); $custom_detail->save(); $c_id = $custom_detail->id; } } } return $c_id; }
public function ticket_custom_add($ticket_id, $custom_arr) { foreach ($custom_arr as $k => $v) { if (!empty($v)) { $custom_detail = new Model_TicketColumnDetail(); $custom_detail->ticket_id = $ticket_id; $custom_detail->column_id = 1; $custom_detail->detail = $v; $custom_detail->updated_at = date("Y-m-d H:i:s"); $custom_detail->save(); $c_id = $custom_detail->id; } } return $c_id; }