Esempio n. 1
0
 /**
  * ACTION CREATE note | $id=PrimaryKey -> TRIGER FROM VIEW  -ptr.nov-
  */
 public function actionCreate()
 {
     $model = new SignupForm();
     if ($model->load(Yii::$app->request->post())) {
         if ($user = $model->signup()) {
             //if (Yii::$app->getUser()->login($user)) {  // user save signup return langsung login
             //    return $this->goHome();
             //}
             $searchModel_Userlogin = new UserloginSearch();
             $dataProvider_Userlogin = $searchModel_Userlogin->search(Yii::$app->request->queryParams);
             return $this->render('index', ['searchModel_Userlogin' => $searchModel_Userlogin, 'dataProvider_Userlogin' => $dataProvider_Userlogin]);
         }
     }
     return $this->render('signup', ['model' => $model]);
 }
 /**
  * Lists all Mdlpermission models and Modul Erp models.
  * @return mixed
  */
 public function actionIndex()
 {
     if (self::getPermission()->BTN_VIEW) {
         $searchModel = new UserloginSearch();
         $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
         $searchModelpermision = new MdlpermissionSearch(['USER_ID' => 1]);
         $dataProviderpermision = $searchModelpermision->search(Yii::$app->request->queryParams);
         $params = Yii::$app->request->queryParams;
         $baris = Modulerp::find()->count();
         if (count($params) == 0) {
         } else {
             # code...
             if (count($params) < $baris) {
                 $user_id = $params['MdlpermissionSearch']["USER_ID"];
                 $modul = Mdlpermission::find()->select('MODUL_ID')->where(['USER_ID' => $user_id])->asArray()->all();
                 $erp = Modulerp::find()->where(['not in', 'MODUL_ID', $modul])->all();
                 foreach ($erp as $key => $value) {
                     # code...
                     $connection = Yii::$app->db;
                     $connection->createCommand()->batchInsert('modul_permission', ['USER_ID', 'MODUL_ID'], [[$user_id, $value['MODUL_ID']]])->execute();
                 }
             }
         }
         // print_r(count($params));
         // die();
         if (Yii::$app->request->post('hasEditable')) {
             $id = Yii::$app->request->post('editableKey');
             Yii::$app->response->format = Response::FORMAT_JSON;
             $model = Mdlpermission::findOne($id);
             $out = Json::encode(['output' => '', 'message' => '']);
             $post = [];
             $posted = current($_POST['Mdlpermission']);
             $post['Mdlpermission'] = $posted;
             if ($model->load($post)) {
                 $output = '';
                 if (isset($posted['BTN_CREATE'])) {
                     $model->save();
                     $output = $model->BTN_CREATE;
                 }
                 if (isset($posted['BTN_EDIT'])) {
                     $model->save();
                     $output = $model->BTN_EDIT;
                 }
                 if (isset($posted['BTN_DELETE'])) {
                     $model->save();
                     $output = $model->BTN_DELETE;
                 }
                 if (isset($posted['BTN_VIEW'])) {
                     $model->save();
                     $output = $model->BTN_VIEW;
                 }
                 if (isset($posted['BTN_REVIEW'])) {
                     $model->save();
                     $output = $model->BTN_REVIEW;
                 }
                 if (isset($posted['BTN_PROCESS1'])) {
                     $model->save();
                     $output = $model->BTN_PROCESS1;
                 }
                 if (isset($posted['BTN_PROCESS2'])) {
                     $model->save();
                     $output = $model->BTN_PROCESS2;
                 }
                 if (isset($posted['BTN_PROCESS3'])) {
                     $model->save();
                     $output = $model->BTN_PROCESS3;
                 }
                 if (isset($posted['BTN_PROCESS4'])) {
                     $model->save();
                     $output = $model->BTN_PROCESS4;
                 }
                 if (isset($posted['BTN_PROCESS5'])) {
                     $model->save();
                     $output = $model->BTN_PROCESS5;
                 }
                 if (isset($posted['BTN_SIGN1'])) {
                     $model->save();
                     $output = $model->BTN_SIGN1;
                 }
                 if (isset($posted['BTN_SIGN2'])) {
                     $model->save();
                     $output = $model->BTN_SIGN2;
                 }
                 if (isset($posted['BTN_SIGN3'])) {
                     $model->save();
                     $output = $model->BTN_SIGN3;
                 }
                 if (isset($posted['BTN_SIGN4'])) {
                     $model->save();
                     $output = $model->BTN_SIGN4;
                 }
                 if (isset($posted['BTN_SIGN5'])) {
                     $model->save();
                     $output = $model->BTN_SIGN5;
                 }
                 $out = Json::encode(['output' => $output, 'message' => '']);
             }
             echo $out;
             return;
         }
         //SCENARIO MESSAGE PERMMISSION -ptr.nov--
         $paramMsg = Yii::$app->getRequest()->getQueryParam('msg');
         if ($paramMsg == 'alert') {
             $jsMsg = '$("#msg-alert").modal("show")';
             $this->getView()->registerJs($jsMsg);
         }
         $profile = Yii::$app->getUserOpt->profile_user();
         //componen
         $userId = $profile->id;
         return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'searchModelpermision' => $searchModelpermision, 'dataProviderpermision' => $dataProviderpermision, 'userPrmission' => $userId]);
     } else {
         $this->redirect(array('/site/validasi'));
         //
     }
 }