Beispiel #1
0
 /**
  * @param $data
  * @param array $actionsSet
  * @return array
  */
 private function getStatuses($data, $actionsSet)
 {
     $statuses = TaskService::getTaskStatus();
     if (!$data) {
         $statuses = [TaskService::STATUS_NEW => 'New'];
     } else {
         if (!empty($actionsSet[TaskService::ACTION_CHANGE_STATUS])) {
             $statuses = TaskService::getTaskStatus();
             if ($actionsSet[TaskService::ACTION_CHANGE_STATUS] == 2) {
                 unset($statuses[TaskService::STATUS_NEW]);
                 unset($statuses[TaskService::STATUS_VERIFIED]);
                 unset($statuses[TaskService::STATUS_CANCEL]);
             }
         }
     }
     return $statuses;
 }
 public function getTasksAction()
 {
     /**
      * @todo: Split this method to 5 separate methods on one per every type: "doing', "verifying", "created", "team"
      */
     /**
      * @var $taskService \DDD\Service\Task
      * @var $dataSet \DDD\Domain\Task\Task[]
      */
     $taskService = $this->getServiceLocator()->get('service_task');
     $auth = $this->getServiceLocator()->get('library_backoffice_auth');
     $type = $this->params()->fromQuery('type', 'doing');
     $loggedInUserID = $auth->getIdentity()->id;
     $dataSet = $taskService->getUDList($loggedInUserID, $type);
     $preparedData = [];
     if ($dataSet->count()) {
         foreach ($dataSet as $row) {
             $rowClass = $location = '';
             if (strtotime($row->getEndDate()) <= strtotime(date('Y-m-j 23:59')) && $row->getTask_status() < Task::STATUS_DONE) {
                 $rowClass = 'danger';
             }
             if ($row->getProperty_name()) {
                 $location = $row->getProperty_name() . ' (' . $row->getUnit_number() . ')';
             } elseif ($row->getBuildingName()) {
                 $location = $row->getBuildingName();
             }
             $actions = '<a href="/task/edit/' . $row->getId() . '" class="btn btn-xs btn-primary hidden-xs" target="_blank" data-html-content="View"></a>';
             $actions .= '<a href="/task/edit/' . $row->getId() . '" class="btn btn-xs btn-primary visible-xs-block" target="_blank"><span class="glyphicon glyphicon-chevron-right"></span></a>';
             if ($type == 'verifying') {
                 $actions .= ' <a href="/task/edit/' . $row->getId() . '" class="btn btn-xs btn-success btn-task-verify hidden-xs" data-task-id="' . $row->getId() . '">Verify</a>';
             }
             $statusTitle = Task::getTaskStatus()[$row->getTask_status()];
             $statusLabelClass = Task::getTaskStatusLabelClass($row->getTask_status());
             $statusTitleFirstCharacter = substr($statusTitle, 0, 1);
             $statusHtml = '<label class="task-label label ' . $statusLabelClass . '" title = "' . $statusTitle . '">' . $statusTitleFirstCharacter . '</label>';
             $preparedData[] = ["0" => Task::getTaskPriorityLabeled()[$row->getPriority()], "1" => $statusHtml, "2" => $row->getCreation_date() ? date(Constants::GLOBAL_DATE_FORMAT, strtotime($row->getCreation_date())) : '', "3" => strlen($row->getTitle()) > 20 ? substr($row->getTitle(), 0, 20) . '...' : $row->getTitle(), "4" => $row->getResponsibleName(), "5" => $location, "6" => $row->getTaskType(), "7" => $row->getEndDate() ? date(Constants::GLOBAL_DATE_FORMAT, strtotime($row->getEndDate())) : '', "8" => $row->getTeamName(), "9" => $actions, "DT_RowClass" => $rowClass];
         }
         return new JsonModel(["aaData" => $preparedData]);
     } else {
         return new JsonModel(["aaData" => []]);
     }
 }
Beispiel #3
0
 private function setStatusSelect()
 {
     return [0 => '-- All Statuses --', Task::STATUS_ALL_OPEN => '-- All Open --'] + Task::getTaskStatus();
 }
Beispiel #4
0
 public function ajaxGetReservationTasksAction()
 {
     /**
      * @var \DDD\Service\Booking\BookingTicket $bookingTicketService
      * @var \DDD\Dao\Task\Task $tasksDao
      * @var \DDD\Service\Task $taskService
      */
     $tasksDao = $this->getServiceLocator()->get('dao_task_task');
     $taskService = $this->getServiceLocator()->get('service_task');
     $request = $this->params();
     $currentPage = $request->fromQuery('start') / $request->fromQuery('length') + 1;
     $results = $tasksDao->getTasksOnReservationForDatatable((int) $request->fromQuery('reservationId'), (int) $request->fromQuery('start'), (int) $request->fromQuery('length'), $request->fromQuery('order'), $request->fromQuery('search'), $request->fromQuery('all', '1'));
     $tasks = $results['result'];
     $tasksCount = $results['total'];
     //        $tasksCount = $tasksDao->getTasksCountOnReservationForDatatable((integer)$request->fromQuery('reservationId'), $request->fromQuery('search')['value'], $request->fromQuery('all', '1'));
     foreach ($tasks as $row) {
         $rowClass = '';
         if (strtotime($row->getEndDate()) <= strtotime(date('Y-m-j 23:59')) && $row->getTask_status() < TaskService::STATUS_DONE) {
             $rowClass = 'danger';
         }
         $permissions = $taskService->composeUserTaskPermissions($row->getId());
         $result[] = [TaskService::getTaskPriorityLabeled()[$row->getPriority()], TaskService::getTaskStatus()[$row->getTask_status()], $row->getStartDate() ? date(Constants::GLOBAL_DATE_FORMAT, strtotime($row->getStartDate())) : '', $row->getEndDate() ? date(Constants::GLOBAL_DATE_FORMAT, strtotime($row->getEndDate())) : '', strlen($row->getTitle()) > 30 ? substr($row->getTitle(), 0, 30) . '...' : $row->getTitle(), $row->getTaskType(), $row->getCreatorName(), $row->getResponsibleName(), count($permissions) ? '<a href="/task/edit/' . $row->getId() . '" class="btn btn-xs btn-primary" target="_blank">View</a>' : '', "DT_RowClass" => $rowClass];
     }
     if (!isset($result) or $result === null) {
         $result = [];
     }
     $resultArray = ['sEcho' => $request->fromQuery('sEcho'), 'iTotalRecords' => $tasksCount, 'iTotalDisplayRecords' => $tasksCount, 'iDisplayStart' => ($currentPage - 1) * (int) $request->fromQuery('start'), 'iDisplayLength' => (int) $request->fromQuery('length'), 'aaData' => $result];
     return new JsonModel($resultArray);
 }
Beispiel #5
0
 /**
  * Fetch all or a subset of resources
  *
  * @param  array $params
  * @return ApiProblem|mixed
  *
  * @api {get} API_DOMAIN/warehouse/configs Configs List
  * @apiVersion 1.0.0
  * @apiName GetConfigs
  * @apiGroup Config
  *
  * @apiDescription This method returns the list of all warehouse configurations
  *
  * @apiHeader {String} Content-Type application/json
  * @apiHeader {String} Authorization Bearer ACCESS_TOKEN
  *
  * @apiSuccess {Int} assets The update interval for updating assets list. The value is in seconds
  * @apiSuccess {Int} locations The update interval for updating locations list. The value is in seconds
  * @apiSuccess {Int} users The update interval for updating users list. The value is in seconds
  * @apiSuccess {Int} categories The update interval for updating category list. The value is in seconds
  * @apiSuccess {Int} configs The update interval for updating configurations. The value is in seconds
  * @apiSuccess {Int} version The current API version
  * @apiSuccess {Int} requestTTL The value indicating how long should a request stay in the mobile
  * @apiSuccess {Object} assetTypes All possible values for asset types
  * @apiSuccess {Object} assetValuableStatuses All possible values for Valuable asset statuses
  * @apiSuccess {Object} locationTypes All possible values for location types
  * @apiSuccess {Object} assetChangeTypes All possible values for asset change types
  * @apiSuccess {Object} attachmentTypes All possible values for attachment types
  * @apiSuccess {Object} moduleTypes All possible values for module types
  * @apiSuccess {Object} imageConfigs The maximum width and height for images. Anything larger is compressed on the client to match this criteria.
  *
  * @apiSuccessExample {json} Sample Response:
  *     HTTP/1.1 200 OK
  *     {
  *         "updateIntervals": {
  *             "assets": 86400,
  *             "locations": 86400,
  *             "users": 86400,
  *             "categories": 86400,
  *             "configs": 86400
  *         },
  *         "requestTTL": 604800,
  *         "version": 1,
  *         "assetTypes": {
  *              "1": "Consumable",
  *              "2": "Valuable"
  *         },
  *         "assetValuableStatuses": {
  *             "1": "Working",
  *             "2": "Broken",
  *             "3": "Lost",
  *             "4": "Retired",
  *             "5": "Expunged",
  *             "6": "New",
  *             "7": "Repair"
  *         },
  *         "locationTypes": {
  *             "1": "Apartment",
  *             "2": "Storage",
  *             "3": "Office",
  *             "4": "Building"
  *         },
  *         "assetChangeTypes" : {
  *             "155": "Status Change",
  *             "156": "Assignee Change",
  *             "157": "Location Change",
  *             "158": "Added Comment"
  *         },
  *         "attachmentTypes": {
  *             "1": "All",
  *             "2": "Image",
  *             "3": "Document"
  *         },
  *         "moduleTypes": {
  *             "1": "Incident"
  *         },
  *         "imageConfigs": {
  *             "maxWidth": 1024,
  *             "maxHeight": 1024
  *         }
  *     }
  */
 public function fetchAll($params = array())
 {
     try {
         $config = $this->serviceLocator->get('config');
         $requestHandler = $this->serviceLocator->get('Service\\RequestHandler');
         $assetService = $this->serviceLocator->get('service_warehouse_asset');
         $result = [];
         if (isset($config['warehouse'])) {
             $result['updateIntervals']['assets'] = $config['warehouse']['assets'];
             $result['updateIntervals']['locations'] = $config['warehouse']['locations'];
             $result['updateIntervals']['users'] = $config['warehouse']['users'];
             $result['updateIntervals']['categories'] = $config['warehouse']['categories'];
             $result['updateIntervals']['configs'] = $config['warehouse']['updateTime'];
             $result['requestTTL'] = $config['warehouse']['apiExpired'];
             $result['version'] = $config['warehouse']['version'];
         }
         $result['assetTypes'] = CategoryService::$categoryTypes;
         $assetStatuses = $assetService->getValuableAssetsStatusesArray(true);
         $result['assetValuableStatuses'] = [];
         if ($assetStatuses && count($assetStatuses)) {
             $result['assetValuableStatuses'] = $assetStatuses;
         }
         $result['locationTypes'] = AssetService::$types;
         $result['assetChangeTypes'] = AssetService::$assetChangeTypes;
         $result['attachmentTypes'] = Files::getAttachmentTypes();
         $result['moduleTypes'] = TaskService::getModuleTypes();
         $result['imageConfigs'] = $config['imageConfigs'];
         return $result;
     } catch (\Exception $e) {
         return $requestHandler->handleException($e);
     }
 }
Beispiel #6
0
 /**
  * @param $id
  * @param $type
  * @return array|bool
  */
 public function getEntityTasks($id, $type)
 {
     /**
      * @var \DDD\Dao\Task\Task $tasksDao
      */
     $tasksDao = $this->getServiceLocator()->get('dao_task_task');
     $tasks = false;
     switch ($type) {
         case self::CARD_RESERVATION:
             $result = $tasksDao->getTasksOnReservation($id);
             break;
         case self::CARD_APARTMENT:
             $result = $tasksDao->getFrontierTasksOnApartment($id);
             break;
         case self::CARD_BUILDING:
             $result = $tasksDao->getTasksOnBuilding($id);
             break;
     }
     if (!empty($result)) {
         foreach ($result as $row) {
             $tasks[] = ['id' => $row->getId(), 'title' => $row->getTitle(), 'priority' => $row->getPriority(), 'priorityLabel' => TaskService::getTaskPriorityLabeled()[$row->getPriority()], 'type' => $row->getTaskTypeId()];
         }
     }
     return $tasks;
 }