public function save_installation_task_notes()
 {
     $task_id = $this->input->post('task_id');
     $notes = $this->input->post('notes');
     $this->installation_task_model->edit($task_id, array('notes' => $notes));
     send_json_message('Task successfully updated', 'success');
 }
 public function add_travel_time()
 {
     $assignment_id = $this->input->post('assignment_id');
     $value = $this->input->post('value');
     $assignment = $this->assignment_model->get($assignment_id);
     $this->order_time_model->push_back_starting_time($assignment->order_id, $assignment->technician_id, $value);
     send_json_message('The starting time has been updated.', 'success');
 }
 public function set_order_task_status()
 {
     $status = $this->input->post('status');
     $order_task_id = $this->input->post('order_task_id');
     $order_id = $this->input->post('order_id');
     $this->orders_task_model->update_order_task($status, $order_task_id, $order_id);
     send_json_message('The tasks was successfully updated');
 }
 public function set_task_status()
 {
     $status = $this->input->post('status');
     $maintenance_task_template_id = $this->input->post('maintenance_task_template_id');
     $assignment_id = $this->input->post('assignment_id');
     $this->maintenance_task_model->update_task($status, $maintenance_task_template_id, $assignment_id);
     $all_completed = $this->maintenance_task_model->all_tasks_completed($assignment_id);
     trigger_event('maintenance_tasks_completed', 'assignment', $assignment_id, !$all_completed, 'miniant');
     send_json_message('The task was successfully updated');
 }
Esempio n. 5
0
 public function remove_message($message_id)
 {
     $message = $this->message_model->get($message_id);
     if ($message->author_id != $this->session->userdata('user_id') && !has_capability('orders:deleteothermessages')) {
         send_json_message('You are not authorised to delete another person\'s notes!', 'warning');
     } else {
         $this->message_model->delete($message_id);
         send_json_message('The message was deleted');
     }
 }
 public function get_diagnostic_diagram()
 {
     $order_id = $this->input->post('order_id');
     $order = (object) $this->order_model->get_values($order_id);
     if (empty($order->location_diagram_id)) {
         send_json_message('There is no diagram for this job site yet', 'warning');
         return false;
     } else {
         $location_diagram = $this->location_diagram_model->get($order->location_diagram_id);
         send_json_data(array('dataurl' => $location_diagram->diagram));
     }
 }
 public function set_task_status()
 {
     $status = $this->input->post('status');
     $task_id = $this->input->post('repair_task_id');
     $task = $this->repair_task_model->get($task_id);
     $assignment = $this->assignment_model->get_from_cache($task->assignment_id);
     $this->repair_task_model->update_task($status, $task_id);
     if (!$status) {
         trigger_event('repair_tasks_completed', 'order', $assignment->order_id, true, 'miniant');
     }
     send_json_message('The task was successfully updated');
 }
 public function process_edit()
 {
     require_capability('site:editrefrigerant_types');
     $required_fields = array('name' => 'Refrigerant type name');
     if ($refrigerant_type_id = (int) $this->input->post('refrigerant_type_id')) {
         $refrigerant_type = $this->refrigerant_type_model->get($refrigerant_type_id);
         $redirect_url = base_url() . 'miniant/refrigerant_types/edit/' . $refrigerant_type_id;
     } else {
         $redirect_url = base_url() . 'miniant/refrigerant_types/add';
         $refrigerant_type_id = null;
     }
     foreach ($required_fields as $field => $description) {
         $this->form_validation->set_rules($field, $description, 'trim|required');
     }
     $success = $this->form_validation->run();
     $action_word = $refrigerant_type_id ? 'updated' : 'created';
     if (IS_AJAX) {
         $json = new stdClass();
         if ($success) {
             $json->result = 'success';
             $json->message = "Refrigerant type {$refrigerant_type_id} has been successfully {$action_word}!";
         } else {
             send_json_message($this->form_validation->error_string(' ', "\n"), 'danger');
             return null;
         }
     } else {
         if (!$success) {
             add_message('The form could not be submitted. Please check the errors below', 'danger');
             $errors = validation_errors();
             return $this->edit($refrigerant_type_id);
         }
     }
     $refrigerant_type_data = array('name' => $this->input->post('name'));
     if (empty($refrigerant_type_id)) {
         if (!($refrigerant_type_id = $this->refrigerant_type_model->add($refrigerant_type_data))) {
             add_message('Could not create this refrigerant_type!', 'error');
             redirect($redirect_url);
         }
     } else {
         if (!$this->refrigerant_type_model->edit($refrigerant_type_id, $refrigerant_type_data)) {
             add_message('Could not update this refrigerant_type!', 'error');
             redirect($redirect_url);
         }
     }
     add_message("Refrigerant type {$refrigerant_type_id} has been successfully {$action_word}!", 'success');
     redirect(base_url() . 'miniant/refrigerant_types');
 }
Esempio n. 9
0
 public function remove_part()
 {
     $sr_part_id = $this->input->post('order_part_id');
     $this->orders_part_model->delete($sr_part_id);
     send_json_message('This part was successfully removed from this unit');
 }
 public function delete_refrigerant_used($assignment_refrigerant_id)
 {
     $assignment_refrigerant = $this->assignment_refrigerant_model->get($assignment_refrigerant_id);
     $this->assignment_refrigerant_model->delete(array('id' => $assignment_refrigerant_id));
     if (!$this->assignment_refrigerant_model->get(array('assignment_id' => $assignment_refrigerant->assignment_id))) {
         trigger_event('refrigerant_used_recorded', 'assignment', $assignment_refrigerant->assignment_id, true, 'miniant');
     }
     send_json_message('The refrigerant used/reclaimed was successfully deleted');
 }
Esempio n. 11
0
 public function add_or_remove_technician()
 {
     $added_id = $this->input->post('added_id');
     $removed_id = $this->input->post('removed_id');
     $assignment_id = $this->input->post('assignment_id');
     $order_id = $this->input->post('order_id');
     $unit_id = $this->input->post('unit_id');
     if (!empty($added_id)) {
         if (!($assignment = $this->assignment_model->get(array('order_id' => $order_id, 'technician_id' => $added_id, 'unit_id' => $unit_id)))) {
             $assignment = $this->assignment_model->get($assignment_id);
             $this->assignment_model->add(array('appointment_date' => $assignment->appointment_date, 'estimated_duration' => $assignment->estimated_duration, 'technician_id' => $added_id, 'order_id' => $order_id, 'unit_id' => $assignment->unit_id, 'workflow_id' => $assignment->workflow_id, 'location_token' => $assignment->location_token, 'diagnostic_required' => $assignment->diagnostic_required, 'diagnostic_authorised' => $assignment->diagnostic_authorised, 'no_issues_found' => $assignment->no_issues_found, 'dowd_text' => $assignment->dowd_text));
         }
     } else {
         if (!empty($removed_id)) {
             if ($assignment = $this->assignment_model->get(array('order_id' => $order_id, 'technician_id' => $removed_id, 'unit_id' => $unit_id), true)) {
                 $this->assignment_model->delete($assignment->id);
             }
         }
     }
     send_json_message('success');
 }
Esempio n. 12
0
 public function process_edit()
 {
     require_capability('site:editaccounts');
     $required_fields = array('name' => 'Billing Name', 'billing_address_city' => 'Billing address suburb', 'billing_address_postcode' => 'Billing address post code');
     if ($this->input->post('billing_address_po_box_on')) {
         $required_fields['billing_address_po_box'] = 'Billing address PO Box';
     } else {
         $required_fields['billing_address_number'] = 'Billing address number';
         $required_fields['billing_address_street'] = 'Billing address street';
         $required_fields['billing_address_street_type'] = 'Billing address street type';
     }
     if ($account_id = (int) $this->input->post('account_id')) {
         $account = $this->account_model->get($account_id);
         $redirect_url = base_url() . 'accounts/edit/' . $account_id;
     } else {
         $redirect_url = base_url() . 'accounts/add';
         $account_id = null;
     }
     foreach ($required_fields as $field => $description) {
         $this->form_validation->set_rules($field, $description, 'trim|required');
     }
     $success = $this->form_validation->run();
     $action_word = $account_id ? 'updated' : 'created';
     if (IS_AJAX) {
         $json = new stdClass();
         if ($success) {
             $json->result = 'success';
             $json->message = "account {$account_id} has been successfully {$action_word}!";
         } else {
             send_json_message($this->form_validation->error_string(' ', "\n"), 'danger');
             return null;
         }
     } else {
         if (!$success) {
             add_message('The form could not be submitted. Please check the errors below', 'danger');
             $errors = validation_errors();
             return $this->edit($account_id);
         }
     }
     $account_data = array('name' => $this->input->post('name'), 'cc_hold' => $this->input->post('cc_hold'), 'abn' => $this->input->post('abn'));
     if (empty($account_id)) {
         if (!($account_id = $this->account_model->add($account_data))) {
             add_message('Could not create this account!', 'error');
             redirect($redirect_url);
         }
     } else {
         if (!$this->account_model->edit($account_id, $account_data)) {
             add_message('Could not update this account!', 'error');
             redirect($redirect_url);
         }
     }
     $billing_address_data = array('unit' => $this->input->post('billing_address_unit'), 'po_box_on' => $this->input->post('billing_address_po_box_on'), 'po_box' => $this->input->post('billing_address_po_box'), 'street' => $this->input->post('billing_address_street'), 'street_type' => $this->input->post('billing_address_street_type'), 'number' => $this->input->post('billing_address_number'), 'city' => $this->input->post('billing_address_city'), 'postcode' => $this->input->post('billing_address_postcode'), 'type_id' => $this->address_model->get_type_id('Billing'), 'account_id' => $account_id);
     if ($billing_address_data['po_box_on']) {
         $billing_address_data['unit'] = null;
         $billing_address_data['number'] = null;
         $billing_address_data['street'] = null;
         $billing_address_data['street_type'] = null;
     } else {
         $billing_address_data['po_box_on'] = false;
     }
     $billing_address_id = $this->input->post('billing_address_id');
     if ($billing_address_id) {
         $this->address_model->edit($this->input->post('billing_address_id'), $billing_address_data);
     } else {
         $billing_address_id = $this->address_model->add($billing_address_data);
     }
     add_message("account {$account_id} has been successfully {$action_word}!", 'success');
     redirect(base_url() . 'accounts');
 }
Esempio n. 13
0
 public function update_event()
 {
     $id = $this->input->post('id');
     $job_site_id = $this->input->post('job_site_id');
     $confirmed = $this->input->post('confirmed');
     $start = $this->input->post('start');
     $title = $this->input->post('title');
     $all_day = $this->input->post('all_day');
     $source = $this->input->post('source');
     $booking = $this->booking_model->get($id);
     $booking_params = array('booking_date' => $start);
     $this->booking_model->edit($id, $booking_params);
     send_json_message('The booking was successfully updated.');
 }
Esempio n. 14
0
 public function delete_tree_element()
 {
     $this->load->model('miniant/diagnostic_tree_model');
     $element_type = $this->input->post('element_type');
     $element_id = $this->input->post('element_id');
     $method_name = "delete_{$element_type}";
     if ($this->diagnostic_tree_model->{$method_name}($element_id)) {
         send_json_message("This {$element_type} was successfully deleted", 'success');
     } else {
         send_json_message("This {$element_type} could not be deleted", 'danger');
     }
 }
Esempio n. 15
0
 public function delete_status_event($status_event_id)
 {
     $this->status_event_model->delete($status_event_id);
     send_json_message('The status trigger was successfully deleted');
 }
 public function update_statuses($servicequote_id)
 {
     require_capability('servicequotes:editsqs');
     $status_ids = $this->input->post('values');
     $this->servicequote_model->set_statuses($servicequote_id, $status_ids);
     send_json_message('Statuses were updated');
 }
Esempio n. 17
0
 public function update_statuses($invoice_tenancy_id)
 {
     $status_ids = $this->input->post('values');
     $this->invoice_tenancy_model->set_statuses($invoice_tenancy_id, $status_ids);
     send_json_message('Statuses were updated');
 }
 public function remove_tenancy($tenancy_id, $units_too = false)
 {
     if ($units_too) {
         $this->unit_model->delete(array('tenancy_id' => $tenancy_id));
     }
     if ($this->unit_model->get(compact('tenancy_id'))) {
         send_json_message('This tenancy is associated with existing units', 'danger');
         return false;
     }
     $this->tenancy_model->delete($tenancy_id);
     send_json_message('Tenancy/Owner successfully deleted', 'success');
 }
Esempio n. 19
0
 public function process_edit()
 {
     require_capability('site:editaddresses');
     $required_fields = array('number' => 'Number', 'street' => 'Street address', 'street_type' => 'Street type', 'city' => 'Suburb', 'postcode' => 'Postcode', 'type_id' => 'Address Type');
     if ($address_id = (int) $this->input->post('address_id')) {
         $address = $this->address_model->get($address_id);
         $redirect_url = base_url() . 'addresses/edit/' . $address_id;
     } else {
         $redirect_url = base_url() . 'addresses/add';
         $address_id = null;
     }
     foreach ($required_fields as $field => $description) {
         $this->form_validation->set_rules($field, $description, 'trim|required');
     }
     $success = $this->form_validation->run();
     $action_word = $address_id ? 'updated' : 'created';
     if (IS_AJAX) {
         $json = new stdClass();
         if ($success) {
             $json->result = 'success';
             $json->message = "address {$address_id} has been successfully {$action_word}!";
         } else {
             send_json_message($this->form_validation->error_string(' ', "\n"), 'danger');
             return null;
         }
     } else {
         if (!$success) {
             add_message('The form could not be submitted. Please check the errors below', 'danger');
             $errors = validation_errors();
             return $this->edit($address_id);
         }
     }
     $address_data = array('unit' => $this->input->post('unit'), 'account_id' => $this->input->post('account_id'), 'number' => $this->input->post('number'), 'street' => $this->input->post('street'), 'street_type' => $this->input->post('street_type'), 'city' => $this->input->post('city'), 'state' => 'WA', 'postcode' => $this->input->post('postcode'), 'type_id' => $this->input->post('type_id'));
     if (empty($address_data['account_id'])) {
         $address_data['account_id'] = null;
     }
     if (empty($address_id)) {
         if (!($address_id = $this->address_model->add($address_data))) {
             add_message('Could not create this address!', 'error');
             redirect($redirect_url);
         }
     } else {
         if (!$this->address_model->edit($address_id, $address_data)) {
             add_message('Could not update this address!', 'error');
             redirect($redirect_url);
         }
     }
     // If requested through AJAX, echo response, do not redirect
     if (IS_AJAX) {
         echo json_encode($json);
         return null;
     }
     add_message("address {$address_id} has been successfully {$action_word}!", 'success');
     redirect($redirect_url);
 }
Esempio n. 20
0
 public function update_event()
 {
     if (IS_AJAX) {
         $assignment_id = $this->input->post('document_id');
         $technician_id = $this->input->post('technician_id');
         $start = strtotime($this->input->post('start'));
         $end = strtotime($this->input->post('end'));
         $title = $this->input->post('title');
         $all_day = $this->input->post('all_day');
         $source = $this->input->post('source');
     } else {
         var_dump($this->input->post());
         die;
     }
     $order_type = strtolower($source['data']['order_type']);
     $assignment = $this->assignment_model->get($assignment_id);
     $unit = $this->unit_model->get($assignment->unit_id);
     $assignment_params = array('technician_id' => $technician_id, 'appointment_date' => $start, 'estimated_duration' => ($end - $start) / 60, 'priority_level_id' => 1);
     $this->assignment_model->edit($assignment_id, $assignment_params);
     // If only one technician is left working on this job, set him up as the senior technician
     $this->order_model->set_as_senior_if_last($assignment_id);
     if (IS_AJAX) {
         send_json_message('The event was successfully updated.');
     } else {
         return true;
     }
 }