I am new to PHP and appgini has proved to be excellent but I am struggling with an issue and I hoped someone could help me?
I have a date field called $LastVist. This is entered by the user. I have another date field called $NextVisit. I have a third field called $x631Status, this is an integer field with a value of 1 through to 6.
what I have been trying to do is multiply $x631Status by 30 then add this to $LastVisit to give me what the date of the $NextVisit should be but it is not displaying any date.
I have amended the tabl_dml.php file on the insert and edit lines as it showed in the support pages but still no luck. the code i found on google is below. I would be very grateful if you could help show me what I am doing wrong?
$data['NextVisit'] = strtotime($LastVisit ." + [$x631Status * 30]");
Automatically calculate date
Re: Automatically calculate date
You should change that to:
The above code should be in the tablename_before_insert() and tablename_before_update() hooks rather than in the tablename_dml file.
Code: Select all
$NextVisitTS = strtotime($data['LastVisit']) + $data['x631Status'] * 30 * 86400;
$data['NextVisit'] = date('Y-m-d', $NextVisitTS);
AppGini plugins to add more power to your apps:
- DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
- Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
- Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.