/** * Logs the data in error mode. */ private function error_log($title, $log_matter, $IsAuthorised) { require_once OFSC_ROOT . 'toalogservice.php'; $log = ToaLogService::GetLog($IsAuthorised); if ($log != null) { $log->error($title, __METHOD__, array(null, null), $log_matter); } }
/** * Logging incase of auth failures. * To be used in case of auth failures only. */ private function logAuthFailure($message) { // If authentication is failed, then pass '0' while fetching logging object $this->IsAuthorised = 0; $log = ToaLogService::GetLog($this->IsAuthorised); if ($log != null) { $log->error($message); } }
public function updateWorkOrder() { require_once OFSC_ROOT . 'toalogservice.php'; $log = ToaLogService::GetLog(); try { //Input validation is required to prevent malicious data being processed and unexpected data being returned. //Sanitizing the WorkOrderId in order to avoid SQL injection attack. $wkOrderId = $this->sanitizeWorkOrderId(); $result = null; if ($wkOrderId != null) { //Caution: All data that is part of WHERE clause must be sanitized to avoid SQL injection attack. $result = RNCPHP\ROQL::queryObject("SELECT TOA.Work_Order FROM TOA.Work_Order where TOA.Work_Order.ID = " . $wkOrderId)->next(); } else { if ($log != null) { $log->debug("Invalid WorkOrder Id: " . $this->getWorkOrderId()); } } if ($result != null && ($workOrder = $result->next()) != null) { $workOrder->Contact_Phone = $this->getContactPhone(); $workOrder->Contact_Email = $this->getContactEmail(); $workOrder->Contact_Mobile_Phone = $this->getContactMobilePhone(); $workOrder->WO_Time_Slot = $this->getWorkOrderTimeSlot(); $workOrder->WO_Status = $this->getWorkOrderStatus(); $workOrder->End_Time = $this->getEndTime(); $workOrder->Start_End_Time = $this->getStartEndTime(); $workOrder->ETA = $this->getEta(); $workOrder->Delivery_Window_Start = $this->getDeliveryWindowStart(); $workOrder->Delivery_Window_End = $this->getDeliveryWindowEnd(); $workOrder->Resource = $this->getResource(); $workOrder->Travel_Time = $this->getTravelTime(); $workOrder->Field_Service_Note = $this->getFieldServiceNote(); $workOrder->Duration = $this->getDuration(); $updateFailed = false; if ($this->getWorkOrderDate() != null) { try { $workOrderDate = new DateTime($this->getWorkOrderDate()); $workOrder->WO_Date = $workOrderDate->getTimestamp(); } catch (Exception $e) { $updateFailed = true; $this->setResponseStatus('failed'); $this->setResponseDescription('Unable to update WorkOrder'); if ($log != null) { $log->debug("Invalid WorkOrder Date : " . $this->getWorkOrderDate()); } } } else { $updateFailed = true; $this->setResponseStatus('failed'); $this->setResponseDescription('Unable to update WorkOrder'); if ($log != null) { $log->debug("WorkOrder Date is empty or null."); } } if ($this->getExternalId() != null) { $workOrder->External_ID = $this->getExternalId(); } else { $updateFailed = true; $this->setResponseStatus('failed'); $this->setResponseDescription('Unable to update WorkOrder'); if ($log != null) { $log->debug("External Id is null or empty."); } } if (!$updateFailed) { $workOrder->save(); $this->setResponseStatus('sent'); $this->setResponseDescription('WorkOrder updated'); } } else { $this->setResponseStatus('failed'); $this->setResponseDescription('Unable to update WorkOrder'); if ($log != null) { $log->debug("Unable to update WorkOrder Id: " . $this->getWorkOrderId()); } } } catch (RNCPHP\ConnectAPIError $err) { $this->setResponseStatus('failed'); $this->setResponseDescription('Unable to update WorkOrder'); if ($log != null) { $log->debug("Unable to update WorkOrder Id: " . $this->getWorkOrderId() . " Error: " . $err->getMessage()); } } }