public function index($assignment_id) { require_capability('assignments:recordrefrigerantsused'); $technician_id = $this->session->userdata('user_id'); $this->assignment = $this->assignment_model->get($assignment_id); if (empty($this->assignment)) { add_message('This job is no longer on record.', 'warning'); redirect(base_url()); } $order = (object) $this->order_model->get_values($this->assignment->order_id); $order_type = $this->order_model->get_type_string($order->order_type_id); parent::update_time($order->id); $this->load->library('Miniant_Workflow_manager', array(), 'workflow_manager'); $this->workflow_manager->initialise(array('workflow' => $order_type, 'stage' => 'refrigerants_used', 'param' => $assignment_id, 'module' => 'miniant')); if ($technician_id == $order->senior_technician_id) { $units = $this->assignment_model->get_units($assignment_id); } else { $units = $this->assignment_model->get_units($assignment_id, $technician_id); } foreach ($units as $key => $unit) { $units[$key]->assignment = (object) $this->assignment_model->get_values($unit->assignment_id); if (!empty($unit->assignment->diagnostic_id)) { $units[$key]->diagnostic = (object) $this->diagnostic_model->get_values($unit->assignment->diagnostic_id); } $units[$key]->template_parts_used = $this->part_type_model->get(array('unit_type_id' => $unit->unit_type_id, 'in_template' => true)); // $units[$key]->required_parts = $this->diagnostic_model->get_required_parts($units[$key]->diagnostic->id, null, true); $units[$key]->refrigerants = $this->assignment_refrigerant_model->get(array('assignment_id' => $unit->assignment_id)); } $info_title_options = array('title' => 'Unit info', 'help' => 'Information', 'icons' => array()); $title = null; if ($order_type == 'Repair') { $title = 'Repair job: refrigerants used'; } $this->load_stage_view(array('units' => $units, 'info_title_options' => $info_title_options, 'diagnostic_id' => $this->assignment->diagnostic_id, 'title' => $title)); }
public function index($assignment_id) { require_capability('servicequotes:writesqs'); if (!($assignment = $this->assignment_model->get($assignment_id))) { die("The assignment ID {$assignment_id} could not be found!"); } $this->assignment = $this->assignment_model->get($assignment_id); if (empty($this->assignment)) { add_message('This job is no longer on record.', 'warning'); redirect(base_url()); } $order = $this->order_model->get($this->assignment->order_id); $order_type = $this->order_model->get_type_string($order->order_type_id); parent::update_time($order->id); $diagnostics = $this->diagnostic_model->get_for_technician($this->assignment, $this->session->userdata('technician_id'), $order->senior_technician_id); $diagnostic = reset($diagnostics); $tasks = $this->order_model->get_tasks($order->id); $this->load->library('Miniant_Workflow_manager', array(), 'workflow_manager'); $this->workflow_manager->initialise(array('workflow' => $order_type, 'stage' => 'postjob_checklist', 'param' => $assignment_id, 'module' => 'miniant')); $title_options = array('title' => $order_type . ' post-job checklist', 'help' => 'You must complete these tasks before obtaining the client\'s signature', 'icons' => array()); $complete = $this->order_model->has_statuses($order->id, array('POST-JOB COMPLETE')); if (!$complete) { add_message('You must complete all the tasks below before moving to the next section', 'warning'); } $this->load_stage_view(array('tasks' => $tasks, 'completed' => $complete)); }
public function index($assignment_id) { $this->load->model('miniant/diagnostic_tree_model'); require_capability('servicequotes:writesqs'); $technician_id = parent::get_technician_id($assignment_id); $is_technician = user_has_role($this->session->userdata('user_id'), 'Technician'); $this->assignment = $this->assignment_model->get($assignment_id); if (empty($this->assignment)) { add_message('This job is no longer on record.', 'warning'); redirect(base_url()); } $order = (object) $this->order_model->get_values($this->assignment->order_id); $order_type = $this->order_model->get_type_string($order->order_type_id); parent::update_time($order->id); $this->load->library('Miniant_Workflow_manager', array(), 'workflow_manager'); $this->workflow_manager->initialise(array('workflow' => $order_type, 'stage' => 'required_parts', 'param' => $this->assignment->id, 'module' => 'miniant')); if ($technician_id == $order->senior_technician_id) { $units = $this->assignment_model->get_units($assignment_id); } else { $units = $this->assignment_model->get_units($assignment_id, $technician_id); } $diagnostic_estimate_tree = $this->diagnostic_tree_model->get_estimate_tree($assignment_id); $estimated_time = $this->diagnostic_tree_model->get_estimate_time($diagnostic_estimate_tree); // We no longer ask the technician to estimate the labour, it is done entirely by the system based on diagnostic rules $this->diagnostic_model->edit($this->assignment->diagnostic_id, array('estimated_time' => $estimated_time)); // Create SQ if none for this job/unit yet $sq = $this->servicequote_model->get(array('order_id' => $order->id, 'diagnostic_id' => $this->assignment->diagnostic_id), true); if (empty($sq->id)) { $sq_id = $this->servicequote_model->create_from_diagnostic($this->assignment->diagnostic_id); } else { $sq_id = $sq->id; } // Replace required_parts (loaded from step_parts table) with actual parts (from parts table) foreach ($units as $key => $unit) { $units[$key]->assignment = (object) $this->assignment_model->get_values($units[$key]->assignment_id); $units[$key]->diagnostic = (object) $this->diagnostic_model->get_values($units[$key]->assignment->diagnostic_id); // Only provide the SQ ID if this stage has been completed if ($this->assignment_model->has_statuses($units[$key]->assignment_id, array('REQUIRED PARTS RECORDED'))) { $units[$key]->required_parts = $this->diagnostic_model->get_required_parts($units[$key]->assignment->diagnostic_id, $sq_id); } else { $units[$key]->required_parts = $this->diagnostic_model->get_required_parts($units[$key]->assignment->diagnostic_id); } foreach ($units[$key]->required_parts as $part_key => $part) { form_element::$default_data["part_model_number[{$part->id}]"] = $part->part_number; } } $parts_title_options = array('title' => '', 'help' => 'Record the parts required this SQ', 'icons' => array()); $info_title_options = array('title' => 'Unit info', 'help' => 'Information', 'icons' => array()); $this->load_stage_view(array('units' => $units, 'parts_title_options' => $parts_title_options, 'info_title_options' => $info_title_options, 'diagnostic_id' => $this->assignment->diagnostic_id, 'is_technician' => $is_technician, 'sq_id' => $sq_id)); }
public function index($assignment_id) { $this->assignment = $this->assignment_model->get_values($assignment_id); if (empty($this->assignment)) { add_message('This job is no longer on record.', 'warning'); redirect(base_url()); } $order = (object) $this->order_model->get_values($this->assignment->order_id); $order_type = $this->order_model->get_type_string($order->order_type_id); $this->load->library('Miniant_Workflow_manager', array(), 'workflow_manager'); $this->workflow_manager->initialise(array('workflow' => $order_type, 'stage' => 'unit_serial', 'param' => $assignment_id, 'module' => 'miniant')); $technician_id = parent::get_technician_id($assignment_id); $is_technician = user_has_role($this->session->userdata('user_id'), 'Technician'); parent::update_time($order->id); $order_technician = $this->order_technician_model->get(array('order_id' => $order->id, 'technician_id' => $technician_id), true); if ($is_technician) { trigger_event('start', 'order_technician', $order_technician->id, false, 'miniant'); } $next_page_url = $this->workflow_manager->get_next_url(); $order_technician = $this->order_technician_model->get(array('order_id' => $order->id, 'technician_id' => $technician_id), true); $units = $this->get_units($assignment_id, $technician_id, $order->senior_technician_id); $this->load_stage_view(array('units' => $units)); }
/** * For repairs, breakdown and maintenance workflows, parts used are associated with a diagnosed issue. For Installations they are simply associated with the assignment * @param string $type Repair workflows use this stage twice. The first time is for parts used during the assigned repair tasks (type == null). The second time is following a new diagnostic (type == 'diagnostic') */ public function index($assignment_id, $type = null) { require_capability('assignments:recordpartsused'); $technician_id = $this->session->userdata('user_id'); $this->assignment = $this->assignment_model->get($assignment_id); if (empty($this->assignment)) { add_message('This job is no longer on record.', 'warning'); redirect(base_url()); } $order = (object) $this->order_model->get_values($this->assignment->order_id); $order_type = $this->order_model->get_type_string($order->order_type_id); parent::update_time($order->id); $this->load->library('Miniant_Workflow_manager', array(), 'workflow_manager'); $this->workflow_manager->initialise(array('workflow' => $order_type, 'stage' => 'parts_used', 'param' => $this->assignment->id, 'extra_param' => $type, 'module' => 'miniant')); if ($technician_id == $order->senior_technician_id) { $units = $this->assignment_model->get_units($assignment_id); } else { $units = $this->assignment_model->get_units($assignment_id, $technician_id); } // TODO This is very messy and confusing. Needs to be refactored! // We need to load the following: // 1. Parts required to be used, determined by the diagnosed issues and their diagnostic_rules // 2. Template parts (Nitrogen, sundries etc.) that we always show the technician // 3. Values for the above if they were entered previously foreach ($units as $key => $unit) { $units[$key]->assignment = (object) $this->assignment_model->get_values($unit->assignment_id); // Installations don't have a diagnostic if (!empty($units[$key]->assignment->diagnostic_id)) { $units[$key]->diagnostic = (object) $this->diagnostic_model->get_values($unit->assignment->diagnostic_id); } // Template parts $template_parts_used = $this->part_type_model->get(array('unit_type_id' => $unit->unit_type_id, 'in_template' => true)); $for_repair_task = $order_type == 'Repair' && $type != 'diagnostic'; foreach ($template_parts_used as $key2 => $template_part) { if ($part_used = $this->part_model->get(array('assignment_id' => $unit->assignment_id, 'part_type_id' => $template_part->id, 'for_repair_task' => $for_repair_task), true)) { $template_parts_used[$key2]->description = $template_part->field_type == 'text' ? $part_used->description : $part_used->quantity; $this->preload_form_data($template_part, $part_used); } else { $template_parts_used[$key2]->description = null; } } $units[$key]->template_parts_used = $template_parts_used; $first_repair_task = $this->repair_task_model->get(array('assignment_id' => $unit->assignment_id), true); if (!empty($first_repair_task->diagnostic_issue_id)) { $diagnostic_issue = $this->diagnostic_issue_model->get($first_repair_task->diagnostic_issue_id); if ($type == 'diagnostic') { $units[$key]->diagnostic = $this->diagnostic_model->get($this->assignment->diagnostic_id, true); } else { $units[$key]->diagnostic = $this->diagnostic_model->get($diagnostic_issue->diagnostic_id, true); } } else { if (!empty($units[$key]->assignment->diagnostic_id)) { $units[$key]->diagnostic = $this->diagnostic_model->get($units[$key]->assignment->diagnostic_id, true); } } // Required parts based on diagnostic if (!empty($units[$key]->diagnostic)) { $can_be_fixed_now = $order_type != 'Repair'; $units[$key]->diagnostic_issues = $this->diagnostic_issue_model->get(array('diagnostic_id' => $units[$key]->diagnostic->id, 'can_be_fixed_now' => $can_be_fixed_now)); $required_parts = $this->diagnostic_model->get_required_parts($units[$key]->diagnostic->id, null, $can_be_fixed_now); foreach ($required_parts as $key2 => $required_part) { $part_type = $this->part_type_model->get($required_part->part_type_id); if (empty($required_part->part_name)) { $required_parts[$key2]->part_name = $part_type->name; } if ($part_used = $this->part_model->get(array('assignment_id' => $unit->assignment_id, 'part_type_id' => $part_type->id), true)) { $this->preload_form_data($part_type, $part_used); } } $units[$key]->required_parts = $required_parts; } else { $units[$key]->required_parts = array(); } $units[$key]->custom_parts = array(); if ($custom_parts = $this->part_model->get_custom_parts($unit->assignment_id)) { $units[$key]->custom_parts = $custom_parts; foreach ($custom_parts as $custom_part) { form_element::$default_data['custom_description[' . $custom_part->id . ']'] = $custom_part->quantity; form_element::$default_data['custom_po_number[' . $custom_part->id . ']'] = $custom_part->po_number; form_element::$default_data['custom_origin[' . $custom_part->id . ']'] = $custom_part->origin; } } } $title = ''; switch ($order_type) { case 'Installation': $title = 'Parts used during installation'; break; case 'Repair': $title = 'Repair job: parts used'; break; case 'Breakdown': case 'Maintenance': case 'Service': $title = 'Parts used to repair diagnosed issues'; } $parts_title_options = array('title' => '', 'help' => 'Record the parts used to repair the reported issues', 'icons' => array()); $info_title_options = array('title' => 'Unit info', 'help' => 'Information', 'icons' => array()); $this->load_stage_view(array('units' => $units, 'diagnostic_id' => $this->assignment->diagnostic_id, 'parts_title_options' => $parts_title_options, 'info_title_options' => $info_title_options, 'title' => $title, 'type' => $type)); }