fix
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
#include "pgsql_wrapper.h"
|
#include "pgsql_wrapper.h"
|
||||||
#include "cfg.h"
|
#include "cfg.h"
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
|
#include "jobs.h"
|
||||||
|
|
||||||
long ReviewReminder(CVars in, CVars &out);
|
long ReviewReminder(CVars in, CVars &out);
|
||||||
long OfferPending(CVars in, CVars &out);
|
long OfferPending(CVars in, CVars &out);
|
||||||
@@ -74,7 +75,37 @@ long InterestPending(CVars in, CVars &out) {
|
|||||||
long PastDueWarings(CVars in, CVars &out) {
|
long PastDueWarings(CVars in, CVars &out) {
|
||||||
logfmt(logINFO, "ENTER PastDueWarings()");
|
logfmt(logINFO, "ENTER PastDueWarings()");
|
||||||
long contract_id = 0;
|
long contract_id = 0;
|
||||||
const PGresult *res = pgsql_query("SELECT mc.id AS contract_id, mc.member_id,mc.auto_remind "
|
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 "
|
||||||
|
" WHERE mc.status IN (1,2) AND mc.auto_remind > 2 "
|
||||||
|
" AND delivery_date < now() GROUP BY mc.member_id ,mc.auto_remind, contract_id ORDER BY mc.auto_remind DESC");
|
||||||
|
if (res != NULL && pgsql_num_rows(res) > 0) {
|
||||||
|
for (int i = 0, n = pgsql_num_rows(res); i < n; i++) {
|
||||||
|
map<const char*, const char*>f = pgsql_fetch_assoc(res, i);
|
||||||
|
if (f.empty()) continue;
|
||||||
|
CVars rec;
|
||||||
|
map_to_cvars(f, rec);
|
||||||
|
// 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 = %lu ", rec["member_id"].Long(),rec["contract_id"].Long());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logfmt(logINFO, "/PastDueWarings()");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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 "
|
" FROM members_jobs_contract mc "
|
||||||
" LEFT JOIN members m ON m.id=mc.client_id "
|
" LEFT JOIN members m ON m.id=mc.client_id "
|
||||||
" WHERE mc.status IN (1,2) AND mc.auto_remind < 3 "
|
" WHERE mc.status IN (1,2) AND mc.auto_remind < 3 "
|
||||||
|
|||||||
Reference in New Issue
Block a user