public function search()
    {
        $roles = Role::select(array('roles.id', 'roles.name', 'roles.id as users', 'roles.created_at'));
        return Datatables::of($roles)->edit_column('users', '{{{ DB::table(\'assigned_roles\')->where(\'role_id\', \'=\', $id)->count()  }}}')->add_column('actions', '<a href="javascript:void(0)" id="role_edit" role_id="{{{ $id }}}" class="btn_table btn btn-info"><i class="fa fa-share-square-o"></i> Edit</a>
	                             <a href="javascript:void(0)" id="role_delete" role_id="{{{ $id }}}" class="btn_table btn btn-danger"><i class="fa fa-trash-o"></i> Delete</a>
	                ')->remove_column('id')->make();
    }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     // Title
     $title = Lang::get('admin/roles/title.role_management');
     $roles = Role::select(array('roles.id', 'roles.name', 'roles.id as users', 'roles.created_at'))->get();
     // Show the page
     $this->render('admin.roles/.index', compact('roles', 'title'));
 }
Esempio n. 3
0
 public function run()
 {
     DB::table('users')->delete();
     User::create(array('name' => 'Kristijan', 'lozinka' => Hash::make('kristijan'), 'role_id' => Role::select('id')->where('ime', '=', 'Administrator')->first()->id));
     User::create(array('name' => 'Andrija', 'lozinka' => Hash::make('andrija'), 'role_id' => Role::select('id')->where('ime', '=', 'Asistent')->first()->id));
     User::create(array('name' => 'Hrvoje', 'lozinka' => Hash::make('hrvoje'), 'role_id' => Role::select('id')->where('ime', '=', 'Instruktor')->first()->id));
     User::create(array('name' => 'Antun', 'lozinka' => Hash::make('antun'), 'role_id' => Role::select('id')->where('ime', '=', 'Voditelj tečaja')->first()->id));
 }
 public function tablaRolesPermiso()
 {
     $id = Input::get("id");
     $roles = Role::select("id", "name")->orderBy("id")->get();
     $permisos = PermissionRole::where("role_id", "=", $id)->select("id", "state")->orderBy("id")->get();
     $html = View::make("dashboard.roles.rolesTablaPermisos")->with(array("roles" => $roles, "permisos" => $permisos, "role" => Input::get("role"), "id" => $id));
     $datos = (string) $html;
     return Response::json(array("datos" => $datos));
 }
Esempio n. 5
0
 public function listRole()
 {
     if (!Request::ajax()) {
         return App::abort(404);
     }
     $start = Input::has('start') ? (int) Input::get('start') : 0;
     $length = Input::has('length') ? Input::get('length') : 10;
     $search = Input::has('search') ? Input::get('search') : [];
     $roles = Role::select('id', 'name');
     if (!empty($search)) {
         foreach ($search as $key => $value) {
             if (empty($value)) {
                 continue;
             }
             $value = ltrim(rtrim($value));
             $roles->where($key, 'like', '%' . $value . '%');
         }
     }
     $order = Input::has('order') ? Input::get('order') : [];
     if (!empty($order)) {
         $columns = Input::has('columns') ? Input::get('columns') : [];
         foreach ($order as $value) {
             $column = $value['column'];
             if (!isset($columns[$column]['name']) || empty($columns[$column]['name'])) {
                 continue;
             }
             $roles->orderBy($columns[$column]['name'], $value['dir'] == 'asc' ? 'asc' : 'desc');
         }
     }
     $count = $roles->count();
     if ($length > 0) {
         $roles = $roles->skip($start)->take($length);
     }
     $arrRoles = $roles->get()->toArray();
     $arrReturn = ['draw' => Input::has('draw') ? Input::get('draw') : 1, 'recordsTotal' => Role::count(), 'recordsFiltered' => $count, 'data' => []];
     if (!empty($arrRoles)) {
         foreach ($arrRoles as $role) {
             $arrReturn['data'][] = array(++$start, $role['id'], $role['name']);
         }
     }
     $response = Response::json($arrReturn);
     $response->header('Content-Type', 'application/json');
     return $response;
 }
Esempio n. 6
0
 public function indexAction()
 {
     $request = $this->getRequest();
     $model = new Role();
     $searchForm = new Logic_Role_Form_Filter();
     $this->view->form = $searchForm;
     $filter = $request->getParam('filter_is_deleted', false);
     $ghost = "false";
     if ($filter) {
         $searchForm->getElement('filter_is_active')->setChecked(false);
         $searchForm->getElement('filter_is_deleted')->setChecked(true);
         $ghost = "true";
     }
     $select = $model->select()->from('role')->where('ghost = ' . $ghost);
     $page = $request->getParam('page', 1);
     $sort = $request->getParam('sort', 'id');
     $order = $request->getParam('order', 'asc');
     $select->order($sort . ' ' . $order);
     $paginator = new Base_Paginator(new Zend_Paginator_Adapter_DbTableSelect($select));
     $paginator->setCurrentPageNumber($page);
     $this->view->paginator = $paginator;
     $this->view->headers = array('role_name');
     $this->view->headScript()->appendFile('/static/js/filtr_active.js');
 }
Esempio n. 7
0
 /**
  * Show a list of all the roles formatted for Datatables.
  *
  * @return Datatables JSON
  */
 public function getData()
 {
     $roles = Role::select(array('roles.id', 'roles.name', 'roles.id as users', 'roles.created_at'));
     return Datatables::of($roles)->edit_column('users', '{{{ DB::table(\'assigned_roles\')->where(\'role_id\', \'=\', $id)->count()  }}}')->add_column('actions', '<a href="{{{ URL::to(\'admin/roles/\' . $id . \'/edit\' ) }}}" class="iframe btn btn-xs btn-default">{{{ Lang::get(\'button.edit\') }}}</a>
                             <a href="{{{ URL::to(\'admin/roles/\' . $id . \'/delete\' ) }}}" class="iframe btn btn-xs btn-danger">{{{ Lang::get(\'button.delete\') }}}</a>
                 ')->remove_column('id')->make();
 }
 /**
  * Show a list of all the roles formatted for Datatables.
  *
  * @return Datatables JSON
  */
 public function getData()
 {
     $roles = Role::select(array('roles.id', 'roles.name', 'roles.id as users', 'roles.created_at', 'roles.updated_at'));
     return Datatables::of($roles)->edit_column('created_at', '{{ $created_at->format("Y-m-d h:i:s") }}')->edit_column('updated_at', '{{ $updated_at->format("Y-m-d h:i:s") }}')->edit_column('users', '<span class="label label-success">{{{ DB::table(\'assigned_roles\')->where(\'role_id\', \'=\', $id)->count()  }}}</span>')->add_column('actions', '
         <div class="btn-group">
         <a href="{{{ URL::to(\'admin/roles/\' . $id . \'/edit\' ) }}}" class="iframe btn btn-xs btn-primary"><i class="fa fa-pencil"></i> {{ Lang::get("button.edit") }}</a>
         @if (!in_array($name, [\'admin\',\'comment\']))
         <a href="{{{ URL::to(\'admin/roles/\' . $id . \'/delete\' ) }}}" class="iframe btn btn-xs btn-danger"><i class="fa fa-trash-o"></i> {{ Lang::get("button.delete") }}</a>
         @endif
         </div>
         ')->remove_column('id')->remove_column('rn')->make();
 }
 /**
  * Show a list of all the roles formatted for Datatables.
  *
  * @return Datatables JSON
  */
 public function getData()
 {
     $roles = Role::select(array('roles.id', 'roles.name', 'roles.id as users', 'roles.created_at'));
     if (Api::Enabled()) {
         $u = $roles->get();
         return Api::make($u->toArray());
     } else {
         return Datatables::of($roles)->edit_column('users', '{{{ DB::table(\'assigned_roles\')->where(\'role_id\', \'=\', $id)->count()  }}}')->add_column('actions', '<div class="btn-group"><a href="{{{ URL::to(\'admin/roles/\' . $id . \'/edit\' ) }}}" class="modalfy btn btn-sm btn-primary">{{{ Lang::get(\'button.edit\') }}}</a>
                             <a data-row="{{{  $id }}}" data-method="delete" data-table="roles" href="{{{ URL::to(\'admin/roles/\' . $id . \'\' ) }}}" class="ajax-alert-confirm btn btn-sm btn-danger" @if($name == "admin" || $name == "users")disabled@endif>{{{ Lang::get(\'button.delete\') }}}</a></div>
                 ')->make();
     }
 }
Esempio n. 10
0
 /**
  * Pobranie danych roli do wyświetlenia
  *
  * @param integer $id id roli
  * @return Row_Rola wiersz z danymi
  */
 public function showRole($id)
 {
     $modelGroup = new Group();
     $select = $modelGroup->select()->from(array('g' => 'group'), array())->joinLeft(array('rg' => 'role_group'), 'rg.id_group = g.id', array())->where('g.ghost = \'f\'')->where('rg.id_role = ?', $id)->columns(array('groups' => new Zend_Db_Expr('array_to_string(array_agg(description),\'<br />\')')))->setIntegrityCheck(false);
     $model = new Role();
     $cols = array('role_name', 'description', 'groups' => new Zend_Db_Expr('(' . $select . ')'), 'ghost' => new Zend_Db_Expr('CASE WHEN ghost=true THEN \'tak\' ELSE \'nie\' END'));
     $select = $model->select()->from(array('r' => 'role'))->columns($cols)->where('r.id = ?', $id);
     $data = $model->fetchRow($select);
     return $data;
 }
Esempio n. 11
0
 /**
  * Show a list of all the roles formatted for Datatables.
  *
  * @return Datatables JSON
  */
 public function data()
 {
     $roles = Role::select(array('roles.id', 'roles.name', 'roles.description', 'roles.id as users', 'roles.created_at'));
     return Datatables::of($roles)->edit_column('users', '{{{ DB::table(\'assigned_roles\')->where(\'role_id\', \'=\', $id)->count()  }}}')->add_column('actions', '<div class="btn-group">
               <button type="button" class="btn btn-xs btn-primary dropdown-toggle" data-toggle="dropdown">
                 Action <span class="caret"></span>
               </button>
               <ul class="dropdown-menu" role="menu">
                 <li><a href="{{{ URL::to(\'admin/roles/\' . $id ) }}}">{{{ Lang::get(\'button.show\') }}}</a></li>
                 <li><a href="{{{ URL::to(\'admin/roles/\' . $id . \'/edit\' ) }}}">{{{ Lang::get(\'button.edit\') }}}</a></li>
                 @if($name == \'admin\')
                 @else
                 <li><a href="{{{ URL::to(\'admin/roles/\' . $id . \'/delete\' ) }}}">{{{ Lang::get(\'button.delete\') }}}</a></li>
                 @endif
               </ul>
             </div>')->remove_column('id')->make();
 }
Esempio n. 12
0
 public function getDataToUserReport()
 {
     $profileModel = new Profile();
     $select = $profileModel->select()->order('id_user');
     $profileDataArray = $profileModel->fetchAll($select)->toArray();
     $groupModel = new Group();
     $select = $groupModel->select();
     $groupDataArray = $groupModel->fetchAll($select)->toArray();
     foreach ($groupDataArray as $key => $value) {
         $tmp[$value['id']] = $value;
     }
     $groupDataArray = $tmp;
     unset($tmp);
     $branchModel = new Branch();
     $select = $branchModel->select();
     $branchDataArray = $branchModel->fetchAll($select)->toArray();
     foreach ($branchDataArray as $key => $value) {
         $tmp[$value['id']] = $value;
     }
     $branchDataArray = $tmp;
     unset($tmp);
     $userModel = new User();
     $select = $userModel->select();
     $userDataArray = $userModel->fetchAll($select)->toArray();
     foreach ($userDataArray as $key => $value) {
         $tmp[$value['id']] = $value;
     }
     $userDataArray = $tmp;
     unset($tmp);
     $roleModel = new Role();
     $select = $roleModel->select();
     $roleDataArray = $roleModel->fetchAll($select)->toArray();
     foreach ($roleDataArray as $key => $value) {
         $tmp[$value['id']] = $value;
     }
     $roleDataArray = $tmp;
     unset($tmp);
     $groupArray = array();
     foreach ($profileDataArray as $key => $value) {
         $data = $this->getAuthorizationsForProfile($value['id']);
         foreach ($data as $key2 => $values) {
             foreach ($values as $key3 => $privs) {
                 /* if ($privs['ghost'] === true) {
                     unset($data[$key2][$key3]);
                     continue;
                     }
                    */
                 $tmp = array('login' => '', 'surname' => '', 'first_name' => '', 'group' => '', 'role' => '', 'branch' => '', 'ghost' => '');
                 if ($key2 === 'group') {
                     $tmp['group'] = $groupDataArray[$privs['id_group']]['group_name'];
                 }
                 if ($key2 === 'role') {
                     $tmp['role'] = $roleDataArray[$privs['id_role']]['description'];
                 }
                 $tmp['login'] = $userDataArray[$value['id_user']]['login'];
                 $tmp['surname'] = $userDataArray[$value['id_user']]['surname'];
                 $tmp['first_name'] = $userDataArray[$value['id_user']]['first_name'];
                 $tmp['branch'] = $branchDataArray[$value['id_branch']]['branch_name'];
                 $tmp['ghost'] = $userDataArray['ghost'] ? 'NIEAKTYWNY' : 'AKTYWNY';
                 $groupArray[] = $tmp;
             }
         }
     }
     return $groupArray;
 }