ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

v 1.3.3 grocery CRUD - an automatic Codeigniter CRUD

April 11, 2011 3:24am

Subscribe [77]
  • #151 / Aug 26, 2011 3:12am

    InsiteFX

    6819 posts

    [SOLVED]
    This was due to it running in a dashboard for the backend administration!
    Which was also including it’s own jQuery script file. Solved it by
    remarking out the the dashboards jQuery file! They were loading it at the
    bottom of the html file not on top.

    ============================================================================
    Ok,

    This is running on CI 2.0.2

    Everything is working fine, except for the pagination
    this is happening on a localhost and live server!

    jQuery is throwing these errors in Firebug, also tested on IE9 same problem:

    $("#crud_page").numeric is not a function
    [Break On This Error] $('#crud_page').numeric();
    flexigrid.js (line 149)
    
    $(this).ajaxSubmit is not a function
    [Break On This Error] success: function(data){
    flexigrid.js (line 32)

    So no pagination is happening, but everything else is working!
    I have checked an it is creating the cookies.
    It is creating the pagination stubs.

  • #152 / Aug 27, 2011 7:34am

    cadaeib

    3 posts

    Maybe there is a mistake in application/models/grocery_model.php in the function get_relation_1_n_unselected_array .... here the new version who is working for me, we should work on the PK of the selection table not on primary_key_alias_to_selection_table :

    function get_relation_1_n_unselected_array($field_info, $selected_values)
        {
            $selection_primary_key = $this->get_primary_key($field_info->selection_table);
            
            $this->db->order_by("{$field_info->selection_table}.{$field_info->title_field_selection_table}");
            $results = $this->db->get($field_info->selection_table)->result();
            $results_array = array();
            foreach($results as $row)
            {
                //if(!isset($selected_values[$row->{$field_info->primary_key_alias_to_selection_table}])){
                if(!isset($selected_values[$row->{$selection_primary_key}])){
                    $results_array[$row->{$selection_primary_key}] = $row->{$field_info->title_field_selection_table};
                    //$results_array[$row->{$field_info->primary_key_alias_to_selection_table}] = $row->{$field_info->title_field_selection_table};
                    } 
            }
            return $results_array;        
            
        }
  • #153 / Aug 27, 2011 11:19am

    web-johnny

    235 posts

    Maybe there is a mistake in application/models/grocery_model.php in the function get_relation_1_n_unselected_array .... here the new version who is working for me, we should work on the PK of the selection table not on primary_key_alias_to_selection_table :

    function get_relation_1_n_unselected_array($field_info, $selected_values)
        {
            $selection_primary_key = $this->get_primary_key($field_info->selection_table);
            
            $this->db->order_by("{$field_info->selection_table}.{$field_info->title_field_selection_table}");
            $results = $this->db->get($field_info->selection_table)->result();
            $results_array = array();
            foreach($results as $row)
            {
                //if(!isset($selected_values[$row->{$field_info->primary_key_alias_to_selection_table}])){
                if(!isset($selected_values[$row->{$selection_primary_key}])){
                    $results_array[$row->{$selection_primary_key}] = $row->{$field_info->title_field_selection_table};
                    //$results_array[$row->{$field_info->primary_key_alias_to_selection_table}] = $row->{$field_info->title_field_selection_table};
                    } 
            }
            return $results_array;        
            
        }

    Thanks for your post that makes me realize that ... the grocery_model has not been committed right!!! You’ re right actually this was a bug that another user find and I fixed that for v.1.1 . I hope this is the only file that was not committed successfully. I hate to do that but I will delete and upload again my project to google-project. It’s really really weird, I think I must change the version control and move to github. I’ve already create an account and when I got some time I will move there immediately .
    What do you think about github? Is it good for open-source projects?

    Many thanks for your post

  • #154 / Aug 27, 2011 7:34pm

    cadaeib

    3 posts

    Just one word :: thanks !
    Thanks for your work, yes github is good one and bugs (or mistake or what else ) is no matter ...
    You are the Chief.
    I will working on render for hmvc to have many flexigrids on the same page (like customers list and orders for one selected customer, i should add button on tools column to get orders for a particular customer) ... and i post my work in this topic, ok ?

  • #155 / Aug 27, 2011 8:03pm

    web-johnny

    235 posts

    Just one word :: thanks !
    Thanks for your work, yes github is good one and bugs (or mistake or what else ) is no matter ...
    You are the Chief.
    I will working on render for hmvc to have many flexigrids on the same page (like customers list and orders for one selected customer, i should add button on tools column to get orders for a particular customer) ... and i post my work in this topic, ok ?

    I will be glad if you post something like this here. Thanks for being a grocery CRUD addicted member 😊

  • #156 / Aug 28, 2011 7:18am

    web-johnny

    235 posts

    [SOLVED]
    This was due to it running in a dashboard for the backend administration!
    Which was also including it’s own jQuery script file. Solved it by
    remarking out the the dashboards jQuery file! They were loading it at the
    bottom of the html file not on top.

    ============================================================================
    Ok,

    This is running on CI 2.0.2

    Everything is working fine, except for the pagination
    this is happening on a localhost and live server!

    jQuery is throwing these errors in Firebug, also tested on IE9 same problem:

    $("#crud_page").numeric is not a function
    [Break On This Error] $('#crud_page').numeric();
    flexigrid.js (line 149)
    
    $(this).ajaxSubmit is not a function
    [Break On This Error] success: function(data){
    flexigrid.js (line 32)

    So no pagination is happening, but everything else is working!
    I have checked an it is creating the cookies.
    It is creating the pagination stubs.

    Actually I think this is a JavaScript conflict. Try to delete all the cookies and sessions and try again. If this is not working for you, check if there are two jquery libraries in your project. For example if you have jquery-1.4.3 and 1.6.2 it will have problem. If this doesn’t work for you can you please attach me an image of how the table looks like?

  • #157 / Aug 28, 2011 3:36pm

    Sinapit

    10 posts

    @web-johnny

    can you give me example how to check field exist or not?

    example..i want to check username exist or not on one table

  • #158 / Aug 29, 2011 12:42pm

    web-johnny

    235 posts

    @web-johnny

    can you give me example how to check field exist or not?

    example..i want to check username exist or not on one table

    You can use the set_rules of codeigniter and use callbacks. See the examples at : http://ellislab.com/codeigniter/user-guide/libraries/form_validation.html#callbacks and you can also see how to use it in grocery crud at: http://www.grocerycrud.com/crud/example/set_validation_rules. It works EXACTLY with the same way as codeigniter rules, it’s very easy

  • #159 / Aug 29, 2011 5:44pm

    Sinapit

    10 posts

    i’m using this code but not worked.

    public function index()
        {
            $crud = new grocery_CRUD();
            $crud->set_theme('datatables');
            $crud->set_table('tbl_customer');
            $crud->columns('name_customer', 'city', 'state', 'phone', 'cellphone', 'id_status');
            $crud->set_relation('id_status','tbl_status','status_msg');
            $crud->display_as('name_customer','Name');
            $crud->display_as('url','Homepage');
            $crud->display_as('id_status','Status');
            $crud->display_as('username_customer','Username');
            $crud->display_as('password_customer','Password');
            $crud->set_subject('Customer');
            $crud->required_fields('name_customer', 'address', 'city', 'zip',  'country', 'state', 'cellphone', 'email', 'username_customer', 'password_customer');    
            $crud->callback_field('password_customer',array($this,'_password_customer_field'));
            $crud->set_rules('username_customer','Username','callback_username_check');
            $crud->set_rules('email','Email','valid_email');
            $crud->callback_before_insert(array($this,'_field_encryption'));
            $crud->callback_before_update(array($this,'_field_encryption')); 
            $crud->callback_after_insert(array($this,'_insert_field'));
                            
            $this->output->set_output_data('title','Hanggardecor.com - Administration: Customer');
            $this->output->set_output_data('breadcrumb','Home / Customer');
                
            $crud->render();        
        }
    public function username_check($post_array)
        {                
            $username = $this->customer_model->username_check($post_array['username_customer']);
            if( $username )
            {        
                $this->form_validation->set_message('username_check', 'Your Username allready exist, please use another Username');    
                return FALSE;    
                
            }else{
                return TRUE;            
            }    
            return $post_array;    
        }

    please help me.

  • #160 / Aug 30, 2011 6:27pm

    web-johnny

    235 posts

    i’m using this code but not worked.

    public function index()
        {
            $crud = new grocery_CRUD();
            $crud->set_theme('datatables');
            $crud->set_table('tbl_customer');
            $crud->columns('name_customer', 'city', 'state', 'phone', 'cellphone', 'id_status');
            $crud->set_relation('id_status','tbl_status','status_msg');
            $crud->display_as('name_customer','Name');
            $crud->display_as('url','Homepage');
            $crud->display_as('id_status','Status');
            $crud->display_as('username_customer','Username');
            $crud->display_as('password_customer','Password');
            $crud->set_subject('Customer');
            $crud->required_fields('name_customer', 'address', 'city', 'zip',  'country', 'state', 'cellphone', 'email', 'username_customer', 'password_customer');    
            $crud->callback_field('password_customer',array($this,'_password_customer_field'));
            $crud->set_rules('username_customer','Username','callback_username_check');
            $crud->set_rules('email','Email','valid_email');
            $crud->callback_before_insert(array($this,'_field_encryption'));
            $crud->callback_before_update(array($this,'_field_encryption')); 
            $crud->callback_after_insert(array($this,'_insert_field'));
                            
            $this->output->set_output_data('title','Hanggardecor.com - Administration: Customer');
            $this->output->set_output_data('breadcrumb','Home / Customer');
                
            $crud->render();        
        }
    public function username_check($post_array)
        {                
            $username = $this->customer_model->username_check($post_array['username_customer']);
            if( $username )
            {        
                $this->form_validation->set_message('username_check', 'Your Username allready exist, please use another Username');    
                return FALSE;    
                
            }else{
                return TRUE;            
            }    
            return $post_array;    
        }

    please help me.

    remove the username_customer from the required_field because it uses the set_rules. I am not sure, but I think it will work. So the :

    $crud->required_fields('name_customer', 'address', 'city', 'zip',  'country', 'state', 'cellphone', 'email', 'username_customer', 'password_customer');

    will be :

    $crud->required_fields('name_customer', 'address', 'city', 'zip',  'country', 'state', 'cellphone', 'email', 'password_customer');
  • #161 / Aug 30, 2011 6:42pm

    chule143

    5 posts

    Why I can not upload files in IE and Opera? but I can in Firefox

    function products() {

    $this->load->library('grocery_CRUD');
    $crud = new grocery_CRUD();

    $crud->set_theme('flexigrid');
    $crud->set_table('tbl_products');
    $crud->required_fields('number', 'id_prod_vendor');
    $crud->columns('number', 'desc', 'id_prod_vendor', 'offer', 'season');
    $crud->set_subject('Product');

    $crud->display_as('id_prod_vendor', 'Vendor')
    ->display_as('desc', 'Description')
    ->display_as('season', 'Seasonal Product')
    ->display_as('offer', 'Sale Product');

    $crud->set_field_upload('image', 'public/uploads/products');

    $crud->set_relation('id_prod_vendor', 'tbl_prod_vendor', 'vendor');

    $crud->change_field_type('offer', 'true_false');
    $crud->change_field_type('season', 'true_false');

    $crud->render();
    }

  • #162 / Aug 31, 2011 11:39pm

    Sinapit

    10 posts

    i’m using this code but not worked.

    public function index()
        {
            $crud = new grocery_CRUD();
            $crud->set_theme('datatables');
            $crud->set_table('tbl_customer');
            $crud->columns('name_customer', 'city', 'state', 'phone', 'cellphone', 'id_status');
            $crud->set_relation('id_status','tbl_status','status_msg');
            $crud->display_as('name_customer','Name');
            $crud->display_as('url','Homepage');
            $crud->display_as('id_status','Status');
            $crud->display_as('username_customer','Username');
            $crud->display_as('password_customer','Password');
            $crud->set_subject('Customer');
            $crud->required_fields('name_customer', 'address', 'city', 'zip',  'country', 'state', 'cellphone', 'email', 'username_customer', 'password_customer');    
            $crud->callback_field('password_customer',array($this,'_password_customer_field'));
            $crud->set_rules('username_customer','Username','callback_username_check');
            $crud->set_rules('email','Email','valid_email');
            $crud->callback_before_insert(array($this,'_field_encryption'));
            $crud->callback_before_update(array($this,'_field_encryption')); 
            $crud->callback_after_insert(array($this,'_insert_field'));
                            
            $this->output->set_output_data('title','Hanggardecor.com - Administration: Customer');
            $this->output->set_output_data('breadcrumb','Home / Customer');
                
            $crud->render();        
        }
    public function username_check($post_array)
        {                
            $username = $this->customer_model->username_check($post_array['username_customer']);
            if( $username )
            {        
                $this->form_validation->set_message('username_check', 'Your Username allready exist, please use another Username');    
                return FALSE;    
                
            }else{
                return TRUE;            
            }    
            return $post_array;    
        }

    please help me.

    remove the username_customer from the required_field because it uses the set_rules. I am not sure, but I think it will work. So the :

    $crud->required_fields('name_customer', 'address', 'city', 'zip',  'country', 'state', 'cellphone', 'email', 'username_customer', 'password_customer');

    will be :

    $crud->required_fields('name_customer', 'address', 'city', 'zip',  'country', 'state', 'cellphone', 'email', 'password_customer');

    not work :(

  • #163 / Sep 01, 2011 5:34pm

    web-johnny

    235 posts

    @Sinapit can you please write in the post the table without the data? for example:

    CREATE TABLE IF NOT EXISTS `customers` (
      `customerNumber` int(11) NOT NULL AUTO_INCREMENT,
      `customerName` varchar(50) NOT NULL,
      `contactLastName` varchar(50) NOT NULL,
      `contactFirstName` varchar(50) NOT NULL,
      `phone` varchar(50) NOT NULL,
      `addressLine1` varchar(50) NOT NULL,
      `addressLine2` varchar(50) DEFAULT NULL,
      `city` varchar(50) NOT NULL,
      `state` varchar(50) DEFAULT NULL,
      `postalCode` varchar(15) DEFAULT NULL,
      `country` varchar(50) NOT NULL,
      `salesRepEmployeeNumber` int(11) DEFAULT NULL,
      `creditLimit` double DEFAULT NULL,
      PRIMARY KEY (`customerNumber`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=500 ;
  • #164 / Sep 02, 2011 10:34am

    Sinapit

    10 posts

    public function index()
        {
            $crud = new grocery_CRUD();
            $crud->set_theme('datatables');
            $crud->set_table('tbl_customer');
            $crud->columns('name_customer', 'city', 'state', 'phone', 'cellphone', 'id_status');
            $crud->set_relation('id_status','tbl_status','status_msg');
            $crud->display_as('name_customer','Name');
            $crud->display_as('url','Homepage');
            $crud->display_as('id_status','Status');
            $crud->display_as('username_customer','Username');
            $crud->display_as('password_customer','Password');
            $crud->set_subject('Customer');
            $crud->required_fields('name_customer', 'address', 'city', 'zip',  'country', 'state', 'cellphone', 'email', 'password_customer');    
            $crud->callback_field('password_customer',array($this,'_password_customer_field'));
            $crud->set_rules('username_customer','Username','callback_username_check');
            $crud->set_rules('email','Email','valid_email');
            $crud->callback_before_insert(array($this,'_field_encryption'));
            $crud->callback_before_update(array($this,'_field_encryption')); 
            $crud->callback_after_insert(array($this,'_insert_field'));
                            
            $this->output->set_output_data('title','Hanggardecor.com - Administration: Customer');
            $this->output->set_output_data('breadcrumb','Home / Customer');
                
            $crud->render();        
        }
    public function username_check($str)
        {                
            $username = $this->customer_model->username_check($str);
            if( $username )
            {        
                $this->form_validation->set_message('username_check', 'Your Username allready exist, please use another Username');    
                return FALSE;    
                
            }else{
                return TRUE;            
            }    
        }

    thanks to @web-johnny

  • #165 / Sep 03, 2011 2:35pm

    Sinapit

    10 posts

    @web-johnny

    Can you give me example how to make distinct field?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases