コード例 #1
0
 /**
  * @param Task $task
  * @return Task
  */
 private function validateDistance($task)
 {
     if (!is_numeric($task->getDistance())) {
         $task->setDistance(0);
     }
     return $task;
 }
コード例 #2
0
 private function getTaskInfoFromInput()
 {
     $task = new Task();
     $input = Input::get("input");
     if (isset($input['id'])) {
         $task->setId(HTML::entities($input["id"]));
     }
     if (isset($input['client'])) {
         $task->setClient(HTML::entities(trim($input["client"])));
     }
     if (isset($input['traseu'])) {
         $task->setTraseu(HTML::entities(trim($input["traseu"])));
     }
     if (isset($input['detalii'])) {
         $task->setDetalii(HTML::entities(trim($input["detalii"])));
     }
     if (isset($input['vehicle'])) {
         $task->setVehicle(HTML::entities($input["vehicle"]));
     }
     $task->setCursa(HTML::entities($input["cursa"]));
     $task->setSofer(HTML::entities($input["sofer"]));
     $task->setBani(HTML::entities($input["bani"]));
     $task->setDataString(HTML::entities($input["dataText"]));
     $task->setOraText(HTML::entities($input["ora"]));
     $task->setDistance(HTML::entities($input["distance"]));
     $task->setVehicleNo(HTML::entities($input["vehicleNo"]));
     $task->setSofer(trim($task->getSofer()));
     $task->setBani(trim($task->getBani()));
     $task->setVehicleNo(trim($task->getVehicleNo()));
     $hourTransformed = 60;
     //1 minut is nice for the long ones
     if (strcmp($task->getCursa(), "scurt") == 0) {
         //numai pt cele scurte
         try {
             if (strlen($task->getOraText()) > 0) {
                 $hourSplitted = explode(':', $task->getOraText());
                 $hourTransformed = $hourSplitted[0] * 3600;
                 //add the hours //all in seconds
                 $hourTransformed += $hourSplitted[1] * 60;
                 // add the minutes
             }
         } catch (\Exception $e) {
             //can't afford an error here
         }
     }
     $date = new \DateTime();
     $date->setTimestamp(HTML::entities($input["data"]) / 1000 + $hourTransformed);
     $task->setDateTime($date);
     return $task;
 }