예제 #1
0
 public function store()
 {
     $kit = Kits::findOrFail(Input::get('ID'));
     foreach ($kit->contents as $cont) {
         if ($cont->DamagedLogID == null && Input::has('DamagedMsg_' . $cont->ID)) {
             $cont->DamagedLogID = Logs::DamageReport($kit->KitType, $kit->ID, $cont->ID, base64_decode(Input::get('DamagedMsg_' . $cont->ID)));
         }
         if ($cont->MissingLogID == null && Input::has('MissingMsg_' . $cont->ID)) {
             $cont->MissingLogID = Logs::MissingReport($kit->KitType, $kit->ID, $cont->ID, base64_decode(Input::get('MissingMsg_' . $cont->ID)));
         }
         $cont->save();
     }
     return "OK";
 }
예제 #2
0
 public function store()
 {
     $kit = Kits::findOrFail(Input::get('ID'));
     $kit->KitState = 2;
     $kit->save();
     foreach ($kit->contents as $content) {
         if (Input::has('isMissing_' . $content->ID) && Input::get('isMissing_' . $content->ID) == '1' && $content->MissingLogID == null) {
             $message = Input::get('MissingID_' . $content->ID);
             $logID = Logs::MissingReport($kit->KitType, $kit->ID, $content->ID, $message);
             $content->MissingLogID = $logID;
         }
         if (Input::has('isDamaged_' . $content->ID) && Input::get('isDamaged_' . $content->ID) == '1' && $content->DamagedLogID == null) {
             $message = Input::get('DamagedID_' . $content->ID);
             $logID = Logs::DamageReport($kit->KitType, $kit->ID, $content->ID, $message);
             $content->DamagedLogID = $logID;
         }
         $content->save();
     }
     if (Input::has('LogMessage') && strlen(Input::get('LogMessage')) > 0) {
         $message = Input::get('LogMessage');
         $logNote = Logs::Note($kit->KitType, $kit->ID, NULL, $message);
     }
     return Redirect::action('recieve_kit.index');
 }
예제 #3
0
 public function kitDetails($kitID)
 {
     $kit = Kits::findOrFail($kitID);
     $bookingIDs = DB::select("(SELECT ID\n                                    FROM Booking AS B\n                                   WHERE B.KitID = ?\n                                         AND B.EndDate < now()\n                                   LIMIT 3\n                                 )\n                                 UNION\n                                 (\n                                  SELECT ID\n                                    FROM Booking AS B\n                                   WHERE B.KitID = ?\n                                         AND B.EndDate >= now()\n                                   LIMIT 3\n                                )\n                               ", array($kitID, $kitID));
     $ids = array();
     foreach ($bookingIDs as $id) {
         array_unshift($ids, $id->ID);
     }
     $bookings = Booking::whereIn("ID", $ids)->get();
     // print dd($bookings->toarray());
     $logs = DB::select("SELECT L.LogType, L.LogDate, KC.Name, KC. SerialNumber, L.LogMessage\n                               FROM Logs AS L\n                                 INNER JOIN Kits as K ON (K.ID = L.LogKey2)\n                                   INNER JOIN KitContents as KC ON (KC.KitID = L.LogKey2 AND KC.ID = L.LogKey3)\n                              WHERE K.ID = ?\n                                    AND L.LogType in (1,2)\n                              ORDER BY LogDate DESC\n                            ", array($kitID));
     return View::make("kit.kitDetails", ['kit' => $kit, 'bookings' => $bookings, 'logs' => $logs]);
 }