/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Bills::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, 'watches_id' => $this->watches_id, 'pament_mode' => $this->pament_mode, 'quantity' => $this->quantity]); $query->andFilterWhere(['like', 'billrecord', $this->billrecord])->andFilterWhere(['like', 'created_at', $this->created_at]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getBills() { return $this->hasMany(Bills::className(), ['pament_mode' => 'id']); }
public function actionReport($billId) { $this->layout = false; $models = Bills::find()->where(['billrecord' => $billId])->all(); // get your HTML raw content without any layouts or scripts $content = $this->render('billTemplate', ['items' => $models]); // setup kartik\mpdf\Pdf component $pdf = new Pdf(['mode' => Pdf::MODE_CORE, 'format' => Pdf::FORMAT_A4, 'orientation' => Pdf::ORIENT_PORTRAIT, 'destination' => Pdf::DEST_BROWSER, 'content' => $content, 'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css', 'cssInline' => '.kv-heading-1{font-size:18px}', 'options' => ['title' => 'Krajee Report Title'], 'methods' => ['SetHeader' => ['<p align="center"><img src="/img/test-header.png" class="img-responsive col-md-12" alt="Responsive image"> </p>' . date("r")], 'SetFooter' => ['<p align="center"><img src="/img/test-footer.png" class="img-responsive col-md-12" alt="Responsive image"> </p> ']]]); Yii::$app->response->format = \yii\web\Response::FORMAT_RAW; $headers = Yii::$app->response->headers; $headers->add('Content-Type', 'application/pdf'); // return the pdf output as per the destination setting return $pdf->render(); }
/** * @return \yii\db\ActiveQuery */ public function getBills() { return $this->hasMany(Bills::className(), ['watches_id' => 'id']); }
/** * Finds the Bills model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Bills the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Bills::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }