/** * Changes the brand for the Inventory Item * * @param Request $supplier (Ajax) * @param Inventory $item * * @return boolean */ public function changeBrand(Request $supplier, Inventory $item) { if ($item->changeBrandTo($supplier->input('id'))) { return $this->getPossibleSuppliers($supplier); } return false; }
/** * Execute the job. * * @return bool */ public function handle() { $this->inventory->category_id = $this->request->input('category', $this->inventory->category_id); $this->inventory->metric_id = $this->request->input('metric', $this->inventory->metric_id); $this->inventory->name = $this->request->input('name', $this->inventory->name); $this->inventory->description = $this->request->clean($this->request->input('description', $this->inventory->description)); return $this->inventory->save(); }
/** * Execute the job. * * @return bool */ public function handle() { $this->inventory->user_id = auth()->id(); $this->inventory->category_id = $this->request->input('category'); $this->inventory->metric_id = $this->request->input('metric'); $this->inventory->name = $this->request->input('name'); $this->inventory->description = $this->request->clean($this->request->input('description')); return $this->inventory->save(); }
/** * Creates a variant of the specified inventory item. * * @param InventoryRequest $request * @param int|string $itemId * * @return bool */ public function store(InventoryRequest $request, $itemId) { $item = $this->inventory->findOrFail($itemId); $variant = $item->newVariant(); $variant->name = $request->input('name', $item->name); $variant->category_id = $request->input('category', $item->category_id); $variant->metric_id = $request->input('metric', $item->metric_id); return $variant->save(); }
/** * Captures the Inventory models restored event * and cascades the restore to all of it's stocks. * * @param Inventory $model */ public function restored(Inventory $model) { $stocks = $model->stocks()->onlyTrashed()->get(); if (count($stocks) > 0) { foreach ($stocks as $stock) { $stock->restore(); } } }
/** * Execute the job. * * @return bool */ public function handle() { $this->stock->user_id = auth()->id(); $this->stock->inventory_id = $this->inventory->getKey(); $this->stock->location_id = $this->request->input('location'); $this->stock->quantity = $this->request->input('quantity'); $this->stock->cost = $this->request->input('cost'); $this->stock->reason = $this->request->input('reason'); return $this->stock->save(); }
public function test() { //$item = Inventory::find(1); $result = Inventory::find(1); echo json_encode($result->getTotalStockQuantity()); dd($result); //return view('test', compact('result')); }
public function actionReport($id) { // get your HTML raw content without any layouts or scripts $model = Inventory::find()->where(['id' => $id])->one(); $content = $this->renderPartial('_reportView', ['model' => $model]); // setup kartik\mpdf\Pdf component $pdf = new Pdf(['mode' => Pdf::MODE_CORE, 'format' => Pdf::FORMAT_A4, 'orientation' => Pdf::ORIENT_PORTRAIT, 'destination' => Pdf::DEST_BROWSER, 'content' => $content, 'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css', 'cssInline' => '.kv-heading-1{font-size:18px}', 'options' => ['title' => 'Krajee Report Title'], 'methods' => []]); // return the pdf output as per the destination setting return $pdf->render(); }
/** * Processes returning stock from the work order back into the specified inventory. * * @param PartReturnRequest $request * @param int|string $workOrderId * @param int|string $itemId * @param int|string $stockId * * @throws \Stevebauman\Inventory\Exceptions\InvalidQuantityException * * @return bool */ public function postPut(PartReturnRequest $request, $workOrderId, $itemId, $stockId) { $workOrder = $this->workOrder->findOrFail($workOrderId); // Even though the inventory item isn't necessary here, we'll // find it anyway so we can check for the requests validity // and ensure the specified stock is actually attached to // the one requested. $item = $this->inventory->findOrFail($itemId); $item->stocks()->findOrFail($stockId); $stock = $workOrder->parts()->findOrFail($stockId); return $this->dispatch(new Put($request, $workOrder, $stock)); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Inventory::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['budget_id' => $this->budget_id, 'productuser_id' => $this->productuser_id, 'partner_id' => $this->partner_id, 'department_id' => $this->department_id, 'bill_no' => $this->bill_no, 'd_date' => $this->d_date, 'date_accept' => $this->date_accept]); $query->andFilterWhere(['like', 'id', $this->id])->andFilterWhere(['like', 'inventory', $this->inventory])->andFilterWhere(['like', 'file', $this->file]); return $dataProvider; }
/** * Create Request of inventory item * * @param Request $request * * @return array */ public function request(Request $request) { $item = Inventory::where('serialnr', $request->serialnr)->first(); // If no item was found in database, create it. if (count($item) < 1) { $item = Inventory::createNewItem($request); } $stock = InventoryStock::where('inventory_id', $item->id)->where('location_id', 1)->first(); // If no stock was found in database, create one. if (count($stock) < 1) { $stock = InventoryStock::createEmptyStock($item); } // create a request transaction $transaction = $stock->newTransaction(); $transaction->requested($request->quantity); return redirect()->back()->with('message', $request->quantity . ' stk has been requested!'); }
public function SubAudit($audit) { $audit_obj = array(); foreach ($audit as $index) { $entity_obj = null; switch ($index->entity_type) { case 'user': if (in_array('VIEW_USER', $this->permission)) { $entity_obj = User::find($index->entity_id); } break; case 'company': if (User::isSuperAdmin()) { $entity_obj = \App\Models\Company::find($index->entity_id); } break; case 'inventory': if (User::isSuperAdmin()) { $entity_obj = Inventory::find($index->entity_id); } break; case 'client': if (in_array('VIEW_CLIENT', $this->permission)) { $entity_obj = Client::find($index->entity_id); } break; case 'advertiser': if (in_array('VIEW_ADVERTISER', $this->permission)) { $entity_obj = Advertiser::with('GetClientID')->find($index->entity_id); } break; case 'creative': if (in_array('VIEW_CREATIVE', $this->permission)) { $entity_obj = Creative::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'campaign': if (in_array('VIEW_CAMPAIGN', $this->permission)) { $entity_obj = Campaign::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'offer': if (in_array('VIEW_OFFER', $this->permission)) { $entity_obj = Offer::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'pixel': if (in_array('VIEW_PIXEL', $this->permission)) { $entity_obj = Pixel::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'targetgroup': if (in_array('VIEW_TARGETGROUP', $this->permission)) { $entity_obj = Targetgroup::find($index->entity_id); } break; case 'targetgroup_geolocation_map': if (in_array('VIEW_TARGETGROUP', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = Geolocation::find($index->after_value); } else { $entity_obj = Geolocation::find($index->entity_id); } } break; case 'targetgroup_creative_map': if (in_array('VIEW_TARGETGROUP', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = Creative::find($index->after_value); } else { $entity_obj = Creative::find($index->entity_id); } } break; case 'targetgroup_segment_map': if (in_array('VIEW_TARGETGROUP', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = Segment::find($index->after_value); } else { $entity_obj = Segment::find($index->entity_id); } } break; case 'targetgroup_geosegment_map': if (in_array('VIEW_TARGETGROUP', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = GeoSegmentList::find($index->after_value); } else { $entity_obj = GeoSegmentList::find($index->entity_id); } } break; case 'targetgroup_bwlist_map': if (in_array('VIEW_TARGETGROUP', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = BWList::find($index->after_value); } else { $entity_obj = BWList::find($index->entity_id); } } break; case 'targetgroup_bidprofile_map': if (in_array('VIEW_TARGETGROUP', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = Bid_Profile::find($index->after_value); } else { $entity_obj = Bid_Profile::find($index->entity_id); } } break; case 'geosegment': if (in_array('VIEW_GEOSEGMENTLIST', $this->permission)) { $entity_obj = GeoSegmentList::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'geosegmententrie': if (in_array('VIEW_GEOSEGMENTLIST', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = GeoSegment::find($index->after_value); } else { $entity_obj = GeoSegment::find($index->entity_id); } } break; case 'bwlist': if (in_array('VIEW_BWLIST', $this->permission)) { $entity_obj = BWList::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'bwlistentrie': if (in_array('VIEW_BWLIST', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = BWEntries::find($index->after_value); } else { $entity_obj = BWEntries::find($index->entity_id); } } break; case 'bid_profile': if (in_array('VIEW_BIDPROFILE', $this->permission)) { $entity_obj = Bid_Profile::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'bid_profile_entry': if (in_array('VIEW_BIDPROFILE', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = Bid_Profile::where('id', $index->after_value)->first(); } else { $entity_obj = Bid_Profile_Entry::with('getParent')->find($index->entity_id); } } break; case 'modelTable': if (in_array('VIEW_MODEL', $this->permission)) { if ($index->audit_type == 'del') { $entity_obj = BWList::where('id', $index->after_value)->first(); } else { $entity_obj = ModelTable::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } } break; case 'offer_pixel_map': if (in_array('VIEW_OFFER', $this->permission)) { $entity_obj = Pixel::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'advertiser_model_map': if (in_array('VIEW_ADVERTISER', $this->permission)) { $entity_obj = ModelTable::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'positive_offer_model': if (in_array('VIEW_MODEL', $this->permission)) { $entity_obj = Offer::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; case 'negative_offer_model': if (in_array('VIEW_MODEL', $this->permission)) { $entity_obj = Offer::with(['getAdvertiser' => function ($q) { $q->with('GetClientID'); }])->find($index->entity_id); } break; } if (!is_null($entity_obj)) { array_push($audit_obj, $index); array_push($audit_obj, $entity_obj); } } return $audit_obj; }
/** * Returns a new navbar for the inventory stock index. * * @param Inventory $item * * @return \Illuminate\Support\Fluent */ public function navbar(Inventory $item) { return $this->fluent(['id' => 'inventory-stocks', 'title' => 'Item Stocks', 'url' => route('maintenance.inventory.stocks.index', [$item->getKey()]), 'menu' => view('inventory.stocks._nav', compact('item')), 'attributes' => ['class' => 'navbar-default']]); }
<?php use App\Models\Inventory; /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ Route::get('/', ['as' => 'home', function () { $items = Inventory::all()->take(4); return view('welcome', ['items' => $items]); }]); Route::group(['prefix' => 'cart'], function () { Route::get('/', ['uses' => 'CartController@index', 'as' => 'cart.index']); Route::get('add/{product_id}', ['uses' => 'CartController@add', 'as' => 'cart.add']); Route::get('update/{product_id}/{quantity}', ['uses' => 'CartController@update', 'as' => 'cart.update']); Route::get('remove/{product_id}', ['uses' => 'CartController@remove', 'as' => 'cart.remove']); Route::get('clear', ['uses' => 'CartController@clear', 'as' => 'cart.clear']); }); Route::group(['prefix' => 'checkout'], function () { Route::match(['get', 'post'], '/', ['uses' => 'CheckoutController@index', 'as' => 'checkout.index']); // Route::match(['get', 'post'],'shipping', ['uses' => 'CheckoutController@shipping', 'as' => 'checkout.shipping']); // Route::match(['get', 'post'],'payment', ['uses' => 'CheckoutController@payment', 'as' => 'checkout.payment']); Route::match(['get', 'post'], 'order', ['uses' => 'CheckoutController@order', 'as' => 'checkout.order']); }); // Coupon group routes
public function actionProcess() { $model = new Inventory(); if ($model->load(Yii::$app->request->post())) { $model->bill_no = $model->bill_no; $model->inventory = 'i'; $model->save(); $cart = new Cart(); foreach ($cart->contents() as $items) { $detail = new \app\models\Inventorydetail(); $detail->load(Yii::$app->request->post()); $detail->inventory_id = $model->id; $detail->product_id = $items['id']; $detail->qty = $items['qty']; $detail->price = $items['price']; $product = Products::findOne($items['id']); echo $product->qty = $items['qty']; $product->save(); $detail->save(); } $cart->destroy(); return $this->redirect(['inventory/index']); } }
/** * Regenerates the SKU of the specified inventory item. * * @param int|string $id * * @return bool */ public function regenerate($id) { $item = $this->inventory->findOrFail($id); return $item->regenerateSku(); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $staff = Inventory::find($id); $staff->delete(); return redirect()->route('inventory.index')->withMessage('Inventory Item Deleted')->withStatus('success'); }
/** * Deletes the specified inventory stock. * * @param int|string $itemId * @param int|string $stockId * * @return bool */ public function destroy($itemId, $stockId) { $item = $this->inventory->findOrFail($itemId); $stock = $item->stocks()->findOrFail($stockId); return $stock->delete(); }
/** * Returns a new form for creating a new inventory item. * * @param Inventory $inventory * @param bool|false $variant * * @return \Orchestra\Contracts\Html\Builder */ public function form(Inventory $inventory, $variant = false) { return $this->form->of('inventory', function (FormGrid $form) use($inventory, $variant) { if ($inventory->exists) { if ($variant === true) { // If the inventory item exists and we're looking to create a form // for a variant, we'll set the forms options accordingly. $method = 'POST'; $url = route('maintenance.inventory.variants.store', [$inventory->getKey()]); $form->submit = 'Create'; } else { // Otherwise we'll set the options to update the specified inventory item. $method = 'PATCH'; $url = route('maintenance.inventory.update', [$inventory->getKey()]); $form->submit = 'Save'; } } else { $method = 'POST'; $url = route('maintenance.inventory.store'); $form->submit = 'Create'; } $form->with($inventory); $form->attributes(compact('method', 'url')); $categories = Category::getSelectHierarchy('inventories'); $metrics = Metric::all()->pluck('name', 'id'); $metrics->put(0, 'None'); $form->fieldset(function (Fieldset $fieldset) use($categories, $metrics) { $fieldset->control('select', 'category')->value(function (Inventory $item) { return $item->category_id; })->options($categories); $fieldset->control('select', 'metric')->value(function (Inventory $item) { return $item->metric_id; })->options($metrics); $fieldset->control('input:text', 'name')->attributes(['placeholder' => 'ex. Nails']); $fieldset->control('input:textarea', 'description'); }); }); }
/** * Deletes the specified inventory item. * * @param int|string $id * * @return bool */ public function destroy($id) { $item = $this->inventory->findOrFail($id); return $item->delete(); }
} ?> <?php $form = ActiveForm::begin(['action' => 'index.php?r=inventory/process']); ?> <div class="panel panel-info"> <div class="panel panel-heading"> นำเข้าพัสดุ กรอกรายละเอียดในการส่งสินค้า </div> <div class="panel panel-body"> <div class="row"> <div class="col-md-3"> <?php $count = \app\models\Inventory::find()->where(['inventory' => 'i'])->count() + 1; ?> <?php echo $form->field($model, 'id')->textInput(['value' => date('Ymd-') . $count]); ?> </div> <div class="col-md-2"> <?php echo $form->field($model, 'd_date')->widget(DatePicker::className(), ['clientOptions' => ['changeMonth' => true, 'changeYear' => true], 'dateFormat' => 'yyyy-MM-dd', 'options' => ['class' => 'form-control']]); ?> </div> <div class="col-md-3"> <?php echo $form->field($model, 'bill_no')->textInput(); ?>
/** * Update inventory item * GET /inventory/(item)/save * * @param Request $request * @param Inventory $item * * @return */ public function save(Request $request, Inventory $item) { $offset = count($request->category) - 1; /* * Set Category to NULL if requested category is 0 */ $category = $request->category[$offset]; if ($category == 0 && $offset < 1) { $category = NULL; } elseif ($category == 0) { $category = $request->category[$offset - 1]; } $item->serialnr = $request->serialnr; $item->name = $request->name; $item->brand_id = $request->brand_id; $item->category_id = $category; $item->save(); $item->saveDetails($request); $supplier = Supplier::find($request->supplier_id); return Picture::saveImages($item, $supplier, $request); //$item->updateBarcode($request->barcode); //return $item; }
/** * Display a listing of the resource. * * @return Response */ public function index() { $items = Inventory::all(); return view('backoffice.inventory.index', ['items' => $items]); }
public function ChangeStatus($id) { if (Auth::check()) { if (User::isSuperAdmin()) { $entity = Inventory::find($id); } if ($entity) { $data = array(); $audit = new AuditsController(); if ($entity->status == 'Active') { array_push($data, 'status'); array_push($data, $entity->status); array_push($data, 'Inactive'); $entity->status = 'Inactive'; $msg = 'disable'; } elseif ($entity->status == 'Inactive') { array_push($data, 'status'); array_push($data, $entity->status); array_push($data, 'Active'); $entity->status = 'Active'; $msg = 'actived'; } $audit->store('inventory', $id, $data, 'edit'); $entity->save(); return $msg; } return 'please Select your Client'; } return Redirect::to(url('user/login')); }
/** * Finds the Inventory model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Inventory the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Inventory::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
private function previous() { return Inventory::where('id', '<', $this->id)->orderBy('id', 'desc')->first(); }
/** * Returns a new form for putting the stock from the * specified work order back into inventory. * * @param WorkOrder $workOrder * @param Inventory $inventory * @param InventoryStock $stock * * @return \Orchestra\Contracts\Html\Builder */ public function formPut(WorkOrder $workOrder, Inventory $inventory, InventoryStock $stock) { return $this->form->of('work-orders.parts.stocks.put', function (FormGrid $form) use($workOrder, $inventory, $stock) { $form->attributes(['method' => 'POST', 'url' => route('maintenance.work-orders.parts.stocks.put', [$workOrder->getKey(), $inventory->getKey(), $stock->getKey()])]); $form->submit = 'Save'; $form->fieldset(function (Fieldset $fieldset) use($inventory, $stock) { $metric = $inventory->getMetricSymbol(); $fieldset->control('input:text', 'quantity', function (Field $field) { $field->label = 'Return Quantity'; })->value($stock->pivot->quantity)->attribute(['placeholder' => "Enter Quantity in {$metric}"]); }); }); }