/** * Get WorkOrder models from soap payload * @return Array of WorkOrder models */ private function get_work_order_models() { require_once OFSC_ROOT . 'xtree.php'; require_once OFSC_ROOT . 'workorder.php'; $workOrders = array(); $payload = $this->get_http_post_data(); $payload = htmlspecialchars_decode($payload); $payloadTree = new xtree(array('xmlRaw' => $payload, 'stripNamespaces' => true)); $messages = $payloadTree->xtree->Envelope->Body->send_message->messages->message; if (count($messages) == 1) { $workOrder = new WorkOrder(); $workOrder->setMsgId($messages->message_id->_['value']); $workOrder->setUsername($messages->body->username->_['value']); $workOrder->setPassword($messages->body->password->_['value']); $workOrder->setWorkOrderId($messages->body->appt_number->_['value']); $workOrder->setContact($messages->body->customer_number->_['value']); $workOrder->setContactPhone($messages->body->cphone->_['value']); $workOrder->setContactEmail($messages->body->cemail->_['value']); $workOrder->setContactMobilePhone($messages->body->ccell->_['value']); $workOrder->setWorkOrderTimeSlot($messages->body->time_slot->_['value']); $workOrder->setWorkOrderDate($messages->body->date->_['value']); $workOrder->setWorkOrderStatus($messages->body->astatus->_['value']); $workOrder->setEndTime($messages->body->end_time->_['value']); $workOrder->setStartEndTime($messages->body->eta_end_time->_['value']); $workOrder->setEta($messages->body->ETA->_['value']); $workOrder->setExternalId($messages->body->aid->_['value']); $workOrder->setDeliveryWindowStart($messages->body->delivery_window_start->_['value']); $workOrder->setDeliveryWindowEnd($messages->body->delivery_window_end->_['value']); $workOrder->setResource($messages->body->pname->_['value']); $workOrder->setTravelTime($messages->body->travel->_['value']); $workOrder->setFieldServiceNote($messages->body->XA_ACTIVITY_NOTES->_['value']); $workOrder->setDuration($messages->body->duration->_['value']); array_push($workOrders, $workOrder); } else { foreach ($messages as $val) { $workOrder = new WorkOrder(); $workOrder->setUsername($val->body->username->_['value']); $workOrder->setPassword($val->body->password->_['value']); $workOrder->setMsgId($val->message_id->_['value']); $workOrder->setWorkOrderId($val->body->appt_number->_['value']); $workOrder->setContact($val->body->customer_number->_['value']); $workOrder->setContactPhone($val->body->cphone->_['value']); $workOrder->setContactEmail($val->body->cemail->_['value']); $workOrder->setContactMobilePhone($val->body->ccell->_['value']); $workOrder->setWorkOrderTimeSlot($val->body->time_slot->_['value']); $workOrder->setWorkOrderDate($val->body->date->_['value']); $workOrder->setWorkOrderStatus($val->body->astatus->_['value']); $workOrder->setEndTime($val->body->end_time->_['value']); $workOrder->setStartEndTime($val->body->eta_end_time->_['value']); $workOrder->setEta($val->body->ETA->_['value']); $workOrder->setExternalId($val->body->aid->_['value']); $workOrder->setDeliveryWindowStart($val->body->delivery_window_start->_['value']); $workOrder->setDeliveryWindowEnd($val->body->delivery_window_end->_['value']); $workOrder->setResource($val->body->pname->_['value']); $workOrder->setTravelTime($val->body->travel->_['value']); $workOrder->setFieldServiceNote($val->body->XA_ACTIVITY_NOTES->_['value']); $workOrder->setDuration($val->body->duration->_['value']); array_push($workOrders, $workOrder); } } return $workOrders; }