public function fetch(TaskSearchCommand $command) { if ($command->getFilter() != null) { if (strlen($command->getFilter()) < 2) { $command->setFilter(null); //we don't search when lower than 2 chars.. wtf } } $dateDiff = 'P1D'; if (strcmp($command->getTipCursa(), "scurt") == 0) { //for tip cursa scurt we also save the hours in the timestamp. no need to do -1 in search $dateDiff = 'P0D'; } if ($command->getStartDate() != null) { $command->setDateStartDate($command->getStartDate()->sub(new DateInterval('P0D'))); } else { $today = new \DateTime('now'); $command->setDateStartDate($today->sub(new DateInterval($dateDiff))); } $tasksList = $this->getTaskRepository()->fetchFutureTasks($command); $total = $this->getTaskRepository()->fetchCountFutureTasks($command); $result = array(); $result["recordsTotal"] = $total; $result["recordsFiltered"] = $total; $data = array(); foreach ($tasksList as $task) { $haveWePushed = false; if ($command->getSplitDetails()) { $multiDetails = explode(";", $task->getDetalii()); $count = sizeof($multiDetails); foreach ($multiDetails as $detail) { if ($count > 1 && strlen($detail) > 0) { $task->setBani(""); $task->setDetalii($detail); if (str_contains($detail, " ")) { $codBaniList = explode(" ", $detail); foreach ($codBaniList as $codBani) { if (is_numeric($codBani)) { $task->setBani($codBani); } } } $row = $this->createRow($task); array_push($data, $row); $haveWePushed = true; } } } if (!$haveWePushed) { $row = $this->createRow($task); array_push($data, $row); } } $result["data"] = $data; return $result; }
public function fetch() { $start = Input::get("start"); $length = Input::get("length"); $searchArray = Input::get("search"); $startDate = Input::get("startDate"); $endDate = Input::get("endDate"); $search = ""; if (isset($searchArray)) { $search = $searchArray["value"]; } $command = new TaskSearchCommand(); $command->setFilter($search); $command->setLowerLimit($start); $command->setNoResults($length); $command->setStartDate($startDate); $command->setEndDate($endDate); $command->setTipCursa(Input::get("tipCursa")); if (strlen(Input::get("splitDetails")) > 0) { $command->setSplitDetails(true); } return json_encode($this->taskService->fetch($command), 0); }