/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Departamentos::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', 'descripcion', $this->descripcion]); return $dataProvider; }
<div class="collapse" id="form"> <div class="well"> <div class="empleados-form"> <?php $form = ActiveForm::begin(); ?> <?= $form->field($model, 'nombre')->textInput() ?> <?= $form->field($model, 'apellidos')->textInput() ?> <?= $form->field($model, 'celular')->textInput() ?> <?= $form->field($model, 'puesto')->textInput() ?> <?= $form->field($model, 'departamento_did')->dropDownList( ArrayHelper::map(Departamentos::find()->all(), 'id', 'nombre'), // Flat array ('id'=>'label') ['prompt'=>'Seleccione un departamento'] // options ); ?> <?= $form->field($model, 'direccion')->textarea(['rows' => 6]) ?> <div class="form-group"> <?= Html::submitButton($model->isNewRecord ? 'Guardar' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> </div> <?php ActiveForm::end(); ?> </div> </div> </div>
public function actionImprimir() { // get your HTML raw content without any layouts or scrip $Departamentos = Departamentos::find()->all(); $content = $this->renderPartial('_imprimir', ['Departamentos' => $Departamentos]); $header = $this->renderPartial('_header', ['Departamentos' => $Departamentos]); $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(); }