public function postEdittask()
 {
     $basictask = BasicTask::find(Input::get('id'));
     $cause = RefFailureCause::where('id', '!=', $basictask->cause_id)->where('active', '=', 1)->where('project_id', '=', Session::get('project_id'))->get();
     $type = RefTaskType::where('id', '!=', $basictask->type_id)->where('active', '=', 1)->where('project_id', '=', Session::get('project_id'))->get();
     $list = RefTaskList::where('id', '!=', $basictask->list_id)->where('active', '=', 1)->where('project_id', '=', Session::get('project_id'))->get();
     $basic = BasicTask::with('tasklist', 'cause', 'type')->where('id', '=', Input::get('id'))->where('active', '=', 1)->where('project_id', '=', Session::get('project_id'))->get();
     return View::make('basic_data_setup.task.edit')->with('basics', $basic)->with('types', $type)->with('lists', $list)->with('causes', $cause);
 }
示例#2
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'));
 }
 public function postDupproject()
 {
     $validator = Validator::make(Input::all(), Project::$rules);
     if ($validator->passes()) {
         $project = Project::where('created_by', '=', Auth::user()->id)->where('name', '=', Input::get('name'))->where('active', '=', 1)->get();
         if (!$project->isEmpty()) {
             return Redirect::to('dash-board')->with('message_error', 'Project duplicate !');
         } else {
             $project = new Project();
             $project->name = Input::get('name');
             $project->member_id = Auth::user()->id;
             $project->created_by = Auth::user()->id;
             $project->save();
             $project_id = Input::get('project_id');
             $basic_equipment = BasicEquipment::where('project_id', '=', $project_id)->where('active', '=', 1)->get();
             $basic_failure = BasicFailure::where('project_id', '=', $project_id)->where('active', '=', 1)->get();
             $basic_task = BasicTask::where('project_id', '=', $project_id)->where('active', '=', 1)->get();
             $ref_task_interval = RefTaskInterval::where('project_id', '=', $project_id)->where('active', '=', 1)->get();
             // Duplicate Basic Equipment
             if (!$basic_equipment->isEmpty()) {
                 foreach ($basic_equipment as $bq) {
                     $ref_cate = RefCategory::find($bq->category_id);
                     $category = new RefCategory();
                     $category->description = $ref_cate->description;
                     $category->created_by = Auth::user()->id;
                     $category->project_id = $project->id;
                     $category->save();
                     $ref_type = RefType::find($bq->type_id);
                     $type = new RefType();
                     $type->description = $ref_type->description;
                     $type->created_by = Auth::user()->id;
                     $type->project_id = $project->id;
                     $type->save();
                     $ref_part = RefPart::find($bq->part_id);
                     $part = new RefPart();
                     $part->description = $ref_part->description;
                     $part->created_by = Auth::user()->id;
                     $part->project_id = $project->id;
                     $part->save();
                     $basic_eq = new BasicEquipment();
                     $basic_eq->category_id = $category->id;
                     $basic_eq->type_id = $type->id;
                     $basic_eq->part_id = $part->id;
                     $basic_eq->created_by = Auth::user()->id;
                     $basic_eq->project_id = $project->id;
                     $basic_eq->save();
                 }
             }
             // Duplicate Basic Failure
             if (!$basic_failure->isEmpty()) {
                 foreach ($basic_failure as $bf) {
                     $mode = RefFailureMode::find($bf->mode_id);
                     $f_mode = new RefFailureMode();
                     $f_mode->description = $mode->description;
                     $f_mode->created_by = Auth::user()->id;
                     $f_mode->project_id = $project->id;
                     $f_mode->save();
                     $cause = RefFailureCause::find($bf->cause_id);
                     $f_cause = new RefFailureCause();
                     $f_cause->description = $cause->description;
                     $f_cause->created_by = Auth::user()->id;
                     $f_cause->project_id = $project->id;
                     $f_cause->save();
                     $basic_f = new BasicFailure();
                     $basic_f->mode_id = $f_mode->id;
                     $basic_f->cause_id = $f_cause->id;
                     $basic_f->created_by = Auth::user()->id;
                     $basic_f->project_id = $project->id;
                     $basic_f->save();
                 }
             }
             // Duplication Basic Task
             if (!$basic_task->isEmpty()) {
                 foreach ($basic_task as $bt) {
                     $basic_tk = new BasicTask();
                     $cause_t = RefFailureCause::where('id', '=', $bt->cause_id)->where('project_id', '=', $project->id)->where('active', '=', 1)->get();
                     // print_r($cause_t);
                     if ($cause_t->isEmpty()) {
                         $cause_ft = RefFailureCause::find($bt->cause_id);
                         $f_cause_t = new RefFailureCause();
                         $f_cause_t->description = $cause_ft->description;
                         $f_cause_t->created_by = Auth::user()->id;
                         $f_cause_t->project_id = $project->id;
                         $f_cause_t->save();
                         $basic_tk->cause_id = $f_cause_t->id;
                     } else {
                         $basic_tk->cause_id = $cause_t->id;
                     }
                     $task_tp = RefTaskType::find($bt->type_id);
                     $tk_type = new RefTaskType();
                     $tk_type->description = $task_tp->description;
                     $tk_type->created_by = Auth::user()->id;
                     $tk_type->project_id = $project->id;
                     $tk_type->save();
                     $basic_tk->type_id = $tk_type->id;
                     $task_lt = RefTaskList::find($bt->list_id);
                     $tk_list = new RefTaskList();
                     $tk_list->description = $task_lt->description;
                     $tk_list->created_by = Auth::user()->id;
                     $tk_list->project_id = $project->id;
                     $tk_list->save();
                     $basic_tk->list_id = $tk_list->id;
                     $basic_tk->created_by = Auth::user()->id;
                     $basic_tk->project_id = $project->id;
                     $basic_tk->save();
                 }
             }
             if (!$ref_task_interval->isEmpty()) {
                 foreach ($ref_task_interval as $t_inter) {
                     $tk_inter = new RefTaskInterval();
                     $tk_inter->interval = $t_inter->interval;
                     $tk_inter->description = $t_inter->description;
                     $tk_inter->created_by = Auth::user()->id;
                     $tk_inter->project_id = $project->id;
                     $tk_inter->save();
                 }
             }
             Session::put('project_id', $project->id);
             Session::put('project', $project->name);
             return Redirect::to('dash-board')->withSuccess('Duplicate Project Success.');
         }
     }
     return Redirect::to('dash-board')->withErrors($validator)->withInput();
 }
示例#5
0
 public function postUpdatecause()
 {
     $input = Input::all();
     $input['updated_by'] = Auth::user()->id;
     $check = RefFailureCause::where('id', '!=', Input::get('id'))->where('description', '=', Input::get('description'))->where('active', '=', 1)->where('project_id', '=', Session::get('project_id'))->get();
     if ($check->isEmpty()) {
         $cause = RefFailureCause::find(Input::get('id'));
         $cause->update($input);
         return Redirect::to('reference-data/failure/cause');
     } else {
         return Redirect::to('reference-data/failure/cause')->withErrors('Failure Mode duplicate!');
     }
 }