Job filters

This commit is contained in:
CHIEFSOFT\ameye
2023-06-06 13:07:56 -04:00
parent fbc8599ded
commit 2136e57884
4 changed files with 25 additions and 5 deletions
+21 -3
View File
@@ -270,6 +270,7 @@ return 0;
long WrenchJobManagerActiveTasksList(CVars in, CVars &out) {
logfmt(logINFO, "WrenchJobManagerActiveTasksList()");
char vname[30];
char status_filter[300];
char extra_filter[300];
long ret = PHP_API_BAD_PARAM;
@@ -296,17 +297,34 @@ long WrenchJobManagerActiveTasksList(CVars in, CVars &out) {
}
}
/*
res = pgsql_query("SELECT mc.id AS contract_id, mc.job_id AS job_id, mc.price, mc.timeline_days,mc.contract, "
" mj.title, mj.description AS description,mc.job_detail AS job_description, "
" (CASE WHEN mc.status=4 THEN 'Review' "
" WHEN mc.status = 1 AND mc.delivery_date > now() THEN 'Active' "
" WHEN mc.status = 1 AND mc.delivery_date < now() THEN 'Past Due' "
" ELSE 'Others' END) AS status_description,mc.delivery_date "
" FROM members_jobs_contract mc LEFT JOIN members_jobs mj ON mj.id = mc.job_id LEFT JOIN members m ON m.id=mc.client_id "
" WHERE mc.member_id =%lu %s AND mc.status IN (1,2,4) AND mc.delivery_date > now() "
" ORDER BY mc.id DESC LIMIT %lu OFFSET %lu", in["member_id"].Long(),extra_filter, limit, offset);
*/
snprintf(status_filter, sizeof (status_filter), " AND mc.delivery_date > now() ");
if (in["job_mode"]=="PASTDUE"){
snprintf(status_filter, sizeof (status_filter), " AND mc.delivery_date < now() ");
}
const PGresult *res;
res = pgsql_query("SELECT mc.id AS contract_id, mc.job_id AS job_id, mc.price, mc.timeline_days,mc.contract, "
" mj.title, mj.description AS description,mc.job_detail AS job_description, "
" (CASE WHEN mc.status=4 THEN 'Review' "
" WHEN mc.status = 1 AND mc.delivery_date > now() THEN 'Active' "
" WHEN mc.status = 1 AND mc.delivery_date <now() THEN 'Past Due' "
" WHEN mc.status = 1 AND mc.delivery_date < now() THEN 'Past Due' "
" ELSE 'Others' END) AS status_description,mc.delivery_date "
" FROM members_jobs_contract mc LEFT JOIN members_jobs mj ON mj.id = mc.job_id LEFT JOIN members m ON m.id=mc.client_id "
" WHERE mc.member_id =%lu %s AND mc.status IN (1,2,4) AND mc.delivery_date > now() "
" ORDER BY mc.id DESC LIMIT %lu OFFSET %lu", in["member_id"].Long(),extra_filter, limit, offset);
" WHERE mc.member_id =%lu %s AND mc.status IN (1,2,4) %s "
" ORDER BY mc.id DESC LIMIT %lu OFFSET %lu", in["member_id"].Long(),extra_filter, status_filter, limit, offset);
//ORDER BY id DESC LIMIT %lu OFFSET %lu", in["member_id"].Long(), limit, offset);
if (res != NULL && pgsql_num_rows(res) > 0) {
out["total_record"] = pgsql_num_rows(res);
+2 -2
View File
@@ -330,7 +330,7 @@ long RecoCheckTaskDue( int itm_count, CVars in, CVars &out ){
try {
int ic = itm_count;
long member_id = REQ_LONG(in, "member_id", 1, -1);
res = pgsql_query("SELECT * FROM members_jobs_contract WHERE member_id = %lu AND status =1 AND delivery_date > now() ",member_id);
res = pgsql_query("SELECT * FROM members_jobs_contract WHERE member_id = %lu AND status =1 AND delivery_date < now() ",member_id);
if (res != NULL && pgsql_num_rows(res) > 0) {
snprintf(vname, sizeof (vname), "title_%05d", ic);
@@ -410,7 +410,7 @@ long RecoCheckBlog( int itm_count, CVars in, CVars &out ){
snprintf(vname, sizeof (vname), "button_text_%05d", ic);
out[vname] = "View Article";
ret = PHP_API_OK;
} catch (bad_parameter) {
+1
View File
@@ -154,6 +154,7 @@ class WrenchApi extends BaseController
$in["action"] = WRENCHBOARD_FAMILY_MANAGE;
break;
case 'jobmanageractive':
$in["job_mode"] = $in["job_mode"] ?? "ACTIVE";
$in["action"] = WRENCHBOARD_JOB_ACTIVE;
break;
case 'jobmanagercreatejob':
+1
View File
@@ -227,6 +227,7 @@ switch ($endpoint) {
$in["job_mode"] = UPDATE_JOB;
break;
case 'jobmanageractive':
$in["job_mode"] = $in["job_mode"] ?? "ACTIVE";
$in["action"] = WRENCHBOARD_JOB_ACTIVE;
break;
case 'jobmanagerdeletejob':