Ejemplo n.º 1
0
 /**
  * @param $cityId
  * @param $hours
  * @return bool|string
  */
 public function getIncrementedDateCity($cityId, $hours)
 {
     $cityDao = new \DDD\Dao\Geolocation\Cities($this->getServiceLocator(), 'ArrayObject');
     $city = $cityDao->fetchOne(['id' => $cityId], ['timezone']);
     if ($city && $city['timezone']) {
         return Helper::incrementDateByTimezone($city['timezone'], $hours, 'Y-m-d H:i:s');
     }
     return date('Y-m-d H:i:s');
 }
Ejemplo n.º 2
0
 public function ajaxReportIncidentAction()
 {
     /**
      * @var \DDD\Dao\Booking\Booking $reservationDao
      * @var \DDD\Service\Task $taskService
      */
     $user = $this->getServiceLocator()->get('library_backoffice_auth');
     $taskService = $this->getServiceLocator()->get('service_task');
     $request = $this->getRequest();
     $result = ['status' => 'success', 'msg' => 'Incident report has been created.', 'title' => '', 'taskId' => 0];
     $taskId = (int) $request->getPost('task_id', 0);
     try {
         if ($request->isXmlHttpRequest() && $taskId) {
             $task = $taskService->getTaskDao()->getTaskById($taskId);
             $apartmentId = $task->getProperty_id();
             $buildingId = $task->getBuildingId();
             $resId = $task->getResId();
             $timezone = $task->getTimezone();
             $currentDateCity = Helper::getCurrenctDateByTimezone($timezone, 'Y-m-d H:i:s');
             $ninetySixHoursLaterDateCity = Helper::incrementDateByTimezone($timezone, 96, 'Y-m-d H:i:s');
             $userId = $user->getIdentity()->id;
             $creator = $user->getIdentity()->id;
             switch ((int) $request->getPost('incident_type', 0)) {
                 case HouseKeeping::INCIDENT_REPORT_EVIDENCE_OF_SMOKING:
                     $damageType = 'There was evidence of smoking';
                     break;
                 case HouseKeeping::INCIDENT_REPORT_KEYS_WERE_NOT_RETURNED:
                     $damageType = 'The keys were not returned';
                     break;
                 case HouseKeeping::INCIDENT_REPORT_DIRTY_HOUSE:
                     $damageType = 'The house was left in a unusually dirty condition';
                     break;
                 case HouseKeeping::INCIDENT_REPORT_BROKEN_FURNITURE:
                     $damageType = 'There was broken furniture';
                     break;
                 case HouseKeeping::INCIDENT_REPORT_OTHER:
                     $damageType = $request->getPost('description', 'Incident Report');
                     break;
             }
             $title = $damageType;
             $description = '';
             $incidentTaskId = $taskService->createReportIncidentTask($resId, $apartmentId, $buildingId, $currentDateCity, $ninetySixHoursLaterDateCity, $title, $creator, $description, $userId, $taskId);
             $result['title'] = $title;
             $result['taskId'] = $incidentTaskId;
         }
     } catch (\Exception $e) {
         $result['status'] = 'error';
         $result['msg'] = TextConstants::SERVER_ERROR;
     }
     return new JsonModel($result);
 }