/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Chart::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(['CHART_ID' => $this->CHART_ID, 'USER_ID' => $this->USER_ID, 'KODE_POS_ORIGIN' => $this->KODE_POS_ORIGIN, 'KODE_POS_DES' => $this->KODE_POS_DES, 'TOTAL_BERAT' => $this->TOTAL_BERAT, 'HARGA' => $this->HARGA]); $query->andFilterWhere(['like', 'USERNAME', $this->USERNAME])->andFilterWhere(['like', 'NOFAKTUR', $this->NOFAKTUR])->andFilterWhere(['like', 'KURIR', $this->KURIR])->andFilterWhere(['like', 'PROVORIGIN', $this->PROVORIGIN])->andFilterWhere(['like', 'PROVDES', $this->PROVDES])->andFilterWhere(['like', 'ORIGIN_CITY', $this->ORIGIN_CITY])->andFilterWhere(['like', 'DES_CITY', $this->DES_CITY])->andFilterWhere(['like', 'KATEGORI_KIRIM', $this->KATEGORI_KIRIM]); return $dataProvider; }
/** * Finds the Chart model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Chart the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Chart::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionPdf($id) { /* $mpdf=new mPDF(); $mpdf->WriteHTML($this->renderPartial('mpdf',['model' => $this->findModel($id),])); //$mpdf->WriteHTML($this->renderPartial('mpdf')); $mpdf->Output('Expdf.pdf', 'D'); exit; */ // $model = new Order(); // $total = new Chart(); $sql = Order::find()->where(['G_ORDER' => $id])->asArray()->one(); $list = Chart::find()->where(['FAKTUR' => $id])->asArray()->all(); $total = Chart::find()->select('sum(HARGA) as total')->where(['FAKTUR' => $id])->asArray()->all(); $mpdf = new mPDF(); $mpdf->WriteHTML($this->renderPartial('invoice', ['sql' => $sql, 'list' => $list, 'total' => $total])); $mpdf->Output(); exit; //return $this->renderPartial('mpdf'); }