Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. public function actionPrint() {
  2. $mPDF1 = Yii::app()->ePdf->mpdf('ar','A4','14','dejavusanscondensed');
  3. $model=new Country('search');
  4.  
  5. $model->center_id = 1;// This value will be passed from dropdown
  6. //and i want the report to be made on this
  7.  
  8. $model->unsetAttributes();
  9. if(isset($_GET['Country']))
  10. $model->attributes=$_GET['Country'];
  11.  
  12. $html = '';
  13. $html .= $this->renderPartial('candidates', array('model'=>$model, 'enablePagination' => false),true);
  14. $mPDF1->WriteHTML($html, false);
  15. $mPDF1->Output('list.pdf','D');
  16. }
  17.  
  18. $this->widget('zii.widgets.grid.CGridView', array(
  19. 'id'=>'country-grid',
  20. 'dataProvider'=>$model->search($enablePagination),
  21. 'summaryText' => '',
  22. // 'enablePagination' => false,
  23. 'filter'=>$model,
  24. 'columns'=>array(
  25. 'name',
  26. array(
  27. 'header'=>' Total Registered Candidates',
  28. 'value'=>'$data->itemsTotal',
  29. ),
  30. ),
  31. ));
  32. echo CHtml::link(
  33. 'Save as PDF',
  34. Yii::app()->createUrl('country/print'),
  35. array('class'=>'btnPrint btn btn-danger','target'=>'_blank'));
  36.  
  37. public function search($enablePagination = true)
  38. {
  39. $criteria->together= true;
  40. $criteria->with=array('center');
  41. $criteria->compare('center.name', $this->center_id, true);
  42. ..........
  43. if ($enablePagination)
  44. {
  45. $pagination = array(
  46. 'pageSize' => 30,
  47. );
  48. }
  49. else
  50. {
  51. $pagination = false;
  52. }
  53.  
  54. return new CActiveDataProvider($model, array(
  55. 'criteria' => $criteria,
  56. 'pagination' => $pagination,
  57. ));
  58. }
  59.  
  60. $criteria->compare('center.name', $this->center_id, true);
  61.  
  62. $criteria->compare('center_id', $this->center_id);
  63.  
  64. $criteria->compare('center.id', $this->center_id);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement