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); }
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" => []]); } }
/** * @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; }