public function actionToDone($id) { \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $res = []; if (Yii::$app->request->isAjax) { $model = SaleOrder::findOne($id); $model->state = 'done'; $res = ['status' => $model->update()]; } return $res; }
public function actionRfq($id) { $this->layout = False; $model = SaleOrder::findOne($id); if ($model === null) { throw new NotFoundHttpException(); } $dataContent = []; $dataContentModel = $model->saleOrderLines; $no = 1; $TermCondition_murni = preg_replace('#\\R+#', '<br/>', $model->internal_notes); $TermCondition_enter = explode("<br/>", $TermCondition_murni); $TermCondition = []; foreach ($TermCondition_enter as $key => $value) { $split_term = str_split($value, 90); foreach ($split_term as $key_split_term => $value_split_term) { array_push($TermCondition, $value_split_term); } } $NoteMurni = preg_replace('#\\R+#', '<br/>', $model->note); $NoteEnter = explode("<br/>", $NoteMurni); $Note = []; foreach ($NoteEnter as $key => $value) { $split_note = str_split($value, 90); foreach ($split_note as $key_split_note => $value_split_note) { array_push($Note, $value_split_note); } } // var_dump($Note); foreach ($dataContentModel as $key => $value) { $price_sub = number_format($value->product_uom_qty * $value->price_unit, 2); $unit = number_format($value->price_unit, 2); if ($value->name === null) { $deskription_orderline = ""; } else { $deskription_orderline = $value->name; } $dataContent[$key]['no'] = $no; $dataContent[$key]['product_uom_qty'] = $value->product_uom_qty; $dataContent[$key]['unit'] = $value->productUom->name; $dataContent[$key]['default_code'] = $value->product->default_code; $dataContent[$key]['name_product'] = $value->product->name_template; $dataContent[$key]['unit_price'] = $unit; $dataContent[$key]['price_sub'] = $price_sub; $dataContent[$key]['deskription_orderline'] = $deskription_orderline; $dataContent[$key]['Note'] = $Note; $dataContent[$key]['TermCondition'] = $TermCondition; $dataContent[$key]['material_line'] = []; foreach ($value->materialLines as $keyM => $vM) { if ($vM->desc === null) { $descriptionMaterial = ""; } else { $descriptionMaterial = $vM->desc; } $dataContent[$key]['material_line'][] = ['product_id' => $vM->product->name_template, 'partNumber' => $vM->product->default_code, 'descriptionMaterial' => $descriptionMaterial, 'qty' => $vM->qty, 'uom' => $vM->uom0->name]; } $no++; } if ($model->partner->state === null) { $state = ""; } else { $state = $model->partner->state->name; } if ($model->partner->country === null) { $country = ""; } else { $country = $model->partner->country->name; } if ($model->attention0 !== null) { $AttentionName = $model->attention0->name; $AttentionPhone = $model->attention0->phone; if ($model->attention0->fax !== null) { $fax = $model->attention0->fax; } else { if ($model->partner->fax !== null) { $fax = $model->partner->fax; } else { $fax = ""; } } if ($model->attention0->email !== null) { $email = $model->attention0->email; } else { if ($model->partner->fax !== null) { $email = $model->partner->email; } else { $email = ""; } } } else { $fax = ""; $email = ""; $AttentionName = ""; $AttentionPhone = ""; } $TermCondition_murni = preg_replace('#\\R+#', '<br/>', $model->internal_notes); $TermCondition_enter = explode("<br/>", $TermCondition_murni); $TermCondition = []; foreach ($TermCondition_enter as $key => $value) { // echo $value.'<br/>'; array_push($TermCondition, str_split($value, 50)); } // var_dump($TermCondition); $NoteMurni = preg_replace('#\\R+#', '<br/>', $model->internal_notes); $NoteEnter = explode("<br/>", $NoteMurni); $Note = []; foreach ($NoteEnter as $key => $value) { // echo $value.'<br/>'; array_push($Note, str_split($value, 50)); } return $this->render('rfq', ['Note' => $Note, 'TermCondition' => $TermCondition, 'model' => $model, 'state' => $state, 'country' => $country, 'fax' => $fax, 'email' => $email, 'AttentionName' => $AttentionName, 'AttentionPhone' => $AttentionPhone, 'dataContent' => $dataContent]); }