Next due dash

This commit is contained in:
CHIEFSOFT\ameye
2023-07-01 16:18:52 -04:00
parent f09e3c4f41
commit d644201544
2 changed files with 31 additions and 8 deletions
+20 -2
View File
@@ -756,10 +756,11 @@ long WrenchLoadDashData(CVars in, CVars &out) {
try {
long member_id = REQ_LONG(in, "member_id", 1, -1);
REQ_STRING(in, "uid", 3, 150, "(.*)");
// REQ_LONG(in, "page", 1, -1);
// const PGresult *res;
const PGresult *res = pgsql_query("SELECT * FROM members WHERE id=%lu", member_id);
const PGresult *res = pgsql_query("SELECT * FROM members WHERE id=%lu AND uid='%s'", member_id, in["uid"].c_str());
if (res != NULL && pgsql_num_rows(res) > 0) {
map<const char*, const char*>f = pgsql_fetch_assoc(res, 0);
CVars rec;
@@ -768,7 +769,24 @@ long WrenchLoadDashData(CVars in, CVars &out) {
out["status"] = "OK";
out = rec;
}
// LET SEE IF YOU HAVE NEXT DUE ITEM NOW
out["next_due_status"] = "0";
const PGresult *res2 = pgsql_query("
"SELECT mj.contract AS item_code,mj.delivery_date AS due_date,mj.price,mj.client_id ,c.description AS currency "
" FROM members_jobs_contract mj "
" LEFT JOIN members_jobs j ON j.id = mj.job_id "
" LEFT JOIN currency c ON c.country=j.country "
" WHERE mj.member_id = %lu AND mj.status =1 AND mj.delivery_date > now() "
" UNION "
" SELECT mj.contract AS item_code,mj.delivery_date AS due_date,mj.price,mj.client_id ,c.description AS currency "
" FROM members_jobs_contract mj "
" LEFT JOIN members_jobs j ON j.id = mj.job_id "
" LEFT JOIN currency c ON c.country=j.country "
" WHERE mj.client_id = %lu AND mj.status =1 AND mj.delivery_date > now() "
" ORDER BY due_date ASC;",member_id,member_id);
if (res2 != NULL && pgsql_num_rows(res2) > 0) {
out["next_due_status"] = "1";
}
} catch (bad_parameter) {
logfmt(logINFO, "ERROR CALL long medTrReasonList(CVars in, CVars &out)");
+11 -6
View File
@@ -163,12 +163,17 @@ class ResultFormatter extends Model
case WRENCHBOARD_ACCOUNT_DASHDATA:
$res = $out;
$res['home_activities'] = [];
$res['next_due'] = [
"item_code" => 'THISISCODE',
"due_date" => '2023-07-20',
"price" => '2100.05',
"currency" => 'Naira'
];
if ($res["next_due_status"]==1) {
$res['next_due'] = [
"item_code" => $out["item_code"],
"due_date" => $out["due_date"],
"price" => $out["price"],
"currency" => $out["currency"],
];
}
else{
$res['next_due'] = [];
}
break;
case WRENCHBOARD_ACCOUNT_HOMEBANNERS:
$total = $out["total_record"];