You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 line
4.2KB

  1. <?php
  2. namespace backend\controllers;
  3. use Yii;
  4. use common\models\User;
  5. use yii\data\ActiveDataProvider;
  6. use yii\web\Controller;
  7. use yii\web\NotFoundHttpException;
  8. use yii\filters\VerbFilter;
  9. use yii\filters\AccessControl;
  10. use kartik\mpdf\Pdf;
  11. /**
  12. * UserController implements the CRUD actions for User model.
  13. */
  14. class CommuniquerController extends BackendController
  15. {
  16. public function behaviors()
  17. {
  18. return [
  19. 'verbs' => [
  20. 'class' => VerbFilter::className(),
  21. 'actions' => [
  22. 'delete' => ['post'],
  23. ],
  24. ],
  25. 'access' => [
  26. 'class' => AccessControl::className(),
  27. 'rules' => [
  28. [
  29. 'allow' => true,
  30. 'roles' => ['@'],
  31. 'matchCallback' => function ($rule, $action) {
  32. return Yii::$app->user->identity->status == USER::STATUS_ADMIN
  33. || Yii::$app->user->identity->status == USER::STATUS_BOULANGER;
  34. }
  35. ]
  36. ],
  37. ],
  38. ];
  39. }
  40. public function actionIndex()
  41. {
  42. return $this->render('index') ;
  43. }
  44. public function actionAffiche()
  45. {
  46. // get your HTML raw content without any layouts or scripts
  47. $content = $this->renderPartial('affiche',[
  48. ]);
  49. $pdf = new Pdf([
  50. // set to use core fonts only
  51. 'mode' => Pdf::MODE_UTF8,
  52. // A4 paper format
  53. 'format' => Pdf::FORMAT_A4,
  54. // portrait orientation
  55. 'orientation' => Pdf::ORIENT_LANDSCAPE,
  56. // stream to browser inline
  57. 'destination' => Pdf::DEST_BROWSER,
  58. // your html content input
  59. 'content' => $content,
  60. // format content from your own css file if needed or use the
  61. // enhanced bootstrap css built by Krajee for mPDF formatting
  62. //'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css',
  63. // any css to be embedded if required
  64. //'cssInline' => '.kv-heading-1{font-size:18px}',
  65. // set mPDF properties on the fly
  66. //'options' => ['title' => 'Krajee Report Title'],
  67. // call mPDF methods on the fly
  68. /*'methods' => [
  69. 'SetHeader'=>['Commandes du '.$date_str],
  70. 'SetFooter'=>['{PAGENO}'],
  71. ]*/
  72. ]);
  73. // return the pdf output as per the destination setting
  74. return $pdf->render();
  75. }
  76. public function actionModeemploi()
  77. {
  78. // get your HTML raw content without any layouts or scripts
  79. $content = $this->renderPartial('mode_emploi_multi',[
  80. 'pdf' => true
  81. ]);
  82. $pdf = new Pdf([
  83. // set to use core fonts only
  84. 'mode' => Pdf::MODE_UTF8,
  85. // A4 paper format
  86. 'format' => Pdf::FORMAT_A4,
  87. // portrait orientation
  88. 'orientation' => Pdf::ORIENT_PORTRAIT,
  89. // stream to browser inline
  90. 'destination' => Pdf::DEST_BROWSER,
  91. // your html content input
  92. 'content' => $content,
  93. 'marginRight' => 0,
  94. 'marginLeft' => 0,
  95. 'marginTop' => 0,
  96. 'marginBottom' => 0,
  97. // format content from your own css file if needed or use the
  98. // enhanced bootstrap css built by Krajee for mPDF formatting
  99. //'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css',
  100. 'cssFile' => '@app/web/css/screen.css',
  101. // any css to be embedded if required
  102. //'cssInline' => '.kv-heading-1{font-size:18px}',
  103. // set mPDF properties on the fly
  104. //'options' => ['title' => 'Krajee Report Title'],
  105. // call mPDF methods on the fly
  106. /*'methods' => [
  107. 'SetHeader'=>['Commandes du '.$date_str],
  108. 'SetFooter'=>['{PAGENO}'],
  109. ]*/
  110. ]);
  111. // return the pdf output as per the destination setting
  112. return $pdf->render();
  113. }
  114. }