public static function getThemAllLastStatus($files) { $xfiles = []; $xfiles['aviser'] = []; $xfiles['repair_to_do'] = []; $xfiles['order_to_do'] = []; foreach ($files as $key => $file) { if (isset($file['laststatus'][0])) { $last = $file['laststatus'][0]['code']; if ($last['label'] == 'PE' || $last['label'] == 'PED') { $xfiles['aviser'][] = $files[$key]; } else { if ($last['label'] == 'I/A' || $last['label'] == 'TDY' || $last['label'] == 'EC') { $xfiles['repair_to_do'][] = $files[$key]; } else { if ($last['label'] == 'TW') { if ($file['type'] == 'ORDER') { $details = OrderDetails::where('file_id', $file['id'])->with('article.supplier')->get(); $files[$key]['order_details'] = $details; } else { $details = RepairDetails::where('file_id', $file['id'])->with('article.supplier')->get(); $files[$key]['order_details'] = $details; } $xfiles['order_to_do'][] = $files[$key]; } else { } } } } } return $xfiles; }
public function editRepair($id) { $files = File::with('client', 'technicien', 'status.code.group', 'status.technicien')->get()->find($id); if (empty($files)) { return redirect('/404'); } //$files = File::with('client', 'technicien')->get(); $repairs = Repair::where('file_id', $files['id'])->with('device.history.file.laststatus', 'details')->first(); $details = RepairDetails::where('file_id', $files['id'])->with('article.supplier')->get(); $repairs['repair_details'] = $details; $repairs["modele"] = Modeles::where('id', $repairs['device']['model_id'])->with('category', 'brand', 'articles')->first(); $repairs['device']['history'] = CodeStatus::getOUT($repairs['device']['history']); $status = CodeStatus::with('group')->get(); $status = CodeStatus::filterStatus($status, $files['status']); $files['last_status'] = CodeStatus::getLastStatus($files['status']); $supp = Supplier::all(); $articles = Article::all(); $leftmenu['files'] = 'active'; return view('/files/edit-repair', ['leftmenu' => $leftmenu, 'files' => $files, 'repairs' => $repairs, 'code_status' => $status, 'suppliers' => $supp, 'articles' => $articles]); }