示例#1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Quotation::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['quotation_id' => $this->quotation_id, 'quotation_no' => $this->quotation_no, 'quotation_date' => $this->quotation_date, 'quotation_date_transaction' => $this->quotation_date_transaction, 'quotation_customerid' => $this->quotation_customerid, 'quotation_createid' => $this->quotation_createid, 'quotation_charge' => $this->quotation_charge, 'quotation_tax_percent' => $this->quotation_tax_percent, 'quotation_tax_amount' => $this->quotation_tax_amount, 'quotation_revision' => $this->quotation_revision, 'quotation_parts_total' => $this->quotation_parts_total, 'quotation_gst_payable' => $this->quotation_gst_payable]);
     $query->andFilterWhere(['like', 'quotation_createname', $this->quotation_createname])->andFilterWhere(['like', 'quotation_remark', $this->quotation_remark])->andFilterWhere(['like', 'quotation_system', $this->quotation_system])->andFilterWhere(['like', 'quotation_partno', $this->quotation_partno])->andFilterWhere(['like', 'quotation_invoice', $this->quotation_invoice])->andFilterWhere(['like', 'quotation_deliveryorder', $this->quotation_deliveryorder])->andFilterWhere(['like', 'quotation_tax_label', $this->quotation_tax_label])->andFilterWhere(['like', 'quotation_printed_status', $this->quotation_printed_status])->andFilterWhere(['like', 'quotation_no_user_format', $this->quotation_no_user_format]);
     return $dataProvider;
 }
示例#2
0
 /**
  * Creates a new Quotation model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Quotation();
     $model2 = new QuotationDetail();
     $newQuotationDetail = new QuotationDetail();
     $product = Product::find()->where(['product_type' => 'p'])->orderBy('product_id')->all();
     $service = Product::find()->where(['product_type' => 's'])->orderBy('product_id')->all();
     $customer = Customer::find()->orderBy('customer_name')->all();
     $quotation = Quotation::find()->orderBy(['quotation_id' => SORT_DESC])->one();
     $uid = Yii::$app->user->identity->user_id;
     $uname = Yii::$app->user->identity->user_name;
     if (isset($_POST['description'])) {
         $quotationDetailList = $_POST['description'];
         $customer_id = $_POST['customer-list'];
         $quotation_id = $_POST['quotation_id'];
         $quotation_no = $_POST['quotation_no'];
         $quotation_date = $_POST['quotation_date'];
         $productType = $_POST['productType'];
         $qty = $_POST['qty'];
         $unit = $_POST['unit'];
         $cost = $_POST['cost'];
         $remarks = $_POST['remarks'];
         $hidden_price = $_POST['hidden_price'];
         $hidden_gst = $_POST['hidden_gst'];
         $hidden_tax_code = $_POST['hidden_tax_code'];
         $hidden_tax_rate = $_POST['hidden_tax_rate'];
         $hidden_price_gst = $_POST['hidden_price_gst'];
         $hidden_total = $_POST['hidden_total'];
         $hidden_gsttotal = $_POST['hidden_gsttotal'];
         $hidden_gstpricetotal = $_POST['hidden_gstpricetotal'];
         $hidden_product_name = $_POST['hidden_product_name'];
         if ($quotationDetailList != NULL) {
             if ($remarks == NULL) {
                 $remarks = "-";
             }
             $newQuotation = new Quotation();
             $newQuotation->quotation_id = $quotation_id;
             $newQuotation->quotation_no = $quotation_no;
             $newQuotation->quotation_date = $quotation_date;
             $newQuotation->quotation_date_transaction = $quotation_date;
             $newQuotation->quotation_customerid = $customer_id;
             $newQuotation->quotation_createid = $uid;
             $newQuotation->quotation_createname = $uname;
             $newQuotation->quotation_remark = $remarks;
             $newQuotation->quotation_system = "y";
             $newQuotation->quotation_partno = "y";
             $newQuotation->quotation_invoice = "123";
             $newQuotation->quotation_deliveryorder = "lol";
             $newQuotation->quotation_charge = 123;
             $newQuotation->quotation_tax_label = "lol";
             $newQuotation->quotation_tax_percent = 1;
             $newQuotation->quotation_tax_amount = 100;
             $newQuotation->quotation_printed_status = "y";
             $newQuotation->quotation_revision = 1;
             $newQuotation->quotation_parts_total = $hidden_total;
             $newQuotation->quotation_no_user_format = "lol";
             $newQuotation->quotation_gst_payable = $hidden_gsttotal;
             $newQuotation->quotation_total_amount = $hidden_gstpricetotal;
             $newQuotation->save();
             foreach ($quotationDetailList as $key => $n) {
                 if ($n != NULL) {
                     if ($unit[$key] == NULL) {
                         $unit[$key] = "-";
                     }
                     $newQuotationDetail = new QuotationDetail();
                     $newQuotationDetail->quotationdetail_quotationid = $quotation_id;
                     $newQuotationDetail->quotationdetail_productid = $n;
                     $newQuotationDetail->quotationdetail_partno = "lol";
                     $newQuotationDetail->quotationdetail_productname = $hidden_product_name[$key];
                     $newQuotationDetail->quotationdetail_producttype = $productType[$key];
                     $newQuotationDetail->quotationdetail_unit = $qty[$key];
                     $newQuotationDetail->quotationdetail_unitname = $unit[$key];
                     $newQuotationDetail->quotationdetail_product_cost = $cost[$key];
                     $newQuotationDetail->quotationdetail_price = $hidden_price[$key];
                     $newQuotationDetail->quotationdetail_tax_code = $hidden_tax_code[$key];
                     $newQuotationDetail->quotationdetail_tax_rate = $hidden_tax_rate[$key];
                     $newQuotationDetail->quotationdetail_tax_amount = $hidden_gst[$key];
                     $newQuotationDetail->quotationdetail_total_amount = $hidden_price_gst[$key];
                     $newQuotationDetail->quotationdetail_gst_status = 1;
                     $newQuotationDetail->save();
                 }
             }
         }
     }
     if ($newQuotationDetail->save()) {
         return $this->redirect(['index']);
     } elseif ($newQuotationDetail->load(Yii::$app->request->post())) {
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model, 'model2' => $model2, 'product' => $product, 'service' => $service, 'customer' => $customer, 'quotation' => $quotation]);
     }
 }