public function ticket_add($input_arr) { $current_time = date("Y-m-d H:i:s"); $ticket = new Model_Ticket(); $ticket->created_at = $current_time; $ticket->updated_at = $current_time; $ticket->priority = $input_arr['priority']; $ticket->emergency = $input_arr['emergency']; $ticket->reporter = $input_arr['reporter']; $ticket->owner = $input_arr['owner']; $ticket->assigned_qa = $input_arr['assigned_qa']; $ticket->status = $input_arr['status']; $ticket->summary = $input_arr['summary']; $ticket->pmt_id = $input_arr['pmt_id']; $ticket->environment = $input_arr['environment']; $ticket->department = $input_arr['department']; $ticket->component = $input_arr['component']; $ticket->is_regression = isset($input_arr['is_regression']) ? $input_arr['is_regression'] : '0'; $ticket->version = $input_arr['version']; $ticket->description = $input_arr['description']; $ticket->is_occasional = isset($input_arr['is_occasional']) ? $input_arr['is_occasional'] : '0'; $ticket->person_liable = $input_arr['person_liable']; $ticket->resolution = ''; $ticket->reason = ''; $ticket->reason_detail = ''; $ticket->save(); $ticket_id = $ticket->id; //add cc $cc_arr_whole = explode(';', $input_arr['cc_user']); $cc_arr_user = Bll_UserBiz::get_instance()->process_cc_users($cc_arr_whole); if ($input_arr['component']) { $owner = Bll_DdComponentBiz::get_instance()->get_owner_by_id($input_arr['component']); if ($owner) { $owner_arr = explode(";", $owner); foreach ($owner_arr as $row) { if ($row) { $cc_arr_user[] = $row; } } } } $custom_cc = APF::get_instance()->get_config('custom_cc'); foreach ($custom_cc as $c) { if (count(array_intersect($c['environment'], array($ticket->environment, '0'))) > 0 && in_array($c['priority'], array($ticket->priority, '0')) && in_array($c['component'], array($ticket->component, '0')) && count(array_intersect($c['department'], array($ticket->department, '0'))) > 0) { foreach ($c['cc'] as $crow) { $cc_arr_user[] = $crow; } } } $custom_p01cc = APF::get_instance()->get_config('custom_p01cc'); if ($ticket->priority == 11 || $ticket->priority == 7 || $ticket->priority == 80) { if ($ticket->environment == 19) { foreach ($custom_p01cc as $c) { $cc_arr_user[] = $c; } } } $cc_arr_user = array_unique($cc_arr_user); $add = Bll_TicketCcBiz::get_instance()->cc_user_add($ticket_id, $cc_arr_user); return $ticket_id; }
public function action_close() { $user = Auth::instance()->get_user(); $ticket_id = $this->request->param('id', 0); //getting the parent ticket $ticket = new Model_Ticket(); //only supportadmin can close any ticket if (!$user->has_access('supportadmin')) { $ticket->where('id_user', '=', $user->id_user); } $ticket->where('id_ticket', '=', $ticket_id)->where('id_ticket_parent', 'IS', NULL)->limit(1)->find(); if (!$ticket->loaded()) { Alert::set(Alert::ERROR, __('Not your ticket.')); $this->redirect(Route::url('oc-panel', array('controller' => 'support', 'action' => 'index'))); } else { //close ticket $ticket->status = Model_Ticket::STATUS_CLOSED; $ticket->save(); Alert::set(Alert::SUCCESS, __('Ticket closed.')); $this->redirect(Route::url('oc-panel', array('controller' => 'support', 'action' => 'index'))); } }