Exemplo n.º 1
0
 public function checkFlightDate($listFlightDates, $flight)
 {
     $retval = false;
     $now = strtotime(date('Y-m-d'));
     foreach ($listFlightDates as $flightDate) {
         if (strtotime($flightDate->start) <= $now && strtotime($flightDate->end) >= $now) {
             //check active hour
             // -- Start -- Phuong-VM -- Comment -- 12-05-2015
             /*$startTime = $flight->start_hour ? intvalFromTimeText($flight->start_hour) : 0;
             		$endTime = $flight->end_hour ? intvalFromTimeText($flight->end_hour) : 0;
             		$nowTime = intvalFromTimeText(date('H:i:s'));
             		if( ($startTime == 0 || $startTime <= $nowTime) && ($endTime == 0 || $endTime >= $nowTime) ){
             			//passed
             			$retval = true;
             			break;
             		}*/
             // -- Start -- Phuong-VM -- Comment -- 12-05-2015
             // -- Start -- Phuong-VM -- add -- 12-05-2015
             //$listHours = json_decode($flightDate->hour);
             if (!empty($flightDate->hour)) {
                 foreach ($flightDate->hour as $hour) {
                     $startTime = $hour->start ? intvalFromTimeText($hour->start) : 0;
                     $endTime = $hour->end ? intvalFromTimeText($hour->end) : 0;
                     $nowTime = intvalFromTimeText(date('H:i'));
                     if (($startTime == 0 || $startTime <= $nowTime) && ($endTime == 0 || $endTime >= $nowTime)) {
                         //passed
                         $retval = true;
                         break;
                     }
                 }
             } else {
                 $retval = true;
             }
             // -- Start -- Phuong-VM -- add -- 12-05-2015
         }
     }
     return $retval;
 }
Exemplo n.º 2
0
 public static function getCurrentDayRun($dateRange, $flightInventoryPerDay)
 {
     $inventoryCurrent = 0;
     $inventoryExp = 0;
     if (!empty($dateRange)) {
         foreach ($dateRange as $date) {
             $dayCurrent = 0;
             //Get thoi gian hien tai
             $timeToday = strtotime(date('Y-m-d'));
             //Get gio hien tai
             $nowTime = intvalFromTimeText(date('H:i'));
             //Chuyen ngay bat dau, ngay ket thuc chay flight sang time
             $timeStart = strtotime($date->start);
             $timeEnd = strtotime($date->end);
             $dateToday = \Carbon\Carbon::createFromTimeStamp($timeToday);
             $dateStart = \Carbon\Carbon::createFromTimeStamp($timeStart);
             $dateEnd = \Carbon\Carbon::createFromTimeStamp($timeEnd);
             // Truong hop hop data khong setting daily inventory thi tinh daily inventory trung binh moi ngay phai chay
             $daily_inventory = isset($date->daily_inventory) && $date->daily_inventory > 0 ? $date->daily_inventory : $flightInventoryPerDay;
             // Ngay hien tai trong khoang thoi gian chay flight
             if ($timeToday >= $timeStart && $timeToday <= $timeEnd) {
                 $dayCurrent = $dateToday->diffInDays($dateStart);
                 $inventoryCurrent += $dayCurrent * $daily_inventory;
                 $inventoryExp += $dayCurrent * $daily_inventory;
                 if (!empty($date->hour)) {
                     foreach ($date->hour as $hour) {
                         $start = $hour->start ? intvalFromTimeText($hour->start) : 0;
                         $end = $hour->end ? intvalFromTimeText($hour->end) : 0;
                         $time_inventory = $hour->time_inventory ? $hour->time_inventory : $daily_inventory;
                         if (($start == 0 || $start <= $nowTime) && ($end == 0 || $end >= $nowTime)) {
                             $inventoryCurrent = $time_inventory;
                         } else {
                             if ($end != 0 && $end < $nowTime) {
                                 if ($hour->time_inventory) {
                                     $inventoryExp += $time_inventory;
                                 }
                             }
                         }
                     }
                 } else {
                     $inventoryCurrent = $daily_inventory;
                 }
                 break;
             } else {
                 $dayCurrent = $date->diff;
                 $inventoryExp += $dayCurrent * $daily_inventory;
             }
         }
     }
     $result['inventory_current'] = $inventoryCurrent;
     $result['inventory_exp'] = $inventoryExp;
     return $result;
 }