Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function actionPrint() {
- $mPDF1 = Yii::app()->ePdf->mpdf('ar','A4','14','dejavusanscondensed');
- $model=new Country('search');
- $model->center_id = 1;// This value will be passed from dropdown
- //and i want the report to be made on this
- $model->unsetAttributes();
- if(isset($_GET['Country']))
- $model->attributes=$_GET['Country'];
- $html = '';
- $html .= $this->renderPartial('candidates', array('model'=>$model, 'enablePagination' => false),true);
- $mPDF1->WriteHTML($html, false);
- $mPDF1->Output('list.pdf','D');
- }
- $this->widget('zii.widgets.grid.CGridView', array(
- 'id'=>'country-grid',
- 'dataProvider'=>$model->search($enablePagination),
- 'summaryText' => '',
- // 'enablePagination' => false,
- 'filter'=>$model,
- 'columns'=>array(
- 'name',
- array(
- 'header'=>' Total Registered Candidates',
- 'value'=>'$data->itemsTotal',
- ),
- ),
- ));
- echo CHtml::link(
- 'Save as PDF',
- Yii::app()->createUrl('country/print'),
- array('class'=>'btnPrint btn btn-danger','target'=>'_blank'));
- public function search($enablePagination = true)
- {
- $criteria->together= true;
- $criteria->with=array('center');
- $criteria->compare('center.name', $this->center_id, true);
- ..........
- if ($enablePagination)
- {
- $pagination = array(
- 'pageSize' => 30,
- );
- }
- else
- {
- $pagination = false;
- }
- return new CActiveDataProvider($model, array(
- 'criteria' => $criteria,
- 'pagination' => $pagination,
- ));
- }
- $criteria->compare('center.name', $this->center_id, true);
- $criteria->compare('center_id', $this->center_id);
- $criteria->compare('center.id', $this->center_id);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement