Пример #1
0
 public function report()
 {
     $logs = array();
     if (isset($_POST['submit'])) {
         $pod = Input::get('pod_api_id');
         // "43"; //Input::get('pod');
         $from = Input::get('from_date') . ' ' . Input::get('from_time');
         //"2016-01-20 15:29:44"; // Input::get('from_date');
         $to = Input::get('to_date') . ' ' . Input::get('to_time');
         // "3000-00-00 00:00:00"; //Input::get('to_date');
         $state = Input::get('state');
         //"2"; // Input::get('state');
         $logs = OffPodLog::with(array('pod' => function ($query) {
             $query->with('apiPod');
             $query->with(array('groupSchedules' => function ($query) {
                 $query->with('group');
             }));
             $query->with('expSchedules');
         }))->where('pod_id', 'LIKE', "%{$pod}%")->where('state', 'LIKE', "%{$state}%")->where('from_time', '>=', $from)->where('to_time', '<=', $to)->get()->toArray();
     }
     return View::make('off_pod_logs.report', compact('logs'));
 }
Пример #2
0
 public function podOn($ip_address = "172.20.16.5", $podname = "Dhading")
 {
     date_default_timezone_set('Asia/Kathmandu');
     $apiPod = ApiPod::where('pod', '=', $podname)->first();
     if (is_object($apiPod)) {
         $apiPod_array = $apiPod->toArray();
         $pod = Pod::where('pod_api_id', '=', $apiPod_array['id'])->first();
         if (is_object($pod)) {
             $pod_array = $pod->toArray();
             $down = OffPod::where('pod_id', '=', $pod_array['id'])->first();
             if (is_object($down)) {
                 $down->delete();
                 $downPod = $down->toArray();
                 //insert into pod logs
                 $downPodLog = array();
                 $downPodLog['pod_id'] = $downPod['pod_id'];
                 $downPodLog['from_time'] = $downPod['created_at'];
                 $downPodLog['to_time'] = date('Y-m-d H:i:s');
                 $downPodLog['state'] = $downPod['state'];
                 if ($downPod['schedule_id'] != 0) {
                     $downPodLog['schedule_from_time'] = $down->schedule->from_time;
                     $downPodLog['schedule_to_time'] = $down->schedule->to_time;
                 }
                 $offPodLog = OffPodLog::create($downPodLog);
                 if ($downPod['state'] == '3') {
                     $this->sendNotification($param = array('type' => 'on', 'pod_id' => $pod_array['id'], 'description' => $apiPod_array['pod'] . " which was in red zone is on "));
                 } elseif ($downPod['state'] == '2') {
                     $this->sendNotification($param = array('type' => 'on', 'pod_id' => $pod_array['id'], 'description' => $apiPod_array['pod'] . " which was in yellow zone is on "));
                 } elseif ($downPod['state'] == '1' or $downPod['state'] == '0') {
                     $this->sendNotification($param = array('type' => 'on', 'pod_id' => $pod_array['id'], 'description' => $apiPod_array['pod'] . " which was in blue zone is on "));
                 }
             }
         }
     }
 }