I m not able to pass value by add_action beetween 2 table, the first "preventivo":
[attachment=400:preventivo_table.jpg]
and the second "preventivo_corpo":
[attachment=401:preventivo_corpo_table.jpg].
My controller "preventivi" with add_action
public function preventivi()
{
$crud = new grocery_CRUD();
$crud->set_table('preventivo');
$crud->set_subject('Preventivi');
$crud->columns('id_prev','id_op','data','id_cli','cantiere');
$crud->set_relation('id_op','operatore','{cognome} {nome}');
$crud->set_relation('id_cli','clienti','rag_soc');
$crud->display_as('id_cli','Cliente');
$crud->add_action('Aggiungi Prodotti', 'http://www.noleggiogruedili.com/images/icon-preventivo.gif', '','ui-icon-plus',array($this,'aggiungi_prod'));
$output = $crud->render();
$this->_example_output($output);
}
controller aggiungi_prod
function aggiungi_prod($primary_key, $row)
{
$this->session->set_flashdata('id_prev2', $row->id_prev);
return site_url('main/preventivo_corpo/add');
}
controller preventivo_corpo
public function preventivo_corpo()
{
$this->session->keep_flashdata('id_prev2');
$crud = new grocery_CRUD();
$crud->set_table('preventivo_corpo');
$crud->set_subject('Prodotti');
$crud->columns('testina','id_prev', 'id_cat_prod', 'id_prod', 'id_for', 'qta', 'costo_for', 'sc_for', 'costo_netto', 'prezzo_offerta', 'sc_offerta', 'prezzo_netto', 'utile', 'provvigione');
$crud->set_relation('id_cat_prod','categoria_prodotti','cat_prodotti');
$crud->set_relation('id_prod','prodotti','desc_prodotti');
$crud->set_relation('id_for','fornitori','rag_soc');
$crud->field_type('costo_netto', 'invisible');
$crud->field_type('prezzo_netto', 'invisible');
$crud->field_type('utile', 'invisible');
/*$crud->field_type('id_prev', 'invisible');*/
$crud->callback_before_insert(array($this,'netto'));
$crud->callback_add_field('id_prev',array($this,'callback_add_id_prev'));
$crud->display_as('id_cat_prod','Categoria');
$crud->display_as('id_prod','Prodotto');
$crud->display_as('id_for','Fornitore');
$crud->display_as('costo_for','Costo lordo unitario');
$crud->display_as('prezzo_offerta','Prezzo lordo unitario');
$crud->display_as('costo_netto','Costo netto totale');
$crud->display_as('prezzo_netto','Prezzo netto totale');
$output = $crud->render();
$this->_example_output($output);
}
controller callback_add_id_prev
function callback_add_id_prev()
{
/*return "<input type='text' value='".$this->session->flashdata('id_prev')."'";*/
return "<input type='text' value='".$this->session->flashdata('id_prev2')."'";
}
I tried to follow this: http://www.grocerycr...eded/#entry1078
What I d like to do is:
after add a preventivo, click on action and add products and other data in table "preventivo_corpo", passing it the id_prev:
[attachment=402:preventivo_table_click.jpg]
My code seem to pass just the id_prev of last row.
Can u help me?
Thanks,
Michele