Skip to content

Feature/purchase reminders#13

Open
robertjensen wants to merge 5 commits intofeature/multiple_as_functions_ofsfrom
feature/purchase_reminders
Open

Feature/purchase reminders#13
robertjensen wants to merge 5 commits intofeature/multiple_as_functions_ofsfrom
feature/purchase_reminders

Conversation

@robertjensen
Copy link
Member

This PR adds a purchase reminder facility to cinfdata as suggested by Asger Barkholt Moss

To install, create an extra dataplot table named dateplots_purchase_reminders:

CREATE TABLE `dateplots_purchase_reminders` (                                                          
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,                                                       
  `time` timestamp NOT NULL DEFAULT current_timestamp(),                                               
  `type` int unsigned NOT NULL,                                                                
  `value` double DEFAULT NULL,                                                                         
  PRIMARY KEY (`id`),                                                                                  
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;                                               
grant all on nanomadedata.dateplots_purchase_reminders to 'mail_alarm'@'%';

Remember to change nanomadedata to the name of your database.

Install the python3 QR package:
sudo apt install python3-qrcode

Cinfdata will now recognize email alarms with a description starting with [purchase_reminders] as a purchase reminder and show them in the overview on the order.php page. From here you can generate QR codes that when activated will increase a counter by 1 and thus trig the email alarm.

Sensible defaults for an email alarm is something like this;
Description: [purchase_reminders]Order chocolate turtles
Check: q0 > p0
No repeat interval: 86400
Parameter: 0.1
query: select unix_timestamp(time), value from dateplots_purchase_reminders where type=25 order by id desc limit 1

Email body something like this:

It has been reported, that we are out of chocolate turtles!!

Once you have ordered new ones, reset this alarm by pressing this link:
http://cinfdataurl/cinfdata/other/order.php?id=25&action=reset

Notice that for now, there is no mechanism to insert the expected type-id into the select statement and the email. This will normally be the existing highest id + 1. This is confirmed when the alarm is created and can easily be changed if it was something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant