Example #1
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)
 {
     $items = Item::find($id);
     $items->quantity = $items->quantity + Input::get('in_out_qty');
     $items->save();
     $inventories = new Inventory();
     $inventories->item_id = $id;
     $inventories->user_id = Auth::user()->id;
     $inventories->in_out_qty = Input::get('in_out_qty');
     $inventories->remarks = Input::get('remarks');
     $inventories->save();
     Session::flash('message', 'You have successfully updated item');
     return Redirect::to('inventory/' . $id . '/edit');
 }
Example #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(ReceivingRequest $request)
 {
     $receivings = new Receiving();
     $receivings->supplier_id = Input::get('supplier_id');
     $receivings->user_id = Auth::user()->id;
     $receivings->payment_type = Input::get('payment_type');
     $receivings->comments = Input::get('comments');
     $receivings->save();
     // process receiving items
     $receivingItems = ReceivingTemp::all();
     foreach ($receivingItems as $value) {
         $receivingItemsData = new ReceivingItem();
         $receivingItemsData->receiving_id = $receivings->id;
         $receivingItemsData->item_id = $value->item_id;
         $receivingItemsData->cost_price = $value->cost_price;
         $receivingItemsData->quantity = $value->quantity;
         $receivingItemsData->total_cost = $value->total_cost;
         $receivingItemsData->save();
         //process inventory
         $items = Item::find($value->item_id);
         $inventories = new Inventory();
         $inventories->item_id = $value->item_id;
         $inventories->user_id = Auth::user()->id;
         $inventories->in_out_qty = $value->quantity;
         $inventories->remarks = 'RECV' . $receivings->id;
         $inventories->save();
         //process item quantity
         $items->quantity = $items->quantity + $value->quantity;
         $items->save();
     }
     //delete all data on ReceivingTemp model
     ReceivingTemp::truncate();
     $itemsreceiving = ReceivingItem::where('receiving_id', $receivingItemsData->receiving_id)->get();
     Session::flash('message', 'You have successfully added receivings');
     //return Redirect::to('receivings');
     return view('receiving.complete')->with('receivings', $receivings)->with('receivingItemsData', $receivingItemsData)->with('receivingItems', $itemsreceiving);
 }
Example #3
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $sales = new Sale();
     // $sales->customer_id = Input::get('customer_id');
     Session::put('add_payment', Input::get('add_payment'));
     $sales->customer_id = 1;
     $sales->customer_name = Input::get('customer_name');
     $sales->user_id = Auth::user()->id;
     $sales->payment_type = Input::get('payment_type');
     $sales->comments = Input::get('comments');
     $sales->save();
     // process sale items
     $saleItems = SaleTemp::all();
     foreach ($saleItems as $value) {
         $saleItemsData = new SaleItem();
         $saleItemsData->sale_id = $sales->id;
         $saleItemsData->item_id = $value->item_id;
         $saleItemsData->cost_price = $value->cost_price;
         $saleItemsData->selling_price = $value->selling_price;
         $saleItemsData->quantity = $value->quantity;
         $saleItemsData->total_cost = $value->total_cost;
         $saleItemsData->total_selling = $value->total_selling;
         $saleItemsData->save();
         //process inventory
         $items = Item::find($value->item_id);
         if ($items->type == 1) {
             $inventories = new Inventory();
             $inventories->item_id = $value->item_id;
             $inventories->user_id = Auth::user()->id;
             $inventories->in_out_qty = -$value->quantity;
             $inventories->remarks = 'SL0000' . $sales->id;
             $inventories->save();
             //process item quantity
             $items->quantity = $items->quantity - $value->quantity;
             $items->save();
         } else {
             $itemkits = ItemKitItem::where('item_kit_id', $value->item_id)->get();
             foreach ($itemkits as $item_kit_value) {
                 $inventories = new Inventory();
                 $inventories->item_id = $item_kit_value->item_id;
                 $inventories->user_id = Auth::user()->id;
                 $inventories->in_out_qty = -($item_kit_value->quantity * $value->quantity);
                 $inventories->remarks = 'SL0000' . $sales->id;
                 $inventories->save();
                 //process item quantity
                 $item_quantity = Item::find($item_kit_value->item_id);
                 $item_quantity->quantity = $item_quantity->quantity - $item_kit_value->quantity * $value->quantity;
                 $item_quantity->save();
             }
         }
     }
     //delete all data on SaleTemp model
     SaleTemp::truncate();
     $itemssale = SaleItem::where('sale_id', $saleItemsData->sale_id)->get();
     Session::flash('message', 'You have successfully added sales');
     //return Redirect::to('receivings');
     return view('sale.complete2')->with('sales', $sales)->with('saleItemsData', $saleItemsData)->with('saleItems', $itemssale);
 }
Example #4
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)
 {
     $items = Item::find($id);
     // process inventory
     $inventories = new Inventory();
     $inventories->item_id = $id;
     $inventories->user_id = Auth::user()->id;
     $inventories->in_out_qty = Input::get('quantity') - $items->quantity;
     $inventories->remarks = 'Manual Edit of Quantity';
     $inventories->save();
     // save update
     $items->upc_ean_isbn = Input::get('upc_ean_isbn');
     $items->item_name = Input::get('item_name');
     $items->size = Input::get('size');
     $items->satuan = Input::get('satuan');
     $items->fk_cat = Input::get('fk_cat');
     $items->fk_location = Input::get('fk_location');
     $items->description = Input::get('description');
     $items->cost_price = Input::get('cost_price');
     $items->grocery_price = Input::get('grocery_price');
     $items->selling_price = Input::get('selling_price');
     $items->selling_price2 = Input::get('selling_price2');
     $items->selling_price3 = Input::get('selling_price3');
     $items->qty_min = Input::get('qty_min');
     $items->qty_min_2 = Input::get('qty_min_2');
     $items->qty_min_2 = Input::get('qty_min_3');
     $items->disc_currency = Input::get('disc_currency');
     $items->disc_persen = Input::get('disc_persen');
     $items->quantity = Input::get('quantity');
     $items->save();
     // process avatar
     $image = $request->file('avatar');
     if (!empty($image)) {
         $avatarName = 'item' . $id . '.' . $request->file('avatar')->getClientOriginalExtension();
         $request->file('avatar')->move(base_path() . '/public/images/items/', $avatarName);
         $img = Image::make(base_path() . '/public/images/items/' . $avatarName);
         $img->resize(100, null, function ($constraint) {
             $constraint->aspectRatio();
         });
         $img->save();
         $itemAvatar = Item::find($id);
         $itemAvatar->avatar = $avatarName;
         $itemAvatar->save();
     }
     Session::flash('message', 'You have successfully updated item');
     return Redirect::to('items');
 }