/**
  * Store new waste register entry associated with job and waste code
  *
  * @param JobCard $job_card
  * @return $this
  */
 public function store(Request $request, JobCard $job_card)
 {
     $this->authorize('edit_waste_register');
     $this->validate($request, ['operator_id' => 'required|exists:users,id', 'waste_codes_id' => 'required|exists:waste_codes,id', 'weight_kg' => 'required|numeric|min:0']);
     $job_card->wasteRegisterEntries()->save(WasteRegisterEntry::create($request->all()));
     flash()->success('Entry Saved', 'A new waste entry has been created.');
     return redirect()->action('WasteRegisterController@show', $job_card);
 }
 /**
  * @param Request $request
  * @param JobCard $job_card
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(Request $request, JobCard $job_card)
 {
     $this->authorize('edit_slitting_log_sheet');
     $slitting_log_sheet = new SlittingLogSheet();
     $job_card->slittingLogSheets()->save($slitting_log_sheet);
     flash()->success('New Log Sheet', 'A new log sheet has been created.');
     return redirect()->action('SlittingLogSheetsController@edit', [$slitting_log_sheet]);
 }
 /**
  * Store a log sheet from the request
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function store(Request $request, JobCard $job_card)
 {
     $this->authorize('edit_printing_log_sheet');
     $this->validate($request, ['printing_team_list' => 'required|array']);
     $printing_log_sheet = new PrintingLogSheet();
     $job_card->printingLogSheets()->save($printing_log_sheet);
     $printing_log_sheet->printingTeam()->attach($request->input('printing_team_list'));
     flash()->success('New Log Sheet', 'The new log sheet has been created.');
     return redirect()->action('PrintingLogSheetsController@edit', [$job_card, $printing_log_sheet]);
 }
 public function store(Request $request, JobCard $job_card)
 {
     $this->authorize('edit_laminating_log_sheet');
     $this->validate($request, ['pass_number' => 'required|integer|between:1,2']);
     $laminating_log_sheet = new LaminatingLogSheet();
     $laminating_log_sheet->pass_number = $request->get('pass_number');
     $job_card->laminatingLogSheets()->save($laminating_log_sheet);
     flash()->success('New Log Sheet', 'A new log sheet has been created.');
     return redirect()->action('LaminatingLogSheetsController@edit', [$laminating_log_sheet]);
 }
 /**
  * Store a log sheet from the request
  *
  * @param Requests\StorePrintingPassSheetFromRequest $request
  * @param JobCard $job_card
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function store(StorePrintingPassSheetFromRequest $request, JobCard $job_card)
 {
     $this->authorize('pass_printing_job');
     if (isset($job_card->printingPassSheet) && $job_card->printingPassSheet->count() > 0) {
         return redirect()->action('PrintingPassSheetsController@edit', [$job_card]);
     }
     $passSheet = PrintingPassSheet::create(['material_grade_id' => $request->material_grade_id, 'material_thickness' => $request->material_thickness, 'material_width' => $request->material_width, 'treatment_side' => $request->treatment_side, 'adhesion_checked' => $request->adhesion_checked, 'register_checked' => $request->register_checked, 'blade_lines_checked' => $request->blade_lines_checked, 'dot_skipping_checked' => $request->dot_skipping_checked, 'slur_checked' => $request->slur_checked, 'note' => $request->note, 'unwind_drawing_id' => $request->unwind_drawing_id]);
     foreach ($request->sequence as $key => $value) {
         $station = PrintingPassSheetStation::create(['sequence' => $request->sequence[$key], 'inks_id' => $request->inks_id[$key], 'delta_e' => $request->delta_e[$key]]);
         $passSheet->stations()->save($station);
     }
     $job_card->printingPassSheet()->save($passSheet);
     flash()->success('Created', 'Printing pass sheet has been created.');
     return redirect()->action('PrintingPassSheetsController@edit', [$job_card]);
 }
 /**
  * Calculate the current months Expected GP
  *
  * @return string
  */
 public function monthExpectedGp()
 {
     return Cache::store('database')->remember(__CLASS__ . "::" . __FUNCTION__ . $this->date->month . $this->date->year, 60, function () {
         $monthJobs = JobCard::dueThisMonth($this->date)->get();
         return round($monthJobs->sum('expected_gp_contribution'));
     });
 }
Пример #7
0
 /**
  * Cost Vs Selling Price Report
  *
  * @return $this
  */
 public function costVsSelling($month, $year)
 {
     $this->authorize('view_gp_report');
     $date = Carbon::create($year, $month);
     $jobIds = DespatchLogEntry::thisMonth($date)->get()->pluck('despatch_log_book_job_cards_id_fk')->toArray();
     return view('reports.costVsSelling')->with(['jobs' => JobCard::find($jobIds)]);
 }
Пример #8
0
 /**
  * Returns a random active job
  *
  * @return mixed
  */
 protected function getRandomJob($department = null)
 {
     $jobs = \App\Models\JobCard::active()->lists('job_cards_id')->toArray();
     if ($department == 'printing') {
         $jobs = \App\Models\JobCard::active()->printingCurrentTen()->lists('job_cards_id')->toArray();
     }
     $randomJob = \App\Models\JobCard::find($this->fake->randomElements($jobs))[0];
     return $randomJob;
 }
 /**
  * @test
  */
 public function scope_for_sheets_associated_with_given_job()
 {
     $job = JobCard::find(1);
     $job_log_sheets = PrintingLogSheet::associatedWithJob($job)->get();
     $associated_log_sheets_manually = DB::table('printing_log_sheets')->where('job_id_fk', $job->job_cards_id)->get();
     foreach ($job_log_sheets as $sheet) {
         $this->assertEquals($sheet->job_id_fk, $job->job_cards_id);
     }
     $this->assertCount(count($associated_log_sheets_manually), $job_log_sheets);
 }
Пример #10
0
 /**
  * Overwrite the parent boot method
  *
  * @return void
  */
 public static function boot()
 {
     parent::boot();
     JobCard::creating(function ($jobCard) {
         $jobCard->job_cards_added_user_id_fk = \Auth::user()->id;
         $jobCard->job_cards_modified_user_id_fk = \Auth::user()->id;
     });
     JobCard::updating(function ($jobCard) {
         $jobCard->job_cards_modified_user_id_fk = \Auth::user()->id;
     });
 }
 /**
  * Determine job to be run in this shift given a starting time
  *
  * @param Carbon $shiftStartTime
  */
 public function shiftJobs($shiftStartTime)
 {
     $printingJobs = JobCard::active()->printingCurrentTen()->get()->sortBy('job_cards_print_priority');
     while ($printingJobs->first() != null && $printingJobs->first()->job_cards_print_date->lt($shiftStartTime)) {
         $previousJob = $printingJobs->shift();
     }
     if (isset($previousJob) && $printingJobs->first() != $shiftStartTime) {
         $printingJobs->prepend($previousJob);
     }
     return $printingJobs;
 }
 /**
  * @test
  */
 public function job_card_times()
 {
     $job = JobCard::find(4541);
     $calculator = new QtyTimeRequiredCalculator($job);
     $this->assertInstanceOf(JobCosting::class, $calculator->job_costing, "Job Costing Type");
     $this->assertInternalType('double', $calculator->production_quantity, "production_quantity");
     $this->assertInternalType('int', $calculator->printing_hours, "printing_hours type");
     $this->assertInternalType('int', $calculator->laminating_hours, "laminating_hours type");
     $this->assertInternalType('int', $calculator->slitting_hours, "production_quantity type");
     $this->assertInternalType('int', $calculator->lead_time, "production_quantity type");
 }
 /**
  * @test
  */
 public function expected_gp()
 {
     $gpTarget = GlobalVariable::first()->monthly_gp_target;
     $currentMonthJobs = JobCard::dueThisMonth()->get();
     $gpCalculator = new GpIndicatorsCalculator();
     $this->assertInstanceOf(GpIndicatorsCalculator::class, $gpCalculator, "GP Calculator Object");
     $globalTarget = GlobalVariable::first()->monthly_gp_target;
     $expectedGpCalc = 0;
     $sellingPriceCalc = 0;
     foreach ($currentMonthJobs as $job) {
         $this->assertInstanceOf(JobCard::class, $job);
         $expectedGpCalc += $job->expected_gp_contribution;
         $sellingPriceCalc += $job->selling_price * $job->production_quantity;
     }
     $target = $gpTarget >= $expectedGpCalc ? $gpTarget : $expectedGpCalc;
     $this->assertEquals(round($expectedGpCalc), $gpCalculator->monthExpectedGp(), "Current Month Expected");
     $this->assertEquals(round($sellingPriceCalc), $gpCalculator->monthExpectedTurnOver(), "Current Month Expected Turn Over");
     //        $this->assertEquals($expectedGpCalc / $target * 100, $gpCalculator->monthExpectedPercentage(),
     //            "Current Month Expected Percentage");
     $this->assertInternalType('float', $gpCalculator->monthExpectedPercentage(), "Current Month Expected Percentage");
     $this->assertEquals(round($expectedGpCalc / $globalTarget * 100), round($gpCalculator->monthProductionExpectedPercentage()), "Current Month Production Expected Percentage");
 }
Пример #14
0
 /**
  * Update ink_cost associated with JobCard
  *
  * @param Request $request
  * @param JobCard $job_card
  * @return $this
  */
 public function updateInkCost(Request $request, JobCard $job_card)
 {
     $this->authorize('edit_buffer');
     $this->validate($request, ['ink_cost' => 'required|numeric|min:1']);
     $job_card->ink_cost = $request->get('ink_cost');
     $job_card->save();
     flash()->success('Ink Cost Saved!', 'Job Card (' . $job_card->job_cards_id . ') has been updated.');
     return redirect()->back();
 }
Пример #15
0
 private function getRandomActiveJob()
 {
     $this->jobs = App\Models\JobCard::active()->lists('job_cards_id')->toArray();
     return App\Models\JobCard::find($this->fake->randomElements($this->jobs))[0];
 }
Пример #16
0
 /**
  * @test
  */
 public function requiredMaterial()
 {
     $job = JobCard::find(4307);
     $this->assertInstanceOf(JobCard::class, $job, "Job Card Model");
     $costing = $job->jobCosting;
     $this->assertInstanceOf(JobCosting::class, $costing, "Job Costing Model");
     $requiredMat1 = $job->requiredMaterialLayer(1);
     $requiredMat2 = $job->requiredMaterialLayer(2);
     $requiredMat3 = $job->requiredMaterialLayer(3);
     $mat1Width = $job->materialWidthLayer(1);
     $mat2Width = $job->materialWidthLayer(2);
     $requiredMat1Calc = $job->required_print_meters * $job->materialLayer(1)->gramsPerMeter($mat1Width) / 1000;
     $requiredMat2Calc = $job->required_production_meters * $job->materialLayer(2)->gramsPerMeter($mat2Width) / 1000;
     $this->assertEquals($requiredMat1Calc, $requiredMat1, "Required Material 1");
     $this->assertEquals($requiredMat2Calc, $requiredMat2, "Required Material 2");
     $this->assertEquals(0, $requiredMat3, "Required Material 3");
 }
Пример #17
0
 /**
  * Collection of jobs started in this department in current shift
  * @return Collection
  */
 public function currentShiftJobsStarted()
 {
     $jobsStartedIds = DB::table(PrintingLogSheet::table())->select('job_id_fk')->groupBy('job_id_fk')->havingRaw('min(created_at) >= \'' . $this->current_shift->starting_time . '\'')->havingRaw('min(created_at) <= \'' . $this->current_shift->ending_time . '\'')->pluck('job_id_fk');
     return JobCard::find($jobsStartedIds);
 }
Пример #18
0
 /**
  * Testing API functionality
  *
  * @param User $user
  * @return string
  */
 public function getActiveJobs(User $user)
 {
     Auth::loginUsingId($user->id);
     $this->authorize('view_buffer_management');
     return JobCard::active()->get();
 }