Esempio n. 1
0
 public function closingStockDo(Request $req)
 {
     $cs = Cs::create(['user_id' => $this->_user->user_id, 'cs_year' => $req->input('year')]);
     foreach (MatModel::fetchForClosing() as $row) {
         $vals = ['cs_id' => $cs->cs_id, 'mat_id' => $row->mat_id, 'mat_stock_awal' => $row->mat_stock_awal, 'mat_stock_akhir' => $row->mat_stock_akhir];
         Csm::create($vals);
         $mat = MatModel::find($row->mat_id);
         $mat->mat_stock_awal = $mat->mat_stock_akhir;
         $mat->save();
     }
     Session::flash('success', '<div class="info success">Closing Stok untuk tahun ' . $req->input('year') . ' berhasil dilakukan.</div>');
     return redirect('material/closingStock');
 }