⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Cannot hide or visible the field that link from one table to other table on add



Chan Chea
  • profile picture
  • Member

Posted 15 November 2018 - 08:55 AM

Hi all the member in Grocery CRUD, currently I had fact this problem for three days that I cannot fix it, so please help to check with my code below:

 

 

 public function product_return_stock(){
    $crud = new grocery_CRUD();
$crud->set_table('returnstock');
$crud->set_relation('pro_id','products','pro_name')
     ->set_relation('rst_created_by','users','u_name');
$crud->columns('pro_id','rst_amount','rst_price','rst_created_date','rst_created_by','rst_descrip');
$crud->unset_edit();
$crud->unset_delete();
$crud->unset_clone();
$crud->unset_read_fields('rst_updated_date', 'rst_updated_by');
$crud->field_type('rst_created_date','invisible')
     //->field_type('rst_created_by','invisible')
     ->field_type('rst_descrip','invisible');
$crud->required_fields(array('pro_id','rst_amount','rst_price','rst_descrip'));
$crud->field_type('rst_amount', 'integer');
$crud->field_type('rst_price', 'integer');
$crud->field_type('rst_descrip', 'text');
$crud->add_field_type('rst_created_by','invisible');
//$crud->unset_add_fields('rst_updated_by','rst_updated_date');
$crud->fields('pro_id','rst_amount','rst_price','rst_created_date','rst_created_by','rst_descrip');
$crud->callback_after_insert(array($this,'update_amount_product_after_product_return'));
$crud->callback_before_insert(array($this,'before_insert_return_stock_callback'));
 
$output = $crud->render();
$this->_example_output($output);
    }
    function before_insert_return_stock_callback($post_array){
$getSessionID = $this->session->userdata('user');
    $this->load->model('users_model');
    $user = $this->users_model->getUserRole($getSessionID);
$post_array['rst_created_date'] = date('Y-m-d');
    $post_array['rst_created_by'] = $user->u_id;
return $post_array;
    }
    function update_amount_product_after_product_return($post_array,$primary_key){
    $pro_id = $post_array['pro_id'];
    $amount = $post_array['rst_amount'];
    $total_amount = "pro_available_amount+" . $amount;
    $this->db->set('pro_available_amount', $total_amount, FALSE);
    $this->db->where('pro_id', $pro_id);
    $this->db->update('products'); // gives UPDATE mytable SET field = field+1 WHERE id = 2
    return true;
    }

 


Chan Chea
  • profile picture
  • Member

Posted 15 November 2018 - 08:59 AM

Why don't you help on this?

I need your help now. please


Chan Chea
  • profile picture
  • Member

Posted 15 November 2018 - 10:18 AM

Please help


Chan Chea
  • profile picture
  • Member

Posted 15 November 2018 - 10:20 AM

Please help


Chan Chea
  • profile picture
  • Member

Posted 15 November 2018 - 10:22 AM

Please help


Chan Chea
  • profile picture
  • Member

Posted 16 November 2018 - 01:26 AM

Please help


web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 16 November 2018 - 16:09 PM

Hello @Chan Chea,

 

Can you please describe the problem that you have? Can you please attach a screenshot or add the database relations that you are trying to achieve?
 

For example a simple structure like:

Steps to reproduce:

Expected Results:
Actual Results:


will be very helpful

 

Regards

Johnny