Exemplo n.º 1
0
 /**
  * Lists all Invoice models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new InvoiceSearch();
     $invoice = Invoice::find(1)->one();
     echo '<pre>';
     print_r($invoice->getItems()->asArray()->all());
     echo '</pre>';
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Exemplo n.º 2
0
 /**
  * Displays a single Customer model.
  * @param string $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     $searchModel = new InvoiceSearch();
     $dataProvider = $searchModel->search(['InvoiceSearch' => ['customer_id' => $id]]);
     $extraInfor = ['revenues' => Invoice::getRevenuesFormInvoiceList($dataProvider->getModels()), 'transactionCount' => $dataProvider->getTotalCount(), 'debit' => $model->getDebitCurrency()];
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash('kv-detail-success', yii::t('backend/modules/customer', 'Saved record successfully'));
         // Multiple alerts can be set like below
         // Yii::$app->session->setFlash('kv-detail-warning', 'A last warning for completing all data.');
         // Yii::$app->session->setFlash('kv-detail-info', '<b>Note:</b> You can proceed by clicking <a href="#">this link</a>.');
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('view', ['model' => $model, 'dataProvider' => $dataProvider, 'searchModel' => $searchModel, 'extraInfor' => $extraInfor]);
     }
 }