public function store() { $inp = Input::all(); // print dd($inp); $id = $inp['ID']; $kit = Kits::findOrFail($id); if (!isset($inp['Available'])) { $inp['Available'] = 0; } $kit->fill($inp); $kit->save(); $res = "OK"; if (isset($inp["contents"])) { foreach ($inp["contents"] as $idx => $item) { if ($item["status"] == 1) { if (strlen($item["DamagedLogID"]) == 0) { $item["DamagedLogID"] = null; } if (strlen($item["MissingLogID"]) == 0) { $item["MissingLogID"] = null; } $content = KitContents::create($item); $content->save(); } else { if ($item["status"] == 3) { $content = KitContents::findOrFail($item["ID"]); $content->fill($item); if (isset($item["Damaged"])) { if ($item["Damaged"] == 0) { $content->DamagedLogID = null; } else { if ($item["DamagedLogID"] == null) { $content->DamagedLogID = Logs::DamageReport($kit->KitType, $kit->ID, $content->ID, $item["DamagedMessage"]); } } } else { $content->DamagedLogID = null; } if (isset($item["Missing"])) { if ($item["Missing"] == 0) { $content->MissingLogID = null; } else { if ($item["MissingLogID"] == null) { $content->MissingLogID = Logs::MissingReport($kit->KitType, $kit->ID, $content->ID, $item["missingMessage"]); } } } else { $content->MissingLogID = null; } $content->save(); } } if ($item["status"] == 4 && $item["ID"] != "***NEW***") { // delete the kitContent $content = KitContents::destroy($item["ID"]); } } } return $res; }
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"; }
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'); }