public function actionImprimir() { // get your HTML raw content without any layouts or scrip $Empresas = Empresas::find()->all(); $content = $this->renderPartial('_imprimir', ['Empresas' => $Empresas]); $header = $this->renderPartial('_header', ['Empresas' => $Empresas]); $pdf = new Pdf(['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' => $header, 'SetFooter' => ['{PAGENO}']]]); // return the pdf output as per the destination setting return $pdf->render(); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Empresas::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]); $query->andFilterWhere(['like', 'razao_social', $this->razao_social])->andFilterWhere(['like', 'nome_fantasia', $this->nome_fantasia])->andFilterWhere(['like', 'cnpj', $this->cnpj])->andFilterWhere(['like', 'insc_estadual', $this->insc_estadual])->andFilterWhere(['like', 'endereco', $this->endereco])->andFilterWhere(['like', 'numero', $this->numero])->andFilterWhere(['like', 'bairro', $this->bairro])->andFilterWhere(['like', 'estado', $this->estado])->andFilterWhere(['like', 'cidade', $this->cidade])->andFilterWhere(['like', 'cep', $this->cep])->andFilterWhere(['like', 'telefone', $this->telefone])->andFilterWhere(['like', 'telefone1', $this->telefone1])->andFilterWhere(['like', 'telefone2', $this->telefone2])->andFilterWhere(['like', 'email', $this->email]); return $dataProvider; }