public function destroy($id_articulo) { try { DB::beginTransaction(); $articulo = Articulo::find($id_articulo); $articulo_stock = Stock::find($id_articulo); if (is_null($articulo)) { App::abort(404); } $articulo_stock->delete(); $articulo->delete(); DB::commit(); $articulos = DB::table('articulos')->join('rubros', 'articulos.id_rubro', '=', 'rubros.id_rubro')->join('proveedores', 'articulos.id_proveedor', '=', 'proveedores.id_proveedor')->join('stock', 'articulos.id_articulo', '=', 'stock.id_articulo')->join('sucursales', 'stock.id_sucursal', '=', 'sucursales.id_sucursal')->select('articulos.id_articulo', 'rubros.rubro', 'articulos.nombre', 'articulos.descripcion', 'articulos.alto', 'articulos.largo', 'articulos.ancho_prof', 'articulos.precio_compra', 'rubros.id_rubro', 'proveedores.nom_raz', 'stock.cantidad', 'sucursales.nombre as sucursal')->orderby('articulos.nombre', 'asc')->paginate(100); return View::make('lista_articulos')->with('articulos', $articulos); } catch (Exception $ex) { DB::rollBack(); echo $ex->getMessage(); } }
public function getVentareposicion($id) { $stock_r = VistaStock::find($id); //actualiza el stock $update_stock = Stock::find($id); $update_stock->activo = 0; $update_stock->save(); //actualiza tipo de baja $update_material_baja = MaterialBaja::find($stock_r->material_baja_id); $update_material_baja->reposicion = 1; $update_material_baja->stock = 0; $update_material_baja->save(); //registra la venta en tabla reposicion $reposicion = new Reposicion(); $reposicion->motivos = 'Pieza de stock ' . $stock_r->folio; $reposicion->material_baja_id = $stock_r->material_baja_id; $reposicion->captura_usuario_id = Auth::user()->id; $reposicion->precio_reposicion = $stock_r->precio_venta; $reposicion->save(); return Redirect::back(); }
public function post_stocksave() { $sparepart = Sparepart::where('part_number', '=', Input::get('part_number'))->first(); $msg = 'Part Number tidak ada di database pusat'; if ($sparepart) { if (Input::get('id') == '') { $stock = new Stock(); $stock->pool_id = Auth::user()->pool_id; $stock->sparepart_id = $sparepart->id; $stock->min_qty = Input::get('min_qty'); $stock->sale_price = Input::get('sale_price'); $stock->discount = 0; $stock->sale_on = 0; $stock->qty = Input::get('qty'); $stock->user_id = Auth::user()->id; $stock->note = Input::get('note'); $stock->save(); $msg = 'Stock berhasil di tambahkan di gudang pool'; } else { $stock = Stock::find(Input::get('id')); $stock->pool_id = Auth::user()->pool_id; $stock->sparepart_id = $sparepart->id; $stock->min_qty = Input::get('min_qty'); $stock->sale_price = Input::get('sale_price'); $stock->discount = 0; $stock->sale_on = 0; //$stock->qty = $stock->qty + Input::get('new_qty'); $stock->user_id = Auth::user()->id; $stock->note = Input::get('note'); $stock->save(); $msg = 'Stock berhasil di update'; Trackinginventory::create(array('pool_id' => Auth::user()->pool_id, 'sparepart_id' => $sparepart->id, 'qty' => Input::get('new_qty'), 'user_id' => Auth::user()->id, 'note' => 'Part Ajustment oleh ' . Auth::user()->fullname)); } } return Redirect::to('warehouses/stock')->with('status', $msg); }
/** * Show the form for editing the specified stock. * * @param int $id * @return Response */ public function edit($id) { $stock = Stock::find($id); return View::make('stocks.edit', compact('stock')); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $this->stock->find($id)->delete(); return Redirect::route('stocks.index'); }
} $stock->save(); $subscribers = Subscription::subscribers($stock); foreach ($subscribers as $sub) { $msg = "Stock Update\n{$stock->company}: {$stock->price}"; $sub->send($msg); } echo json_encode($stock); break; case 'stocks': $stocks = Stock::findAll(); echo json_encode($stocks); break; case 'delete': $company = Request::any('company'); $stock = Stock::find($company); $stock->delete(); echo json_encode($stock); break; case 'subscribers': $subscribers = Subscriber::findAll(); echo json_encode($subscribers); break; case 'send': $msg = Request::any('message'); $recs = Subscriber::findAll(); foreach ($recs as $r) { SMS::send($r->phone, $msg); } echo json_encode(["success" => true]); break;