Пример #1
0
 public function users()
 {
     $crud = new grocery_CRUD();
     $crud->set_table('users');
     $crud->set_subject('Users');
     $crud->columns('username', 'email', 'groups', 'active');
     if ($this->uri->segment(3) !== 'read') {
         $crud->add_fields('username', 'first_name', 'last_name', 'email', 'phone', 'groups', 'password', 'password_confirm');
         $crud->edit_fields('username', 'first_name', 'last_name', 'email', 'phone', 'groups', 'last_login', 'old_password', 'new_password');
     } else {
         $crud->set_read_fields('username', 'first_name', 'last_name', 'email', 'phone', 'groups', 'last_login');
     }
     $crud->set_relation_n_n('groups', 'users_groups', 'groups', 'user_id', 'group_id', 'name');
     //VALIDATION
     $crud->required_fields('username', 'first_name', 'last_name', 'email', 'phone', 'password', 'password_confirm');
     $crud->set_rules('email', 'E-mail', 'required|valid_email');
     $crud->set_rules('phone', 'Phone', 'required|numeric');
     $crud->set_rules('password', 'Password', 'required|min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']|matches[password_confirm]');
     $crud->set_rules('new_password', 'New password', 'min_length[' . $this->config->item('min_password_length', 'ion_auth') . ']|max_length[' . $this->config->item('max_password_length', 'ion_auth') . ']');
     //FIELD TYPES
     $crud->change_field_type('last_login', 'readonly');
     $crud->change_field_type('password', 'password');
     $crud->change_field_type('password_confirm', 'password');
     $crud->change_field_type('old_password', 'password');
     $crud->change_field_type('new_password', 'password');
     //CALLBACKS
     $crud->callback_insert(array($this, 'create_user_callback'));
     $crud->callback_update(array($this, 'edit_user_callback'));
     $crud->callback_field('last_login', array($this, 'last_login_callback'));
     $crud->callback_column('active', array($this, 'active_callback'));
     //VIEW
     $output = $crud->render();
     $data['judul'] = 'Users';
     $data['crumb'] = array('Users' => '');
     $template = 'admin_template';
     $view = 'grocery';
     $this->outputview->output_admin($view, $template, $data, $output);
 }
Пример #2
0
 public function crud()
 {
     $crud = new grocery_CRUD();
     $crud->set_theme(THEMA_CRUD);
     $crud->set_table('usuario');
     $crud->set_subject('Usuarios');
     $crud->required_fields('nome', 'login', 'email', 'tipo_usuario_id', 'situacao_id');
     $crud->columns('nome', 'login', 'email', 'tipo_usuario_id', 'situacao_id');
     $crud->edit_fields('nome', 'login', 'email', 'tipo_usuario_id', 'situacao_id');
     $crud->add_fields('nome', 'login', 'email', 'tipo_usuario_id');
     $crud->set_relation('tipo_usuario_id', 'tipo_usuario', 'descricao');
     $crud->set_relation('situacao_id', 'situacao', 'descricao');
     $crud->callback_insert(array($this, 'create'));
     $crud->callback_delete(array($this, 'delete'));
     $crud->callback_update(array($this, 'update'));
     $crud->where('situacao_id', 1);
     $crud->or_where('situacao_id', 2);
     $contents = $crud->render();
     //        $this->load->view('template_crud', $contents);
     $this->template->set('titulo', 'Manter Usuário');
     $this->template->set('subtitle', 'Usuário');
     // nome do template , nome da view
     $this->template->load('template_teste', 'crudpage', $contents);
 }
Пример #3
0
    function supervisor_management()
    {
        $id = $this->ion_auth->user()->row()->id;
        $this->load->library('grocery_CRUD');
        try {
            $crud = new grocery_CRUD();
            $this->load->library('user_agent');
            if ($this->agent->is_mobile() && $this->agent->is_tablet() === FALSE) {
                $crud->set_theme('bootstrap');
                $crud->unset_search();
            } else {
                $crud->set_theme('datatables');
                //datatables, flexigrid, bootstrap
            }
            $crud->set_table('users');
            $crud->set_subject('Supervisor');
            $crud->columns('username', 'password_visible', 'su_branch_id', 'su_can_uploadhotdeal');
            $crud->required_fields('username', 'password_visible', 'su_branch_id');
            $crud->fields('username', 'password_visible', 'su_branch_id', 'su_can_uploadhotdeal');
            $crud->display_as('password_visible', 'Password');
            $crud->display_as('su_branch_id', 'Branch');
            $crud->display_as('su_can_uploadhotdeal', 'Able to upload food & beverage');
            $crud->callback_add_field('su_branch_id', array($this, '_selected_branch_callback'));
            //For add page set pre-selected value if got pass in brach id
            $crud->field_type('su_branch_id', 'dropdown', $this->ion_auth->get_merchant_branch_list($id));
            //For view show the branch list text
            $crud->callback_insert(array($this, 'supervisor_insert_callback'));
            $crud->callback_update(array($this, 'supervisor_update_callback'));
            $crud->set_rules('username', 'Username', 'trim|required|callback_supervisor_username_check');
            $crud->field_type('su_can_uploadhotdeal', 'true_false');
            $controller = 'merchant';
            $function = 'profile';
            $crud->set_lang_string('insert_success_message', 'Your data has been successfully stored into the database.
		 <script type="text/javascript">
                 var originallocation = window.location.pathname;
                 if(originallocation.indexOf("/supervisor/add") > -1)
                {
		  window.location = "' . site_url($controller . '/' . $function) . '";
                }
		 </script>
		 <div style="display:none">
		 ');
            $crud->set_lang_string('update_success_message', 'Your data has been successfully stored into the database.
		 <script type="text/javascript">
                 var originallocation = window.location.pathname;
                 if(originallocation.indexOf("/supervisor/edit") > -1)
                {
                window.location = "' . site_url($controller . '/' . $function) . '";
                 }
		 </script>
		 <div style="display:none">
		 ');
            $crud->set_lang_string('form_save_and_go_back', 'Save and View Supervisor');
            $crud->set_lang_string('form_update_and_go_back', 'Update and View Supervisor');
            $crud->unset_export();
            $crud->unset_print();
            $crud->unset_read();
            $state = $crud->getState();
            //filter that this is supervisor type user and it is under this merchant
            $crud->where('su_merchant_id', $id);
            $crud->where('main_group_id', $this->group_id_supervisor);
            $output = $crud->render();
            return $output;
        } catch (Exception $e) {
            show_error($e->getMessage() . ' --- ' . $e->getTraceAsString());
        }
    }