コード例 #1
0
 public function destroy($kitTypeID)
 {
     // This Shall be fun!
     // We have to deconstruct the types based on the forign key dependencys
     // First iterate all the kits, for each kit remove all contents,
     // and then all bookings (and all booking details)
     // then finally we can remove the kit type and then all the logs for that
     // kit type.
     foreach (Kits::where('KitType', '=', $kitTypeID)->get() as $kit) {
         foreach (KitContents::where("KitID", '=', $kit->ID)->get() as $content) {
             KitContents::destroy($content->ID);
         }
         foreach (Booking::where("KitID", '=', $kit->ID)->get() as $booking) {
             foreach (BookingDetails::where("BookingID", '=', $booking->ID)->get() as $detail) {
                 BookingDetails::destroy($detail->ID);
             }
             Booking::destroy($booking->ID);
         }
         Kits::destroy($kit->ID);
     }
     KitTypes::destroy($kitTypeID);
     // Do the logs last, as all the deletes will log the changes of deleting the bits.
     Logs::where('LogKey1', '=', $kitTypeID)->delete();
     return "OK";
 }
コード例 #2
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";
 }
コード例 #3
0
 public function show2($LogKey1 = NULL, $LogKey2 = NULL)
 {
     $clause = "LogKey1 = " . $LogKey1;
     $filters = array();
     if (Input::get('FILTERS-ALL') != "T") {
         $filters = $this->ArrayOfFilters(Input::all());
         $clause = $this->GetFilterClause($filters) . "LogKey1 = " . $LogKey1;
     } else {
         foreach (LogType::all() as $logType) {
             array_unshift($filters, $logType->ID);
         }
     }
     if ($LogKey2) {
         $clause = $clause . " and LogKey2 = " . $LogKey2;
     }
     $logs = Logs::whereraw($clause)->get();
     $kTyp = KitTypes::find($LogKey1);
     $kit = Kits::find($LogKey2);
     $title = "Log for " . $kTyp->Name . " -> " . $kit->Name;
     if ((int) $kit->Specialized == 1) {
         $title = $title . ' + ' . $kit->SecializedName;
     }
     return CheckIfAuthenticated('Logs.show', ['ID' => $LogKey2, 'logs' => $logs, 'logTitle' => $title, 'logTypes' => LogType::all(), 'filters' => $filters], 'home.index', [], true);
 }
コード例 #4
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');
 }
コード例 #5
0
 public function create()
 {
     $kit = Kits::create(array('KitType' => 0, 'AtBranch' => 0, 'KitState' => 1, 'Available' => 0, 'Name' => "New Kit Name", 'KitDesc' => "Place a description of the contents of this kit here. "));
     $res = $this->makeJTreeKitRecord($kit);
     return $res;
 }
コード例 #6
0
 public function index()
 {
     $kits = Kits::get();
     return View::make('members/browsekit')->with('kits', $kits);
 }
コード例 #7
0
 public function getAvailableKit()
 {
     if (!Request::ajax()) {
         return "not a json request";
     }
     $post = Input::all();
     $kitsOfType = Kits::where('Available', '1')->where('KitType', $post['KitTypeID'])->orderBy('Specialized', 'asc')->get();
     foreach ($kitsOfType as $kit) {
         $query = "select B.ID " . "from Booking as B " . "inner join Kits as K " . "on B.KitID = K.ID " . "where B.KitID = " . $kit->ID . " " . "and (" . "('" . $post['StartDate'] . "' between CAST(B.StartDate as Date) and CAST(B.EndDate as Date)) " . "or ('" . $post['EndDate'] . "' between CAST(B.StartDate as Date) and CAST(B.EndDate as Date))" . ")";
         $bookings = DB::select(DB::raw($query));
         if (intval(count($bookings)) == 0) {
             return $kit;
         }
     }
     return "";
 }