⚠ 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

pass value in add_Action



mirr0r
  • profile picture
  • Member

Posted 18 December 2012 - 16:09 PM

Hi
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

mirr0r
  • profile picture
  • Member

Posted 22 January 2013 - 13:56 PM

Ok I solved in this way:
[color=#282828][font=helvetica, arial, sans-serif]controller "preventivi" with add_action[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]

$crud->add_action('Aggiungi Prodotti', 'http://www.noleggiogruedili.com/images/icon-preventivo.gif', '','ui-icon-plus',array($this,'aggiungi_prod'));
[/font][/color]

[color=#282828][font=helvetica, arial, sans-serif]controller aggiungi_prod[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]

function aggiungi_prod($primary_key, $row)
{

$this->session->set_flashdata('id_prev', $primary_key);
return site_url('main/preventivo_corpo/add');

}
[/font][/color]

[color=#282828][font=helvetica, arial, sans-serif]controller preventivo_corpo[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]

$id_prev = $this->session->flashdata('id_prev');
$crud->field_type('id_prev', 'hidden', $id_prev);
[/font][/color]
[color=#282828][font=helvetica, arial, sans-serif]I hope this can help someone, I lost a lot of time to get work![/font][/color]

[color=#282828][font=helvetica, arial, sans-serif]M.[/font][/color]