diff --git a/wrenchboard/src/include/jobs_manager.h b/wrenchboard/src/include/jobs_manager.h index ea3015a1..da501782 100644 --- a/wrenchboard/src/include/jobs_manager.h +++ b/wrenchboard/src/include/jobs_manager.h @@ -5,5 +5,5 @@ long WrenchJobManagerOffers( CVars in, CVars &out); long WrenchJobManagerList( CVars in, CVars &out ); - +long WrenchUsersTasksList( CVars in, CVars &out); #endif \ No newline at end of file diff --git a/wrenchboard/src/shared_tool/jobs_manager.cc b/wrenchboard/src/shared_tool/jobs_manager.cc index a8ac1429..629be4f2 100644 --- a/wrenchboard/src/shared_tool/jobs_manager.cc +++ b/wrenchboard/src/shared_tool/jobs_manager.cc @@ -262,3 +262,88 @@ long WrenchJobManagerList( CVars in, CVars &out){ } return 0; } + + + +long WrenchUsersTasksList(CVars in, CVars &out) { + logfmt(logINFO, "WrenchMemberActiveJobs()"); + char vname[30]; + long ret = PHP_API_BAD_PARAM; + + try { + long member_id = REQ_LONG(in, "member_id", 1, -1); + long offset = REQ_LONG(in, "offset", 1, -1); + long limit = REQ_LONG(in, "limit", 1, -1); + + out["total_record"] = "0"; + + 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 0) { + out["total_record"] = pgsql_num_rows(res); + + for (int i = 0, n = pgsql_num_rows(res); i < n; i++) { + mapf = pgsql_fetch_assoc(res, i); + if (f.empty()) continue; + CVars rec; + map_to_cvars(f, rec); + + snprintf(vname, sizeof (vname), "title_%05d", i); + out[vname] = rec["title"]; + + snprintf(vname, sizeof (vname), "project_%05d", i); + out[vname] = rec["project"]; + + snprintf(vname, sizeof (vname), "description_%05d", i); + out[vname] = rec["description"]; + + snprintf(vname, sizeof (vname), "status_description_%05d", i); + out[vname] = rec["status_description"]; + + snprintf(vname, sizeof (vname), "delivery_date_%05d", i); + out[vname] = rec["delivery_date"]; + + snprintf(vname, sizeof (vname), "status_description_%05d", i); + out[vname] = rec["status_description"]; + + snprintf(vname, sizeof (vname), "timeline_days_%05d", i); + out[vname] = rec["timeline_days"]; + + snprintf(vname, sizeof (vname), "contract_%05d", i); + out[vname] = rec["contract"]; + + snprintf(vname, sizeof (vname), "job_description_%05d", i); + out[vname] = rec["job_description"]; + + snprintf(vname, sizeof (vname), "price_%05d", i); + out[vname] = rec["price"]; + + snprintf(vname, sizeof (vname), "job_id_%05d", i); + out[vname] = rec["job_id"]; + + snprintf(vname, sizeof (vname), "contract_id_%05d", i); + out[vname] = rec["contract_id"]; + } + } + ret = PHP_API_OK; + out["status"] = "OK"; + } catch (bad_parameter) { + logfmt(logINFO, "ERROR CALL long WrenchMemberActiveJobs(CVars in, CVars &out)"); + } + logfmt(logINFO, "/WrenchMemberActiveJobs()"); + return ret; + + + +} diff --git a/wrenchboard/src/shared_tool/mobile.cc b/wrenchboard/src/shared_tool/mobile.cc index 51f2704a..1a857703 100644 --- a/wrenchboard/src/shared_tool/mobile.cc +++ b/wrenchboard/src/shared_tool/mobile.cc @@ -12,6 +12,7 @@ #include #include "account.h" #include "history.h" +#include "jobs_manager.h" #include "account_mngt.h" #include "contract.h" @@ -306,5 +307,6 @@ long WrenchReturnJobOffersList(CVars in, CVars &out) { /* This return the list of jobs on the home page of the apps*/ long WrenchReturnActiveJobsList(CVars in, CVars &out) { - return WrenchMemberActiveJobs(in, out); + return WrenchUsersTasksList(in, out); + // retired return WrenchMemberActiveJobs(in, out); } \ No newline at end of file