/**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $batch = Batch::findOrfail($id);
     //dd($batch);//
     return view('batch.show', compact('batch'));
     //
 }
Esempio n. 2
0
 public function batchesRunsRemaining()
 {
     $batches = Batch::whereHas('samples', function ($query) {
         $query->where('runs_remaining', '>', 0);
     })->get();
     return view('sampleRuns.batchesRunsRemaining', ['batches' => $batches]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     $batches = array(['batch_name' => 'BE6', 'department_id' => '1'], ['batch_name' => 'BE5', 'department_id' => '1'], ['batch_name' => 'BT5', 'department_id' => '2'], ['batch_name' => 'BCS1', 'department_id' => '3']);
     foreach ($batches as $batch) {
         Batch::create($batch);
     }
 }
Esempio n. 4
0
 public function getNextCode()
 {
     $latest = Parcels::max('code');
     $latestfromBatch = Batch::max('code');
     $thisDay = Carbon::now()->format('ymd');
     if (!$latest || $thisDay != substr($latest, 0, 6)) {
         return Carbon::now()->format('ymdH') . '001';
     }
     if ($latestfromBatch && $latestfromBatch > $latest) {
         return ++$latestfromBatch;
     }
     return ++$latest;
 }
Esempio n. 5
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $circles = Circle::all();
     foreach ($circles as $circle) {
         $count = rand(0, 4);
         if ($count == 0) {
             continue;
         }
         foreach (range(1, $count) as $number) {
             Batch::create(['maxscore' => rand(10, 40), 'circle_id' => $circle->id, 'seqno' => $number]);
         }
     }
 }
Esempio n. 6
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot(Guard $auth)
 {
     view()->composer('*', function ($view) {
         $pages = Page::orderBy('position', 'asc')->get();
         $view->with('pages', $pages);
     });
     view()->composer('*', function ($view) {
         $view->with('currentUser', Auth::user());
     });
     view()->composer('sidebar.special', function ($view) {
         $specialProduct = Product::where('special', 1)->get();
         $view->with('specialProduct', $specialProduct);
     });
     view()->composer('sidebar.admin', function ($view) {
         $today = \Carbon\Carbon::today();
         $orders = DB::table('orders')->where('dateOrdered', '=', $today)->where('status_id', '>', 1)->count('id');
         $view->with('orders', $orders);
     });
     view()->composer('sidebar.admin', function ($view) {
         $today = date('l');
         $hours = DB::table('hours')->where('day', $today)->value('hours');
         $view->with('hours', $hours);
     });
     view()->composer('sidebar.admin', function ($view) {
         $batches = Batch::where('proddate', \Carbon\Carbon::today())->count();
         $view->with('batches', $batches);
     });
     view()->composer('sidebar.admin', function ($view) {
         $date = date('Y-m-d');
         $shift = Shift::where('date', $date)->pluck('id');
         $employeees = Shift::find($shift)->users()->count();
         $view->with('employeees', $employeees);
     });
     view()->composer('sidebar.special', function ($view) {
         $categories = Category::all();
         $view->with('categories', $categories);
     });
     view()->composer('*', function ($view) use($auth) {
         $user = Auth::user();
         if (Auth::user()) {
             $cart = DB::table('orders')->select('id')->where('status_id', '=', 1)->where('user_id', '=', $user->id)->value('id');
             $cartItems = DB::table('order_products')->where('order_id', '=', $cart)->sum('quantity');
             $view->with('cartItems', $cartItems);
         }
     });
 }
 public function postLabel($id, Request $req)
 {
     $userid = $this->auth->user()->id;
     $this->auth->user()->points += 10;
     // TODO: decide the point
     $this->auth->user()->save();
     $label = $req->get('label');
     $itemId = $req->get('item');
     $batchId = $req->get('batch');
     \Log::info($label . " " . $itemId . " " . $batchId);
     //        $batchId = $this->auth->user()->batch_id;
     $batch = \App\Batch::find($batchId);
     $batch->remain_count--;
     $batch->save();
     $user_item = new \App\ItemUserRelation();
     $user_item->fill(['batch_id' => $batchId, 'item_id' => $itemId, 'user_id' => $userid]);
     $user_item->label = $label == 'True';
     $user_item->save();
     return redirect('/tag/' . $id);
 }
Esempio n. 8
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $batch = Batch::find($id);
     $batch->delete();
     return redirect('batch');
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $medications = Medication::personalize()->get();
     $batchs = Batch::personalize()->get();
     return view('medication.index', ['medications' => $medications, 'batchs' => $batchs]);
 }
Esempio n. 10
0
 public function checkBatchCompatibility(Sample $sample)
 {
     // Set i5 indexes if not null
     if ($sample->i5_index_id) {
         $i5 = $sample->i5_index->index_set_id;
         $new_i5_index_id = $sample->i5_index->id;
     }
     // Set i7 indexes
     $i7 = $sample->i7_index->index_set_id;
     $new_i7_index_id = $sample->i7_index->id;
     $currentIndexSet = IndexSet::find($i7);
     // Get Batch and loop through its samples
     $batch = Batch::find($sample->batch_id);
     if (count($batch->samples)) {
         foreach ($batch->samples as $s) {
             // Must be from the same index set
             if ($currentIndexSet->id != $s->i7_index->index_set_id) {
                 Session::flash('flash_message', "Index set mismatch!   Existing batch is " . $s->i7_index->IndexSet->name);
                 return false;
             }
             // If both i7 & i5 are already used
             if ($s->i5_index_id) {
                 if ($s->i7_index_id == $new_i7_index_id && $s->i5_index_id == $new_i5_index_id) {
                     Session::flash('flash_message', 'I7 and I5 combination already in batch');
                     return false;
                 }
                 // If single index and new i7 is already in batch
             } elseif ($s->i7_index_id == $new_i7_index_id) {
                 Session::flash('flash_message', 'Index conflict!   New I7 index already in single index batch ');
                 return false;
             }
             // If using dual index when batch is single
             if ($sample->i5_index_id && !$s->i5_index_id) {
                 Session::flash('flash_message', 'Batch is single index! New sample is dual   Existing Index set ' . $s->i7_index->IndexSet->name);
                 return false;
                 // Or vice versa
             } elseif ($s->i5_index_id && !$sample->i5_index_id) {
                 Session::flash('flash_message', "Batch is dual index! New sample is single.   Existing Index set " . $s->i7_index->IndexSet->name);
                 return false;
             }
         }
     }
     Session::flash('success_message', 'Sample added');
     return true;
 }
Esempio n. 11
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $productionSchedule = Batch::find($id);
     Activity::log('Cancelled production schedule #' . $productionSchedule->id . '.');
     $productionSchedule->delete();
     return Redirect::action('ProductionController@index')->with('status', 'Production schedule was successfully updated.');
 }
Esempio n. 12
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['maxscore' => 'required|numeric|min:1|max:40']);
     $batch = Batch::findOrFail($id);
     $batch->maxscore = $request->maxscore;
     $batch->save();
     foreach ($request->scores as $pupil_id => $score) {
         if ($score != "") {
             $submission = Submission::firstOrCreate(['pupil_id' => $pupil_id, 'batch_id' => $batch->id]);
             if ($submission->score != $score) {
                 $submission->score = $score;
                 $submission->save();
             }
         } else {
             Submission::where('pupil_id', $pupil_id)->where('batch_id', $batch->id)->delete();
         }
     }
     return redirect('circle/' . $batch->circle_id . '/analyze');
 }
Esempio n. 13
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function track(Batch $batch, Request $request)
 {
     $this->validate($request, ['towns_id' => 'required|integer', 'status_id' => 'required|integer', 'message' => '']);
     if ($batch->isDelivered()) {
         alert()->warning('The batch has been delivered already.', 'Oops');
         return redirect('batch/' . $batch->id);
     }
     $batch->update(['status_id' => $request->get('status_id')]);
     foreach ($batch->parcel()->get() as $t) {
         $t->parcel->update(['status_id' => $request->get('status_id')]);
         $t->parcel->track()->create(['towns_id' => $request->get('towns_id'), 'user_id' => auth()->user()->id, 'message' => $request->get('message'), 'status_id' => $request->get('status_id')]);
     }
     $batch->track()->create(['town_id' => $request->get('towns_id'), 'user_id' => auth()->user()->id, 'message' => $request->get('message'), 'status_id' => $request->get('status_id')]);
     // Fire email event at this stage
     event(new ActivityLog(auth()->user()->username . ' updated the track details for the batch ' . $batch->description . ' with the code ' . $batch->code . '  successfully.'));
     alert()->success('Batch track details updated successfully', 'Success');
     return redirect('batch/' . $batch->id);
 }
 /**
  * @param $batchId
  * @return mixed
  */
 private function getBatchSamples($batchId)
 {
     $batch = Batch::find($batchId);
     return $batch->samples;
 }
Esempio n. 15
0
 public function update(Batch $batch, BatchEditRequest $request)
 {
     $batch->update($request->all());
     return redirect('batches');
 }
Esempio n. 16
0
 private function findById($id)
 {
     return Batch::find($id);
 }
Esempio n. 17
0
 public function store(SampleRunRequest $request)
 {
     $input = $request->all();
     $run = new Run($input);
     $run->users_id = Auth::user()->id;
     $run->run_date = Carbon::now()->addDays($request->get('run_date'));
     $run->created_at = Carbon::now();
     $run->updated_at = Carbon::now();
     $run->save();
     $batch_ids = Session::get('run_batch_ids');
     $batches = Batch::whereIn('id', $batch_ids)->get();
     $errors = $this->validateBatches($batches);
     if (!$errors) {
         $this->runSamples = array();
         foreach ($batches as $batch) {
             foreach ($batch->samples as $sample) {
                 if ($sample->runs_remaining > 0) {
                     $sampleRun = new SampleRun();
                     $sampleRun->created_at = Carbon::now();
                     $sampleRun->updated_at = Carbon::now();
                     $sampleRun->run_id = $run->id;
                     $sampleRun->sample_id = $sample->id;
                     $sampleRun->save();
                     $sample->runs_remaining -= 1;
                     $sample->update();
                     array_push($this->runSamples, $sample);
                 }
             }
         }
     }
     if ($errors) {
         return view('sampleRuns.errors', ['batches' => $batches]);
     }
     $this->exportSheet($run);
     //return redirect('runs');
 }
Esempio n. 18
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     //		dd($request);
     $saldo = Saldo::find($id);
     $data = $saldo->getFillable();
     $willupdate = $request->only($data);
     if ($willupdate['batch_id'] == null) {
         $willupdate['batch_id'] = Batch::max('id') + 1;
     }
     Saldo::find($id)->update($willupdate);
     return redirect('saldo');
 }