Your IP : 216.73.216.79


Current Path : /var/www/html/ekursus/backend/controllers/
Upload File :
Current File : /var/www/html/ekursus/backend/controllers/ApplicationController.php

<?php

namespace backend\controllers;

use Yii;
use backend\models\Application;
use backend\models\ApplicationSearch;
use backend\models\course\Course;
use backend\models\contractor\Contractor;
use backend\models\contractorstaff\ContractorStaff;
use backend\models\timetable\Timetable;
use backend\models\Trainee;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use mPDF;
use kartik\mpdf\Pdf;
use yii\web\UploadedFile;
use yii\filters\AccessControl;
use common\components\AccessRule;

/**
 * ApplicationController implements the CRUD actions for Application model.
 */
class ApplicationController extends Controller
{
    /**
     * {@inheritdoc}
     */
    public function behaviors()
    {
        return [
            'access' => [
                'class' => AccessControl::className(),
                'ruleConfig' => [
                    'class' => AccessRule::className(),
                ],
                'rules' => [
                    [
                        'actions' => ['index', 'upload', 'index1', 'index2', 'index3', 'index4', 'check', 'view', 'create', 'create1', 'create2', 'create3', 'perform-ajax-validation', 'update', 'update1', 'update2', 'pdf1', 'pdf11', 'pdf2', 'pdf3', 'pdf4', 'pdfhq1', 'pdfhq2', 'pdfhq3', 'pdfhari1', 'pdfhqhari2', 'delete', 'view-peserta'],
                        'allow' => true,
                        'roles' => ['@'],
                    ],
                ],
            ],
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'delete' => ['POST'],
                ],
            ],
        ];
    }

    /**
     * Lists all Application models.
     * @return mixed
     */
    public function actionIndex()
    {
        $searchModel = new ApplicationSearch();
        $dataProvider = $searchModel->search1(Yii::$app->request->queryParams);

        return $this->render('index', [
            'searchModel' => $searchModel,
            'dataProvider' => $dataProvider,
        ]);
    }

    public function actionUpload($kod_jadual)
    {
        $model = new Application();

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['upload', 'kod_jadual' => $model->kod_jadual]);
        }

        return $this->render('upload', [
            'model' => $model,
        ]);
    }


    public function actionIndex1($kod_jadual)
    {
        $searchModel = new ApplicationSearch();
        $dataProvider = $searchModel->search1(Yii::$app->request->queryParams);

        return $this->render('index1', [
            'searchModel' => $searchModel,
            // 'kod_jadual' => $kod_jadual,
            'dataProvider' => $dataProvider,
        ]);
    }


    public function actionIndex2()
    {
        $username = filter_var($username, FILTER_SANITIZE_STRING);

        $searchModel = new ApplicationSearch();
        $dataProvider = $searchModel->search2(Yii::$app->request->queryParams);

        return $this->render('index2', [
            'searchModel' => $searchModel,
            'dataProvider' => $dataProvider,
        ]);
    }

    public function actionIndex3($kod_jadual)
    {
        $searchModel = new ApplicationSearch();
        $dataProvider = $searchModel->search1(Yii::$app->request->queryParams);

        return $this->render('index3', [
            'searchModel' => $searchModel,
            'kod_jadual' => $kod_jadual,
            'dataProvider' => $dataProvider,
        ]);
    }

    public function actionIndex4($no_spkk)
    {
        $searchModel = new ApplicationSearch();
        $dataProvider = $searchModel->search3(Yii::$app->request->queryParams);

        return $this->render('index4', [
            'searchModel' => $searchModel,
            'no_spkk' => $no_spkk,
            'dataProvider' => $dataProvider,
        ]);
    }

    public function actionViewPeserta($kod_jadual)
    {
        $searchModel = new ApplicationSearch();
        $dataProvider = $searchModel->search1(Yii::$app->request->queryParams);

        return $this->render('view_peserta', [
            'searchModel' => $searchModel,
            'dataProvider' => $dataProvider,
        ]);
    }

    /**
     * Displays a single Application model.
     * @param integer $id
     * @return mixed
     * @throws NotFoundHttpException if the model cannot be found
     */
    public function actionView($id)
    {
        return $this->render('view', [
            'model' => $this->findModel($id),
        ]);
    }

    /**
     * Creates a new Application model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
    public function actionCreate()
    {
        $model = new Application();

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['update', 'id' => $model->id]);
        }

        return $this->render('create', [
            'model' => $model,
        ]);
    }

    public function actionCreate1($kod_jadual, $fnegeri, $fkursus, $flokasi, $fmula, $ftamat)
    {
        $kod_jadual = filter_var($kod_jadual, FILTER_SANITIZE_STRING);
        $fnegeri = filter_var($fnegeri, FILTER_SANITIZE_STRING);
        $fkursus = filter_var($fkursus, FILTER_SANITIZE_STRING);
        $flokasi = filter_var($flokasi, FILTER_SANITIZE_STRING);
        $fmula = filter_var($fmula, FILTER_SANITIZE_STRING);
        $ftamat = filter_var($ftamat, FILTER_SANITIZE_STRING);

        $model = new Application();

        $_GET['kod_jadual'];
        $id = Yii::$app->user->identity->staff->id;
        $staff = \backend\models\Staff::findOne($id);
        $user = \common\models\User::findOne($staff->userid);
        $timetable = Timetable::findOne($id);
        $contractorstaff = ContractorStaff::find()->where(['no_spkk' => $user->username])->all();
        $course = Course::findOne($id);
        $model->kod_jadual = $_GET['kod_jadual'];
        $model->no_spkk = $user->username;
        $model->status_mohon = 'P';

        if ($model->load(Yii::$app->request->post())) {
            if ($model->save(false)) {
                $trainee = new Trainee();
                // $trainee->no_kp = $contractorstaff->no_kp;

                $nama = ContractorStaff::find()->where(['contractor_staff_id' => $_POST['staff']])->one();
                $trainee->nama_peserta = $nama->contractor_staff_name;
                $trainee->no_kp = $nama->no_kp;
                $trainee->no_tel = $nama->no_tel_bimbit;
                $trainee->jantina = $nama->kod_jantina;
                $trainee->jawatan = $nama->jawatan;
                $trainee->kod_permohonan = $model->id;
                $trainee->kod_jadual = $model->kod_jadual;
                //   echo $trainee->no_kp; exit;
                $trainee->save(false);
                yii::$app->session->setFlash('success', 'Permohonan anda telah dihantar. Sila semak status permohonan');

                return $this->redirect(['trainee/index5']);
            }
        }

        return $this->render('create1', [
            'model' => $model,
        ]);
    }

    public function actionCreate2($kod_jadual)
    {
        $model = new Application();
        $model->scenario = 'managePeserta';

        // validate any AJAX requests fired off by the form
        // if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
        // Yii::$app->response->format = Response::FORMAT_JSON;
        // return ActiveForm::validate($model);
        // }

        if ($model->load(Yii::$app->request->post())) {

            $_GET['kod_jadual'];
            $id = Yii::$app->user->identity->staff->id;
            $staff = \backend\models\Staff::findOne($id);
            $user = \common\models\User::findOne($staff->userid);
            $timetable = Timetable::findOne($id);
            $course = Course::findOne($id);
            $contractor = Contractor::find()->where(['no_spkk' => $user->username])->all();
            $nama = Contractor::find()->where(['no_spkk' => $_POST['contractor']])->one();
            $model->kod_jadual = $_GET['kod_jadual'];
            $model->no_spkk;
            $model->status_mohon = 'D';
            //        echo '<pre>';
            // print_r($model);
            // echo '</pre>';exit();
            if ($model->save(false)) {
                $trainee = new Trainee();
                $trainee->kod_permohonan = $model->id;
                $trainee->kod_jadual = $_GET['kod_jadual'];
                $trainee->nama_peserta = $model->nama_peserta;
                $trainee->no_kp = $model->nombor_kad_pengenalan;
                $trainee->jawatan = $model->jawatan;
                $trainee->jantina = $model->jantina;
                $trainee->no_tel = $model->nombor_telefon;
                if ($trainee->save(false)) {

                    yii::$app->session->setFlash('success', 'Permohonan anda telah dihantar. Sila semak status permohonan');

                    return $this->redirect(['application/index1', 'kod_jadual' => $_GET['kod_jadual']]);
                }
            }
        }

        return $this->render('create2', [
            'model' => $model,
        ]);
    }


    protected function performAjaxValidation($model)

    {

        if (isset($_POST['ajax']) && $_POST['ajax'] === 'result-form') {

            $model->validate();

            Yii::app()->end();
        }
    }


    public function actionCreate3($kod_jadual)
    {
        $model = new \backend\models\FileApplicantTrainee();

        if ($model->load(Yii::$app->request->post())) {
            if ($model->validate()) {

                $model->file_applicant_trainee_csv = UploadedFile::getInstance($model, 'file_applicant_trainee_csv');

                if (!empty($model->file_applicant_trainee_csv)) {
                    $filename = $model->file_applicant_trainee_csv->name;
                    $upload = $model->file_applicant_trainee_csv->saveAs('uploads/' . $filename);
                    $model->file_applicant_trainee_csv = $filename;
                }
                $model->save(false);

                $file_applicant_trainee_id = $model->file_applicant_trainee_id;

                if ($upload) {
                    define('CSV_PATH', 'uploads/');
                    $csv_file = CSV_PATH . $filename;

                    $filecsv = file($csv_file);
                    // $filecsvtemp = file($csv_file);
                    // $filecsv = array_shift($filecsvtemp );

                    $id = Yii::$app->db->createCommand("SELECT id FROM application ORDER BY id DESC LIMIT 1")->queryOne();

                    if ($id) {
                        $id = $id['id'] + 1;
                    } else {
                        $id = 1;
                    }

                    $i = 0;
                    foreach ($filecsv as $data) {
                        $modelnew = new Application();
                        $hasil = explode(",", $data);

                        if ($i == 0) {
                            $i++;
                            continue;
                        }
                        $kod_jadual = $hasil[0];
                        $no_spkk = $hasil[1];
                        $perakuan = $hasil[2];
                        $status_mohon = $hasil[3];
                        $sebab = $hasil[4];
                        $no_siri_sijil = $hasil[5];
                        $kedatangan = $hasil[6];
                        $tkh_mohon = $hasil[7];
                        $surat_rujukan = $hasil[8];
                        $tkh_surat = $hasil[9];


                        $modelnew->id = $id;
                        $modelnew->kod_jadual = $kod_jadual;
                        $modelnew->no_spkk = $no_spkk;
                        $modelnew->perakuan = $perakuan;
                        $modelnew->status_mohon = $status_mohon;
                        $modelnew->sebab = $sebab;
                        $modelnew->no_siri_sijil = $no_siri_sijil;
                        $modelnew->kedatangan_dok = $kedatangan_dok;
                        $modelnew->tkh_mohon = $tkh_mohon;
                        $modelnew->surat_rujukan = $surat_rujukan;
                        $modelnew->tkh_surat = $tkh_surat;

                        // echo '<pre>';
                        // print_r($modelnew);
                        // echo '</pre>';
                        // exit();

                        $modelnew->save(false);

                        $id++;

                        // $cnt++;
                    }
                    // $cnt++;
                }
                Yii::$app->session->setFlash('success', Yii::t('app', 'Senarai data berjaya di muatnaik.'));

                return $this->redirect(['index', 'kod_jadual' => $_GET['kod_jadual']]);
            }
        }

        return $this->render('create3', ['model' => $model]);
    }


    /**
     * Updates an existing Application model.
     * If update is successful, the browser will be redirected to the 'view' page.
     * @param integer $id
     * @return mixed
     * @throws NotFoundHttpException if the model cannot be found
     */
    public function actionUpdate($id, $kod_jadual)
    {
        $model = $this->findModel($id);

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['update', 'id' => $model->id, 'kod_jadual' => $kod_jadual]);
        }

        return $this->render('update', [
            'model' => $model,
            'kod_jadual' => $kod_jadual,
        ]);
    }


    public function actionUpdate1($id)
    {
        $model = $this->findModel($id);

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['update1', 'id' => $model->id]);
        }

        return $this->render('update1', [
            'model' => $model,
        ]);
    }

    public function actionUpdate2($id)
    {
        $model = $this->findModel($id);

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['index', 'kod_jadual' => $_GET['kod_jadual']]);
        }

        return $this->render('update2', [
            'model' => $model,
        ]);
    }

    public function actionPdf1($kod_permohonan)
    {
        // get your HTML raw content without any layouts or scripts
        $content = $this->renderPartial('pdf_sijil');

        // setup kartik\mpdf\Pdf component
        $pdf = new Pdf([
            // set to use core fonts only
            'mode' => Pdf::MODE_CORE,
            // 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,
            // 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' => [''],
                'SetFooter' => [''],
            ]
        ]);

        // return the pdf output as per the destination setting
        return $pdf->render();
    }

    public function actionPdf11($kod_permohonan)
    {
        // get your HTML raw content without any layouts or scripts
        $content = $this->renderPartial('pdf_sijillebihhari');

        // setup kartik\mpdf\Pdf component
        $pdf = new Pdf([
            // set to use core fonts only
            'mode' => Pdf::MODE_CORE,
            // 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,
            // 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' => [''],
                'SetFooter' => [''],
            ]
        ]);

        // return the pdf output as per the destination setting
        return $pdf->render();
    }

    public function actionPdf2($kod_permohonan)
    {
        // get your HTML raw content without any layouts or scripts
        $content = $this->renderPartial('pdf_tawaran');

        // setup kartik\mpdf\Pdf component
        $pdf = new Pdf([
            // set to use core fonts only
            'mode' => Pdf::MODE_CORE,
            // 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,
            // 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' => [''],
                'SetFooter' => [''],
            ]
        ]);

        // return the pdf output as per the destination setting
        return $pdf->render();
    }

    public function actionPdf3($kod_permohonan)
    {
        // get your HTML raw content without any layouts or scripts
        $content = $this->renderPartial('pdf_tolak');

        // setup kartik\mpdf\Pdf component
        $pdf = new Pdf([
            // set to use core fonts only
            'mode' => Pdf::MODE_CORE,
            // 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,
            // 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' => [''],
                'SetFooter' => [''],
            ]
        ]);

        // return the pdf output as per the destination setting
        return $pdf->render();
    }

    public function actionPdf4($kod_permohonan)
    {
        // get your HTML raw content without any layouts or scripts
        $content = $this->renderPartial('pdf_amaran');

        // setup kartik\mpdf\Pdf component
        $pdf = new Pdf([
            // set to use core fonts only
            'mode' => Pdf::MODE_CORE,
            // 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,
            // 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' => [''],
                'SetFooter' => [''],
            ]
        ]);

        // return the pdf output as per the destination setting
        return $pdf->render();
    }

    public function actionPdfhq1($kod_permohonan)
    {
        // get your HTML raw content without any layouts or scripts
        $content = $this->renderPartial('pdf_tawaranhq');

        // setup kartik\mpdf\Pdf component
        $pdf = new Pdf([
            // set to use core fonts only
            'mode' => Pdf::MODE_CORE,
            // 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,
            // 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' => [''],
                'SetFooter' => [''],
            ]
        ]);

        // return the pdf output as per the destination setting
        return $pdf->render();
    }

    public function actionPdfhq2($kod_permohonan)
    {
        // get your HTML raw content without any layouts or scripts
        $content = $this->renderPartial('pdf_tolakhq');

        // setup kartik\mpdf\Pdf component
        $pdf = new Pdf([
            // set to use core fonts only
            'mode' => Pdf::MODE_CORE,
            // 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,
            // 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' => [''],
                'SetFooter' => [''],
            ]
        ]);

        // return the pdf output as per the destination setting
        return $pdf->render();
    }


    public function actionPdfhq3($kod_permohonan)
    {
        // get your HTML raw content without any layouts or scripts
        $content = $this->renderPartial('pdf_amaranhq');

        // setup kartik\mpdf\Pdf component
        $pdf = new Pdf([
            // set to use core fonts only
            'mode' => Pdf::MODE_CORE,
            // 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,
            // 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' => [''],
                'SetFooter' => [''],
            ]
        ]);

        // return the pdf output as per the destination setting
        return $pdf->render();
    }

    public function actionPdfhari1($kod_permohonan)
    {
        // get your HTML raw content without any layouts or scripts
        $content = $this->renderPartial('pdf_tawaranlebihhari');

        // setup kartik\mpdf\Pdf component
        $pdf = new Pdf([
            // set to use core fonts only
            'mode' => Pdf::MODE_CORE,
            // 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,
            // 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' => [''],
                'SetFooter' => [''],
            ]
        ]);

        // return the pdf output as per the destination setting
        return $pdf->render();
    }


    public function actionPdfhqhari2($kod_permohonan)
    {
        // get your HTML raw content without any layouts or scripts
        $content = $this->renderPartial('pdf_tawaranhqlebihhari');

        // setup kartik\mpdf\Pdf component
        $pdf = new Pdf([
            // set to use core fonts only
            'mode' => Pdf::MODE_CORE,
            // 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,
            // 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' => [''],
                'SetFooter' => [''],
            ]
        ]);

        // return the pdf output as per the destination setting
        return $pdf->render();
    }

    /**
     * Deletes an existing Application model.
     * If deletion is successful, the browser will be redirected to the 'index' page.
     * @param integer $id
     * @return mixed
     * @throws NotFoundHttpException if the model cannot be found
     */
    public function actionDelete($id, $kod_jadual)
    {
        $this->findModel($id)->delete();
        yii::$app->session->setFlash('success', 'Data peserta berjaya dihapuskan');
        return $this->redirect(['index1', 'kod_jadual' => $_GET['kod_jadual']]);
    }

    /**
     * Finds the Application model based on its primary key value.
     * If the model is not found, a 404 HTTP exception will be thrown.
     * @param integer $id
     * @return Application the loaded model
     * @throws NotFoundHttpException if the model cannot be found
     */
    protected function findModel($id)
    {
        if (($model = Application::findOne($id)) !== null) {
            return $model;
        }

        throw new NotFoundHttpException(Yii::t('app', 'The requested page does not exist.'));
    }
}