Пример #1
0
 public function searchBom($parent)
 {
     $query = MrpBom::find();
     $params['MrpBomSearch']['bom_id'] = $parent;
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'create_uid' => $this->create_uid, 'create_date' => $this->create_date, 'write_date' => $this->write_date, 'write_uid' => $this->write_uid, 'date_stop' => $this->date_stop, 'product_uom' => $this->product_uom, 'product_uos_qty' => $this->product_uos_qty, 'date_start' => $this->date_start, 'product_qty' => $this->product_qty, 'product_uos' => $this->product_uos, 'product_efficiency' => $this->product_efficiency, 'active' => $this->active, 'product_rounding' => $this->product_rounding, 'sequence' => $this->sequence, 'company_id' => $this->company_id, 'routing_id' => $this->routing_id, 'product_id' => $this->product_id, 'bom_id' => $this->bom_id]);
     $query->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'position', $this->position])->andFilterWhere(['like', 'type', $this->type]);
     return $dataProvider;
 }
Пример #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMrpBoms()
 {
     return $this->hasMany(MrpBom::className(), ['bom_id' => 'id']);
 }
Пример #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMrpBoms()
 {
     return $this->hasMany(MrpBom::className(), ['product_uom' => 'id']);
 }
Пример #4
0
 private function prepareLineDataNew($lines)
 {
     $res = [];
     foreach ($lines as $k => $line) {
         // if set
         if (isset($line->opLine->move->move_dest_id) && $line->opLine->move->move_dest_id) {
             $moveDest = $line->opLine->move->moveDest;
             // before we must check if move dest id setted
             if (array_key_exists($moveDest->id, $res)) {
                 $res[$moveDest->id]['set'][] = $this->prepareSetPrintNew($line);
             } else {
                 // init to be printed
                 // TOP LEVEL PRINTED
                 $res[$moveDest->id] = ['no' => $line->no, 'qty' => $moveDest->product_qty, 'uom' => $moveDest->productUom->name, 'name' => $moveDest->desc ? nl2br($moveDest->desc) : nl2br($moveDest->product->name_template), 'name2' => $moveDest->name, 'desc' => $moveDest->desc, 'set' => [$this->prepareSetPrintNew($line)], 'part_no' => $moveDest->product->default_code];
                 // CHECK SET QTY
                 if ($moveDest->product->mrpBoms) {
                     $bomId = $moveDest->product->mrpBoms[0]->id;
                     $bomObj = \app\models\MrpBom::find()->where('product_id=:prodId AND bom_id = :bomId')->addParams([':prodId' => $line->product_id, ':bomId' => $bomId])->one();
                     $res[$moveDest->id]['qty'] = $line->product_qty / $bomObj->product_qty;
                 }
             }
             /*var_dump($line->product->name_template);
               if($line->product->superNotes):
                   foreach($line->product->superNotes as $notes):
                       if($notes->show_in_do_line && isset($res[$moveDest->id]['name'])) $res[$moveDest->id]['name'].='<br/>'.$notes->template_note; #SHOW ETRA NOTES PRODUCT INTO LINE
                   endforeach;
               endif;*/
         } else {
             // not set
             $res[$line->id] = $this->prepareLinenew($line);
         }
     }
     return $res;
 }
Пример #5
0
 public function actionGenerateProductSet($id, $product_id)
 {
     $dataMove = StockMove::find()->where(['id' => $id])->one();
     $bom = MrpBom::find()->where(['product_id' => $product_id, 'type' => 'phantom'])->one();
     if (!$bom) {
         throw new NotFoundHttpException('This Product Not Setted Into Phantom BOM');
     }
     $searchModel = new MrpBomSearch();
     $dataProvider = $searchModel->searchBom($bom->id);
     foreach ($dataProvider->getModels() as $model) {
         $newMove = new StockMove();
         $newMove->create_uid = $dataMove->create_uid;
         $newMove->create_date = $dataMove->create_date;
         $newMove->date = $dataMove->create_date;
         $newMove->write_date = $dataMove->write_date;
         $newMove->write_uid = $dataMove->write_uid;
         $newMove->origin = $dataMove->origin;
         $newMove->product_uos_qty = $dataMove->product_uos_qty;
         $newMove->date_expected = $dataMove->date_expected;
         $newMove->product_uom = $model->product_uom;
         $newMove->move_dest_id = $dataMove->id;
         $newMove->product_qty = $dataMove->product_qty * $model->product_qty;
         $newMove->product_uos = $model->product_uom;
         $newMove->partner_id = $dataMove->partner_id;
         $newMove->product_id = $model->product_id;
         $newMove->location_id = $dataMove->location_id;
         $newMove->company_id = $dataMove->company_id;
         $newMove->picking_id = $dataMove->picking_id;
         $newMove->state = $dataMove->state;
         $newMove->location_dest_id = $dataMove->location_dest_id;
         $newMove->tracking_id = $dataMove->tracking_id;
         $newMove->product_packaging = $dataMove->product_packaging;
         $newMove->purchase_line_id = $dataMove->purchase_line_id;
         $newMove->sale_line_id = $dataMove->sale_line_id;
         $newMove->name = $model->name;
         $newMove->desc = $model->name;
         $newMove->no = $dataMove->no;
         $newMove->weight_uom_id = 3;
         $newMove->save();
     }
     $stockmove = StockMove::findOne($id);
     $stockmove->picking_id = '';
     $stockmove->location_dest_id = 12;
     $stockmove->update();
     return $this->redirect(['view-move-childs', 'id' => $id]);
 }
Пример #6
0
 /**
  * Finds the MrpBom model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return MrpBom the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = MrpBom::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }