|
- <?php
-
- namespace backend\controllers;
-
- use Yii;
- use common\models\User;
- use yii\data\ActiveDataProvider;
- use yii\web\Controller;
- use yii\web\NotFoundHttpException;
- use yii\filters\VerbFilter;
- use yii\filters\AccessControl;
- use kartik\mpdf\Pdf;
-
- /**
- * UserController implements the CRUD actions for User model.
- */
- class CommuniquerController extends BackendController
- {
- public function behaviors()
- {
- return [
- 'verbs' => [
- 'class' => VerbFilter::className(),
- 'actions' => [
- 'delete' => ['post'],
- ],
- ],
- 'access' => [
- 'class' => AccessControl::className(),
- 'rules' => [
- [
- 'allow' => true,
- 'roles' => ['@'],
- 'matchCallback' => function ($rule, $action) {
- return Yii::$app->user->identity->status == USER::STATUS_ADMIN
- || Yii::$app->user->identity->status == USER::STATUS_BOULANGER;
- }
- ]
- ],
- ],
- ];
- }
-
- public function actionIndex()
- {
- return $this->render('index') ;
- }
-
- public function actionAffiche()
- {
-
- // get your HTML raw content without any layouts or scripts
- $content = $this->renderPartial('affiche',[
-
- ]);
-
- $pdf = new Pdf([
- // set to use core fonts only
- 'mode' => Pdf::MODE_UTF8,
- // A4 paper format
- 'format' => Pdf::FORMAT_A4,
- // portrait orientation
- 'orientation' => Pdf::ORIENT_LANDSCAPE,
- // stream to browser inline
- 'destination' => Pdf::DEST_BROWSER,
- // your html content input
- 'content' => $content,
- // format content from your own css file if needed or use the
- // enhanced bootstrap css built by Krajee for mPDF formatting
- //'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css',
- // any css to be embedded if required
- //'cssInline' => '.kv-heading-1{font-size:18px}',
- // set mPDF properties on the fly
- //'options' => ['title' => 'Krajee Report Title'],
- // call mPDF methods on the fly
-
- /*'methods' => [
- 'SetHeader'=>['Commandes du '.$date_str],
- 'SetFooter'=>['{PAGENO}'],
- ]*/
- ]);
-
- // return the pdf output as per the destination setting
- return $pdf->render();
-
- }
-
- public function actionModeemploi()
- {
-
- // get your HTML raw content without any layouts or scripts
- $content = $this->renderPartial('mode_emploi_multi',[
- 'pdf' => true
- ]);
-
- $pdf = new Pdf([
- // set to use core fonts only
- 'mode' => Pdf::MODE_UTF8,
- // A4 paper format
- 'format' => Pdf::FORMAT_A4,
- // portrait orientation
- 'orientation' => Pdf::ORIENT_PORTRAIT,
- // stream to browser inline
- 'destination' => Pdf::DEST_BROWSER,
- // your html content input
- 'content' => $content,
- 'marginRight' => 0,
- 'marginLeft' => 0,
- 'marginTop' => 0,
- 'marginBottom' => 0,
- // format content from your own css file if needed or use the
- // enhanced bootstrap css built by Krajee for mPDF formatting
- //'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css',
- 'cssFile' => '@app/web/css/screen.css',
- // any css to be embedded if required
- //'cssInline' => '.kv-heading-1{font-size:18px}',
- // set mPDF properties on the fly
- //'options' => ['title' => 'Krajee Report Title'],
- // call mPDF methods on the fly
-
- /*'methods' => [
- 'SetHeader'=>['Commandes du '.$date_str],
- 'SetFooter'=>['{PAGENO}'],
- ]*/
- ]);
-
- // return the pdf output as per the destination setting
- return $pdf->render();
-
- }
-
- }
|