Ejemplo n.º 1
0
 public function run()
 {
     Warehouse::truncate();
     Warehouse::create(['date' => Carbon::now(), 'partNumber' => 'D11111', 'count' => 1000]);
     Warehouse::create(['date' => Carbon::now(), 'partNumber' => 'D22222', 'count' => 2000]);
     Warehouse::create(['date' => Carbon::now(), 'partNumber' => 'D33333', 'count' => 3000]);
 }
Ejemplo n.º 2
0
 public function updateRetrieve(WarehouseRetrieveRequest $request)
 {
     $item = Warehouse::where('partNumber', '=', $request->input('partNumber'))->first();
     if ($item) {
         if ($item['count'] >= $request->input('count')) {
             $item['count'] -= $request->input('count');
             $item->save();
         } else {
             $messages = 'Insufficient units for item ' . $request->input('partNumber') . '. You can only retrieve ' . $item['count'] . ' units.';
             return redirect('warehouse/retrieve')->withErrors($messages);
         }
     } else {
         $messages = 'Item ' . $request->input('partNumber') . ' could not be found';
         return redirect('warehouse/retrieve')->withErrors($messages);
     }
     return redirect('warehouse');
 }
Ejemplo n.º 3
0
 /** Devuelve el detalle de un almacén especificado
  * @param $id
  * @return Warehouse
  */
 public function warehouseDetail($id)
 {
     $w = Warehouse::findOrFail($id);
     return $w;
 }
Ejemplo n.º 4
0
 public function move_warehouse(Request $request)
 {
     $good_warehouse_id = $request->good_warehouse_id;
     $warehouse_id = $request->warehouse_id;
     $quantity = $request->quantity;
     $goodWarehouse = GoodWarehouse::find($good_warehouse_id);
     $target_warehouse = Warehouse::find($warehouse_id);
     $targetGoodWarehouse = $target_warehouse->goodWarehouses()->where('good_id', $goodWarehouse->good->id)->first();
     if ($targetGoodWarehouse) {
         $targetGoodWarehouse->quantity += $quantity;
         $targetGoodWarehouse->save();
     } else {
         $targetGoodWarehouse = new GoodWarehouse();
         $targetGoodWarehouse->quantity = $quantity;
         $targetGoodWarehouse->good_id = $goodWarehouse->good->id;
         $targetGoodWarehouse->warehouse_id = $warehouse_id;
         $targetGoodWarehouse->save();
     }
     $goodWarehouse->quantity -= $quantity;
     $goodWarehouse->save();
     $exportGoods = new ImportedGoods();
     $exportGoods->quantity = -1 * $quantity;
     $exportGoods->good_id = $goodWarehouse->good->id;
     $exportGoods->warehouse_id = $goodWarehouse->warehouse->id;
     $exportGoods->note = "Chuyển hàng sang kho " . $target_warehouse->name;
     $exportGoods->save();
     $importGoods = new ImportedGoods();
     $importGoods->quantity = $quantity;
     $importGoods->good_id = $goodWarehouse->good->id;
     $importGoods->warehouse_id = $target_warehouse->id;
     $importGoods->note = "Nhập hàng từ kho " . $goodWarehouse->warehouse->name;
     $importGoods->save();
     $request->session()->flash('message', 'Chuyển kho thành công');
     return redirect('/manage/warehouse/' . $goodWarehouse->warehouse->id);
 }
Ejemplo n.º 5
0
 public function delete($id)
 {
     Warehouse::findOrFail($id)->delete();
     return redirect('/almacenes');
 }
Ejemplo n.º 6
0
 public function indexStockmoves($id)
 {
     $wh = Warehouse::find($id);
     if (is_null($wh)) {
         return Redirect::route('warehouses.index');
     }
     return View::make('warehouses.indexStockmoves')->with(array('warehouse' => $wh, 'stockmoves' => $wh->stockmoves));
 }
Ejemplo n.º 7
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $warehouse = Warehouse::findOrFail($id);
     $warehouse->delete();
     session()->flash('flash_message_danger', 'Almacén borrado correctamente.');
     //        Si flash_message_important esta presente, el mensaje no desaparece hasta que el usuario lo cierre
     //        session()->flash('flash_message_important', true);
     return Redirect::to('almacenes');
 }
Ejemplo n.º 8
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $user = User::findOrFail($id);
     $activities = Activity::lists('name', 'id');
     /*        $warehouses = Warehouse::where('company_id', Auth::user()->current_company_id)->
               get()->
               lists('name', 'id');*/
     //        $warehouses = Warehouse::where('company_id', Auth::user()->current_company_id)->
     //        get()->
     //        lists('name', 'id');
     if (Auth::user()->currentCompany->parent == 1) {
         $warehouses = Warehouse::lists('name', 'id');
     } else {
         $warehouses = Warehouse::where('company_id', Auth::user()->current_company_id)->get()->lists('name', 'id');
     }
     $securityLevel = ['10' => 'Técnico', '20' => 'Supervisor', '30' => 'Jefe', '40' => 'Gerente', '50' => 'Director'];
     return view('users.edit', compact('user', 'activities', 'warehouses', 'securityLevel'));
 }
Ejemplo n.º 9
0
 /**
  *  Devuelve el Warehouse de destino del movimiento con todos sus atributos
  * @return Warehouse
  */
 public function getDestinationAttribute()
 {
     $destination = Warehouse::find($this->destination_id);
     return $destination;
 }
Ejemplo n.º 10
0
 public function movimientosPorAlmacen(Request $request)
 {
     $desde = date_format(date_create($request->fechaDesde), "Y/m/d H:i:s");
     $hasta = date_format(date_create($request->fechaHasta), "Y/m/d 23:59:99");
     if ($request->rdOrigin == 'one') {
         $origin_id[] = $request->origin;
     } else {
         $warehouses = Warehouse::select('id')->where('company_id', $request->companyList)->where('activity_id', $request->rdActivity)->get();
         foreach ($warehouses as $warehouse) {
             $origin_id[] = $warehouse->id;
         }
     }
     if ($request->rdDestination == 'one') {
         $destination_id[] = $request->destination;
     } else {
         $warehouses = Warehouse::select('id')->where('company_id', $request->companyList)->where('activity_id', $request->rdActivity)->get();
         foreach ($warehouses as $warehouse) {
             $destination_id[] = $warehouse->id;
         }
     }
     $movements = Movement::where('created_at', '>=', $desde)->where('created_at', '<=', $hasta)->whereIn('origin_id', $origin_id)->whereIn('destination_id', $destination_id)->whereIn('status_id', [1, 2, 4])->get();
     return view('reports.movimientosPorAlmacen', compact('movements'));
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     // Currencies
     view()->composer(array('customers.edit', 'customer_invoices.create', 'companies.edit', 'customer_groups.create', 'customer_groups.edit'), function ($view) {
         $view->with('currencyList', \App\Currency::lists('name', 'id'));
     });
     // Customer Groups
     view()->composer(array('customers.edit'), function ($view) {
         $view->with('customer_groupList', \App\CustomerGroup::lists('name', 'id'));
     });
     // Payment Methods
     view()->composer(array('customers.edit', 'customer_invoices.create', 'customer_groups.create', 'customer_groups.edit'), function ($view) {
         $view->with('payment_methodList', \App\PaymentMethod::lists('name', 'id'));
     });
     // Sequences
     view()->composer(array('customers.edit', 'customer_invoices.create', 'customer_groups.create', 'customer_groups.edit'), function ($view) {
         $view->with('sequenceList', \App\Sequence::lists('name', 'id'));
     });
     // Invoice Template
     view()->composer(array('customers.edit', 'customer_invoices.create', 'customer_groups.create', 'customer_groups.edit'), function ($view) {
         $view->with('customerinvoicetemplateList', \App\Template::where('model_name', '=', 'CustomerInvoice')->lists('name', 'id'));
     });
     // Carriers
     view()->composer(array('customers.edit', 'customer_invoices.create', 'customer_groups.create', 'customer_groups.edit'), function ($view) {
         $view->with('carrierList', \App\Carrier::lists('name', 'id'));
     });
     // Sales Representatives
     view()->composer(array('customers.edit', 'customer_invoices.create'), function ($view) {
         $view->with('salesrepList', \App\SalesRep::select(DB::raw('concat (firstname," ",lastname) as name, id'))->lists('name', 'id'));
     });
     // Price Lists
     view()->composer(array('customers.edit', 'customer_groups.create', 'customer_groups.edit'), function ($view) {
         $view->with('price_listList', \App\PriceList::lists('name', 'id'));
     });
     // Warehouses
     view()->composer(array('products.create', 'stock_movements.create', 'configurationkeys.key_group_2', 'customer_invoices.create'), function ($view) {
         $whList = \App\Warehouse::with('address')->get();
         $list = [];
         foreach ($whList as $wh) {
             $list[$wh->id] = $wh->address->alias;
         }
         $view->with('warehouseList', $list);
         // $view->with('warehouseList', \App\Warehouse::lists('name', 'id'));
     });
     // Taxes
     view()->composer(array('customer_invoices.create', 'products.create', 'products.edit'), function ($view) {
         $view->with('taxList', \App\Tax::orderby('percent', 'desc')->lists('name', 'id'));
     });
     view()->composer(array('products.create', 'products.edit', 'customer_invoices.create'), function ($view) {
         $view->with('taxpercentList', \App\Tax::lists('percent', 'id'));
     });
     // Languages
     view()->composer(array('users.create', 'users.edit'), function ($view) {
         $view->with('languageList', \App\Language::lists('name', 'id'));
     });
     // Categories
     view()->composer(array('products.create', 'products._panel_main_data'), function ($view) {
         $view->with('categoryList', \App\Category::orderby('name', 'asc')->lists('name', 'id'));
     });
     // Stock Movement Types
     view()->composer(array('stock_movements.index', 'stock_movements.create'), function ($view) {
         $view->with('movement_typeList', \App\StockMovement::stockmovementList());
     });
 }