This commit is contained in:
2022-05-12 21:28:21 -04:00
parent 64b74940b8
commit c414318ca8
+7 -2
View File
@@ -73,6 +73,7 @@ long InterestPending(CVars in, CVars &out) {
long PastDueWarings(CVars in, CVars &out) {
logfmt(logINFO, "ENTER PastDueWarings()");
long contract_id = 0;
const PGresult *res = pgsql_query("SELECT mc.id AS contract_id, mc.member_id,mc.auto_remind "
" FROM members_jobs_contract mc "
" LEFT JOIN members m ON m.id=mc.client_id "
@@ -84,8 +85,12 @@ long PastDueWarings(CVars in, CVars &out) {
if (f.empty()) continue;
CVars rec;
map_to_cvars(f, rec);
cron_email(WRB_CRONJOB_PASTDUE_ALERT, rec, out); // send the cron email
// note we send once in the loop
// we need the loop to mar items but wanted to send the email only once
if ( contract_id != rec["contract_id"].Long() ){
contract_id = rec["contract_id"].Long();
cron_email(WRB_CRONJOB_PASTDUE_ALERT, rec, out); // send the cron email
}
pgsql_exec("UPDATE members_jobs_contract SET auto_remind=auto_remind + 1 "\
"WHERE member_id=%lu AND id = 4 ", rec["member_id"].Long(),rec["contract_id"].Long());