?> </div> </div> </div> <div class="row"> <div class="col-md-12"> <?php echo ListView::widget(['summary' => false, 'itemView' => '_topic', 'id' => 'yboardTopic', 'dataProvider' => $dataProvider]); ?> </div> </div> <div> <?php echo $this->render('_forumfooter'); ?> </div> </div> <div style="display:none;"> <?php if (Yii::$app->user->can('moderator')) { Dialog::begin(['id' => 'dlgTopicForm', 'clientOptions' => ['modal' => true, 'title' => YBoard::t('yboard', 'Update topic'), 'autoOpen' => false, 'modal' => true, 'height' => 400, 'width' => 300, 'buttons' => [['text' => YBoard::t('yboard', 'Change'), 'class' => 'btn btn-sm btn-success', 'click' => new JsExpression(' function() { YBoard.changeTopic("' . \Yii::$app->urlmanager->createAbsoluteUrl($this->context->module->id . '/moderator/change-topic') . '"); }')], ['text' => YBoard::t('yboard', 'Cancel'), 'class' => 'btn btn-sm btn-danger', 'click' => new JsExpression(' function() { $( this ).dialog( "close" ); }')]]]]); echo $this->render('_topicForm', array('model' => new YBoardTopic())); Dialog::end(); } ?> </div>
/** * @param $view */ public function register($view) { $view->on($view::EVENT_END_BODY, function ($event) { $this->registerAssets($event->sender); if ($this->htmlScope) { echo Html::beginTag('span', ['class' => $this->htmlScopeClass]); } if ($this->dialog == I18N::DIALOG_BS) { \yii\bootstrap\Modal::begin(['header' => '<div id="dots-modal-header"><div id="dots-modal-cat-header"></div><div id="dots-modal-key-header"></div></div>', 'closeButton' => ['class' => 'close dot-close'], 'options' => ['id' => 'dots-btn-modal'], 'toggleButton' => ['id' => 'dots-btns', 'style' => 'display: none;']]); $this->bodyDialog(); \yii\bootstrap\Modal::end(); } else { if ($this->dialog == I18N::DIALOG_JQ) { \yii\jui\Dialog::begin(['options' => ['id' => 'dots-btn-modal', 'style' => 'display: none;'], 'clientOptions' => ['autoOpen' => false, 'width' => '50%']]); $this->bodyDialog(); \yii\jui\Dialog::end(); } else { if ($this->dialog == I18N::DIALOG_MAGNIFIC) { \pavlinter\translation\widgets\MagnificPopup::begin(['toggleButton' => ['id' => 'dots-btns', 'style' => 'display: none;', 'href' => '#dots-btn-modal'], 'popupClass' => 'dot-white-popup', 'effect' => 'zoom-in', 'popupOptions' => ['class' => 'dots-modal-magnific', 'id' => 'dots-btn-modal']]); echo Html::beginTag('div', ['id' => 'dots-modal-header']); echo Html::tag('div', null, ['id' => 'dots-modal-cat-header']); echo Html::tag('div', null, ['id' => 'dots-modal-key-header']); echo Html::endTag('div'); $this->bodyDialog(); \pavlinter\translation\widgets\MagnificPopup::end(); } } } if ($this->htmlScope) { echo Html::endTag('span'); } }); $this->showDot = true; }
?> </div> </div> <div class="form-actions"> <?php echo \yii\helpers\Html::submitButton(Yii::t('app', 'Save'), ['class' => 'btn btn-primery']); ?> </div> <?php kartik\form\ActiveForm::end(); app\widgets\MiniForm::end(); \yii\jui\Dialog::begin(array('id' => "transactionDiag", 'clientOptions' => array('title' => Yii::t('app', 'Choose Reference Document'), 'autoOpen' => false, 'width' => 600))); echo $this->render('//transaction/create', array('model' => new app\models\FormTransaction())); \yii\jui\Dialog::end(); $java = <<<JS \$("#formextmatch-account_id").change(function() { var value = \$("#formextmatch-account_id").val(); \$.post(baseAddress+"/bankbook/extmatchajax", {FormExtmatch: {account_id: value}}).done( function(data) { \$("#result").html(data); } ); }); JS; $this->registerJs("var baseAddress='" . yii\helpers\BaseUrl::base() . "';" . $java, \yii\web\View::POS_READY); ?>
public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->validate()) { if (!empty($model->save())) { if ($_POST['User']['role'] == 1) { $auth = Yii::$app->get('authManager'); $auth->getRolesByUser($model->id); $auth->revokeAll($model->id); $authorRole = $auth->createRole('superadmin'); $auth->assign($authorRole, $model->id); } else { if ($_POST['User']['role'] == 2) { $auth = Yii::$app->get('authManager'); $auth->getRolesByUser($model->id); $auth->revokeAll($model->id); $authorRole = $auth->createRole('admin'); $auth->assign($authorRole, $model->id); } else { if ($_POST['User']['role'] == 3) { $auth = Yii::$app->get('authManager'); $auth->getRolesByUser($model->id); $auth->revokeAll($model->id); $authorRole = $auth->createRole('Pimpinan 1'); $auth->assign($authorRole, $model->id); } else { if ($_POST['User']['role'] == 4) { $auth = Yii::$app->get('authManager'); $auth->getRolesByUser($model->id); $auth->revokeAll($model->id); $authorRole = $auth->createRole('Pimpinan 2'); $auth->assign($authorRole, $model->id); } else { if ($_POST['User']['role'] == 5) { $auth = Yii::$app->get('authManager'); $auth->getRolesByUser($model->id); $auth->revokeAll($model->id); $authorRole = $auth->createRole('User'); $auth->assign($authorRole, $model->id); } } } } } Yii::$app->db->createCommand()->update('user', ['role' => $_POST['User']['role']], ['id' => $model->id])->execute(); $model->save(); Dialog::begin(['clientOptions' => ['modal' => true]]); echo 'Data Sudah Tersimpan'; Dialog::end(); } //return $this->redirect(['/user/profile']); } return $this->render('update', ['model' => $model]); }