Dear Grocery CRUD User,
i have following problems
Situation:
I have two tables
articles – here the articles are defined
stock - here the storage location is defined
when new things arrive, perhaps with a new price, the new price can be stored in the articles table,
but should not affect already stored data entries.
The idea is to copy the purchase and the sales price from the articles table to new entries in the stock table, for this an add_action shall be used.
At the moment, only the price shall be printed via echo,
but how it looks like, for each entry of the table the function will be executed. :-(
My expectation was that the function will only called for the specific row, like view, edit or delete
A second add_action function shall display entries in the stock table for the specific article
$crud->add_action('AddBox', '', '', 'ui-icon-plusthick',array($this,'addSpecArticle'));
$crud->add_action('FindBox', '', '', 'ui-icon-search',array($this,'viewSpecArticle'));
in the table view of the article tables the buttons will be displayed at the end.
The callback functions look like
function addSpecArticle($primary_key , $row)
{
// Add Box for special article in $row
$tarticleno = $row->articleno;
$tpurchprice = $row->purchprice;
$tsalesprice = $row->salesprice;
$twnetto = $row->wnetto;
$twbrutto = $row->wbrutto;
echo "$tarticleno";
echo "\r\n";
echo "$tpurchprice";
echo "\r\n";
echo "$tsalesprice";
echo "\r\n";
echo "$twbrutto";
echo "\r\n";
echo "$twnetto";
echo "\r\n";
}
function viewSpecArticle($primary_key , $row)
{
// View Box for article of the $row
echo "ArtikelNo:";
echo "$row->articleno\r\n";
$crud = new grocery_CRUD();
$crud->where('articleno',$row->articleno);
$crud->set_table('stock');
$output = $crud->render();
$this->_example_output($output);
}
at the top of the window the following line appear
1 9.99 € 12.99 € ArtikelNo:1 2 7.65 € 9.99 € ArtikelNo:2 3 1 € 2 € 40 20 ArtikelNo:3
which come from the above displayed functions,
also several times the stock grid is displayed, before the article grid follows
(image is attached)
I like to display the article table only and after activation of a addbox or findbox -button the new associated
add form of the stock table or the filtered grid view view of the stock table.
How to call the specific functions is the next question :-)
Thank you very much in advance for your help.
GCStarter