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'] : ' ') . '</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; }
/** * [getSuperNotes description] * @return ActiveRecord */ public function getSuperNotes() { // return $this->hasMany(SuperNoteProductRel::className(),['product_id'=>'id'])->viaTable(SuperNotes::className(),['id'=>'id']); // return $this->hasMany(SuperNoteProductRel::className(),['product_id'=>'id']); return $this->hasMany(SuperNotes::className(), ['id' => 'super_note_id'])->via('superNoteProductRels'); }
/** * @return \yii\db\ActiveQuery */ public function getSuperNote() { return $this->hasOne(SuperNotes::className(), ['id' => 'super_note_id']); }