Esempio n. 1
0
 public function getCategory()
 {
     $categories = array();
     foreach (RefCategory::where('project_id', '=', Session::get('project_id'))->where('active', '=', 1)->get() as $category) {
         $categories[$category->id] = $category->description;
     }
     return View::make('report.report_by_category')->with('categories', $categories);
 }
 public function postEditequipment()
 {
     $categories = array();
     $types = array();
     $parts = array();
     $equip = BasicEquipment::find(Input::get('id'));
     $cat = RefCategory::where('id', '!=', $equip->category_id)->where('active', '=', 1)->where('project_id', '=', Session::get('project_id'))->get();
     $type = RefType::where('id', '!=', $equip->type_id)->where('active', '=', 1)->where('project_id', '=', Session::get('project_id'))->get();
     $part = RefPart::where('id', '!=', $equip->part_id)->where('active', '=', 1)->where('project_id', '=', Session::get('project_id'))->get();
     $basic = BasicEquipment::with('category', 'type', 'part')->where('id', '=', Input::get('id'))->where('active', '=', 1)->where('project_id', '=', Session::get('project_id'))->get();
     return View::make('basic_data_setup.equipment.edit')->with('basics', $basic)->with('cat', $cat)->with('type', $type)->with('part', $part);
 }
Esempio n. 3
0
 public function postUpdatecategory()
 {
     $input = Input::all();
     $input['updated_by'] = Auth::user()->id;
     $check = RefCategory::where('id', '!=', Input::get('id'))->where('description', '=', Input::get('description'))->where('active', '=', 1)->where('project_id', '=', Session::get('project_id'))->get();
     if ($check->isEmpty()) {
         $category = RefCategory::find(Input::get('id'));
         $category->update($input);
         return Redirect::to('reference-data/equipment/category');
     } else {
         return Redirect::to('reference-data/equipment/category')->withErrors('Equipment category duplicate!');
     }
 }
Esempio n. 4
0
 public function getExportproject()
 {
     $project_arr = array();
     $project_arr = explode(' ', Input::get('projectname'));
     $project_name = implode('_', $project_arr);
     $datefile = date('dmY');
     $ranfile = rand(11111, 99999);
     $foldername = $project_name . '_' . $ranfile . '_' . $datefile;
     $basic_equipment = array();
     $basic_equipment = BasicEquipment::where('project_id', Input::get('project_id'))->where('type_use', 2)->where('active', 1)->get(array('id', 'category_id', 'type_id', 'part_id'));
     if (!$basic_equipment->isEmpty()) {
         $filename = '001_' . $ranfile . '_' . $datefile;
         $file = Excel::create($filename, function ($excel) use($basic_equipment) {
             $excel->sheet('basic_equipment', function ($sheet) use($basic_equipment) {
                 $sheet->fromArray($basic_equipment);
             });
         })->store('csv', 'public/backup/export/' . $foldername);
         $filenamezip = "public/backup/export/" . $foldername . ".zip";
         $files = glob($file->storagePath . "/*");
         Zipper::make($filenamezip)->add($files);
     }
     $basic_failure = array();
     $basic_failure = BasicFailure::where('project_id', Input::get('project_id'))->where('type_use', 2)->where('active', 1)->get(array('id', 'mode_id', 'cause_id'));
     if (!$basic_failure->isEmpty()) {
         $filename = '002_' . $ranfile . '_' . $datefile;
         $file = Excel::create($filename, function ($excel) use($basic_failure) {
             $excel->sheet('basic_failure', function ($sheet) use($basic_failure) {
                 $sheet->fromArray($basic_failure);
             });
         })->store('csv', 'public/backup/export/' . $foldername);
         $filenamezip = "public/backup/export/" . $foldername . ".zip";
         $files = glob($file->storagePath . "/*");
         Zipper::make($filenamezip)->add($files);
     }
     $basic_task = array();
     $basic_task = BasicTask::where('project_id', Input::get('project_id'))->where('type_use', 2)->where('active', 1)->get(array('id', 'cause_id', 'type_id', 'list_id'));
     if (!$basic_task->isEmpty()) {
         $filename = '003_' . $ranfile . '_' . $datefile;
         $file = Excel::create($filename, function ($excel) use($basic_task) {
             $excel->sheet('basic_task', function ($sheet) use($basic_task) {
                 $sheet->fromArray($basic_task);
             });
         })->store('csv', 'public/backup/export/' . $foldername);
         $filenamezip = "public/backup/export/" . $foldername . ".zip";
         $files = glob($file->storagePath . "/*");
         Zipper::make($filenamezip)->add($files);
     }
     $ref_category = array();
     $ref_category = RefCategory::where('project_id', Input::get('project_id'))->where('type_use', 2)->where('active', 1)->get(array('id', 'description'));
     if (!$ref_category->isEmpty()) {
         $filename = '004_' . $ranfile . '_' . $datefile;
         $file = Excel::create($filename, function ($excel) use($ref_category) {
             $excel->sheet('ref_category', function ($sheet) use($ref_category) {
                 $sheet->fromArray($ref_category);
             });
         })->store('csv', 'public/backup/export/' . $foldername);
         $filenamezip = "public/backup/export/" . $foldername . ".zip";
         $files = glob($file->storagePath . "/*");
         Zipper::make($filenamezip)->add($files);
     }
     $ref_fail_cause = array();
     $ref_fail_cause = RefFailureCause::where('project_id', Input::get('project_id'))->where('type_use', 2)->where('active', 1)->get(array('id', 'description'));
     if (!$ref_fail_cause->isEmpty()) {
         $filename = '005_' . $ranfile . '_' . $datefile;
         $file = Excel::create($filename, function ($excel) use($ref_fail_cause) {
             $excel->sheet('ref_fail_cause', function ($sheet) use($ref_fail_cause) {
                 $sheet->fromArray($ref_fail_cause);
             });
         })->store('csv', 'public/backup/export/' . $foldername);
         $filenamezip = "public/backup/export/" . $foldername . ".zip";
         $files = glob($file->storagePath . "/*");
         Zipper::make($filenamezip)->add($files);
     }
     $ref_fail_mode = array();
     $ref_fail_mode = RefFailureMode::where('project_id', Input::get('project_id'))->where('type_use', 2)->where('active', 1)->get(array('id', 'description'));
     if (!$ref_fail_mode->isEmpty()) {
         $filename = '006_' . $ranfile . '_' . $datefile;
         $file = Excel::create($filename, function ($excel) use($ref_fail_mode) {
             $excel->sheet('ref_fail_mode', function ($sheet) use($ref_fail_mode) {
                 $sheet->fromArray($ref_fail_mode);
             });
         })->store('csv', 'public/backup/export/' . $foldername);
         $filenamezip = "public/backup/export/" . $foldername . ".zip";
         $files = glob($file->storagePath . "/*");
         Zipper::make($filenamezip)->add($files);
     }
     $ref_non = array();
     $ref_non = RefNonCriticalQuestion::where('project_id', Input::get('project_id'))->where('type_use', 2)->where('active', 1)->get(array('id', 'questions'));
     if (!$ref_non->isEmpty()) {
         $filename = '007_' . $ranfile . '_' . $datefile;
         $file = Excel::create($filename, function ($excel) use($ref_non) {
             $excel->sheet('ref_non', function ($sheet) use($ref_non) {
                 $sheet->fromArray($ref_non);
             });
         })->store('csv', 'public/backup/export/' . $foldername);
         $filenamezip = "public/backup/export/" . $foldername . ".zip";
         $files = glob($file->storagePath . "/*");
         Zipper::make($filenamezip)->add($files);
     }
     $ref_order_type = array();
     $ref_order_type = RefOrderType::where('project_id', Input::get('project_id'))->where('type_use', 2)->where('active', 1)->get(array('id', 'name', 'description'));
     if (!$ref_order_type->isEmpty()) {
         $filename = '008_' . $ranfile . '_' . $datefile;
         $file = Excel::create($filename, function ($excel) use($ref_order_type) {
             $excel->sheet('ref_order_type', function ($sheet) use($ref_order_type) {
                 $sheet->fromArray($ref_order_type);
             });
         })->store('csv', 'public/backup/export/' . $foldername);
         $filenamezip = "public/backup/export/" . $foldername . ".zip";
         $files = glob($file->storagePath . "/*");
         Zipper::make($filenamezip)->add($files);
     }
     $ref_part = array();
     $ref_part = RefPart::where('project_id', Input::get('project_id'))->where('type_use', 2)->where('active', 1)->get(array('id', 'description'));
     if (!$ref_part->isEmpty()) {
         $filename = '009_' . $ranfile . '_' . $datefile;
         $file = Excel::create($filename, function ($excel) use($ref_part) {
             $excel->sheet('ref_part', function ($sheet) use($ref_part) {
                 $sheet->fromArray($ref_part);
             });
         })->store('csv', 'public/backup/export/' . $foldername);
         $filenamezip = "public/backup/export/" . $foldername . ".zip";
         $files = glob($file->storagePath . "/*");
         Zipper::make($filenamezip)->add($files);
     }
     $ref_task_interval = array();
     $ref_task_interval = RefTaskInterval::where('project_id', Input::get('project_id'))->where('type_use', 2)->where('active', 1)->get(array('id', 'interval', 'description'));
     if (!$ref_task_interval->isEmpty()) {
         $filename = '010_' . $ranfile . '_' . $datefile;
         $file = Excel::create($filename, function ($excel) use($ref_task_interval) {
             $excel->sheet('ref_task_interval', function ($sheet) use($ref_task_interval) {
                 $sheet->fromArray($ref_task_interval);
             });
         })->store('csv', 'public/backup/export/' . $foldername);
         $filenamezip = "public/backup/export/" . $foldername . ".zip";
         $files = glob($file->storagePath . "/*");
         Zipper::make($filenamezip)->add($files);
     }
     $ref_task_list = array();
     $ref_task_list = RefTaskList::where('project_id', Input::get('project_id'))->where('type_use', 2)->where('active', 1)->get(array('id', 'description'));
     if (!$ref_task_list->isEmpty()) {
         $filename = '011_' . $ranfile . '_' . $datefile;
         $file = Excel::create($filename, function ($excel) use($ref_task_list) {
             $excel->sheet('ref_task_list', function ($sheet) use($ref_task_list) {
                 $sheet->fromArray($ref_task_list);
             });
         })->store('csv', 'public/backup/export/' . $foldername);
         $filenamezip = "public/backup/export/" . $foldername . ".zip";
         $files = glob($file->storagePath . "/*");
         Zipper::make($filenamezip)->add($files);
     }
     $ref_task_type = array();
     $ref_task_type = RefTaskType::where('project_id', Input::get('project_id'))->where('type_use', 2)->where('active', 1)->get(array('id', 'description'));
     if (!$ref_task_type->isEmpty()) {
         $filename = '012_' . $ranfile . '_' . $datefile;
         $file = Excel::create($filename, function ($excel) use($ref_task_type) {
             $excel->sheet('ref_task_type', function ($sheet) use($ref_task_type) {
                 $sheet->fromArray($ref_task_type);
             });
         })->store('csv', 'public/backup/export/' . $foldername);
         $filenamezip = "public/backup/export/" . $foldername . ".zip";
         $files = glob($file->storagePath . "/*");
         Zipper::make($filenamezip)->add($files);
     }
     $ref_type = array();
     $ref_type = RefType::where('project_id', Input::get('project_id'))->where('type_use', 2)->where('active', 1)->get(array('id', 'description'));
     if (!$ref_type->isEmpty()) {
         $filename = '013_' . $ranfile . '_' . $datefile;
         Excel::resetValueBinder();
         $file = Excel::create($filename, function ($excel) use($ref_type) {
             $excel->sheet('ref_type', function ($sheet) use($ref_type) {
                 $sheet->fromArray($ref_type);
             });
         })->store('csv', 'public/backup/export/' . $foldername);
         $filenamezip = "public/backup/export/" . $foldername . ".zip";
         $files = glob($file->storagePath . "/*");
         Zipper::make($filenamezip)->add($files);
     }
     $asset_registers = array();
     $asset_registers = AssetRegister::where('active', 1)->where('project_id', Input::get('project_id'))->get();
     if (!$asset_registers->isEmpty()) {
         $filename = '014_' . $ranfile . '_' . $datefile;
         $file = Excel::create($filename, function ($excel) use($asset_registers) {
             $excel->sheet('asset_registers', function ($sheet) use($asset_registers) {
                 $sheet->fromModel($asset_registers);
             });
         })->store('csv', 'public/backup/export/' . $foldername);
         $filenamezip = "public/backup/export/" . $foldername . ".zip";
         $files = glob($file->storagePath . "/*");
         Zipper::make($filenamezip)->add($files);
     }
     $asset_complex_detail = array();
     $asset_complex_detail = AssetComplexDetail::where('active', 1)->where('project_id', Input::get('project_id'))->get();
     if (!$asset_complex_detail->isEmpty()) {
         $filename = '015_' . $ranfile . '_' . $datefile;
         $file = Excel::create($filename, function ($excel) use($asset_complex_detail) {
             $excel->sheet('asset_complex_detail', function ($sheet) use($asset_complex_detail) {
                 $sheet->fromArray($asset_complex_detail);
             });
         })->store('csv', 'public/backup/export/' . $foldername);
         $filenamezip = "public/backup/export/" . $foldername . ".zip";
         $files = glob($file->storagePath . "/*");
         Zipper::make($filenamezip)->add($files);
     }
     $asset_basic_failure = array();
     $asset_basic_failure = AssetBasicFailure::where('active', 1)->where('project_id', Input::get('project_id'))->get();
     if (!$asset_basic_failure->isEmpty()) {
         $filename = '016_' . $ranfile . '_' . $datefile;
         $file = Excel::create($filename, function ($excel) use($asset_basic_failure) {
             $excel->sheet('asset_basic_failure', function ($sheet) use($asset_basic_failure) {
                 $sheet->fromArray($asset_basic_failure);
             });
         })->store('csv', 'public/backup/export/' . $foldername);
         $filenamezip = "public/backup/export/" . $foldername . ".zip";
         $files = glob($file->storagePath . "/*");
         Zipper::make($filenamezip)->add($files);
     }
     $asset_questions = array();
     $asset_questions = AssetQuestion::where('active', 1)->where('project_id', Input::get('project_id'))->get();
     if (!$asset_questions->isEmpty()) {
         $filename = '017_' . $ranfile . '_' . $datefile;
         $file = Excel::create($filename, function ($excel) use($asset_questions) {
             $excel->sheet('asset_questions', function ($sheet) use($asset_questions) {
                 $sheet->fromArray($asset_questions);
             });
         })->store('csv', 'public/backup/export/' . $foldername);
         $filenamezip = "public/backup/export/" . $foldername . ".zip";
         $files = glob($file->storagePath . "/*");
         Zipper::make($filenamezip)->add($files);
     }
     $task_selection = array();
     $task_selection = TaskSelection::where('active', 1)->where('project_id', Input::get('project_id'))->get();
     if (!$task_selection->isEmpty()) {
         $filename = '018_' . $ranfile . '_' . $datefile;
         $file = Excel::create($filename, function ($excel) use($task_selection) {
             $excel->sheet('task_selection', function ($sheet) use($task_selection) {
                 $sheet->fromArray($task_selection);
             });
         })->store('csv', 'public/backup/export/' . $foldername);
         $filenamezip = "public/backup/export/" . $foldername . ".zip";
         $files = glob($file->storagePath . "/*");
         Zipper::make($filenamezip)->add($files);
     }
     $package_assumptions = array();
     $package_assumptions = PackageAssumption::where('active', 1)->where('project_id', Input::get('project_id'))->get();
     if (!$package_assumptions->isEmpty()) {
         $filename = '019_' . $ranfile . '_' . $datefile;
         $file = Excel::create($filename, function ($excel) use($package_assumptions) {
             $excel->sheet('package_assumptions', function ($sheet) use($package_assumptions) {
                 $sheet->fromArray($package_assumptions);
             });
         })->store('csv', 'public/backup/export/' . $foldername);
         $filenamezip = "public/backup/export/" . $foldername . ".zip";
         $files = glob($file->storagePath . "/*");
         Zipper::make($filenamezip)->add($files);
     }
     Zipper::close();
     return Response::download($filenamezip);
 }
 public function getFormsub8()
 {
     $categories = array();
     $types = array();
     $parts = array();
     foreach (RefCategory::where('project_id', '=', Session::get('project_id'))->where('active', '=', 1)->get() as $category) {
         $categories[$category->id] = $category->description;
     }
     foreach (RefType::where('project_id', '=', Session::get('project_id'))->where('active', '=', 1)->get() as $type) {
         $types[$type->id] = $type->description;
     }
     foreach (RefPart::where('project_id', '=', Session::get('project_id'))->where('active', '=', 1)->get() as $part) {
         $parts[$part->id] = $part->description;
     }
     $modes = array();
     $causes = array();
     foreach (RefFailureMode::where('project_id', '=', Session::get('project_id'))->where('active', '=', 1)->get() as $mode) {
         $modes[$mode->id] = $mode->description;
     }
     foreach (RefFailureCause::where('project_id', '=', Session::get('project_id'))->where('active', '=', 1)->get() as $cause) {
         $causes[$cause->id] = $cause->description;
     }
     $tlists = array();
     $ttypes = array();
     foreach (RefTaskList::where('project_id', '=', Session::get('project_id'))->where('active', '=', 1)->get() as $list) {
         $tlists[$list->id] = $list->description;
     }
     foreach (RefTaskType::where('project_id', '=', Session::get('project_id'))->where('active', '=', 1)->get() as $type) {
         $ttypes[$type->id] = $type->description;
     }
     $assets = array();
     // $asset = AssetRegister::find(Input::get('id'));
     $assets = DB::table('asset_registers')->join('ref_categories', 'asset_registers.cat_id', '=', 'ref_categories.id')->join('ref_parts', 'asset_registers.part_id', '=', 'ref_parts.id')->join('ref_types', 'asset_registers.type_id', '=', 'ref_types.id')->where('asset_registers.active', '=', 1)->select('asset_registers.*', 'ref_categories.description as cat_desc', 'ref_parts.description as part_desc', 'ref_types.description as type_desc')->get();
     return View::make('asset_register.form_sub8')->with('assets', $assets)->with('categories', $categories)->with('types', $types)->with('parts', $parts)->with('modes', $modes)->with('causes', $causes)->with('tlists', $tlists)->with('ttypes', $ttypes)->with('node', Input::get('node'))->with('id', Input::get('id'));
 }