I have a table "nodelist" that persists of a list of servers. There is a column "lastpatch" that contains a date of the day the server was patched.
I want to add a button or something similar that updates the date to today, without going in to edit on that row.
I've managed to scratch something up from examples in this forum and the api.
So I've added a add_action
$crud->add_action('Patch', '', 'node','ui-icon-plus',array($this,'patch'));
(it isn't possible to add a button using the more good looking default theme?)
And also I've created the function patch, actually I tried two..
function patch($primary_key)
{
$patchtoday = array(
"idnode" => $primary_key,
"lastpatch" => date('Y-m-d')
);
$this->db->update('node',$patchtoday,array('idnode' => $primary_key));
return true;
}
function patch($primary_key)
{
$today = date('Y-m-d');
$update_date = array("lastpatch" => $today);
$this->db->where('idnode', $primary_key);
$this->db->update('node', $update_date);
return true;
}
But the problem is that all nodes get their patch date update to today when load the page, not when I press the button.
Is there a way to add a button "Patched" that updates the column lastpatch for selected row?
Thanks