This commit is contained in:
2022-07-30 08:50:58 -04:00
parent 130c8f8b9c
commit efc3692e1d
17 changed files with 49 additions and 37 deletions
+20
View File
@@ -267,6 +267,8 @@ long PaymentPending(CVars in, CVars &out) {
long DeadlineLineApprachClient(CVars in, CVars &out) // called
{
logfmt(logINFO, "DeadlineLineApprachClient()");
// First Reminder
const PGresult *res = pgsql_query("SELECT j.client_id,j.id AS contract_id FROM members_jobs_contract j "\
"WHERE j.due_remind IS NULL AND j.status IN (1,2) "\
"AND j.delivery_date > now() AND j.delivery_date < now() + '1 day' "\
@@ -281,6 +283,24 @@ long DeadlineLineApprachClient(CVars in, CVars &out) // called
pgsql_exec("UPDATE members_jobs_contract SET due_remind=now() WHERE id=%lu", rec["contract_id"].Long());
}
}
const PGresult *res2 = pgsql_query("SELECT j.client_id,j.id AS contract_id FROM members_jobs_contract j "\
"WHERE now() > j.due_remind + '6 hours' AND j.status IN (1,2) "\
"AND j.delivery_date > now() AND j.delivery_date < now() + '1 day' "\
"AND j.client_id IS NOT NULL AND j.client_id > 0 limit %lu", in["one_limit"].Long());
if (res2 != NULL && pgsql_num_rows(res2) > 0) {
for (int i = 0, n = pgsql_num_rows(res2); i < n; i++) {
map<const char*, const char*>f = pgsql_fetch_assoc(res2, i);
if (f.empty()) continue;
CVars rec;
map_to_cvars(f, rec);
job_email(JOBS_DUE_APPROACH_MAIL, rec, out); // send the reminder email
pgsql_exec("UPDATE members_jobs_contract SET due_remind=now() WHERE id=%lu", rec["contract_id"].Long());
}
}
logfmt(logINFO, "/DeadlineLineApprachClient()");
return 0;
}