diff --git a/wrenchboard/src/include/jobs_manager.h b/wrenchboard/src/include/jobs_manager.h index 946be987..58a2f765 100644 --- a/wrenchboard/src/include/jobs_manager.h +++ b/wrenchboard/src/include/jobs_manager.h @@ -7,4 +7,5 @@ long WrenchJobManagerOffers( CVars in, CVars &out); long WrenchJobManagerList( CVars in, CVars &out ); long WrenchJobManagerActiveTasksList( CVars in, CVars &out); long WrenchUsersActiveTasksList(CVars in, CVars &out); +long WrenchUsersTasksReportList(CVars in, CVars &out); #endif \ No newline at end of file diff --git a/wrenchboard/src/shared_tool/jobs.cc b/wrenchboard/src/shared_tool/jobs.cc index bdd736e0..37d00557 100644 --- a/wrenchboard/src/shared_tool/jobs.cc +++ b/wrenchboard/src/shared_tool/jobs.cc @@ -57,7 +57,7 @@ long jobs_calls(CVars in, CVars &out) { return WrenchUsersActiveTasksList( in, out); break; case WRENCHBOARD_JOB_REPORT: - return WrenchUsersActiveTasksList( in, out); + return WrenchUsersTasksReportList( in, out); break; case WRENCHBOARD_JOB_CREATEJOB: job_mode = REQ_LONG(in, "job_mode", 1, -1); diff --git a/wrenchboard/src/shared_tool/jobs_manager.cc b/wrenchboard/src/shared_tool/jobs_manager.cc index 423fd1b6..c2b2daa8 100644 --- a/wrenchboard/src/shared_tool/jobs_manager.cc +++ b/wrenchboard/src/shared_tool/jobs_manager.cc @@ -619,5 +619,131 @@ long WrenchUsersActiveTasksList(CVars in, CVars &out) { +} + +long WrenchUsersTasksReportList(CVars in, CVars &out) { + logfmt(logINFO, "WrenchUsersTasksReportList()"); + char extraq[60]; + 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); + long allstatus = REQ_LONG(in, "allstatus", 1, -1); + + if ( allstatus == 100 ){ + snprintf(extraq, sizeof (extraq), ""); + } + else + { + // snprintf(extraq, sizeof (extraq), " AND mc.delivery_date > now() "); + } + + 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,mc.uid AS contract_uid, " + " mj.banner AS banner, c.code AS currency_code, c.description AS currency_description, mj.uid AS job_uid, " + " (CASE WHEN mc.status=4 THEN 'REVIEW' " + " WHEN mc.status = 5 AND mc.delivery_date > now() THEN 'COMPLETED' " + " 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), "id_%05d", i); + out[vname] = rec["contract_id"]; + + snprintf(vname, sizeof (vname), "job_detail_%05d", i); + out[vname] = ""; + + snprintf(vname, sizeof (vname), "expire_%05d", i); + out[vname] = rec["expire"]; + + 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), "ext_request_%05d", i); + out[vname] = rec["ext_request"]; + + 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), "origin_job_uid_%05d", i); // added to support original job UID + out[vname] = rec["job_uid"]; + + snprintf(vname, sizeof (vname), "contract_id_%05d", i); + out[vname] = rec["contract_id"]; + + snprintf(vname, sizeof (vname), "owner_status_%05d", i); + out[vname] = rec["owner_status"]; + + snprintf(vname, sizeof (vname), "contract_uid_%05d", i); + out[vname] = rec["contract_uid"]; + + snprintf(vname, sizeof (vname), "banner_%05d", i); + out[vname] = rec["banner"]; + + snprintf(vname, sizeof (vname), "currency_%05d", i); + out[vname] = rec["currency_description"]; + + snprintf(vname, sizeof (vname), "currency_code_%05d", i); + out[vname] = rec["currency_code"]; + + } + } + ret = PHP_API_OK; + out["status"] = "OK"; + } catch (bad_parameter) { + logfmt(logINFO, "ERROR CALL long WrenchUsersTasksReportList(CVars in, CVars &out)"); + } + logfmt(logINFO, "/WrenchUsersTasksReportList()"); + return ret; + + + } diff --git a/www-api/app/Models/ResultFormatter.php b/www-api/app/Models/ResultFormatter.php index 04fb05a8..66ae2e2b 100644 --- a/www-api/app/Models/ResultFormatter.php +++ b/www-api/app/Models/ResultFormatter.php @@ -646,6 +646,7 @@ class ResultFormatter extends Model case WRENCHBOARD_JOB_OFFERS: case WRENCHBOARD_JOB_ACTIVE: case WRENCHBOARD_JOB_USERACTIVE: + CASE WRENCHBOARD_JOB_REPORT: $total = $out["total_record"]; $res = array(