Esempio n. 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = InvoiceItem::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(['id' => $this->id, 'qty' => $this->qty, 'price' => $this->price]);
     $query->andFilterWhere(['like', 'item', $this->item])->andFilterWhere(['like', 'code', $this->code]);
     return $dataProvider;
 }
Esempio n. 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getInvoiceItems()
 {
     return $this->hasMany(InvoiceItem::className(), ['id' => 'invoice_item_id'])->viaTable('{{%entp_invoiceitem}}', ['invoice_id' => 'id']);
 }
Esempio n. 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getInvoiceItem()
 {
     return $this->hasOne(InvoiceItem::className(), ['id' => 'invoice_item_id']);
 }
Esempio n. 4
0
 /**
  * Finds the InvoiceItem model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return InvoiceItem the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = InvoiceItem::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 5
0
 public function actionAdditem($entrepreneur_user_id, $invoice_id)
 {
     $model = new InvoiceItem();
     if (Yii::$app->request->post()) {
         $x = Yii::$app->request->post();
         $item = $x['EntpInvoice']['item'];
         $code = $x['EntpInvoice']['code'];
         $qty = $x['EntpInvoice']['qty'];
         $price = $x['EntpInvoice']['price'];
         $invoice = $x['EntpInvoice']['invoice_id'];
         $entp = $x['EntpInvoice']['entrepreneur_user_id'];
         $model->code = $code;
         $model->item = $item;
         $model->price = $price;
         $model->qty = $qty;
         $model->save();
         //if($model->save()){
         $item = new EntpInvoiceItem();
         $item->invoice_item_id = $model->id;
         $item->invoice_id = intval($invoice);
         $item->save();
         //}
         Yii::$app->session->setFlash('success', 'New Item Added');
         $model = $this->findModel($entp, $invoice);
         $query = $model->invoice->getInvoiceItems();
         $dataProvider = new ActiveDataProvider(['query' => $query]);
         return $this->render('view', ['model' => $model, 'dataProvider' => $dataProvider]);
     } else {
         $model = $this->findModel($entrepreneur_user_id, $invoice_id);
         $query = $model->invoice->getInvoiceItems();
         $dataProvider = new ActiveDataProvider(['query' => $query]);
         return $this->render('view', ['model' => $model, 'dataProvider' => $dataProvider]);
     }
 }