Exemplo n.º 1
0
 /**
  * @param $profile_id
  * @return array
  * Возвращает массив ID отделений, где пользователь является управляющим
  */
 protected function getOffiсeIds($profile_id)
 {
     $modelsUsersOffices = UsersOffices::findAll(['profile_id' => $profile_id, 'profile_office_role' => 'manager']);
     return ArrayHelper::map($modelsUsersOffices, 'office_id', 'office_id');
 }
Exemplo n.º 2
0
 /**
  * Delete multiple existing UsersOffices model.
  * For ajax request will return json object
  * and for non-ajax request if deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionBulkDelete()
 {
     $request = Yii::$app->request;
     $pks = $request->post('pks');
     // Array or selected records primary keys
     foreach (UsersOffices::findAll(json_decode($pks)) as $model) {
         $this->deleteRoleAction($model);
         $model->delete();
     }
     if ($request->isAjax) {
         /*
          *   Process for ajax request
          */
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ['forceClose' => true, 'forceReload' => '#crud-datatable-pjax'];
     } else {
         /*
          *   Process for non-ajax request
          */
         return $this->redirect(['index']);
     }
 }