/**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $values = $request->all();
     $proveedor = new Proveedor();
     $proveedor->fill($values);
     $proveedor->save();
     return redirect()->back();
 }
 public function run()
 {
     $faker = Faker::create('es_ES');
     for ($i = 0; $i < 5; $i++) {
         $proveedor = Proveedor::create(['nombre' => $faker->company, 'direccion' => $faker->address, 'telefono' => $faker->phoneNumber]);
     }
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create(Request $request)
 {
     $cuenta = Cuenta::lists('nombre', 'codigo')->all();
     $cuenta = array('' => 'Seleccionar...') + $cuenta;
     if ($request->ajax()) {
         $subcuenta = $this->listaSubcuenta($request->codigo);
         return response()->json($subcuenta);
     }
     $subcuenta = "";
     //$subcuenta = SubCuenta::lists('nombre', 'id')->all(); //
     //$subcuenta = array('' => 'Seleccionar...') + $subcuenta;
     $proveedor = Proveedor::lists('nombre', 'id')->all();
     //
     $proveedor = array('' => 'Seleccionar...') + $proveedor;
     $deposito = Deposito::lists('nombre', 'id')->all();
     //
     $deposito = array('' => 'Seleccionar...') + $deposito;
     $marca = Marca::lists('nombre', 'id')->all();
     //
     $marca = array('' => 'Seleccionar...') + $marca;
     $modelo = Modelo::lists('nombre', 'id')->all();
     //
     $modelo = array('' => 'Seleccionar...') + $modelo;
     return view('carga.create', compact('proveedor', 'cuenta', 'subcuenta', 'marca', 'modelo', 'deposito'));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $producto = Producto::find($id);
     $proveedores = Proveedor::all();
     $nombreProveedores = array();
     foreach ($proveedores as $proveedor) {
         array_push($nombreProveedores, $proveedor->nombre);
     }
     return view('admi.productos.edit')->with(['producto' => $producto, 'proveedores' => $nombreProveedores]);
 }
 public function show($id)
 {
     $proveedor = Proveedor::find($id);
     if (!$proveedor) {
         //ERROR
     }
     $total = 0;
     foreach ($proveedor->consumos as $consumo) {
         $total += $consumo->pivot->consumo;
     }
     return view('home', ['proveedor' => $proveedor, 'consumos' => $proveedor->consumos, 'total_consumo' => $total, 'titulo' => "Consumos proveedor", 'subtitulo' => "Asociados que han consumido del proveedor.", 'link_proveedor' => true, 'show_proveedor' => true]);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $rules = ['nombre' => 'required', 'ruc' => 'required', 'proveedor' => 'required'];
     $this->validate($request, $rules);
     $prov = \App\Proveedor::find($id);
     $prov->nombre = $request->input('nombre');
     $prov->ruc = $request->input('ruc');
     $prov->proveedor = $request->input('proveedor');
     $prov->direccion = $request->input('direccion');
     $prov->save();
     $request->session()->flash('msj_success', 'Se ha editado el proveedor: ' . $request->input('nombre'));
     return redirect()->route('proveedor.index');
 }
 public function run()
 {
     $faker = Faker::create('es_ES');
     $proveedor = Proveedor::find(1);
     $producto = new Producto(['nombre' => 'Morfina', 'descripcion' => $faker->text($maxNbChars = 35), 'existencias' => $faker->numberBetween($min = 60, $max = 465), 'precio' => $faker->numberBetween($min = 1800, $max = 58000)]);
     $producto = $proveedor->productos()->save($producto);
     $producto = new Producto(['nombre' => 'Lidocaina', 'descripcion' => $faker->text($maxNbChars = 35), 'existencias' => $faker->numberBetween($min = 60, $max = 465), 'precio' => $faker->numberBetween($min = 1800, $max = 58000)]);
     $producto = $proveedor->productos()->save($producto);
     $producto = new Producto(['nombre' => 'Prometazina', 'descripcion' => $faker->text($maxNbChars = 35), 'existencias' => $faker->numberBetween($min = 60, $max = 465), 'precio' => $faker->numberBetween($min = 1800, $max = 58000)]);
     $producto = $proveedor->productos()->save($producto);
     $producto = new Producto(['nombre' => 'Diazepam', 'descripcion' => $faker->text($maxNbChars = 35), 'existencias' => $faker->numberBetween($min = 60, $max = 465), 'precio' => $faker->numberBetween($min = 1800, $max = 58000)]);
     $producto = $proveedor->productos()->save($producto);
     $producto = new Producto(['nombre' => 'Acido Acetilsalicílico', 'descripcion' => $faker->text($maxNbChars = 35), 'existencias' => $faker->numberBetween($min = 60, $max = 465), 'precio' => $faker->numberBetween($min = 1800, $max = 58000)]);
     $producto = $proveedor->productos()->save($producto);
     $proveedor = Proveedor::find(2);
     $producto = new Producto(['nombre' => 'Ibuprofeno', 'descripcion' => $faker->text($maxNbChars = 35), 'existencias' => $faker->numberBetween($min = 60, $max = 465), 'precio' => $faker->numberBetween($min = 1800, $max = 58000)]);
     $producto = $proveedor->productos()->save($producto);
     $producto = new Producto(['nombre' => 'Paracetamol', 'descripcion' => $faker->text($maxNbChars = 35), 'existencias' => $faker->numberBetween($min = 60, $max = 465), 'precio' => $faker->numberBetween($min = 1800, $max = 58000)]);
     $producto = $proveedor->productos()->save($producto);
     $producto = new Producto(['nombre' => 'Codeina', 'descripcion' => $faker->text($maxNbChars = 35), 'existencias' => $faker->numberBetween($min = 60, $max = 465), 'precio' => $faker->numberBetween($min = 1800, $max = 58000)]);
     $producto = $proveedor->productos()->save($producto);
     $proveedor = Proveedor::find(3);
     $producto = new Producto(['nombre' => 'Alopurinol', 'descripcion' => $faker->text($maxNbChars = 35), 'existencias' => $faker->numberBetween($min = 60, $max = 465), 'precio' => $faker->numberBetween($min = 1800, $max = 58000)]);
     $producto = $proveedor->productos()->save($producto);
     $producto = new Producto(['nombre' => 'Cloroquina', 'descripcion' => $faker->text($maxNbChars = 35), 'existencias' => $faker->numberBetween($min = 60, $max = 465), 'precio' => $faker->numberBetween($min = 1800, $max = 58000)]);
     $producto = $proveedor->productos()->save($producto);
     $producto = new Producto(['nombre' => 'Condones', 'descripcion' => $faker->text($maxNbChars = 35), 'existencias' => $faker->numberBetween($min = 60, $max = 465), 'precio' => $faker->numberBetween($min = 1800, $max = 58000)]);
     $producto = $proveedor->productos()->save($producto);
     $producto = new Producto(['nombre' => 'Betametasona', 'descripcion' => $faker->text($maxNbChars = 35), 'existencias' => $faker->numberBetween($min = 60, $max = 465), 'precio' => $faker->numberBetween($min = 1800, $max = 58000)]);
     $producto = $proveedor->productos()->save($producto);
     $proveedor = Proveedor::find(4);
     $producto = new Producto(['nombre' => 'Acetilcisteína', 'descripcion' => $faker->text($maxNbChars = 35), 'existencias' => $faker->numberBetween($min = 60, $max = 465), 'precio' => $faker->numberBetween($min = 1800, $max = 58000)]);
     $producto = $proveedor->productos()->save($producto);
     $proveedor = Proveedor::find(5);
     $producto = new Producto(['nombre' => 'Aspirina', 'descripcion' => $faker->text($maxNbChars = 35), 'existencias' => $faker->numberBetween($min = 60, $max = 465), 'precio' => $faker->numberBetween($min = 1800, $max = 58000)]);
     $producto = $proveedor->productos()->save($producto);
     $producto = new Producto(['nombre' => 'Dimercaprol', 'descripcion' => $faker->text($maxNbChars = 35), 'existencias' => $faker->numberBetween($min = 60, $max = 465), 'precio' => $faker->numberBetween($min = 1800, $max = 58000)]);
     $producto = $proveedor->productos()->save($producto);
     $producto = new Producto(['nombre' => 'Nitrato de Sodio', 'descripcion' => $faker->text($maxNbChars = 35), 'existencias' => $faker->numberBetween($min = 60, $max = 465), 'precio' => $faker->numberBetween($min = 1800, $max = 58000)]);
     $producto = $proveedor->productos()->save($producto);
     $producto = new Producto(['nombre' => 'Naloxona', 'descripcion' => $faker->text($maxNbChars = 35), 'existencias' => $faker->numberBetween($min = 60, $max = 465), 'precio' => $faker->numberBetween($min = 1800, $max = 58000)]);
     $producto = $proveedor->productos()->save($producto);
     $producto = new Producto(['nombre' => 'Penicilamina', 'descripcion' => $faker->text($maxNbChars = 35), 'existencias' => $faker->numberBetween($min = 60, $max = 465), 'precio' => $faker->numberBetween($min = 1800, $max = 58000)]);
     $producto = $proveedor->productos()->save($producto);
     $producto = new Producto(['nombre' => 'Tiosulfato de Sodio', 'descripcion' => $faker->text($maxNbChars = 35), 'existencias' => $faker->numberBetween($min = 60, $max = 465), 'precio' => $faker->numberBetween($min = 1800, $max = 58000)]);
     $producto = $proveedor->productos()->save($producto);
     $producto = new Producto(['nombre' => 'Penicilina', 'descripcion' => $faker->text($maxNbChars = 35), 'existencias' => $faker->numberBetween($min = 60, $max = 465), 'precio' => $faker->numberBetween($min = 1800, $max = 58000)]);
     $producto = $proveedor->productos()->save($producto);
 }
 public function gestionar(Request $request)
 {
     if ($request->opcion == 'clientes') {
         $clientes = Cliente::all(['id', 'nombre', 'direccion', 'telefono']);
         return view('admi.reporteClientes')->with(['clientes' => $clientes]);
     }
     if ($request->opcion == 'proveedores') {
         $proveedores = Proveedor::all(['id', 'nombre', 'direccion', 'telefono']);
         return view('admi.reporteProveedores')->with(['proveedores' => $proveedores]);
     }
     if ($request->opcion == 'compras') {
         $compras = Compra::all(['id', 'cliente_id', 'created_at']);
         return view('admi.reporteCompras')->with(['compras' => $compras]);
     }
     if ($request->opcion == 'ventas') {
         $ventas = Venta::all(['id', 'user_id', 'created_at']);
         return view('admi.reporteVentas')->with(['ventas' => $ventas]);
     }
     if ($request->opcion == null) {
         return view('admi.reportes')->with(['mensaje' => 'Tiene que seleccionar una Opcion']);
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $proveedor = \App\Proveedor::find($id);
     $proveedor->delete();
     return redirect('proveedor')->with('message');
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     $proveedor = \App\Proveedor::all()->lists('nombre_proveedor', 'id_proveedor');
     array_unshift($proveedor, 'Seleccione un proveedor');
     return view('marcas.crear')->with('proveedor', $proveedor);
 }
 public function datatables()
 {
     $data = Proveedor::Datatables()->get();
     return Datatables::of(collect($data))->editColumn('nombre', function ($data) {
         return '<a href="proveedor/' . $data->id . '" >' . $data->nombre . '</a>';
     })->addColumn('action', function ($data) {
         return '<a href="proveedor/' . $data->id . '/edit" class="btn btn-xs btn-primary">Edit</a>' . ' / <form method="POST" action="http://localhost/inventario/proveedor/ ' . $data->id . '" accept-charset="UTF-8" style="display:inline"><input name="_method" type="hidden" value="DELETE"><input name="_token" type="hidden" value="' . csrf_token() . '"><button type="submit" class="btn btn-danger btn-xs">Borrar</button></form>';
     })->make(true);
 }
 public function getFiltrarcompra(Request $request)
 {
     if (!$request->ajax()) {
         abort(403);
     }
     $datos = array();
     $inputs = $request->all();
     if (empty($inputs['search'])) {
         $compras = \App\Compra::select(\DB::raw('SQL_CALC_FOUND_ROWS *'), 'id')->where('id', '>', 0)->take($inputs['limit'])->skip($inputs['offset'])->orderBy('created_at', 'ASC')->get();
     } else {
         $compras = \App\Compra::select(\DB::raw('SQL_CALC_FOUND_ROWS *'), 'id')->where('numfactura', 'LIKE', '%' . $inputs["search"] . '%')->take($inputs['limit'])->skip($inputs['offset'])->orderBy('created_at', 'ASC')->get();
     }
     $cantidad = \DB::select(\DB::raw("SELECT FOUND_ROWS() AS total;"));
     $cantidad = $cantidad[0]->total;
     $n = 1;
     foreach ($compras as $compra) {
         $url = '<a href="' . route('compra.edit', $compra->id) . '" class="btn btn-xs btn-success"><i class="fa fa-btn fa-edit"></i>Editar</a>';
         $datos[] = ['num' => $n++, 'numfactura' => $compra->numfactura, 'proveedor' => \App\Proveedor::where('id', $compra->id_proveedor)->first()->proveedor, 'total' => number_format($compra->total, 2, '.', ''), 'act' => $url];
     }
     return \Response::json(['total' => $cantidad, 'rows' => $datos]);
 }
Exemple #13
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Proveedor::destroy($id);
     Session::flash('message', 'Proveedor Eliminado Correctamente');
     return Redirect::to('/proveedores');
 }
 /**
  * Show the application dashboard.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     return view('home', ['asociados' => Asociado::all(), 'proveedores' => Proveedor::all(), 'titulo' => "Relación de asociados y proveedores", 'subtitulo' => "Tablas interactivas para realizar búsquedas rápidas.", 'inicio' => true]);
 }