public function actionProductList($search = null, $id = null)
 {
     $out = ['more' => false];
     if (!is_null($search)) {
         $query = new Query();
         $lowerchr = strtolower($search);
         $command = Yii::$app->db->createCommand("SELECT id, CONCAT('[',default_code,'] ',name_template) as text FROM product_product WHERE active=true AND (name_template ILIKE '%" . $lowerchr . "%' OR default_code ilike '%" . $lowerchr . "%') LIMIT 20");
         $data = $command->queryAll();
         $out['results'] = array_values($data);
     } elseif ($id > 0) {
         $one = \app\models\ProductProduct::findOne($id);
         $out['results'] = ['id' => $id, 'text' => '[' . $one->default_code . '] ' . $one->name_template];
     } else {
         $out['results'] = ['id' => 0, 'text' => 'No matching records found'];
     }
     echo Json::encode($out);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getItem()
 {
     return $this->hasOne(ProductProduct::className(), ['id' => 'item_id']);
 }
Beispiel #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProductProducts()
 {
     return $this->hasMany(ProductProduct::className(), ['product_tmpl_id' => 'id']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProduct()
 {
     return $this->hasOne(ProductProduct::className(), ['id' => 'product_id']);
 }
 private function renderLinesPrintNew($preparedLines)
 {
     $res = [];
     // var_dump($preparedLines);
     $no = 0;
     foreach ($preparedLines as $k => $l) {
         $res[$no] = ['qty' => '<div style="float:left;width:10mm;">' . ($l['no'] ? $l['no'] : '&nbsp;') . '</div>
                 <div>' . floatval($l['qty']) . ' ' . $l['uom'] . '</div><div style="clear:both;"></div>', 'part_no' => $l['part_no']];
         // var_dump($l);
         if (isset($l['name2'])) {
             if (array_key_exists('set', $l) && count($l['set']) && isset($l['name'])) {
                 $res[$no]['name'] = $l['name'];
             } else {
                 $res[$no]['name'] = $l['name2'];
             }
         } else {
             $prod = ProductProduct::findOne($l['product_id']);
             $res[$no]['name'] = '[' . $prod['default_code'] . '] ' . $prod['name_template'] . '<br/>' . $l['name'];
         }
         if (isset($l['note_line_material'])) {
             if (count($l['note_line_material']) == 1) {
                 foreach ($l['note_line_material'] as $line_material) {
                     if ($l['product_id'] != $line_material['product_id']) {
                         $modelprod = ProductProduct::findOne($line_material['product_id']);
                         $uom = ProductUom::findOne($line_material['product_uom']);
                         $res[$no]['name'] .= '<br/>Consist Of : <ul style="margin:0;">';
                         $printSp_note = '';
                         foreach ($modelprod->superNoteProductRels as $spnotes) {
                             $superNotes = SuperNotes::findOne($spnotes['super_note_id']);
                             $printSp_note .= '<br/>' . $superNotes['template_note'];
                         }
                         $res[$no]['name'] .= '<li>[' . $modelprod['default_code'] . '] ' . $modelprod['name_template'] . ' <strong>(' . $line_material['qty'] . ' ' . $uom['name'] . '</strong>)<br/>' . $line_material['desc'] . $printSp_note . '</li>';
                     }
                 }
             } else {
                 if (count($l['note_line_material']) > 1) {
                     $res[$no]['name'] .= '<br/>Consist Of : <ul style="margin:0;">';
                     $batch = "";
                     foreach ($l['note_line_material'] as $line_material) {
                         if ($line_material['prodlot_id']) {
                             $prodlot = StockProductionLot::findOne($line_material['prodlot_id']);
                             $batch = '<strong>SN:</strong> ' . $prodlot['name'] . ' ' . $line_material['desc'];
                         }
                         $modelprod = ProductProduct::findOne($line_material['product_id']);
                         $uom = ProductUom::findOne($line_material['product_uom']);
                         $printSp_note = '';
                         foreach ($modelprod->superNoteProductRels as $spnotes) {
                             $superNotes = SuperNotes::findOne($spnotes['super_note_id']);
                             $printSp_note .= $superNotes['template_note'];
                         }
                         $res[$no]['name'] .= '<li>[' . $modelprod['default_code'] . '] ' . $modelprod['name_template'] . ' <strong>(' . $line_material['qty'] . ' ' . $uom['name'] . '</strong>) <br/>' . $line_material['desc'] . $batch . $printSp_note . '</li>';
                     }
                 }
             }
         }
         // if PRODUCT IS SET TYPE
         if (array_key_exists('set', $l)) {
             $res[$no]['name'] .= '<br/>Consist Of : <ul style="margin:0;">';
             foreach ($l['set'] as $set) {
                 $res[$no]['name'] .= '<li>' . $set['name'] . '</li>';
             }
             $res[$no]['name'] .= '</ul>';
         }
         if (array_key_exists('batches', $l) && count($l['batches']) >= 1) {
             $res[$no]['name'] .= '<br/>' . $this->prepareBathesRender($l);
         }
         $no++;
     }
     /*echo '----------';
       var_dump($res);*/
     return $res;
 }
 public function actionProductlist($search = null, $id = null)
 {
     $out = ['more' => false];
     if (!is_null($search)) {
         $query = new Query();
         $lowerchr = strtolower($search);
         $command = Yii::$app->db->createCommand("SELECT DISTINCT id, '[' || default_code || '] ' || name_template as text FROM product_product WHERE lower(name_template) LIKE '%" . $lowerchr . "%' OR lower(default_code) LIKE '%" . $lowerchr . "%' LIMIT 20");
         $data = $command->queryAll();
         $out['results'] = array_values($data);
     } elseif ($id > 0) {
         $ids = explode(',', $id);
         foreach ($ids as $value) {
             $data[] = ['id' => $value, 'text' => '[' . ProductProduct::find()->where(['id' => $value])->one()->default_code . '] ' . ProductProduct::find()->where(['id' => $value])->one()->name_template];
         }
         $out['results'] = $data;
     } else {
         $out['results'] = ['id' => 0, 'text' => 'No matching records found'];
     }
     echo Json::encode($out);
 }
Beispiel #7
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getItemToSplit()
 {
     return $this->hasOne(ProductProduct::className(), ['id' => 'item_to_split']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getName0()
 {
     return $this->hasOne(ProductProduct::className(), ['id' => 'name']);
 }
 public function actionExportCsv($id)
 {
     $this->layout = 'export';
     $product = ProductProduct::find()->where(['id' => $id])->one();
     return $this->render('report/exportcsv', ['model' => $product]);
 }