Пример #1
0
 /**
  *
  * Proses Simpan Products
  *
  * @return mixed
  */
 public function store()
 {
     if (!$this->hasAccess()) {
         return Response::json(array('success' => false, 'reason' => 'Action Need Login First', 'results' => null))->setCallback();
     }
     if (Input::has('upload')) {
         return $this->processUploadProduct();
     }
     if (Input::has('sethpp')) {
         return $this->updateHpp();
     }
     /*==========  Sesuaikan dengan Field di table  ==========*/
     $product = $this->product;
     $userId = \Auth::user()->id;
     $name = Input::get('name');
     $product->name = $name;
     $catId = Input::get('cat_id', 1);
     $product->cat_id = $catId;
     $product->contruction = Input::get('contruction');
     $product->nodesign = Input::get('nodesign');
     $product->type_id = Input::get('type_id');
     $product->weight = Input::get('weight');
     $product->parent_id = $catId;
     $product->parent_type = '\\Emayk\\Ics\\Repo\\Productcategory\\Productcategory';
     $product->unitweight_id = Input::get('unitweight_id');
     $product->width = Input::get('width');
     $product->unitwidth_id = Input::get('unitwidth_id');
     $product->codeinternal = uniqid('Prd_');
     $product->uuid = uniqid('Prd_');
     $product->createby_id = $userId;
     $product->lastupdateby_id = $userId;
     $product->created_at = new \Datetime();
     $product->updated_at = new \Datetime();
     $saved = $this->product->save() ? true : false;
     /**
      * Buat Stock
      */
     $product->oStock()->add($product, 0, 0, $userId);
     /**
      * Buat Hpp
      */
     $product->getHpp()->add($product, 0, 0);
     if ($saved) {
         Sysprodhistory::createlog(["Product {$name} berhasil dibuat "], $userId, $this->product->id);
     }
     return Response::json(array('success' => $saved, 'results' => $saved ? $this->product->toArray() : null, 'reason' => $saved ? 'Created Successfully' : 'Fail Create'))->setCallback();
 }
Пример #2
0
 /**
  *
  * Proses Simpan Productdetails
  *
  * @return mixed
  */
 public function store()
 {
     if (!$this->hasAccess()) {
         return Response::json(array('success' => false, 'reason' => 'Action Need Login First', 'results' => null))->setCallback();
     }
     /*==========  Sesuaikan dengan Field di table  ==========*/
     $userId = \Auth::user()->id;
     $prodId = Input::get('product_id');
     $this->productdetails->product_id = $prodId;
     $this->productdetails->color_id = Input::get('color_id');
     $this->productdetails->unit_id = Input::get('unit_id');
     $this->productdetails->grade_id = Input::get('grade_id');
     $this->productdetails->salesprice = Input::get('salesprice');
     $this->productdetails->salespricemin = Input::get('salespricemin');
     $this->productdetails->currsp_id = Input::get('currsp_id');
     $this->productdetails->currspm_id = Input::get('currspm_id');
     $this->productdetails->uuid = uniqid('New_');
     $this->productdetails->createby_id = $userId;
     $this->productdetails->lastupdateby_id = $userId;
     $this->productdetails->created_at = new Carbon();
     $this->productdetails->updated_at = new Carbon();
     $saved = $this->productdetails->save() ? true : false;
     if ($saved) {
         Sysprodhistory::createlog(["Product Detail berhasil dibuat "], $userId, $prodId);
     }
     return Response::json(array('success' => $saved, 'results' => $this->productdetails->toArray()))->setCallback();
 }