Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

102 lines
3.1KB

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