コード例 #1
0
ファイル: ReturnController.php プロジェクト: MangTomas23/tgm
 /**
  * Store the return items data 
  * 
  * @return ReturnController@index
  */
 public function store()
 {
     $input = Input::all();
     $customer = Customer::firstOrNew(['name' => $input['customer']]);
     $customer->address = $input['address'];
     $customer->save();
     $ret = new Ret();
     $ret->customer_id = $customer->id;
     $ret->date = $input['date'];
     $ret->reference_no = $input['ref_no'];
     $ret->salesman = $input['salesman'];
     $ret->area = $input['area'];
     $ret->received_by = $input['received_by'];
     $ret->checked_by = $input['checked_by'];
     $ret->save();
     foreach ($input['boxes'] as $i => $box) {
         $retItem = new ReturnItem();
         $retItem->ret_id = $ret->id;
         $retItem->box_id = $box;
         $retItem->no_of_box = $input['no_of_box'][$i];
         $retItem->no_of_packs = $input['no_of_packs'][$i];
         $retItem->amount = $input['amount'][$i];
         $retItem->product_id = Box::find($box)->product->id;
         $retItem->save();
     }
     return Redirect::action('InventoryController@index');
 }
コード例 #2
0
ファイル: OrderController.php プロジェクト: MangTomas23/tgm
 public function store()
 {
     $input = Input::all();
     $salesman = isset($input['salesman']) ? $input['salesman'] : null;
     $customer = Customer::firstOrNew(['name' => $input['name'], 'address' => $input['address']]);
     $customer->save();
     $order = new Order();
     $order->customer_id = $customer->id;
     $order->salesman_id = $salesman;
     $order->date = $input['date'];
     $order->type = $input['type'];
     $order->save();
     foreach ($input['box_id'] as $i => $box_id) {
         $orderItem = new OrderItem();
         $orderItem->order_id = $order->id;
         $orderItem->product_id = Box::find($box_id)->product->id;
         $orderItem->box_id = $box_id;
         $orderItem->no_of_box = $input['no_of_box'][$i];
         $orderItem->no_of_packs = $input['no_of_packs'][$i];
         $orderItem->amount = $input['amount'][$i];
         $orderItem->selling_price = $input['selling_price'][$i];
         $orderItem->save();
     }
     return view('order.addmore');
 }
コード例 #3
0
 public function update()
 {
     $input = Input::all();
     foreach ($input['id'] as $i => $id) {
         $box = Box::find($id);
         $box->purchase_price = $input['purchase_price'][$i];
         $box->selling_price_1 = $input['selling_price_1'][$i];
         $box->selling_price_2 = $input['selling_price_2'][$i];
         $box->save();
     }
     return Redirect::action('PriceListController@index');
 }
コード例 #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $lost = new Lost();
     $lost->date = $input["date"];
     $lost->checked_by = $input["checked_by"];
     $lost->save();
     foreach ($input['boxes'] as $i => $box) {
         $lostItem = new LostItem();
         $lostItem->lost_id = $lost->id;
         $lostItem->no_of_box = $input['no_of_box'][$i];
         $lostItem->no_of_packs = $input['no_of_packs'][$i];
         $lostItem->amount = $input['amount'][$i];
         $lostItem->box_id = $box;
         $lostItem->product_id = Box::find($box)->product->id;
         $lostItem->save();
     }
 }
コード例 #5
0
ファイル: Box.php プロジェクト: MangTomas23/tgm
 public function scopeCountReturns2($query, $box_id)
 {
     $ret = Box::countReturns($box_id);
     $rbox = $ret['no_of_box'];
     $rpacks = $ret['no_of_packs'];
     $box = Box::find($box_id);
     $inStock = $box->instocks->sum('quantity') + $rbox;
     $packsPerBox = $box->no_of_packs;
     $totalPacks = $inStock * $packsPerBox + $rpacks;
     $noOfBoxOrdered = $box->orderItems->sum('no_of_box');
     $noOfPacksOrdered = $box->orderItems->sum('no_of_packs');
     $totalOrders = $noOfBoxOrdered * $packsPerBox + $noOfPacksOrdered;
     $totalNoOfPacksLeft = $totalPacks - $totalOrders;
     $totalNoOfBoxLeft = floor($totalNoOfPacksLeft / $packsPerBox);
     $totalNoOfBoxLeft == null ? 0 : $totalNoOfBoxLeft;
     $totalNoOfPacksLeft == null ? 0 : $totalNoOfPacksLeft;
     $totalLeft = ['no_of_box_available' => $totalNoOfBoxLeft, 'no_of_packs_available' => $totalNoOfPacksLeft - $totalNoOfBoxLeft * $packsPerBox];
     return $totalLeft;
 }
コード例 #6
0
ファイル: InStockController.php プロジェクト: MangTomas23/tgm
 public function store()
 {
     $input = Input::all();
     foreach ($input['boxes'] as $i => $box) {
         if ($input['quantity'][$i] == 0) {
             continue;
         }
         $instock = new InStock();
         $instock->date = $input['date'];
         $instock->supplier_id = $input['supplier'];
         $instock->box_id = $box;
         $b = Box::find($box);
         $instock->product_id = $b->product_id;
         $instock->quantity = $input['quantity'][$i];
         $instock->amount = $input['quantity'][$i] * $b->purchase_price;
         $instock->save();
     }
     return Redirect::action('InventoryController@index');
 }
コード例 #7
0
 public function store()
 {
     $input = Input::all();
     $badOrder = new BadOrder();
     $badOrder->truck_no = $input['truck_no'];
     $badOrder->date = $input['date'];
     $badOrder->received_by = $input['received_by'];
     $badOrder->salesman = $input['salesman'];
     $badOrder->save();
     foreach ($input['boxes'] as $i => $box) {
         $bo_items = new BadOrderItem();
         $bo_items->bad_order_id = $badOrder->id;
         $bo_items->box_id = $box;
         $bo_items->no_of_box = $input['no_of_box'][$i];
         $bo_items->no_of_packs = $input['no_of_packs'][$i];
         $bo_items->amount = $input['amount'][$i];
         $bo_items->product_id = Box::find($box)->product->id;
         $bo_items->save();
     }
     return Redirect::action('BadOrderController@index');
 }
コード例 #8
0
ファイル: InStock.php プロジェクト: MangTomas23/tgm
 public function scopeCount($query, $box_id)
 {
     $count = Box::find($box_id)->instocks->sum('quantity');
     return $count == 0 ? 'Out of Stock' : $count;
 }
コード例 #9
0
ファイル: ProductController.php プロジェクト: MangTomas23/tgm
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update()
 {
     $input = Input::all();
     $product = Product::find($input['id']);
     $rules = array('name' => 'required', 'product_category' => 'required', 'supplier' => 'required');
     $validator = Validator::make($input, $rules);
     if ($validator->passes()) {
         $product->name = $input['name'];
         $product->product_category_id = $input['product_category'];
         $product->supplier_id = $input['supplier'];
         $product->save();
         foreach ($input['box'] as $i => $v) {
             $box = Box::find($v);
             $box->size = $input['size'][$i];
             $box->no_of_packs = $input['packs'][$i];
             $box->purchase_price = $input['purchase_price'][$i];
             $box->selling_price_1 = $input['selling_price_1'][$i];
             $box->selling_price_2 = $input['selling_price_2'][$i];
             $box->save();
         }
         if (isset($input['asize'])) {
             foreach ($input['asize'] as $i => $v) {
                 $box = new Box();
                 $box->product_id = $input['id'];
                 $box->size = $v;
                 $box->no_of_packs = $input['apacks'][$i];
                 $box->purchase_price = $input['apurchase_price'][$i];
                 $box->selling_price_1 = $input['aselling_price_1'][$i];
                 $box->selling_price_2 = $input['aselling_price_2'][$i];
                 $box->save();
             }
         }
         if (isset($input['trash'])) {
             Box::destroy($input['trash']);
         }
         return Redirect::action('ProductController@index');
     }
     return Redirect::action('ProductController@show', $input['id']);
 }