| Current Path : /var/www/html/brspace/frontend/controllers/ |
| Current File : /var/www/html/brspace/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 yii\helpers\ArrayHelper;
use backend\modules\contentDownloads\models\ContentDownloads;
use backend\modules\contentDownloads\models\ContentDownloadsAppendix;
use yii\helpers\Html;
use backend\modules\fruserdynav2\models\FrontendUser;
class SiteController extends Controller {
public $DYNAWEB_DEFAULT_ROUTE_PAGE;
public $DYNAWEB_DEFAULT_ROUTE_PARAMS;
public function beforeAction($action) {
return parent::beforeAction($action);
}
public function behaviors() {
return [
'access' => [
'class' => AccessControl::className(),
'only' => ['logout', 'signup', 'error', 'stub'],
'rules' => [
[
'actions' => ['signup', 'error', 'stub'],
'allow' => true,
'roles' => ['?'],
],
[
'actions' => ['logout', 'error', 'logoutbsn'],
'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 actionLogoutbsn() {
Yii::$app->user->logout();
return $this->redirect(['bsn/e-guide']);
}
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 actionGetsubcategory($code) {
$parent_id = \backend\modules\refdynawebv2\models\Ref::getparentid($code, 'DOWNLOAD_CATEGORY');
$output = Html::dropDownList('upload-subcategory', null,
ArrayHelper::map((new \yii\db\Query())
->from('ref')
->where(['=', 'cat', 'DOWNLOAD_CATEGORY'])
->andwhere(['=', 'param1', $parent_id])
->orderBy(['descr' => SORT_ASC])
->all(), 'code', 'descr'), ['prompt' => '-- Please choose --', 'class' => 'form-select']);
return $output;
}
public function actionGetoperationalprocedureadmin($cat, $keyword, $search_index, $search_name, $search_aka, $sortsubcategory, $search_category, $search_subcategory, $sortrevisiondate) {
$content = '';
$parent_id = \backend\modules\refdynawebv2\models\Ref::getparentid($cat, 'DOWNLOAD_CATEGORY');
$cat_query = \backend\modules\refdynawebv2\models\Ref::find()
->where(['cat' => 'DOWNLOAD_CATEGORY'])
->andwhere(['=', 'param1', $parent_id]);
if (!empty($search_subcategory)) {
$cat_query->andwhere(['LIKE', 'descr', $search_subcategory]);
}
if ($sortsubcategory == 'down')
$cat_query->orderby(['descr' => SORT_DESC]);
else if ($sortsubcategory == 'up')
$cat_query->orderby(['descr' => SORT_ASC]);
else
$cat_query->orderBy(['sort' => SORT_ASC]);
$cat_arr = ArrayHelper::map($cat_query->all(), 'code', 'descr');
if (!empty($cat_arr)) {
foreach ($cat_arr as $cat_code => $cat_label) {
$query = new \yii\db\Query();
$query->from('content_downloads')
->where(['=', 'download_status', 'active'])
->andwhere(['=', 'download_category', $cat_code]);
if (!empty($keyword)) {
$query->andwhere(['OR',
['LIKE', 'download_version', $keyword],
['LIKE', 'download_title', $keyword],
['LIKE', 'download_descr', $keyword]
]);
}
if (!empty($search_index)) {
$query->andwhere(['LIKE', 'download_version', $search_index]);
}
if (!empty($search_name)) {
$query->andwhere(['LIKE', 'download_title', $search_name]);
}
if (!empty($search_aka)) {
$query->andwhere(['LIKE', 'download_descr', $search_aka]);
}
$total = $query->count();
if ($total > 0) {
$content .= '<table border="0" cellpadding="5" cellspacing="0" width="97%">
<tr>
<td width="10%"></td>
<td>
<p>
<a href="#" onclick="opencontentadmin2(\'' . $cat_code . '\')" style="color:black;">
<b>' . strtoupper((string) $cat_label) . '</b>
</a> (' . $total . ')
</p>
</td>
</tr>
</table>
<div class="content content-' . $cat_code . '"></div>
<input type="hidden" value="' . $cat_code . '" class="tab-name-' . $cat . '">';
}
}
}
return $content;
}
public function actionGetoperationalprocedureapproval($cat) {
$content = '';
$parent_id = \backend\modules\refdynawebv2\models\Ref::getparentid($cat, 'DOWNLOAD_CATEGORY');
$cat_arr = ArrayHelper::map(\backend\modules\refdynawebv2\models\Ref::find()
->where(['cat' => 'DOWNLOAD_CATEGORY'])
->andwhere(['=', 'param1', $parent_id])
->orderBy(['sort' => SORT_ASC])->all(), 'code', 'descr');
if (!empty($cat_arr)) {
foreach ($cat_arr as $cat_code => $cat_label) {
$query = new \yii\db\Query();
$query->from('upload')
->where(['=', 'upload_type', 'operational-procedure'])
->andwhere(['=', 'upload_subcategory', $cat_code]);
$total = $query->count();
$content .= '<p style="padding-left:20px;">
<a href="#" onclick="opencontent2(\'' . $cat_code . '\')" style="color:black;">
Sub-Category : <b>' . strtoupper((string) $cat_label) . '</b>
</a> (' . $total . ')
</p>
<div class="content content-' . $cat_code . '"></div>';
}
}
return $content;
}
public function actionGetoperationalprocedureadmin2($cat, $sortindex, $sortname, $sortaka, $keyword, $search_index, $search_name, $search_aka, $sortrevisiondate, $sortstatus) {
$content = '<table border="0" cellpadding="5" cellspacing="0" width="97%">';
$query = new \yii\db\Query();
$query->from('content_downloads')
->where(['=', 'download_status', 'active'])
->andwhere(['=', 'download_category', $cat]);
if (!empty($keyword)) {
$query->andwhere(['OR',
['LIKE', 'download_version', $keyword],
['LIKE', 'download_title', $keyword],
['LIKE', 'download_descr', $keyword]
]);
}
if (!empty($search_index)) {
$query->andwhere(['LIKE', 'download_version', $search_index]);
}
if (!empty($search_name)) {
$query->andwhere(['LIKE', 'download_title', $search_name]);
}
if (!empty($search_aka)) {
$query->andwhere(['LIKE', 'download_descr', $search_aka]);
}
if ($sortindex == 'down')
$query->orderby(['download_version' => SORT_DESC]);
if ($sortindex == 'up')
$query->orderby(['download_version' => SORT_ASC]);
if ($sortname == 'down')
$query->orderby(['download_title' => SORT_DESC]);
if ($sortname == 'up')
$query->orderby(['download_title' => SORT_ASC]);
if ($sortaka == 'down')
$query->orderby(['download_descr' => SORT_DESC]);
if ($sortaka == 'up')
$query->orderby(['download_descr' => SORT_ASC]);
///' . $row['download_file'] . '
if ($sortrevisiondate == 'down')
$query->orderby(['revision_date' => SORT_DESC]);
if ($sortrevisiondate == 'up')
$query->orderby(['revision_date' => SORT_ASC]);
if ($sortstatus == 'down')
$query->orderby(['approval_status' => SORT_DESC]);
if ($sortstatus == 'up')
$query->orderby(['approval_status' => SORT_ASC]);
$model = $query->all();
if (!empty($model)) {
foreach ($model as $row) {
$revision_date = '';
if (!empty($row['revision_date'])) {
$now = time();
$rev_date = strtotime($row['revision_date']);
$datediff = $now - $rev_date;
$datediff2 = round($datediff / (60 * 60 * 24));
$revision_class = '';
if ($datediff2 < 365)
$revision_class = 'revision-green';
else if ($datediff2 >= 365 && $datediff2 <= 730)
$revision_class = 'revision-blue';
else if ($datediff2 > 730)
$revision_class = 'revision-orange';
$revision_date = '<span class="' . $revision_class . '">' . date("d-M-Y", strtotime($row['revision_date'])) . '</span>';
}
//if (!empty($row['revision_date']))
// $revision_date = date("d-M-Y", strtotime($row['revision_date']));
$status_label = \backend\modules\refdynawebv2\models\Ref::getDesc('APPROVAL_STATUS', $row['approval_status'], 'other_param');
$content .= '<tr>
<td width="10%"></td>
<td width="10%"></td>
<td width="10%" style="vertical-align:top;text-align:center;">' . strtoupper((string) $row['download_version']) . '</td>
<td style="vertical-align:top;"><a href="/web/operational-procedure-loggedin-details?id=' . $row['download_id'] . '">' . strtoupper((string) $row['download_title']) . '</a></td>
<td width="20%" style="vertical-align:top;text-align:center;">' . strtoupper((string) $row['download_descr']) . '</td>
<!--<td width="10%" style="vertical-align:top;text-align:center;"><a href="#" onclick="displayappendix(' . $row['download_id'] . ')">' . strtoupper((string) $row['download_version']) . '</a></td>-->
<td width="15%" style="vertical-align:top;text-align:center;">' . $revision_date . '</td>
<td width="15%" style="text-align:center;vertical-align:top;"><span class="' . $row['approval_status'] . '">' . $status_label . '</span></td>
<td width="5%" style="vertical-align:top;text-align:center;"><a href="#" onclick="displayversion(' . $row['download_id'] . ')"><img src="/portalassets/icon/more.png"></a></td>
<td width="25%" style="vertical-align:top;">';
/* if (!empty($row['created_at'])) {
$content .= '<div>Created date : ' . date("d-M-Y (H:i:s)", strtotime($row['created_at'])) . '</div>';
if (!empty($row['created_by']))
$content .= '<div>Created by : ' . \backend\modules\contentDownloads\models\ContentDownloads::getcreatename($row['download_id']) . '</div>';
if (!empty($row['approval_status']))
$content .= '<div>Status : <span class="' . $row['approval_status'] . '">' . \backend\modules\refdynawebv2\models\Ref::getDesc('APPROVAL_STATUS', $row['approval_status']) . '</span></div>';
$content .= '<br>';
}
if (!empty($row['updated_at'])) {
$content .= '<div>Modified date : ' . date("d-M-Y (H:i:s)", strtotime($row['updated_at'])) . '</div>';
if (!empty($row['updated_by']))
$content .= '<div>Modified by : ' . \backend\modules\contentDownloads\models\ContentDownloads::getupdatename($row['download_id']) . '</div>';
if (!empty($row['approval_status']))
$content .= '<div>Status : <span class="' . $row['approval_status'] . '">' . \backend\modules\refdynawebv2\models\Ref::getDesc('APPROVAL_STATUS', $row['approval_status']) . '</span></div>';
$content .= '<br>';
} */
/*
$approved_at = '';
$approved_by = '';
if ($row['approval_status'] == 'draft' || $row['approval_status'] == 'pending') {
$approved_at = date("d-M-Y", strtotime($row['created_at']));
$approved_by = \backend\modules\contentDownloads\models\ContentDownloads::getcreatename($row['download_id']);
}
if ($row['approval_status'] == 'rejected' || $row['approval_status'] == 'approved') {
if (!empty($row['approval_at'])) {
$approved_at = date("d-M-Y", strtotime($row['approval_at']));
$approved_by = \backend\modules\contentDownloads\models\ContentDownloads::getapprovename($row['download_id']);
} else {
if (!empty($row['updated_at'])) {
$approved_at = date("d-M-Y (H:i:s)", strtotime($row['updated_at']));
$approved_by = \backend\modules\contentDownloads\models\ContentDownloads::getupdatename($row['download_id']);
} else {
$approved_at = date("d-M-Y", strtotime($row['created_at']));
$approved_by = \backend\modules\contentDownloads\models\ContentDownloads::getcreatename($row['download_id']);
}
}
}
if ($row['approval_status'] == 'revert' || $row['approval_status'] == 'delete') {
if (!empty($row['updated_at'])) {
$approved_at = date("d-M-Y (H:i:s)", strtotime($row['updated_at']));
$approved_by = \backend\modules\contentDownloads\models\ContentDownloads::getupdatename($row['download_id']);
} else {
$approved_at = date("d-M-Y", strtotime($row['created_at']));
$approved_by = \backend\modules\contentDownloads\models\ContentDownloads::getcreatename($row['download_id']);
}
}
if ($row['approval_status'] == 'decommission') {
if (!empty($row['approval_decommission_at']))
$approved_at = date("d-M-Y (H:i:s)", strtotime($row['approval_decommission_at']));
if (!empty($row['approval_decommission_by']))
$approved_by = \backend\modules\fruserdynav2\models\FrontendUser::getname($row['approval_decommission_by']);
}
$status_label = \backend\modules\refdynawebv2\models\Ref::getDesc('APPROVAL_STATUS', $row['approval_status'], 'other_param');
$content .= '<div>Created date : ' . date("d-M-Y (H:i:s)", strtotime($row['created_at'])) . '</div>';
$content .= '<div>' . $status_label . ' date : ' . $approved_at . '</div>';
$content .= '<div>' . $status_label . ' by : ' . $approved_by . '</div>';
$content .= '<div>Status : <span class="' . $row['approval_status'] . '">' . $status_label . '</span></div>';
*/
if (!empty($row['updated_at']))
$modified_at = date("d-M-Y (H:i:s)", strtotime($row['updated_at']));
else
$modified_at = date("d-M-Y (H:i:s)", strtotime($row['created_at']));
if (!empty($row['updated_by']))
$modified_by = \backend\modules\contentDownloads\models\ContentDownloads::getupdatename($row['download_id']);
else
$modified_by = \backend\modules\contentDownloads\models\ContentDownloads::getcreatename($row['download_id']);
$content .= '<div>Created date : ' . date("d-M-Y (H:i:s)", strtotime($row['created_at'])) . '</div>';
$content .= '<div>Created by : ' . \backend\modules\contentDownloads\models\ContentDownloads::getcreatename($row['download_id']) . '</div>';
$content .= '<div>Last modified date : ' . $modified_at . '</div>';
$content .= '<div>Last modified by : ' . $modified_by . '</div>';
$content .= '</td>
</tr>';
}
}
$content .= '</table>';
return $content;
}
public function actionGetoperationalprocedureapproval2($cat) {
$content = '<table border="0" cellpadding="5" cellspacing="0" width="97%">';
$query = new \yii\db\Query();
$query->from('upload')
->where(['=', 'upload_type', 'operational-procedure'])
->andwhere(['=', 'upload_subcategory', $cat])
->orderby(['upload_id' => SORT_DESC]);
$model = $query->all();
if (!empty($model)) {
foreach ($model as $row) {
$content .= '<tr>
<td width="2%" style="vertical-align:top;"></td>
<td width="7%" style="vertical-align:top;"></td>
<td width="2%" style="vertical-align:top;"><img src="/portalassets/icon/pdf.png"></td>
<td width="10%" style="vertical-align:top;">' . strtoupper((string) \backend\modules\refdynawebv2\models\Ref::getDesc('DOWNLOAD_CATEGORY', $row['upload_subcategory'])) . '</td>
<td width="10%" style="vertical-align:top;">' . strtoupper((string) $row['upload_former']) . '</td>
<td width="17%" style="vertical-align:top;"><a href="/' . $row['upload_file'] . '" target="_blank">' . strtoupper((string) $row['upload_title']) . '</a></td>
<td width="2%" style="vertical-align:top;"><img src="/portalassets/icon/more.png"></td>
<td width="10%" style="vertical-align:top;">' . strtoupper((string) $row['upload_status']) . '</td>
<td width="10%" style="vertical-align:top;">' . date("d F, Y", strtotime($row['created_at'])) . '</td>
<td width="10%" style="vertical-align:top;">' . strtoupper((string) FrontendUser::getname($row['created_by'])) . '</td>
<td width="10%" style="vertical-align:top;">' . strtoupper((string) FrontendUser::getname($row['upload_approver'])) . '</td>
<td width="10%" style="vertical-align:top;">' . strtoupper((string) $row['upload_appendix']) . '</td>
</tr>';
}
}
$content .= '</table>';
return $content;
}
public function actionGetoperationalprocedure($cat, $keyword, $search_index, $search_name, $search_aka, $sortsubcategory, $search_category, $search_subcategory, $sortrevisiondate) {
$content = '';
$parent_id = \backend\modules\refdynawebv2\models\Ref::getparentid($cat, 'DOWNLOAD_CATEGORY');
$cat_query = \backend\modules\refdynawebv2\models\Ref::find()
->where(['cat' => 'DOWNLOAD_CATEGORY'])
->andwhere(['=', 'param1', $parent_id]);
if (!empty($search_subcategory)) {
$cat_query->andwhere(['LIKE', 'descr', $search_subcategory]);
}
if ($sortsubcategory == 'down')
$cat_query->orderby(['descr' => SORT_DESC]);
else if ($sortsubcategory == 'up')
$cat_query->orderby(['descr' => SORT_ASC]);
else
$cat_query->orderBy(['sort' => SORT_ASC]);
$cat_arr = ArrayHelper::map($cat_query->all(), 'code', 'descr');
if (!empty($cat_arr)) {
foreach ($cat_arr as $cat_code => $cat_label) {
$query = new \yii\db\Query();
$query->from('content_downloads')
->where(['=', 'download_status', 'active'])
->andwhere(['=', 'download_category', $cat_code]);
if (!empty($keyword)) {
$query->andwhere(['OR',
['LIKE', 'download_version', $keyword],
['LIKE', 'download_title', $keyword],
['LIKE', 'download_descr', $keyword]
]);
}
if (!empty($search_index)) {
$query->andwhere(['LIKE', 'download_version', $search_index]);
}
if (!empty($search_name)) {
$query->andwhere(['LIKE', 'download_title', $search_name]);
}
if (!empty($search_aka)) {
$query->andwhere(['LIKE', 'download_descr', $search_aka]);
}
$total = $query->count();
if ($total > 0) {
$content .= '<table border="0" cellpadding="5" cellspacing="0" width="97%">
<tr>
<td width="10%"></td>
<td>
<p>
<a href="#" onclick="opencontent2(\'' . $cat_code . '\')" style="color:black;">
<b>' . strtoupper((string) $cat_label) . '</b>
</a> (' . $total . ')
</p>
</td>
</tr>
</table>
<div class="content content-' . $cat_code . '"></div>
<input type="hidden" value="' . $cat_code . '" class="tab-name-' . $cat . '">';
}
}
}
return $content;
}
public function actionGetoperationalprocedure2($cat, $sortindex, $sortname, $sortaka, $keyword, $search_index, $search_name, $search_aka, $search_category, $search_subcategory, $sortmodifieddate, $sortrevisiondate) {
$content = '<table border="0" cellpadding="5" cellspacing="0" width="100%">';
$query = new \yii\db\Query();
$query->from('content_downloads')
->where(['=', 'download_status', 'active'])
->andwhere(['=', 'approval_status', 'approved'])
->andwhere(['=', 'download_category', $cat]);
if ($sortindex == 'down')
$query->orderby(['download_version' => SORT_DESC]);
if ($sortindex == 'up')
$query->orderby(['download_version' => SORT_ASC]);
if ($sortname == 'down')
$query->orderby(['download_title' => SORT_DESC]);
if ($sortname == 'up')
$query->orderby(['download_title' => SORT_ASC]);
if ($sortaka == 'down')
$query->orderby(['download_descr' => SORT_DESC]);
if ($sortaka == 'up')
$query->orderby(['download_descr' => SORT_ASC]);
if ($sortmodifieddate == 'down')
$query->orderby(['updated_at' => SORT_DESC]);
if ($sortmodifieddate == 'up')
$query->orderby(['updated_at' => SORT_ASC]);
if ($sortrevisiondate == 'down')
$query->orderby(['revision_date' => SORT_DESC]);
if ($sortrevisiondate == 'up')
$query->orderby(['revision_date' => SORT_ASC]);
if (!empty($keyword)) {
$query->andwhere(['OR',
['LIKE', 'download_version', $keyword],
['LIKE', 'download_title', $keyword],
['LIKE', 'download_descr', $keyword]
]);
}
if (!empty($search_index)) {
$query->andwhere(['LIKE', 'download_version', $search_index]);
}
if (!empty($search_name)) {
$query->andwhere(['LIKE', 'download_title', $search_name]);
}
if (!empty($search_aka)) {
$query->andwhere(['LIKE', 'download_descr', $search_aka]);
}
$model = $query->all();
if (!empty($model)) {
foreach ($model as $row) {
if (!empty($row['updated_at']))
$modified_date = date("d-M-Y", strtotime($row['updated_at']));
else
$modified_date = date("d-M-Y", strtotime($row['created_at']));
$revision_date = '';
if (!empty($row['revision_date'])) {
$revision_class = '';
/*
$diff_year = date('Y') - date("Y", strtotime($row['revision_date']));
if ($diff_year < 1)
$revision_class = 'revision-green';
if ($diff_year == 1 || $diff_year == 2)
$revision_class = 'revision-blue';
if ($diff_year > 2)
$revision_class = 'revision-orange'; */
$now = time();
$rev_date = strtotime($row['revision_date']);
$datediff = $now - $rev_date;
$datediff2 = round($datediff / (60 * 60 * 24));
if ($datediff2 < 365)
$revision_class = 'revision-green';
else if ($datediff2 >= 365 && $datediff2 <= 730)
$revision_class = 'revision-blue';
else if ($datediff2 > 730)
$revision_class = 'revision-orange';
$revision_date = '<span class="' . $revision_class . '">' . date("d-M-Y", strtotime($row['revision_date'])) . '</span>';
}
$content .= '<tr>
<td width="10%"></td>
<td width="10%"></td>
<td width="10%" style="vertical-align:top;text-align:center;">' . strtoupper((string) $row['download_version']) . '</td>
<td style="vertical-align:top;"><a href="/' . $row['download_file'] . '" target="_blank">' . strtoupper((string) $row['download_title']) . '</a></td>
<td width="20%" style="vertical-align:top;text-align:center;">' . strtoupper((string) $row['download_descr']) . '</td>
<td width="15%" style="vertical-align:top;text-align:center;">' . $revision_date . '</td>
<td style="width:15%;vertical-align:top;text-align:center;">' . $modified_date . '</td>
</tr>';
}
}
$content .= '</table>';
return $content;
}
public function actionGetversionop($id) {
$model = \backend\modules\versionHistory\models\VersionHistory::find()
->where(['=', 'table_name', 'op'])
->andwhere(['=', 'data_id', $id])
->orderby(['sorting' => SORT_DESC])
->all();
$output = '<h1>Record History</h1>
<div>This is the current published major version</div>
<table cellpadding="5" width="100%">
<tr>
<td style="width:5%;">No.</td>
<td style="width:30%;">Modified</td>
<td style="width:20%;">Modified By</td>
<td style="width:10%;">Size</td>
<td style="width:35%;">Comment</td>
</tr>';
if (!empty($model)) {
foreach ($model as $row) {
$output .= '<tr>
<td style="vertical-align:top;">' . $row->version_no . '</td>
<td style="vertical-align:top;">
<a href="/' . $row->file_url . '" target="_blank">' . $row->updated_at . '</a><br>';
if (!empty($row->approved_at))
$output .= 'Approved On ' . $row->approved_at . '<br>';
$output .= 'Approval Status ' . $row->approval_status . '<br>
</td>
<td style="vertical-align:top;">' . $row->updated_by . '</td>
<td style="vertical-align:top;">' . $row->size . '</td>
<td style="vertical-align:top;">' . $row->comment . '</td>
</tr>';
}
}
$output .= '</table>';
return $output;
}
public function actionGetversionpg($id) {
$model = \backend\modules\versionHistory\models\VersionHistory::find()
->where(['=', 'table_name', 'pg'])
->andwhere(['=', 'data_id', $id])
->orderby(['sorting' => SORT_DESC])
->all();
$output = '<h1>Record History</h1>
<div>This is the current published major version</div>
<table cellpadding="5" width="100%">
<tr>
<td style="width:5%;">No.</td>
<td style="width:30%;">Modified</td>
<td style="width:20%;">Modified By</td>
<td style="width:10%;">Size</td>
<td style="width:35%;">Comment</td>
</tr>';
if (!empty($model)) {
foreach ($model as $row) {
$output .= '<tr>
<td style="vertical-align:top;">' . $row->version_no . '</td>
<td style="vertical-align:top;">
<a href="/' . $row->file_url . '" target="_blank">' . $row->updated_at . '</a><br>';
if (!empty($row->approved_at))
$output .= 'Approved On ' . $row->approved_at . '<br>';
$output .= 'Approval Status ' . $row->approval_status . '<br>
</td>
<td style="vertical-align:top;">' . $row->updated_by . '</td>
<td style="vertical-align:top;">' . $row->size . '</td>
<td style="vertical-align:top;">' . $row->comment . '</td>
</tr>';
}
}
$output .= '</table>';
return $output;
}
public function actionGetversiongpa($id) {
$model = \backend\modules\versionHistory\models\VersionHistory::find()
->where(['=', 'table_name', 'gpa'])
->andwhere(['=', 'data_id', $id])
->orderby(['sorting' => SORT_DESC])
->all();
$output = '<h1>Record History</h1>
<div>This is the current published major version</div>
<table cellpadding="5" width="100%">
<tr>
<td style="width:5%;">No.</td>
<td style="width:30%;">Modified</td>
<td style="width:20%;">Modified By</td>
<td style="width:10%;">Size</td>
<td style="width:35%;">Comment</td>
</tr>';
if (!empty($model)) {
foreach ($model as $row) {
$output .= '<tr>
<td style="vertical-align:top;">' . $row->version_no . '</td>
<td style="vertical-align:top;">
<a href="/' . $row->file_url . '" target="_blank">' . $row->updated_at . '</a><br>';
if (!empty($row->approved_at))
$output .= 'Approved On ' . $row->approved_at . '<br>';
$output .= 'Approval Status ' . $row->approval_status . '<br>
</td>
<td style="vertical-align:top;">' . $row->updated_by . '</td>
<td style="vertical-align:top;">' . $row->size . '</td>
<td style="vertical-align:top;">' . $row->comment . '</td>
</tr>';
}
}
$output .= '</table>';
return $output;
}
public function actionGetappendixop($id) {
$title = '';
$modelMain = ContentDownloads::findOne($id);
if (!empty($modelMain)) {
$title = $modelMain->download_version;
}
$output = '<table cellpadding="5">
<tr>
<td>Title</td>
<td>' . $title . '</td>
</tr>
<tr>
<td style="vertical-align:top;">Attachment</td>
<td>';
$modelAppendix = ContentDownloadsAppendix::find()->where(['=', 'parent_id', $id])->orderby(['id' => SORT_ASC])->all();
if (!empty($modelAppendix)) {
foreach ($modelAppendix as $row) {
$output .= '<div style="margin-bottom:5px;"><a href="/' . $row->file_url . '" target="_blank">' . $row->name . '</a></div>';
}
}
echo '</td>
</tr>
</table>';
return $output;
}
public function actionGetappendixpg($id) {
$title = '';
$modelMain = ContentDownloads::findOne($id);
if (!empty($modelMain)) {
$title = $modelMain->download_version;
}
$output = '<table cellpadding="5">
<tr>
<td>Title</td>
<td>' . $title . '</td>
</tr>
<tr>
<td style="vertical-align:top;">Attachment</td>
<td>';
$modelAppendix = ContentDownloadsAppendix::find()->where(['=', 'parent_id', $id])->orderby(['id' => SORT_ASC])->all();
if (!empty($modelAppendix)) {
foreach ($modelAppendix as $row) {
$output .= '<div style="margin-bottom:5px;"><a href="/' . $row->file_url . '" target="_blank">' . $row->name . '</a></div>';
}
}
echo '</td>
</tr>
</table>';
return $output;
}
public function actionGetappendixgpa($id) {
$title = '';
$modelMain = ContentDownloads::findOne($id);
if (!empty($modelMain)) {
$title = $modelMain->download_descr;
}
$output = '<table cellpadding="5">
<tr>
<td>Title</td>
<td>' . $title . '</td>
</tr>
<tr>
<td style="vertical-align:top;">Attachment</td>
<td>';
$modelAppendix = ContentDownloadsAppendix::find()->where(['=', 'parent_id', $id])->orderby(['id' => SORT_ASC])->all();
if (!empty($modelAppendix)) {
foreach ($modelAppendix as $row) {
$output .= '<div style="margin-bottom:5px;"><a href="/' . $row->file_url . '" target="_blank">' . $row->name . '</a></div>';
}
}
echo '</td>
</tr>
</table>';
return $output;
}
public function actionGetdepartmentmanual($code, $sortdepartment, $sortsector, $sorttype, $sortsop, $keyword, $search_dept, $search_sector, $search_type, $search_sop, $sortmodified) {
$content = '<table border="0" cellpadding="5" cellspacing="0" width="100%">';
$query = \backend\modules\departmentManual\models\DepartmentManual::find()
->where(['=', 'dm_year', $code])
->andwhere(['=', 'dm_approval_status', 'approved'])
->andwhere(['=', 'dm_status', '1']);
if ($sortdepartment == 'down') {
$query->innerjoin('ref', 'ref.code=dm_department');
$query->andwhere(['=', 'ref.cat', 'DEPT']);
$query->orderby(['ref.descr' => SORT_DESC]);
}
if ($sortdepartment == 'up') {
$query->innerjoin('ref', 'ref.code=dm_department');
$query->andwhere(['=', 'ref.cat', 'DEPT']);
$query->orderby(['ref.descr' => SORT_ASC]);
}
if ($sortsector == 'down') {
$query->innerjoin('ref', 'ref.code=dm_sector');
$query->andwhere(['=', 'ref.cat', 'SECTOR']);
$query->orderby(['ref.descr' => SORT_DESC]);
}
if ($sortsector == 'up') {
$query->innerjoin('ref', 'ref.code=dm_sector');
$query->andwhere(['=', 'ref.cat', 'SECTOR']);
$query->orderby(['ref.descr' => SORT_ASC]);
}
if ($sorttype == 'down') {
$query->innerjoin('ref', 'ref.code=dm_type');
$query->andwhere(['=', 'ref.cat', 'DM_DOCUMENT_TYPE']);
$query->orderby(['ref.descr' => SORT_DESC]);
}
if ($sorttype == 'up') {
$query->innerjoin('ref', 'ref.code=dm_type');
$query->andwhere(['=', 'ref.cat', 'DM_DOCUMENT_TYPE']);
$query->orderby(['ref.descr' => SORT_ASC]);
}
if ($sortsop == 'down')
$query->orderby(['dm_count_sop' => SORT_DESC]);
if ($sortsop == 'up')
$query->orderby(['dm_count_sop' => SORT_ASC]);
if ($sortmodified == 'down')
$query->orderby(['department_manual.updated_at' => SORT_DESC]);
if ($sortmodified == 'up')
$query->orderby(['department_manual.updated_at' => SORT_ASC]);
if (empty($sortdepartment) && empty($sortsector) && empty($sorttype) && empty($sortsop) & empty($sortmodified)) {
$query->innerjoin('ref', 'ref.code=dm_department');
$query->andwhere(['=', 'ref.cat', 'DEPT']);
$query->orderby(['ref.descr' => SORT_ASC]);
}
if (!empty($keyword)) {
$query->innerjoin('ref rs', 'rs.code=dm_department');
$query->andwhere(['=', 'rs.cat', 'DEPT']);
$query->andwhere(['LIKE', 'rs.descr', $keyword]);
}
if (!empty($search_dept)) {
$query->innerjoin('ref r1', 'r1.code=dm_department');
$query->andwhere(['=', 'r1.cat', 'DEPT']);
$query->andwhere(['LIKE', 'r1.descr', $search_dept]);
}
if (!empty($search_sector)) {
$query->innerjoin('ref r2', 'r2.code=dm_sector');
$query->andwhere(['=', 'r2.cat', 'SECTOR']);
$query->andwhere(['LIKE', 'r2.descr', $search_sector]);
}
if (!empty($search_type)) {
$query->innerjoin('ref r3', 'r3.code=dm_type');
$query->andwhere(['=', 'r3.cat', 'DM_DOCUMENT_TYPE']);
$query->andwhere(['LIKE', 'r3.descr', $search_type]);
}
if (!empty($search_sop)) {
$query->andwhere(['=', 'dm_count_sop', $search_sop]);
}
$model = $query->all();
if (!empty($model)) {
$total_sop = $query->sum('dm_count_sop');
$content .= '<tr><td colspan="2"></td><td style="text-align:center;">Total Count of SOPs <br>(' . number_format($total_sop) . ')</td></tr>';
foreach ($model as $row) {
$tempdm = str_replace("Department : ", "", \backend\modules\refdynawebv2\models\Ref::getDesc('DEPT', $row->dm_department));
$modified_date = '';
if (!empty($row->updated_at))
$modified_date = date("d-M-Y", strtotime($row->updated_at));
$content .= '<tr>
<td style="vertical-align:top;text-align:left;"><a href="/web/department-manual-details?id=' . $row->dm_id . '">' . $tempdm . '</a></td>
<td width="20%" style="vertical-align:top;text-align:center;">' . \backend\modules\refdynawebv2\models\Ref::getDesc('SECTOR', $row->dm_sector) . '</td>
<!--td width="15%" style="vertical-align:top;text-align:center;">' . \backend\modules\refdynawebv2\models\Ref::getDesc('DM_DOCUMENT_TYPE', $row->dm_type) . '</td-->
<td width="15%" style="vertical-align:top;text-align:center;">' . $row->dm_count_sop . '</td>
<td width="15%" style="vertical-align:top;text-align:center;">' . $modified_date . '</td>
</tr>';
}
}
$content .= '</table>';
return $content;
}
public function actionGetdepartmentmanualadmin($code, $sortdepartment, $sortsector, $sorttype, $sortsop, $sortapproval, $sortcreate, $keyword, $search_dept, $search_sector, $search_type, $search_sop, $sortstatus) {
$content = '<table border="0" cellpadding="5" cellspacing="0" width="100%">';
$query = \backend\modules\departmentManual\models\DepartmentManual::find()
->where(['=', 'dm_year', $code])
->andwhere(['=', 'dm_status', '1']);
if ($sortdepartment == 'down') {
$query->innerjoin('ref', 'ref.code=dm_department');
$query->andwhere(['=', 'ref.cat', 'DEPT']);
$query->orderby(['ref.descr' => SORT_DESC]);
}
if ($sortdepartment == 'up') {
$query->innerjoin('ref', 'ref.code=dm_department');
$query->andwhere(['=', 'ref.cat', 'DEPT']);
$query->orderby(['ref.descr' => SORT_ASC]);
}
if ($sortsector == 'down') {
$query->innerjoin('ref', 'ref.code=dm_sector');
$query->andwhere(['=', 'ref.cat', 'SECTOR']);
$query->orderby(['ref.descr' => SORT_DESC]);
}
if ($sortsector == 'up') {
$query->innerjoin('ref', 'ref.code=dm_sector');
$query->andwhere(['=', 'ref.cat', 'SECTOR']);
$query->orderby(['ref.descr' => SORT_ASC]);
}
if ($sorttype == 'down') {
$query->innerjoin('ref', 'ref.code=dm_type');
$query->andwhere(['=', 'ref.cat', 'DM_DOCUMENT_TYPE']);
$query->orderby(['ref.descr' => SORT_DESC]);
}
if ($sorttype == 'up') {
$query->innerjoin('ref', 'ref.code=dm_type');
$query->andwhere(['=', 'ref.cat', 'DM_DOCUMENT_TYPE']);
$query->orderby(['ref.descr' => SORT_ASC]);
}
if ($sortsop == 'down')
$query->orderby(['dm_count_sop' => SORT_DESC]);
if ($sortsop == 'up')
$query->orderby(['dm_count_sop' => SORT_ASC]);
if ($sortapproval == 'down')
$query->orderby(['dm_approval_status' => SORT_DESC]);
if ($sortapproval == 'up')
$query->orderby(['dm_approval_status' => SORT_ASC]);
if ($sortcreate == 'down')
$query->orderby(['created_at' => SORT_DESC]);
if ($sortcreate == 'up')
$query->orderby(['created_at' => SORT_ASC]);
if ($sortstatus == 'down')
$query->orderby(['dm_approval_status' => SORT_DESC]);
if ($sortstatus == 'up')
$query->orderby(['dm_approval_status' => SORT_ASC]);
if (empty($sortdepartment) && empty($sortsector) && empty($sorttype) && empty($sortsop) && empty($sortapproval) && empty($sortcreate) && empty($sortstatusdepartment)) {
$query->innerjoin('ref rsort', 'rsort.code=dm_department');
$query->andwhere(['=', 'rsort.cat', 'DEPT']);
$query->orderby(['rsort.descr' => SORT_ASC]);
}
if (!empty($keyword)) {
$query->innerjoin('ref rs', 'rs.code=dm_department');
$query->andwhere(['=', 'rs.cat', 'DEPT']);
$query->andwhere(['LIKE', 'rs.descr', $keyword]);
}
if (!empty($search_dept)) {
$query->innerjoin('ref r1', 'r1.code=dm_department');
$query->andwhere(['=', 'r1.cat', 'DEPT']);
$query->andwhere(['LIKE', 'r1.descr', $search_dept]);
}
if (!empty($search_sector)) {
$query->innerjoin('ref r2', 'r2.code=dm_sector');
$query->andwhere(['=', 'r2.cat', 'SECTOR']);
$query->andwhere(['LIKE', 'r2.descr', $search_sector]);
}
if (!empty($search_type)) {
$query->innerjoin('ref r3', 'r3.code=dm_type');
$query->andwhere(['=', 'r3.cat', 'DM_DOCUMENT_TYPE']);
$query->andwhere(['LIKE', 'r3.descr', $search_type]);
}
if (!empty($search_sop)) {
$query->andwhere(['=', 'dm_count_sop', $search_sop]);
}
$model = $query->all();
if (!empty($model)) {
$total_sop = $query->sum('dm_count_sop');
$content .= '<tr><td colspan="3"></td><td style="text-align:center;">Total Count of SOPs <br>(' . number_format($total_sop) . ')</td></tr>';
foreach ($model as $row) {
$tempdm = str_replace("Department : ", "", \backend\modules\refdynawebv2\models\Ref::getDesc('DEPT', $row->dm_department));
$content .= '<tr>
<td width="5%" style="vertical-align:top;">';
if ($row->dm_approval_status != 'delete') {
if ($row->delete_status != 'pending') {
$content .= '<a href="#" onclick="deletedepartmentmanual(' . $row->dm_id . ')">
<img src="/portalassets/icon/delete.png" title="Delete file">
</a>';
}
}
$status_label = \backend\modules\refdynawebv2\models\Ref::getDesc('APPROVAL_STATUS', $row->dm_approval_status, 'other_param');
$content .= '</td>
<td width="30%" style="vertical-align:top;text-align:left;"><a href="/web/department-manual-details?id=' . $row->dm_id . '">' . $tempdm . '</a></td>
<td width="20%" style="vertical-align:top;text-align:center;">' . \backend\modules\refdynawebv2\models\Ref::getDesc('SECTOR', $row->dm_sector) . '</td>
<!--<td width="10%" style="vertical-align:top;text-align:center;">' . \backend\modules\refdynawebv2\models\Ref::getDesc('DM_DOCUMENT_TYPE', $row->dm_type) . '</td>-->
<td width="10%" style="vertical-align:top;text-align:center;">' . $row->dm_count_sop . '</td>
<td width="10%" style="vertical-align:top;text-align:center;"><span class="' . $row->dm_approval_status . '">' . $status_label . '</span></td>';
//<td width="10%" style="vertical-align:top;">' . \backend\modules\refdynawebv2\models\Ref::getDesc('APPROVAL_STATUS', $row->dm_approval_status) . '</td>
//<td width="10%" style="vertical-align:top;">' . date("d F, Y", strtotime($row->created_at)) . '</td>
$content .= '<td width="25%" style="vertical-align:top;">';
if (!empty($row->updated_at))
$modified_at = date("d-M-Y (H:i:s)", strtotime($row->updated_at));
else
$modified_at = date("d-M-Y (H:i:s)", strtotime($row->created_at));
if (!empty($row->updated_by))
$modified_by = \backend\modules\departmentManual\models\DepartmentManual::getupdatename($row->dm_id);
else
$modified_by = \backend\modules\departmentManual\models\DepartmentManual::getcreatename($row->dm_id);
$content .= '<div>Created date : ' . date("d-M-Y (H:i:s)", strtotime($row->created_at)) . '</div>';
$content .= '<div>Created by : ' . \backend\modules\departmentManual\models\DepartmentManual::getcreatename($row->dm_id) . '</div>';
$content .= '<div>Last modified date : ' . $modified_at . '</div>';
$content .= '<div>Last modified by : ' . $modified_by . '</div>';
/* if (!empty($row->created_at))
$content .= '<div>Created date : ' . date("d-M-Y (H:i:s)", strtotime($row->created_at)) . '</div>';
if (!empty($row->created_by))
$content .= '<div>Created by : ' . \backend\modules\departmentManual\models\DepartmentManual::getcreatename($row->dm_id) . '</div>';
if (!empty($row->updated_at))
$content .= '<div>Modified date : ' . date("d-M-Y (H:i:s)", strtotime($row->updated_at)) . '</div>';
if (!empty($row->updated_by))
$content .= '<div>Modified by : ' . \backend\modules\departmentManual\models\DepartmentManual::getupdatename($row->dm_id) . '</div>';
if (!empty($row->dm_approval_at))
$content .= '<div>' . \backend\modules\refdynawebv2\models\Ref::getDesc('APPROVAL_STATUS', $row->dm_approval_status) . ' date : ' . date("d-M-Y", strtotime($row->dm_approval_at)) . '</div>';
if (!empty($row->dm_approval_by))
$content .= '<div>' . \backend\modules\refdynawebv2\models\Ref::getDesc('APPROVAL_STATUS', $row->dm_approval_status) . ' by : ' . \backend\modules\departmentManual\models\DepartmentManual::getapprovename($row->dm_id) . '</div>';
if (!empty($row->dm_approval_status))
$content .= '<div>Approval status : <span class="' . $row->dm_approval_status . '">' . \backend\modules\refdynawebv2\models\Ref::getDesc('APPROVAL_STATUS', $row->dm_approval_status) . '</span></div>';
*/
/* $approved_at = '';
$approved_by = '';
if ($row->dm_approval_status == 'draft' || $row->dm_approval_status == 'pending') {
$approved_at = date("d-M-Y (H:i:s)", strtotime($row->created_at));
$approved_by = \backend\modules\departmentManual\models\DepartmentManual::getcreatename($row->dm_id);
}
if ($row->dm_approval_status == 'rejected' || $row->dm_approval_status == 'approved') {
if (!empty($row->dm_approval_at)) {
$approved_at = date("d-M-Y (H:i:s)", strtotime($row->dm_approval_at));
$approved_by = \backend\modules\departmentManual\models\DepartmentManual::getapprovename($row->dm_id);
} else {
$approved_at = date("d-M-Y (H:i:s)", strtotime($row->updated_at));
$approved_by = \backend\modules\departmentManual\models\DepartmentManual::getupdatename($row->dm_id);
}
}
if ($row->dm_approval_status == 'decommission' || $row->dm_approval_status == 'revert' || $row->dm_approval_status == 'delete') {
if (!empty($row->updated_at)) {
$approved_at = date("d-M-Y (H:i:s)", strtotime($row->updated_at));
$approved_by = \backend\modules\departmentManual\models\DepartmentManual::getupdatename($row->dm_id);
} else {
$approved_at = date("d-M-Y (H:i:s)", strtotime($row->created_at));
$approved_by = \backend\modules\departmentManual\models\DepartmentManual::getcreatename($row->dm_id);
}
}
$content .= '<div>' . $status_label . ' date : ' . $approved_at . '</div>';
$content .= '<div>' . $status_label . ' by : ' . $approved_by . '</div>';
$content .= '<div>Status : <span class="' . $row->dm_approval_status . '">' . $status_label . '</span></div>';
*/
$content .= '</td>';
$content .= '</tr>';
}
}
$content .= '</table>';
return $content;
}
public function actionCompliancebulletin($code, $no) {
$no++;
$padding = $no * 10;
$content = '';
//get content
$query = new \yii\db\Query();
$query->from('content_downloads')
->where(['=', 'download_status', 'active'])
->andwhere(['=', 'download_category', $code])
->orderby(['download_title' => SORT_ASC]);
$model = $query->all();
if (!empty($model)) {
foreach ($model as $row) {
$content .= '<p style="padding-left:20px;">';
if (!empty(Yii::$app->user->identity->id) && Yii::$app->user->identity->role == 'admin-microsite') {
$modeladminmicrosite = \backend\modules\fruserdynav2\models\FrontendUserMicrosite::find()
->where(['=', 'frontend_user_id', Yii::$app->user->identity->id])
->andwhere(['=', 'microsite_id', 4])
->all();
if (!empty($modeladminmicrosite)) {
$content .= '<a href="#" onclick="deletefile(' . $row['download_id'] . ')"><img src="/portalassets/icon/delete.png" title="Delete file"></a>';
$content .= ' ';
$content .= '<a href="#" onclick="updatefile(' . $row['download_id'] . ',\'' . addslashes($row['download_title']) . '\')"><img src="/portalassets/icon/edit.png" title="Update file"></a>';
$content .= ' ';
}
} else {
$content .= '<img src="/assets/img/pdf.png" style="margin-right:10px;">';
}
$content .= '<a href="/' . $row['download_file'] . '" target="_blank">' . $row['download_title'] . '</a></p>';
}
}
$parent_id = \backend\modules\refdynawebv2\models\Ref::getparentid($code, 'DOWNLOAD_CATEGORY');
$cat_arr = ArrayHelper::map(\backend\modules\refdynawebv2\models\Ref::find()
->where(['cat' => 'DOWNLOAD_CATEGORY'])
->andwhere(['=', 'param1', $parent_id])
->orderBy(['sort' => SORT_ASC])->all(), 'code', 'descr');
if (!empty($cat_arr)) {
//get submenu
foreach ($cat_arr as $cat_code => $cat_label) {
$content .= '<div style="padding-left:' . $padding . 'px;"><p>
';
if (!empty(Yii::$app->user->identity->id) && Yii::$app->user->identity->role == 'admin-microsite') {
$modeladminmicrosite = \backend\modules\fruserdynav2\models\FrontendUserMicrosite::find()
->where(['=', 'frontend_user_id', Yii::$app->user->identity->id])
->andwhere(['=', 'microsite_id', 4])
->all();
if (!empty($modeladminmicrosite)) {
$content .= '<button type="button" class="btn-link" onclick="addnewfile(\'' . $cat_code . '\')">+ Add File</button>';
}
}
$content .= '<a href="#" onclick="opencontent(\'' . $cat_code . '\',' . $no . ')" style="color:black;">
<b>' . $cat_label . '</b>
</a>';
$content .= '</p>
<div class="content content-' . $cat_code . '"></div></div>';
}
}
return $content;
}
public function actionDeleteappendix($id) {
$status = 0;
$model = \backend\modules\appendix\models\Appendix::findOne($id);
if (!empty($model)) {
if ($model->delete()) {
$status = 1;
}
}
return $status;
}
public function actionDeletedepartmentmanual($id) {
$status = 1;
$model = \backend\modules\departmentManual\models\DepartmentManual::find()->where(['=', 'dm_id', $id])->one();
if (!empty($model)) {
if ($model->delete()) {
} else {
$status = 0;
}
}
$modelAppendix = \backend\modules\appendix\models\Appendix::find()
->where(['=', 'appendix_data_id', $id])
->andwhere(['=', 'appendix_table_name', 'department_manual'])
->all();
if (!empty($modelAppendix)) {
foreach ($modelAppendix as $rowAppendix) {
if ($rowAppendix->delete()) {
} else {
$status = 0;
}
}
}
return $status;
}
public function actionGetdepartmentmanualapproval($code, $sortdepartment, $sortsector, $sorttype, $sortsop, $keyword, $search_dept, $search_sector, $search_type, $search_sop, $status) {
$content = '<table border="0" cellpadding="5" cellspacing="0" width="100%">';
if ($status == 'draft') {
$query = \backend\modules\departmentManual\models\DepartmentManual::find()
->where(['=', 'dm_year', $code])
->andwhere(['=', 'draft_user_id', Yii::$app->user->identity->id])
->andwhere(['=', 'dm_approval_status', $status]);
} else if ($status == 'delete') {
$query = \backend\modules\departmentManual\models\DepartmentManual::find()
->where(['=', 'dm_year', $code])
->andwhere(['=', 'delete_status', 'pending']);
} else {
$query = \backend\modules\departmentManual\models\DepartmentManual::find()
->where(['=', 'dm_year', $code])
->andwhere(['OR', ['=', 'dm_approver', Yii::$app->user->identity->id], ['AND', ['=', 'department_manual.created_by', Yii::$app->user->identity->id], ['=', 'department_manual.created_user_type', 'frontend_user']]])
->andwhere(['=', 'dm_approval_status', $status]);
}
if ($sortdepartment == 'down') {
$query->innerjoin('ref', 'ref.code=dm_department');
$query->andwhere(['=', 'ref.cat', 'DEPT']);
$query->orderby(['ref.descr' => SORT_DESC]);
}
if ($sortdepartment == 'up') {
$query->innerjoin('ref', 'ref.code=dm_department');
$query->andwhere(['=', 'ref.cat', 'DEPT']);
$query->orderby(['ref.descr' => SORT_ASC]);
}
if ($sortsector == 'down') {
$query->innerjoin('ref', 'ref.code=dm_sector');
$query->andwhere(['=', 'ref.cat', 'SECTOR']);
$query->orderby(['ref.descr' => SORT_DESC]);
}
if ($sortsector == 'up') {
$query->innerjoin('ref', 'ref.code=dm_sector');
$query->andwhere(['=', 'ref.cat', 'SECTOR']);
$query->orderby(['ref.descr' => SORT_ASC]);
}
if ($sorttype == 'down') {
$query->innerjoin('ref', 'ref.code=dm_type');
$query->andwhere(['=', 'ref.cat', 'DM_DOCUMENT_TYPE']);
$query->orderby(['ref.descr' => SORT_DESC]);
}
if ($sorttype == 'up') {
$query->innerjoin('ref', 'ref.code=dm_type');
$query->andwhere(['=', 'ref.cat', 'DM_DOCUMENT_TYPE']);
$query->orderby(['ref.descr' => SORT_ASC]);
}
if ($sortsop == 'down')
$query->orderby(['dm_count_sop' => SORT_DESC]);
if ($sortsop == 'up')
$query->orderby(['dm_count_sop' => SORT_ASC]);
if (empty($sortdepartment) && empty($sortsector) && empty($sorttype) && empty($sortsop) && empty($sortapproval) && empty($sortcreate)) {
$query->innerjoin('ref rsort', 'rsort.code=dm_department');
$query->andwhere(['=', 'rsort.cat', 'DEPT']);
$query->orderby(['rsort.descr' => SORT_ASC]);
}
if (!empty($keyword)) {
$query->innerjoin('ref rs', 'rs.code=dm_department');
$query->andwhere(['=', 'rs.cat', 'DEPT']);
$query->andwhere(['LIKE', 'rs.descr', $keyword]);
}
if (!empty($search_dept)) {
$query->innerjoin('ref r1', 'r1.code=dm_department');
$query->andwhere(['=', 'r1.cat', 'DEPT']);
$query->andwhere(['LIKE', 'r1.descr', $search_dept]);
}
if (!empty($search_sector)) {
$query->innerjoin('ref r2', 'r2.code=dm_sector');
$query->andwhere(['=', 'r2.cat', 'SECTOR']);
$query->andwhere(['LIKE', 'r2.descr', $search_sector]);
}
if (!empty($search_type)) {
$query->innerjoin('ref r3', 'r3.code=dm_type');
$query->andwhere(['=', 'r3.cat', 'DM_DOCUMENT_TYPE']);
$query->andwhere(['LIKE', 'r3.descr', $search_type]);
}
if (!empty($search_sop)) {
$query->andwhere(['=', 'dm_count_sop', $search_sop]);
}
$model = $query->all();
if (!empty($model)) {
foreach ($model as $row) {
$tempdm = str_replace("Department : ", "", \backend\modules\refdynawebv2\models\Ref::getDesc('DEPT', $row->dm_department));
if ($status == 'draft') {
$details_url = '/web/department-manual-draft-details?id=' . $row->dm_id;
} else if ($status == 'delete') {
$details_url = '/web/department-manual-delete-details?id=' . $row->dm_id;
} else {
$details_url = '/web/department-manual-approval-details?id=' . $row->dm_id;
}
$content .= '<tr>
<td width="5%"> </td>
<td width="30%" style="vertical-align:top;"><a href="' . $details_url . '">' . $tempdm . '</a></td>
<td width="20%" style="vertical-align:top;">' . \backend\modules\refdynawebv2\models\Ref::getDesc('SECTOR', $row->dm_sector) . '</td>
<td width="15%" style="vertical-align:top;">' . \backend\modules\refdynawebv2\models\Ref::getDesc('DM_DOCUMENT_TYPE', $row->dm_type) . '</td>
<td width="10%" style="vertical-align:top;text-align:center;">' . $row->dm_count_sop . '</td>';
$content .= '<td width="25%" style="vertical-align:top;">';
if (!empty($row->created_at))
$content .= '<div>Created date : ' . date("d F Y, H:i:s", strtotime($row->created_at)) . '</div>';
if (!empty($row->created_by))
$content .= '<div>Created by : ' . \backend\modules\departmentManual\models\DepartmentManual::getcreatename($row->dm_id) . '</div>';
if (!empty($row->updated_at))
$content .= '<div>Modified date : ' . date("d F Y, H:i:s", strtotime($row->updated_at)) . '</div>';
if (!empty($row->updated_by))
$content .= '<div>Modified by : ' . \backend\modules\departmentManual\models\DepartmentManual::getupdatename($row->dm_id) . '</div>';
if (!empty($row->dm_approval_at))
$content .= '<div>' . \backend\modules\refdynawebv2\models\Ref::getDesc('APPROVAL_STATUS', $row->dm_approval_status) . ' date : ' . date("d F, Y", strtotime($row->dm_approval_at)) . '</div>';
if (!empty($row->dm_approval_by))
$content .= '<div>' . \backend\modules\refdynawebv2\models\Ref::getDesc('APPROVAL_STATUS', $row->dm_approval_status) . ' by : ' . \backend\modules\departmentManual\models\DepartmentManual::getapprovename($row->dm_id) . '</div>';
if (!empty($row->dm_approval_status))
$content .= '<div>Approval status : ' . \backend\modules\refdynawebv2\models\Ref::getDesc('APPROVAL_STATUS', $row->dm_approval_status) . '</div>';
$content .= '</td>';
$content .= '</tr>';
}
}
$content .= '</table>';
return $content;
}
public function actionUpdatestatusdm($id, $status, $comment) {
$output = 0;
$model = \backend\modules\departmentManual\models\DepartmentManual::findOne($id);
if (!empty($model)) {
$model->dm_comment = $comment;
$model->dm_approval_status = $status;
$model->dm_approval_at = date("Y-m-d H:i:s");
$model->dm_approval_by = Yii::$app->user->identity->id;
$model->updated_at = date("Y-m-d H:i:s");
$model->updated_by = Yii::$app->user->identity->id;
$model->updated_user_type = 'frontend_user';
if ($model->save(false)) {
if ($status == 'approved' && !empty($model->update_from_id)) {
$modelUpdate = \backend\modules\departmentManual\models\DepartmentManual::findOne($model->update_from_id);
$modelUpdate->dm_status = 0;
$modelUpdate->save(false);
}
$output = 1;
}
}
return $output;
}
public function actionSubmitdepartmentmanual($id) {
$output = 0;
$model = \backend\modules\departmentManual\models\DepartmentManual::findOne($id);
if (!empty($model)) {
$model->dm_approval_status = 'pending';
if ($model->save(false))
$output = 1;
}
return $output;
}
public function actionDeleterequestdepartmentmanual($id, $delete_comment = '') {
$output = 0;
$model = \backend\modules\departmentManual\models\DepartmentManual::findOne($id);
if (!empty($model)) {
$model->delete_status = 'pending';
$model->delete_request_comment = $delete_comment;
$model->delete_request_at = date("Y-m-d H:i:s");
$model->delete_request_by = Yii::$app->user->identity->id;
if ($model->save(false))
$output = 1;
}
return $output;
}
public function actionUpdatedeletionstatusdm($id, $status, $comment = '') {
$output = '';
$model = \backend\modules\departmentManual\models\DepartmentManual::findOne($id);
if (!empty($model)) {
$model->delete_approver_comment = $comment;
if ($status == 'rejected') {
$model->delete_status = 'rejected';
if ($model->save(false))
$output = 'Deletion of Department Manual & SOPs has been Rejected.';
}
if ($status == 'approved') {
$model->dm_approval_status = 'delete';
$model->delete_status = 'approved';
$model->save(false);
//$model->delete();
$modelAppendix = \backend\modules\appendix\models\Appendix::find()
->where(['=', 'appendix_data_id', $id])
->andwhere(['=', 'appendix_table_name', 'department_manual'])
->all();
if (!empty($modelAppendix)) {
foreach ($modelAppendix as $rowAppendix) {
//$rowAppendix->delete();
}
}
$output = 'Deletion of Department Manual & SOPs has been Approved.';
}
}
return $output;
}
public function actionUpdatedeletionstatusop($id, $status, $comment = '') {
$output = '';
$model = \backend\modules\contentDownloads\models\ContentDownloads::findOne($id);
if (!empty($model)) {
$model->delete_approver_comment = $comment;
if ($status == 'rejected') {
$model->delete_status = 'rejected';
if ($model->save(false))
$output = 'Request deletion has been rejected';
}
if ($status == 'approved') {
$model->approval_status = 'delete';
$model->delete_status = 'approved';
$model->save(false);
//$model->delete();
$modelAppendix = \backend\modules\contentDownloads\models\ContentDownloadsAppendix::find()
->where(['=', 'parent_id', $id])
->all();
if (!empty($modelAppendix)) {
foreach ($modelAppendix as $rowAppendix) {
//$rowAppendix->delete();
}
}
$modelVersion = \backend\modules\versionHistory\models\VersionHistory::find()
->where(['=', 'data_id', $id])
->andwhere(['=', 'table_name', 'op'])
->all();
if (!empty($modelVersion)) {
foreach ($modelVersion as $rowVersion) {
//$rowVersion->delete();
}
}
$output = 'Data have been deleted';
}
}
return $output;
}
public function actionDeleteop($id) {
$status = 1;
$model = \backend\modules\contentDownloads\models\ContentDownloads::find()->where(['=', 'download_id', $id])->one();
if (!empty($model)) {
if ($model->delete()) {
} else {
$status = 0;
}
}
$modelAppendix = \backend\modules\contentDownloads\models\ContentDownloadsAppendix::find()
->where(['=', 'parent_id', $id])
->all();
if (!empty($modelAppendix)) {
foreach ($modelAppendix as $rowAppendix) {
if ($rowAppendix->delete()) {
} else {
$status = 0;
}
}
}
$modelVersion = \backend\modules\versionHistory\models\VersionHistory::find()
->where(['=', 'data_id', $id])
->andwhere(['=', 'table_name', 'op'])
->all();
if (!empty($modelVersion)) {
foreach ($modelVersion as $rowVersion) {
if ($rowVersion->delete()) {
} else {
$status = 0;
}
}
}
return $status;
}
public function actionDeleteappendixop($id) {
$status = 0;
$model = \backend\modules\contentDownloads\models\ContentDownloadsAppendix::findOne($id);
if (!empty($model)) {
if ($model->delete()) {
$status = 1;
}
}
return $status;
}
public function actionSubmitop($id) {
$output = 0;
$model = \backend\modules\contentDownloads\models\ContentDownloads::findOne($id);
if (!empty($model)) {
$model->approval_status = 'pending';
if ($model->save(false))
$output = 1;
}
return $output;
}
public function actionUpdatestatusop($id, $status, $comment) {
$output = 0;
$model = \backend\modules\contentDownloads\models\ContentDownloads::findOne($id);
if (!empty($model)) {
$model->approval_comment = $comment;
$model->approval_status = $status;
$model->approval_at = date("Y-m-d H:i:s");
$model->approval_by = Yii::$app->user->identity->id;
if ($model->save(false)) {
if ($status == 'approved') {
if ($status == 'approved' && !empty($model->update_from_id)) {
$modelUpdate = \backend\modules\contentDownloads\models\ContentDownloads::findOne($model->update_from_id);
$modelUpdate->download_status = 'archived';
$modelUpdate->save(false);
}
$modelVersionLatest = \backend\modules\versionHistory\models\VersionHistory::find()
->where(['=', 'data_id', $id])
->andwhere(['=', 'table_name', 'op'])
->orderby(['id' => SORT_DESC, 'sorting' => SORT_DESC])->one();
if (!empty($modelVersionLatest)) {
$version_no = '0.1';
$latest_version_no = $modelVersionLatest->version_no;
$latest_version_no_arr = explode('.', $latest_version_no);
if (!empty($latest_version_no_arr)) {
if ($model->new_version == 1)
$version_no = ($latest_version_no_arr[0] + 1) . '.0';
else
$version_no = ($latest_version_no_arr[0]) . '.' . ($latest_version_no_arr[1] + 1);
}
$modelVersion = new \backend\modules\versionHistory\models\VersionHistory();
$modelVersion->table_name = 'op';
$modelVersion->data_id = $model->download_id;
$modelVersion->version_no = $version_no;
$modelVersion->updated_at = $modelVersionLatest->updated_at;
$modelVersion->updated_by = $modelVersionLatest->updated_by;
$modelVersion->size = $modelVersionLatest->size;
$modelVersion->comment = $modelVersionLatest->comment;
$modelVersion->approved_at = date("d-M-Y (H:i:s)");
$modelVersion->approval_status = \backend\modules\refdynawebv2\models\Ref::getDesc('APPROVAL_STATUS', $model->approval_status);
$modelVersion->file_url = $modelVersionLatest->file_url;
$modelVersion->file_name = $modelVersionLatest->file_name;
$modelVersion->file_ext = $modelVersionLatest->file_ext;
$modelVersion->save();
}
}
$output = 1;
}
}
return $output;
}
public function actionRequestdeleteop($id, $delete_comment = '') {
$output = 0;
$model = \backend\modules\contentDownloads\models\ContentDownloads::findOne($id);
if (!empty($model)) {
$model->delete_status = 'pending';
$model->delete_request_comment = $delete_comment;
$model->delete_request_at = date("Y-m-d H:i:s");
$model->delete_request_by = Yii::$app->user->identity->id;
if ($model->save(false))
$output = 1;
}
return $output;
}
public function actionSubmitemailinstruction($id) {
$output = 0;
$model = \backend\modules\contentArticle\models\ContentArticle::findOne($id);
if (!empty($model)) {
$model->approval_status = 'pending';
if ($model->save(false))
$output = 1;
}
return $output;
}
public function actionDeleteemailinstruction($id) {
$status = 1;
$model = \backend\modules\contentArticle\models\ContentArticle::find()->where(['=', 'article_id', $id])->one();
if (!empty($model)) {
if ($model->delete()) {
} else {
$status = 0;
}
}
$model2 = \backend\modules\contentArticle\models\ContentArticleTranslation::find()
->where(['=', 'article_translation_parent_id', $id])
->all();
if (!empty($model2)) {
foreach ($model2 as $row2) {
if ($row2->delete()) {
} else {
$status = 0;
}
}
}
return $status;
}
public function actionUpdatestatusemail($id, $status, $comment) {
$output = 0;
$model = \backend\modules\contentArticle\models\ContentArticle::findOne($id);
if (!empty($model)) {
$model->approval_comment = $comment;
$model->approval_status = $status;
$model->approval_at = date("Y-m-d H:i:s");
$model->approval_by = Yii::$app->user->identity->id;
$model->updated_at = date("Y-m-d H:i:s");
$model->updated_by = Yii::$app->user->identity->id;
$model->updated_user_type = 'frontend_user';
if ($model->save(false)) {
if ($status == 'approved' && !empty($model->update_from_id)) {
$modelUpdate = \backend\modules\contentArticle\models\ContentArticle::findOne($model->update_from_id);
$modelUpdate->article_status = 'archived';
$modelUpdate->save(false);
}
$output = 1;
}
}
return $output;
}
public function actionDeletederequestemail($id, $delete_comment = '') {
$output = 0;
$model = \backend\modules\contentArticle\models\ContentArticle::findOne($id);
if (!empty($model)) {
$model->delete_status = 'pending';
$model->delete_request_comment = $delete_comment;
$model->delete_request_at = date("Y-m-d H:i:s");
$model->delete_request_by = Yii::$app->user->identity->id;
if ($model->save(false))
$output = 1;
}
return $output;
}
public function actionUpdatedeletionstatusemail($id, $status, $comment = '') {
$output = '';
$model = \backend\modules\contentArticle\models\ContentArticle::findOne($id);
if (!empty($model)) {
$model->delete_approver_comment = $comment;
if ($status == 'rejected') {
$model->delete_status = 'rejected';
if ($model->save(false))
$output = 'Deletion of Email Instruction has been Rejected.';
}
if ($status == 'approved') {
$model->approval_status = 'delete';
$model->delete_status = 'approved';
$model->save(false);
//$model->delete();
$model2 = \backend\modules\contentArticle\models\ContentArticleTranslation::find()
->where(['=', 'article_translation_parent_id', $id])
->all();
if (!empty($model2)) {
foreach ($model2 as $row) {
//$row->delete();
}
}
$output = 'Deletion of Email Instruction has been Approved.';
}
}
return $output;
}
public function actionDeletefolder($id) {
$status = 0;
$model = \backend\modules\elog\models\Elog::findOne($id);
if (!empty($model)) {
if ($model->delete()) {
$status = 1;
}
}
return $status;
}
public function actionDeletefile($id) {
$status = 0;
$model = \backend\modules\elog\models\Elog::findOne($id);
if (!empty($model)) {
if ($model->delete()) {
$status = 1;
}
}
return $status;
}
public function actionGetattachment($url_slug, $no) {
$output = '';
$model = \backend\modules\elog\models\Elog::findOne(['slug' => $url_slug]);
if (!empty($model)) {
$file_link = '';
if ($model->format != 'folder') {
if ($model->format != 'pdf')
$file_link = '<a href="/' . $model->file_url . '" download="' . $model->name . '.' . $model->format . '">' . $model->name . '</a>';
else
$file_link = '<a href="/' . $model->file_url . '" target="_blank">' . $model->name . '</a>';
} else {
$file_link = '<a href="/web/documents-workspace?id=' . $model->slug . '" target="_blank">' . $model->name . '</a>';
}
$output = '<div style="margin-top:20px;" id="row_attachment_' . $no . '">
<input type="hidden" name="attachment_no[]" value="' . $model->id . '">
<a href="#" onclick="deleteattachment(' . $no . ')"><img src="/portalassets/icon/delete.png" title="Delete attachment"></a>
<img src="/portalassets/icon/' . $model->format . '.png">
' . $file_link . '
</div>';
} else {
$output = 'failed';
}
return $output;
}
public function actionSubmitcm($id) {
$output = 0;
$model = \backend\modules\contentDownloads\models\ContentDownloads::findOne($id);
if (!empty($model)) {
$model->approval_status = 'pending';
if ($model->save(false))
$output = 1;
}
return $output;
}
public function actionDeletecm($id) {
$status = 1;
$model = \backend\modules\contentDownloads\models\ContentDownloads::find()->where(['=', 'download_id', $id])->one();
if (!empty($model)) {
if ($model->delete()) {
} else {
$status = 0;
}
}
return $status;
}
public function actionUpdatestatuscm($id, $status, $comment) {
$output = 0;
$model = \backend\modules\contentDownloads\models\ContentDownloads::findOne($id);
if (!empty($model)) {
$model->approval_comment = $comment;
$model->approval_status = $status;
$model->approval_at = date("Y-m-d H:i:s");
$model->approval_by = Yii::$app->user->identity->id;
if ($model->save(false)) {
if ($status == 'approved' && !empty($model->update_from_id)) {
$modelUpdate = \backend\modules\contentDownloads\models\ContentDownloads::findOne($model->update_from_id);
$modelUpdate->download_status = 'archived';
$modelUpdate->save(false);
}
$output = 1;
}
}
return $output;
}
public function actionRequestdeletecm($id, $delete_comment = '') {
$output = 0;
$model = \backend\modules\contentDownloads\models\ContentDownloads::findOne($id);
if (!empty($model)) {
$model->delete_status = 'pending';
$model->delete_request_comment = $delete_comment;
$model->delete_request_at = date("Y-m-d H:i:s");
$model->delete_request_by = Yii::$app->user->identity->id;
if ($model->save(false))
$output = 1;
}
return $output;
}
public function actionUpdatedeletionstatuscm($id, $status, $comment = '') {
$output = '';
$model = \backend\modules\contentDownloads\models\ContentDownloads::findOne($id);
if (!empty($model)) {
$model->delete_approver_comment = $comment;
if ($status == 'rejected') {
$model->delete_status = 'rejected';
if ($model->save(false))
$output = 'Deletion of Circular (Memo) has been Rejected.';
}
if ($status == 'approved') {
//$model->delete();
$model->approval_status = 'delete';
$model->delete_status = 'approved';
$model->save(false);
$output = 'Deletion of Circular (Memo) has been Approved.';
}
}
return $output;
}
public function actionDeletederequestcircular($id) {
$output = 0;
$model = \backend\modules\contentArticle\models\ContentArticle::findOne($id);
if (!empty($model)) {
$model->delete_status = 'pending';
if ($model->save(false))
$output = 1;
}
return $output;
}
public function actionDeletecircular($id) {
$status = 1;
$model = \backend\modules\contentArticle\models\ContentArticle::find()->where(['=', 'article_id', $id])->one();
if (!empty($model)) {
if ($model->delete()) {
} else {
$status = 0;
}
}
$model2 = \backend\modules\contentArticle\models\ContentArticleTranslation::find()
->where(['=', 'article_translation_parent_id', $id])
->all();
if (!empty($model2)) {
foreach ($model2 as $row2) {
if ($row2->delete()) {
} else {
$status = 0;
}
}
}
return $status;
}
public function actionSubmitcircular($id) {
$output = 0;
$model = \backend\modules\contentArticle\models\ContentArticle::findOne($id);
if (!empty($model)) {
$model->approval_status = 'pending';
if ($model->save(false))
$output = 1;
}
return $output;
}
public function actionUpdatestatuscircular($id, $status, $comment) {
$output = 0;
$model = \backend\modules\contentArticle\models\ContentArticle::findOne($id);
if (!empty($model)) {
$model->approval_comment = $comment;
$model->approval_status = $status;
$model->approval_at = date("Y-m-d H:i:s");
$model->approval_by = Yii::$app->user->identity->id;
if ($model->save(false)) {
if ($status == 'approved' && !empty($model->update_from_id)) {
$modelUpdate = \backend\modules\contentArticle\models\ContentArticle::findOne($model->update_from_id);
$modelUpdate->article_status = 'archived';
$modelUpdate->save(false);
}
$output = 1;
}
}
return $output;
}
public function actionUpdatedeletionstatuscircular($id, $status) {
$output = '';
$model = \backend\modules\contentArticle\models\ContentArticle::findOne($id);
if (!empty($model)) {
if ($status == 'rejected') {
$model->delete_status = 'rejected';
if ($model->save(false))
$output = 'Request deletion has been rejected';
}
if ($status == 'approved') {
$model->approval_status = 'delete';
$model->delete_status = 'approved';
$model->save(false);
//$model->delete();
$model2 = \backend\modules\contentArticle\models\ContentArticleTranslation::find()
->where(['=', 'article_translation_parent_id', $id])
->all();
if (!empty($model2)) {
foreach ($model2 as $row) {
//$row->delete();
}
}
$output = 'Data have been deleted';
}
}
return $output;
}
public function actionRequestdeletepg($id, $delete_comment = '') {
$output = 0;
$model = \backend\modules\contentDownloads\models\ContentDownloads::findOne($id);
if (!empty($model)) {
$model->delete_status = 'pending';
$model->delete_request_comment = $delete_comment;
$model->delete_request_at = date("Y-m-d H:i:s");
$model->delete_request_by = Yii::$app->user->identity->id;
if ($model->save(false))
$output = 1;
}
return $output;
}
public function actionRequestdeletegpa($id, $delete_comment = '') {
$output = 0;
$model = \backend\modules\contentDownloads\models\ContentDownloads::findOne($id);
if (!empty($model)) {
$model->delete_status = 'pending';
$model->delete_request_comment = $delete_comment;
$model->delete_request_at = date("Y-m-d H:i:s");
$model->delete_request_by = Yii::$app->user->identity->id;
if ($model->save(false))
$output = 1;
}
return $output;
}
public function actionSubmitpg($id) {
$output = 0;
$model = \backend\modules\contentDownloads\models\ContentDownloads::findOne($id);
if (!empty($model)) {
$model->approval_status = 'pending';
if ($model->save(false))
$output = 1;
}
return $output;
}
public function actionSubmitgpa($id) {
$output = 0;
$model = \backend\modules\contentDownloads\models\ContentDownloads::findOne($id);
if (!empty($model)) {
$model->approval_status = 'pending';
if ($model->save(false))
$output = 1;
}
return $output;
}
public function actionDeletepg($id) {
$status = 1;
$model = \backend\modules\contentDownloads\models\ContentDownloads::find()->where(['=', 'download_id', $id])->one();
if (!empty($model)) {
if ($model->delete()) {
} else {
$status = 0;
}
}
$modelVersion = \backend\modules\versionHistory\models\VersionHistory::find()
->where(['=', 'data_id', $id])
->andwhere(['=', 'table_name', 'pg'])
->all();
if (!empty($modelVersion)) {
foreach ($modelVersion as $rowVersion) {
if ($rowVersion->delete()) {
} else {
$status = 0;
}
}
}
return $status;
}
public function actionDeletegpa($id) {
$status = 1;
$model = \backend\modules\contentDownloads\models\ContentDownloads::find()->where(['=', 'download_id', $id])->one();
if (!empty($model)) {
if ($model->delete()) {
} else {
$status = 0;
}
}
$modelVersion = \backend\modules\versionHistory\models\VersionHistory::find()
->where(['=', 'data_id', $id])
->andwhere(['=', 'table_name', 'gpa'])
->all();
if (!empty($modelVersion)) {
foreach ($modelVersion as $rowVersion) {
if ($rowVersion->delete()) {
} else {
$status = 0;
}
}
}
return $status;
}
public function actionUpdatestatuspg($id, $status, $comment) {
$output = 0;
$model = \backend\modules\contentDownloads\models\ContentDownloads::findOne($id);
if (!empty($model)) {
$model->approval_comment = $comment;
$model->approval_status = $status;
$model->approval_at = date("Y-m-d H:i:s");
$model->approval_by = Yii::$app->user->identity->id;
$model->updated_at = date("Y-m-d H:i:s");
$model->updated_by = Yii::$app->user->identity->id;
$model->updated_user_type = 'frontend_user';
if ($model->save(false)) {
if ($status == 'approved') {
if ($status == 'approved' && !empty($model->update_from_id)) {
$modelUpdate = \backend\modules\contentDownloads\models\ContentDownloads::findOne($model->update_from_id);
$modelUpdate->download_status = 'archived';
$modelUpdate->save(false);
}
$modelVersionLatest = \backend\modules\versionHistory\models\VersionHistory::find()
->where(['=', 'data_id', $id])
->andwhere(['=', 'table_name', 'pg'])
->orderby(['id' => SORT_DESC, 'sorting' => SORT_DESC])->one();
if (!empty($modelVersionLatest)) {
$version_no = '0.1';
$latest_version_no = $modelVersionLatest->version_no;
$latest_version_no_arr = explode('.', $latest_version_no);
if (!empty($latest_version_no_arr)) {
$version_no = ($latest_version_no_arr[0] + 1) . '.0';
}
$modelVersion = new \backend\modules\versionHistory\models\VersionHistory();
$modelVersion->table_name = 'pg';
$modelVersion->data_id = $model->download_id;
$modelVersion->version_no = $version_no;
$modelVersion->updated_at = $modelVersionLatest->updated_at;
$modelVersion->updated_by = $modelVersionLatest->updated_by;
$modelVersion->size = $modelVersionLatest->size;
$modelVersion->comment = $modelVersionLatest->comment;
$modelVersion->approved_at = date("d-M-Y (H:i:s)");
$modelVersion->approval_status = \backend\modules\refdynawebv2\models\Ref::getDesc('APPROVAL_STATUS', $model->approval_status);
$modelVersion->file_url = $modelVersionLatest->file_url;
$modelVersion->file_name = $modelVersionLatest->file_name;
$modelVersion->file_ext = $modelVersionLatest->file_ext;
$modelVersion->save();
}
}
$output = 1;
}
}
return $output;
}
public function actionUpdatestatusgpa($id, $status, $comment) {
$output = 0;
$model = \backend\modules\contentDownloads\models\ContentDownloads::findOne($id);
if (!empty($model)) {
$model->approval_comment = $comment;
$model->approval_status = $status;
$model->approval_at = date("Y-m-d H:i:s");
$model->approval_by = Yii::$app->user->identity->id;
$model->updated_at = date("Y-m-d H:i:s");
$model->updated_by = Yii::$app->user->identity->id;
$model->updated_user_type = 'frontend_user';
if ($model->save(false)) {
if ($status == 'approved') {
if ($status == 'approved' && !empty($model->update_from_id)) {
$modelUpdate = \backend\modules\contentDownloads\models\ContentDownloads::findOne($model->update_from_id);
$modelUpdate->download_status = 'archived';
$modelUpdate->save(false);
}
$modelVersionLatest = \backend\modules\versionHistory\models\VersionHistory::find()
->where(['=', 'data_id', $id])
->andwhere(['=', 'table_name', 'gpa'])
->orderby(['id' => SORT_DESC, 'sorting' => SORT_DESC])->one();
if (!empty($modelVersionLatest)) {
$version_no = '0.1';
$latest_version_no = $modelVersionLatest->version_no;
$latest_version_no_arr = explode('.', $latest_version_no);
if (!empty($latest_version_no_arr)) {
$version_no = ($latest_version_no_arr[0] + 1) . '.0';
}
$modelVersion = new \backend\modules\versionHistory\models\VersionHistory();
$modelVersion->table_name = 'gpa';
$modelVersion->data_id = $model->download_id;
$modelVersion->version_no = $version_no;
$modelVersion->updated_at = $modelVersionLatest->updated_at;
$modelVersion->updated_by = $modelVersionLatest->updated_by;
$modelVersion->size = $modelVersionLatest->size;
$modelVersion->comment = $modelVersionLatest->comment;
$modelVersion->approved_at = date("d-M-Y (H:i:s)");
$modelVersion->approval_status = \backend\modules\refdynawebv2\models\Ref::getDesc('APPROVAL_STATUS', $model->approval_status);
$modelVersion->file_url = $modelVersionLatest->file_url;
$modelVersion->file_name = $modelVersionLatest->file_name;
$modelVersion->file_ext = $modelVersionLatest->file_ext;
$modelVersion->save();
}
}
$output = 1;
}
}
return $output;
}
public function actionUpdatedeletionstatuspg($id, $status, $comment = '') {
$output = '';
$model = \backend\modules\contentDownloads\models\ContentDownloads::findOne($id);
if (!empty($model)) {
$model->delete_approver_comment = $comment;
if ($status == 'rejected') {
$model->delete_status = 'rejected';
if ($model->save(false))
$output = 'Request deletion has been rejected';
}
if ($status == 'approved') {
$model->approval_status = 'delete';
$model->delete_status = 'approved';
$model->save(false);
//$model->delete();
$modelVersion = \backend\modules\versionHistory\models\VersionHistory::find()
->where(['=', 'data_id', $id])
->andwhere(['=', 'table_name', 'pg'])
->all();
if (!empty($modelVersion)) {
foreach ($modelVersion as $rowVersion) {
//$rowVersion->delete();
}
}
$output = 'Data have been deleted';
}
}
return $output;
}
public function actionUpdatedeletionstatusgpa($id, $status, $comment = '') {
$output = '';
$model = \backend\modules\contentDownloads\models\ContentDownloads::findOne($id);
if (!empty($model)) {
$model->delete_approver_comment = $comment;
if ($status == 'rejected') {
$model->delete_status = 'rejected';
if ($model->save(false))
$output = 'Request deletion has been rejected';
}
if ($status == 'approved') {
//$model->delete();
$model->approval_status = 'delete';
$model->delete_status = 'approved';
$model->save(false);
$modelVersion = \backend\modules\versionHistory\models\VersionHistory::find()
->where(['=', 'data_id', $id])
->andwhere(['=', 'table_name', 'gpa'])
->all();
if (!empty($modelVersion)) {
foreach ($modelVersion as $rowVersion) {
//$rowVersion->delete();
}
}
$output = 'Data have been deleted';
}
}
return $output;
}
public function actionRequestdeletedocument($id, $delete_comment = '') {
$output = 0;
$model = \backend\modules\contentDownloads\models\ContentDownloads::findOne($id);
if (!empty($model)) {
$model->delete_status = 'pending';
$model->delete_request_comment = $delete_comment;
$model->delete_request_at = date("Y-m-d H:i:s");
$model->delete_request_by = Yii::$app->user->identity->id;
if ($model->save(false))
$output = 1;
}
return $output;
}
public function actionUpdatedeletionstatusdocument($id, $status, $type = '', $comment = '') {
$output = '';
$model = \backend\modules\contentDownloads\models\ContentDownloads::findOne($id);
if (!empty($model)) {
$model->delete_approver_comment = $comment;
if ($status == 'rejected') {
$model->delete_status = 'rejected';
if ($model->save(false)) {
if ($type == 'initials')
$output = 'Deletion of BR Initials has been Rejected.';
if ($type == 'om')
$output = 'Deletion of Operation Manual has been Rejected.';
}
}
if ($status == 'approved') {
//$model->delete();
$model->approval_status = 'delete';
$model->delete_status = 'approved';
$model->updated_at = date("Y-m-d H:i:s");
$model->updated_by = Yii::$app->user->identity->id;
$model->updated_user_type = 'frontend_user';
$model->save(false);
if ($type == 'initials')
$output = 'Deletion of BR Initials has been Approved.';
if ($type == 'om')
$output = 'Deletion of Operation Manual has been Approved.';
}
}
return $output;
}
public function actionSubmitdocument($id) {
$output = 0;
$model = \backend\modules\contentDownloads\models\ContentDownloads::findOne($id);
if (!empty($model)) {
$model->approval_status = 'pending';
if ($model->save(false))
$output = 1;
}
return $output;
}
public function actionDeletedocument($id) {
$status = 1;
$model = \backend\modules\contentDownloads\models\ContentDownloads::find()->where(['=', 'download_id', $id])->one();
if (!empty($model)) {
if ($model->delete()) {
} else {
$status = 0;
}
}
return $status;
}
public function actionUpdatestatusdocument($id, $status, $comment) {
$output = 0;
$model = \backend\modules\contentDownloads\models\ContentDownloads::findOne($id);
if (!empty($model)) {
$model->approval_comment = $comment;
$model->approval_status = $status;
$model->approval_at = date("Y-m-d H:i:s");
$model->approval_by = Yii::$app->user->identity->id;
$model->updated_at = date("Y-m-d H:i:s");
$model->updated_by = Yii::$app->user->identity->id;
$model->updated_user_type = 'frontend_user';
if ($model->save(false)) {
if ($status == 'approved' && !empty($model->update_from_id)) {
$modelUpdate = \backend\modules\contentDownloads\models\ContentDownloads::findOne($model->update_from_id);
$modelUpdate->download_status = 'archived';
$modelUpdate->save(false);
}
$output = 1;
}
}
return $output;
}
public function actionDeletederequestquickguide($id) {
$output = 0;
$model = \backend\modules\contentArticle\models\ContentArticle::findOne($id);
if (!empty($model)) {
$model->delete_status = 'pending';
if ($model->save(false))
$output = 1;
}
return $output;
}
public function actionSubmitquickguide($id) {
$output = 0;
$model = \backend\modules\contentArticle\models\ContentArticle::findOne($id);
if (!empty($model)) {
$model->approval_status = 'pending';
if ($model->save(false))
$output = 1;
}
return $output;
}
public function actionDeleteguideguide($id) {
$status = 1;
$model = \backend\modules\contentArticle\models\ContentArticle::find()->where(['=', 'article_id', $id])->one();
if (!empty($model)) {
if ($model->delete()) {
} else {
$status = 0;
}
}
$model2 = \backend\modules\contentArticle\models\ContentArticleTranslation::find()
->where(['=', 'article_translation_parent_id', $id])
->all();
if (!empty($model2)) {
foreach ($model2 as $row2) {
if ($row2->delete()) {
} else {
$status = 0;
}
}
}
return $status;
}
public function actionUpdatestatusquickguide($id, $status, $comment) {
$output = 0;
$model = \backend\modules\contentArticle\models\ContentArticle::findOne($id);
if (!empty($model)) {
$model->approval_comment = $comment;
$model->approval_status = $status;
$model->approval_at = date("Y-m-d H:i:s");
$model->approval_by = Yii::$app->user->identity->id;
if ($model->save(false)) {
if ($status == 'approved' && !empty($model->update_from_id)) {
$modelUpdate = \backend\modules\contentArticle\models\ContentArticle::findOne($model->update_from_id);
$modelUpdate->article_status = 'archived';
$modelUpdate->save(false);
}
$output = 1;
}
}
return $output;
}
public function actionUpdatedeletionstatusquickguide($id, $status) {
$output = '';
$model = \backend\modules\contentArticle\models\ContentArticle::findOne($id);
if (!empty($model)) {
if ($status == 'rejected') {
$model->delete_status = 'rejected';
if ($model->save(false))
$output = 'Request deletion has been rejected';
}
if ($status == 'approved') {
$model->delete();
$model2 = \backend\modules\contentArticle\models\ContentArticleTranslation::find()
->where(['=', 'article_translation_parent_id', $id])
->all();
if (!empty($model2)) {
foreach ($model2 as $row) {
$row->delete();
}
}
$output = 'Data have been deleted';
}
}
return $output;
}
public function actionRequestdecomission($id, $decommission_comment, $type) {
$output = 0;
$model = \backend\modules\contentDownloads\models\ContentDownloads::findOne($id);
if (!empty($model)) {
$model->decommission_comment = $decommission_comment;
$model->decommission_status = 'pending';
$model->decommission_by = Yii::$app->user->identity->id;
if ($model->save(false))
$output = 1;
$version_no = '0.1';
$modelVersionLatest = \backend\modules\versionHistory\models\VersionHistory::find()->where(['=', 'data_id', $id])->orderby(['id' => SORT_DESC, 'sorting' => SORT_DESC])->one();
if (!empty($modelVersionLatest)) {
$latest_version_no = $modelVersionLatest->version_no;
$latest_version_no_arr = explode('.', $latest_version_no);
if (!empty($latest_version_no_arr)) {
$version_no = ($latest_version_no_arr[0]) . '.1';
}
}
$file_ext_arr = '';
$file_ext_arr = explode('.', (string) $model->download_file);
$modelVersion = new \backend\modules\versionHistory\models\VersionHistory();
$modelVersion->table_name = $type;
$modelVersion->data_id = $model->download_id;
$modelVersion->version_no = $version_no;
$modelVersion->updated_at = date("d-M-Y (H:i:s)");
$modelVersion->updated_by = Yii::$app->user->identity->fullname;
$modelVersion->size = NULL;
$modelVersion->comment = $decommission_comment;
$modelVersion->approved_at = date("d-M-Y (H:i:s)");
$modelVersion->approval_status = 'Submit for Decommission';
$modelVersion->file_url = $model->download_file;
$modelVersion->file_name = $model->download_title;
$modelVersion->file_ext = end($file_ext_arr);
$modelVersion->save();
}
return $output;
}
public function actionUpdatestatusdecommission($id, $status, $type, $comment) {
$output = 0;
$model = \backend\modules\contentDownloads\models\ContentDownloads::findOne($id);
if (!empty($model)) {
$model->decommission_status = $status;
$model->decommission_approver_comment = $comment;
$model->approval_decommission_at = date("Y-m-d H:i:s");
$model->approval_decommission_by = Yii::$app->user->identity->id;
if ($status == 'approved') {
$model->approval_status = 'decommission';
if ($type == 'op') {
$model->download_category = 'operational-procedure-unpublished-sub-unpublished';
}
if ($type == 'pg') {
$model->download_category = 'operational-procedure-unpublished-sub-unpublished-policy';
}
if ($type == 'gpa') {
$model->download_category = 'gpa-unpublished';
}
$version_no = '1.0';
$modelVersionLatest = \backend\modules\versionHistory\models\VersionHistory::find()->where(['=', 'data_id', $id])->orderby(['id' => SORT_DESC, 'sorting' => SORT_DESC])->one();
if (!empty($modelVersionLatest)) {
$latest_version_no = $modelVersionLatest->version_no;
$latest_version_no_arr = explode('.', $latest_version_no);
if (!empty($latest_version_no_arr)) {
$version_no = ($latest_version_no_arr[0] + 1) . '.0';
}
}
$file_ext_arr = '';
$file_ext_arr = explode('.', (string) $model->download_file);
$modelVersion = new \backend\modules\versionHistory\models\VersionHistory();
$modelVersion->table_name = $type;
$modelVersion->data_id = $model->download_id;
$modelVersion->version_no = $version_no;
$modelVersion->updated_at = date("d-M-Y (H:i:s)");
$modelVersion->updated_by = Yii::$app->user->identity->fullname;
$modelVersion->size = NULL;
$modelVersion->comment = $comment;
$modelVersion->approved_at = date("d-M-Y (H:i:s)");
$modelVersion->approval_status = 'Decommissioned';
$modelVersion->file_url = $model->download_file;
$modelVersion->file_name = $model->download_title;
$modelVersion->file_ext = end($file_ext_arr);
$modelVersion->save();
}
if ($model->save(false))
$output = 1;
}
return $output;
}
public function actionGetdepartmentmanualbsn($code, $sortdepartment, $sortsector, $sorttype, $sortsop, $keyword, $search_dept, $search_sector, $search_type, $search_sop, $sortmodified) {
$content = '<table border="0" cellpadding="5" cellspacing="0" width="100%">';
$query = \backend\modules\departmentManual\models\DepartmentManual::find()
->where(['=', 'dm_year', $code])
->andwhere(['=', 'dm_approval_status', 'approved'])
->andwhere(['=', 'dm_status', '1']);
if ($sortdepartment == 'down') {
$query->innerjoin('ref', 'ref.code=dm_department');
$query->andwhere(['=', 'ref.cat', 'DEPT']);
$query->orderby(['ref.descr' => SORT_DESC]);
}
if ($sortdepartment == 'up') {
$query->innerjoin('ref', 'ref.code=dm_department');
$query->andwhere(['=', 'ref.cat', 'DEPT']);
$query->orderby(['ref.descr' => SORT_ASC]);
}
if ($sortsector == 'down') {
$query->innerjoin('ref', 'ref.code=dm_sector');
$query->andwhere(['=', 'ref.cat', 'SECTOR']);
$query->orderby(['ref.descr' => SORT_DESC]);
}
if ($sortsector == 'up') {
$query->innerjoin('ref', 'ref.code=dm_sector');
$query->andwhere(['=', 'ref.cat', 'SECTOR']);
$query->orderby(['ref.descr' => SORT_ASC]);
}
if ($sorttype == 'down') {
$query->innerjoin('ref', 'ref.code=dm_type');
$query->andwhere(['=', 'ref.cat', 'DM_DOCUMENT_TYPE']);
$query->orderby(['ref.descr' => SORT_DESC]);
}
if ($sorttype == 'up') {
$query->innerjoin('ref', 'ref.code=dm_type');
$query->andwhere(['=', 'ref.cat', 'DM_DOCUMENT_TYPE']);
$query->orderby(['ref.descr' => SORT_ASC]);
}
if ($sortsop == 'down')
$query->orderby(['dm_count_sop' => SORT_DESC]);
if ($sortsop == 'up')
$query->orderby(['dm_count_sop' => SORT_ASC]);
if ($sortmodified == 'down')
$query->orderby(['department_manual.updated_at' => SORT_DESC]);
if ($sortmodified == 'up')
$query->orderby(['department_manual.updated_at' => SORT_ASC]);
if (empty($sortdepartment) && empty($sortsector) && empty($sorttype) && empty($sortsop) & empty($sortmodified)) {
$query->innerjoin('ref', 'ref.code=dm_department');
$query->andwhere(['=', 'ref.cat', 'DEPT']);
$query->orderby(['ref.descr' => SORT_ASC]);
}
if (!empty($keyword)) {
$query->innerjoin('ref rs', 'rs.code=dm_department');
$query->andwhere(['=', 'rs.cat', 'DEPT']);
$query->andwhere(['LIKE', 'rs.descr', $keyword]);
}
if (!empty($search_dept)) {
$query->innerjoin('ref r1', 'r1.code=dm_department');
$query->andwhere(['=', 'r1.cat', 'DEPT']);
$query->andwhere(['LIKE', 'r1.descr', $search_dept]);
}
if (!empty($search_sector)) {
$query->innerjoin('ref r2', 'r2.code=dm_sector');
$query->andwhere(['=', 'r2.cat', 'SECTOR']);
$query->andwhere(['LIKE', 'r2.descr', $search_sector]);
}
if (!empty($search_type)) {
$query->innerjoin('ref r3', 'r3.code=dm_type');
$query->andwhere(['=', 'r3.cat', 'DM_DOCUMENT_TYPE']);
$query->andwhere(['LIKE', 'r3.descr', $search_type]);
}
if (!empty($search_sop)) {
$query->andwhere(['=', 'dm_count_sop', $search_sop]);
}
$model = $query->all();
if (!empty($model)) {
$total_sop = $query->sum('dm_count_sop');
$content .= '<tr><td colspan="2"></td><td style="text-align:center;">Total Count of SOPs <br>(' . number_format($total_sop) . ')</td></tr>';
foreach ($model as $row) {
$tempdm = str_replace("Department : ", "", \backend\modules\refdynawebv2\models\Ref::getDesc('DEPT', $row->dm_department));
if (empty($row->updated_at))
$modified_date = date("d-M-Y", strtotime($row->created_at));
else
$modified_date = date("d-M-Y", strtotime($row->updated_at));
$content .= '<tr>
<td style="vertical-align:top;"><a href="/bsn/department-manual-details?id=' . $row->dm_id . '">' . $tempdm . '</a></td>
<td width="20%" style="vertical-align:top;">' . \backend\modules\refdynawebv2\models\Ref::getDesc('SECTOR', $row->dm_sector) . '</td>
<!--td width="15%" style="vertical-align:top;">' . \backend\modules\refdynawebv2\models\Ref::getDesc('DM_DOCUMENT_TYPE', $row->dm_type) . '</td-->
<td width="15%" style="vertical-align:top;text-align:center;">' . $row->dm_count_sop . '</td>
<td width="15%" style="vertical-align:top;">' . $modified_date . '</td>
</tr>';
}
}
$content .= '</table>';
return $content;
}
public function actionBsndeletedocument($id) {
$status = 1;
$model = \common\models\Documents::find()->where(['=', 'document_id', $id])->one();
if (!empty($model)) {
if ($model->delete()) {
} else {
$status = 0;
}
}
return $status;
}
public function actionDeleteappendixemailinstruction($id) {
$status = 0;
$model = \backend\modules\contentArticle\models\ContentArticleAppendix::findOne($id);
if (!empty($model)) {
if ($model->delete()) {
$status = 1;
}
}
return $status;
}
}