예제 #1
0
 /**
  * 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();
 }
예제 #2
0
 /**
  * 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 new Inventory model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Inventory();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
예제 #4
0
 public function jqgrid(Request $request)
 {
     //        return dd($request->all());
     if (Auth::check()) {
         if (User::isSuperAdmin()) {
             $validate = \Validator::make($request->all(), ['name' => 'required']);
             if ($validate->passes()) {
                 switch ($request->input('oper')) {
                     case 'add':
                         $audit = new AuditsController();
                         $active = 'Inactive';
                         if ($request->input('active') == 'true') {
                             $active = 'Active';
                         }
                         $inventory = new Inventory();
                         $inventory->name = $request->input('name');
                         $inventory->category = $request->input('category');
                         $inventory->type = $request->input('type');
                         $inventory->status = $active;
                         $inventory->daily_limit = $request->input('daily_limit');
                         $inventory->save();
                         $audit->store('inventory', $inventory->id, null, 'add');
                         return $msg = ['success' => true, 'msg' => "your Inventory:{$inventory->id} Added successfully"];
                         break;
                     case 'edit':
                         $inventory_id = $request->input('id');
                         $inventory = Inventory::find($inventory_id);
                         if ($inventory) {
                             $data = array();
                             $audit = new AuditsController();
                             if ($inventory->name != $request->input('name')) {
                                 array_push($data, 'Name');
                                 array_push($data, $inventory->name);
                                 array_push($data, $request->input('name'));
                                 $inventory->name = $request->input('name');
                             }
                             if ($inventory->category != $request->input('category')) {
                                 array_push($data, 'Category');
                                 array_push($data, $inventory->category);
                                 array_push($data, $request->input('category'));
                                 $inventory->category = $request->input('category');
                             }
                             if ($inventory->type != $request->input('type')) {
                                 array_push($data, 'Type');
                                 array_push($data, $inventory->type);
                                 array_push($data, $request->input('type'));
                                 $inventory->type = $request->input('type');
                             }
                             if ($inventory->daily_limit != $request->input('daily_limit')) {
                                 array_push($data, 'Daily Limit');
                                 array_push($data, $inventory->daily_limit);
                                 array_push($data, $request->input('daily_limit'));
                                 $inventory->daily_limit = $request->input('daily_limit');
                             }
                             $audit->store('inventory', $inventory_id, $data, 'edit');
                             $inventory->save();
                             return $msg = ['success' => true, 'msg' => "your Inventory:{$inventory->id} Saved successfully"];
                         }
                         return $msg = ['success' => false, 'msg' => "please Select your Inventory"];
                         break;
                 }
                 return $msg = ['success' => false, 'msg' => "Are U kidding me?"];
             }
             return $msg = ['success' => false, 'msg' => "Please fill all fields"];
         }
         return $msg = ['success' => false, 'msg' => "don't have permission"];
     }
     return Redirect::to(url('user/login'));
 }
예제 #5
0
 /**
  * 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;
 }
예제 #6
0
 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']);
     }
 }
예제 #7
0
 /**
  * Create new Item
  *
  * @param Request       $request
  *
  * @return Inventory    $item
  */
 public static function createNewItem($request)
 {
     $item = new Inventory();
     $item->metric_id = 1;
     $item->name = $request->name;
     $item->serialnr = $request->serialnr;
     $item->save();
     return $item;
 }