| Current Path : /var/www/html/eform/frontend/controllers/ |
| Current File : /var/www/html/eform/frontend/controllers/SiteController.php |
<?php
namespace frontend\controllers;
use Yii;
use yii\filters\AccessControl;
use yii\filters\VerbFilter;
use yii\web\Controller;
use kartik\mpdf\Pdf;
use backend\modules\fruserdynav2\models\FrontendUser;
/**
* Site controller
*/
class SiteController extends Controller
{
/** * system parameter * */
public $DYNAWEB_DEFAULT_ROUTE_PAGE;
public $DYNAWEB_DEFAULT_ROUTE_PARAMS;
/**
* {@inheritDoc}
* @see \yii\web\Controller::beforeAction()
*/
public function beforeAction($action)
{
// $this->layout = 'main_default';
// TODO Auto-generated method stub
return parent::beforeAction($action);
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['logout', 'signup', 'error', 'stub'],
'rules' => [
[
'actions' => ['signup', 'error', 'stub'],
'allow' => true,
'roles' => ['?'],
],
[
'actions' => ['logout', 'error', 'getstaffdetails'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
],
];
}
public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
'captcha' => [
'class' => 'yii\captcha\CaptchaAction',
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
],
];
}
public function actionIndex($frontendpage = null, $params = null)
{
$this->DYNAWEB_DEFAULT_ROUTE_PAGE = $frontendpage;
$this->DYNAWEB_DEFAULT_ROUTE_PARAMS = $params;
return $this->render('index');
}
public function actionPage()
{
return $this->render('page'); // placeholder
}
public function actionLogout()
{
Yii::$app->user->logout();
return $this->goHome();
}
public function actionError()
{
$exception = Yii::$app->errorHandler->exception;
if ($exception !== null) {
return $exception->getMessage();
}
}
public function actionViewpdf($doc_id)
{
if (($model = \common\models\CourseDocument::findOne($doc_id)) !== null) {
$pdf = new Pdf([
'mode' => Pdf::MODE_BLANK,
'filename' => $model->doc_title . '.pdf',
'format' => Pdf::FORMAT_A4,
'orientation' => Pdf::ORIENT_PORTRAIT,
'destination' => Pdf::DEST_DOWNLOAD,
'content' => $model->doc_content,
]);
return $pdf->render();
}
}
public function actionTranslate($language)
{
$cookies = Yii::$app->response->cookies;
Yii::$app->language = $language;
$cookies->add(new \yii\web\Cookie([
'name' => 'language',
'value' => $language
]));
return $this->redirect(Yii::$app->request->referrer ?: Yii::$app->homeUrl);
}
public function actionGetstaffdetails($id)
{
/**
$output = '';
$model = FrontendUser::findOne(['staff_no' => $id]);
if (!empty($model)) {
$output .= $model->fullname . '<->' .
$model->dept . '<->' .
$model->unit . '<->' .
$model->position . '<->' .
date("d/m/Y", strtotime($model->date_join)) . '<->' .
$model->tel_no . '<->' .
$model->mobile_no . '<->' .
$model->address1 . ' ' . $model->address2 . ' ' . $model->address3 . ' ' . $model->postcode . ' ' . $model->city . ' ' . \backend\modules\refdynawebv2\models\Ref::getDesc('STATE', $model->state) . '<->' .
\backend\modules\refdynawebv2\models\Ref::getDesc('MARITAL_STATUS', $model->marital_status) . '<->' .
$model->total_children;
}
**/
$output = '';
$model = \frontend\models\StaffInfo::findOne(['StaffNo' => $id]);
if (!empty($model)) {
$output .= $model->StaffName . '<->' .
$model->department->Name . '<->' .
$model->unit->Name . '<->' .
$model->positions->Name . '<->' .
date("d/m/Y", strtotime($model->JoinDate)) . '<->' .
$model->PermTelNo . '<->' .
$model->CorrTelNo . '<->' .
$model->CorrAddress . '<->' .
// $model->address1 . ' ' . $model->address2 . ' ' . $model->address3 . ' ' . $model->postcode . ' ' . $model->city . ' ' . \backend\modules\refdynawebv2\models\Ref::getDesc('STATE', $model->state) . '<->' .
//\backend\modules\refdynawebv2\models\Ref::getDesc('MARITAL_STATUS', $model->marital_status) . '<->' .
//$model->total_children
'NA' . '<->' .
'NA' ;
}
return $output;
}
}