No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

87 líneas
2.9KB

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