本文整理汇总了PHP中Stock::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Stock::save方法的具体用法?PHP Stock::save怎么用?PHP Stock::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stock
的用法示例。
在下文中一共展示了Stock::save方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removeStock
public static function removeStock($item, $location, $quantity, $date)
{
$stock = new Stock();
$stock->date = $date;
$stock->item()->associate($item);
$stock->location()->associate($location);
$stock->quantity_out = $quantity;
$stock->save();
}
示例2: actionCreate
/**
* Creates a new Stock model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Stock();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例3: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Stock();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Stock'])) {
$model->attributes = $_POST['Stock'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例4: fetch
public static function fetch($warehouse_id, $product_id)
{
$stock = Doctrine_Query::create()->from('Stock s')->where('s.warehouse_id =' . $warehouse_id)->andWhere('s.product_id =' . $product_id)->fetchOne();
if (!$stock) {
$stock = new Stock();
$stock->setWarehouseId($warehouse_id);
$stock->setProductId($product_id);
$stock->setCurrentqty(0);
$stock->setDate("2011-01-01");
$stock->save();
}
return $stock;
}
示例5: saveInStockTable
private function saveInStockTable($idBranch, $idArticle, $amount)
{
try {
$articleStock = Stock::where('article_id', $idArticle)->where('branch_id', $idBranch)->first();
if (!empty($articleStock)) {
$articleStock->stock += $amount;
$articleStock->save();
} else {
$stockTable = new Stock();
$stockTable->branch_id = $idBranch;
$stockTable->article_id = $idArticle;
$stockTable->stock = $amount;
$stockTable->minstock = 0;
$stockTable->save();
}
#if !empty($ArticleStock)
} catch (Exception $e) {
die('No se pudo modificar el stock del artículo' . $idArticle . ' en la sucursal ' . $idBranch);
}
}
示例6: post_nuevo
public function post_nuevo()
{
$inputs = Input::all();
$reglas = array('nombre' => 'required|max:50', 'descripcion' => 'required|max:50', 'alto' => 'required', 'largo' => 'required', 'ancho_prof' => 'required', 'rubro' => 'required|integer', 'sucursal' => 'required', 'stock' => 'required|integer', 'prec_compra' => 'required', 'proveedor' => 'required');
$mensajes = array('required' => 'Campo Obligatorio');
$validar = Validator::make($inputs, $reglas);
if ($validar->fails()) {
Input::flash();
return Redirect::back()->withInput()->withErrors($validar);
} else {
try {
DB::beginTransaction();
$articulo = new Articulo();
$articulo->nombre = Input::get('nombre');
$articulo->descripcion = Input::get('descripcion');
$articulo->alto = Input::get('alto');
$articulo->largo = Input::get('largo');
$articulo->ancho_prof = Input::get('ancho_prof');
$articulo->id_rubro = Input::get('rubro');
$articulo->precio_compra = Input::get('prec_compra');
$articulo->id_proveedor = Input::get('proveedor');
$articulo->save();
$insertedId = $articulo->id_articulo;
$stock = new Stock();
$stock->id_articulo = $insertedId;
$stock->id_sucursal = Input::get('sucursal');
$stock->cantidad = Input::get('stock');
$stock->save();
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)->with('error', 'El Artículo ha sido cargado con Éxito');
} catch (Exception $ex) {
DB::rollBack();
echo $ex->getMessage();
}
}
}
示例7: index
public static function index()
{
return function ($request, $response) {
if ($request->session('admin')) {
switch ($request->method()) {
case 'GET':
# code...
$stocks = Stock::all();
$response->json($stocks->as_array());
break;
case 'POST':
# code...
$data = $request->data();
$stock = new Stock();
$stock->product = $data->product->id;
$stock->quantity = $data->quantity;
$stock->save();
$response->json($stock->as_array());
break;
case 'DELETE':
# code...
echo "DELETE";
break;
case 'PUT':
# code...
echo "PUT";
break;
default:
# code...
break;
}
} else {
$response->code(403);
}
};
}
示例8: emprunter
public function emprunter($form)
{
$materiel_id = $form->getValue('materiel_id');
$nombre = $form->getValue('nombre');
$dispo = StockTable::getInstance()->findOneByMaterielIdAndEtatId($materiel_id, 1);
if ($dispo && $dispo->getNombre() >= $nombre) {
$form->save();
$dispo->addNombre(-$nombre);
$dispo->save();
$emprunte = StockTable::getInstance()->findOneByMaterielIdAndEtatId($materiel_id, 2);
if (!$emprunte) {
$emprunte = new Stock();
$emprunte->setNombre($nombre);
$emprunte->setMaterielId($materiel_id);
$emprunte->setEtatId(2);
} else {
$emprunte->addNombre($nombre);
}
$emprunte->save();
return true;
} else {
return false;
}
}
示例9: postBaja
//.........这里部分代码省略.........
case '1':
//valida que no se quiera añadir a una factura capturada ayer o el folio sea igual al de una venta de stock
$folio_venta = Input::get('folio_venta');
$venta_r = VentaMaterial::where('folio', '=', $folio_venta)->first();
if ($venta_r) {
if (date_format($venta_r->created_at, 'Y-m-d') < date('Y-m-d') or substr($folio_venta, 0, 2) == "S-") {
$factura_error = Session::pull('venta_error', 'error');
return Redirect::back()->with('venta_error', 'error');
}
/*return $factura_r->factura_abierta;*/
}
//validar formulario
//validar formulario
$rules = array('folio_venta' => 'required', 'fecha' => 'required', 'precio_venta' => 'required|numeric', 'material_disponible' => 'required');
$messages = array('required' => 'Capture :attribute', 'numeric' => 'solo números', 'integer' => 'solo se aceptan valores enteros');
$validator = Validator::make(Input::all(), $rules, $messages);
if ($validator->fails()) {
return Redirect::back()->withInput()->withErrors($validator)->with('radio_selected', '1')->with('add', 'true');
}
//fin validar formulario
//genera baja
$lamina_baja = new MaterialBaja();
$lamina_baja->fecha = Input::get('fecha');
$lamina_baja->pieza_marmoleria_id = $pieza_marmoleria_id;
$lamina_baja->area_venta = $area_venta;
$lamina_baja->inventario_recubrimientos_id = Input::get('material_disponible');
$lamina_baja->costo_material_usado = $costo_material;
if (Input::get('tipo_corte') == 2) {
$lamina_baja->observaciones = Input::get('largo') . ' de largo por ' . Input::get('alto') . ' m. de alto';
$lamina_baja->pieza_completa = 0;
$medida_estandar = 0;
}
$lamina_baja->medida_estandar = $medida_estandar;
$lamina_baja->save();
//determina si la venta existe,
$count_venta_material = VentaMaterial::where('folio', '=', Input::get('folio_venta'))->count();
// si existe la venta actualiza el total sumando el precio de la nueva lamina_baja
if ($count_venta_material > 0) {
$venta_material = VentaMaterial::where('folio', '=', Input::get('folio_venta'))->firstorfail();
$venta_material->total_venta = $venta_material->total_venta + Input::get('precio_venta');
$venta_material->save();
} else {
$venta_material = new VentaMaterial();
$venta_material->folio = Input::get('folio_venta');
$venta_material->total_venta = Input::get('precio_venta');
$venta_material->save();
}
//crea el registro del detalle de la baja
$venta_material_baja = new VentaMaterialBaja();
$venta_material_baja->venta_material_id = $venta_material->id;
$venta_material_baja->material_baja_id = $lamina_baja->id;
$venta_material_baja->precio_pieza = Input::get('precio_venta');
$venta_material_baja->save();
//actualiza inventario en la linea #84 ya lo tengo
$inventario->area_stock = $inventario->area_stock - $area_venta;
$inventario->updated_at = Input::get('hoy');
$inventario->precio_stock = $inventario->precio_stock - $costo_material;
$inventario->area_usada = $inventario->area_usada + $area_venta;
//desactiva el inventario de la lamina al llegar al menos de .06, no es suficiente material para crear un liston
if ($inventario->area_stock < 0.06) {
$inventario->activo = 0;
# code...
}
$inventario->save();
break;
case '2':
示例10: buy
public function buy()
{
$this->load->model(array('portfolio', 'stock'));
$stock_symbol = $this->input->post('stock_symbol');
$stock_info = $this->stock->single_quote($stock_symbol);
$shares = $this->input->post('shares');
$stock = new Stock();
$stock->portfolio_id = $this->input->post('portfolio_id');
$stock->user_id = Portfolio::find_by_id($this->input->post('portfolio_id'))->user_id;
$stock->symbol = $this->input->post('stock_symbol');
//need to add market open date verification
$stock->purchase_time = date("Y-m-d H:i:s");
$stock->purchase_price = $stock_info['price'];
$stock->shares = $this->input->post('shares');
$stock->save();
$portfolio = Portfolio::find_by_id($this->input->post('portfolio_id'));
//$portfolio->current_cap = $portfolio->current_cap - ($stock->purchase_price * $stock->shares);
if ($portfolio->commision_bool == 1) {
$portfolio->current_cap = $portfolio->current_cap - $stock->purchase_price * $stock->shares;
$portfolio->current_cap = $portfolio->current_cap - $portfolio->commision;
} else {
$portfolio->current_cap = $portfolio->current_cap - $stock->purchase_price * $stock->shares;
}
$portfolio->last_trade = $stock->id;
$portfolio->save();
redirect('portfolios/view/' . $stock->portfolio_id);
}
示例11: post_stocksave
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);
}
示例12: error
header('Content-Type:application/json');
function error($msg)
{
http_response_code(500);
die(json_encode(['error' => $msg]));
}
try {
switch ($request) {
case 'stock':
$stock = new Stock();
$stock->company = Request::any('company');
$stock->price = Request::any('price');
if (!$stock->company || !$stock->price) {
error('Invalid Input');
}
$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();
示例13: array
function index_put()
{
$models = json_decode($this->put('models'));
$data["results"] = array();
$data["count"] = 0;
foreach ($models as $value) {
$obj = new Stock(null, $this->entity);
$obj->get_by_id($value->id);
$obj->currency_id = $value->currency_id;
$obj->bill_id = $value->bill_id;
$obj->contact_id = $value->contact_id;
$obj->product_id = $value->product_id;
$obj->unit_id = $value->unit_id;
$obj->quantity = $value->quantity;
$obj->price = $value->price;
$obj->issued_date = $value->issued_date;
$obj->deleted = $value->deleted;
if ($obj->save()) {
//Results
$data["results"][] = array("id" => $obj->id, "currency_id" => $obj->currency_id, "bill_id" => $obj->bill_id, "contact_id" => $obj->contact_id, "product_id" => $obj->product_id, "unit_id" => $obj->unit_id, "quantity" => $obj->quantity, "price" => $obj->price, "issued_date" => $obj->issued_date, "deleted" => $obj->deleted, "currency" => $obj->currency->get_raw()->result(), "contact" => $obj->contact->get_raw()->result(), "product" => $obj->product->get_raw()->result(), "unit" => $obj->unit->get()->name);
}
}
$data["count"] = count($data["results"]);
$this->response($data, 200);
}