コード例 #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
 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');
 }
コード例 #3
0
ファイル: OrderController.php プロジェクト: MangTomas23/tgm
 public function query()
 {
     $input = Input::all();
     $response = array();
     $response['product'] = Product::where('name', 'like', $input['query'] . '%')->orderBy('name')->first();
     $response['supplier'] = Supplier::find($response['product']->supplier_id);
     $response['category'] = ProductCategory::find($response['product']->product_category_id);
     $response['boxes'] = Box::where('product_id', $response['product']->id)->get();
     $response['stocks'] = array();
     foreach ($response['boxes'] as $box) {
         $stock = Box::countStock($box->id);
         array_push($response['stocks'], $stock);
     }
     return $response;
 }
コード例 #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
ファイル: routes.php プロジェクト: Craicerjack/socdems2
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/
Route::group(['middleware' => ['web']], function () {
    // Route::get('/login', function () { return view('login');});
    // List all boxes
    Route::get('/boxes', function () {
        $boxes = Box::orderBy('created_at', 'asc')->get();
        return view('box', ['boxes' => $boxes]);
    });
    // Add new box
    Route::post('/boxes', function (Request $request) {
        $validator = Validator::make($request->all(), ['name' => 'required|max:255']);
        if ($validator->fails()) {
            return redirect('/boxes')->withInput()->withErrors($validator);
        }
        $box = new Box();
        $box->name = $request->name;
        $box->save();
        return redirect('/boxes');
    });
    // Delete a box
    Route::delete('/box/{box}', function (Box $box) {
        $box->delete();
        return redirect('/boxes');
    });
});
コード例 #10
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']);
 }
コード例 #11
0
ファイル: AppController.php プロジェクト: MangTomas23/tgm
 public function test2()
 {
     return Box::countReturns2(49);
 }