Ejemplo n.º 1
0
 /**
  * Creates a new Modulerp model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Modulerp();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->save()) {
             $datauser = Userlogin::find()->all();
             foreach ($datauser as $key => $value) {
                 # code...
                 $connection = Yii::$app->db;
                 $profile = Yii::$app->getUserOpt->Profile_user();
                 $usercreate = $profile->username;
                 $connection->createCommand()->batchInsert('modul_permission', ['USER_ID', 'MODUL_ID', 'CREATED_BY'], [[$value['id'], $model->MODUL_ID, $usercreate]])->execute();
             }
         }
         return $this->redirect('index');
     } else {
         return $this->renderAjax('create', ['model' => $model]);
     }
 }