110 lines
4.6 KiB
C++
110 lines
4.6 KiB
C++
// Twillo management toosl
|
|
#include "clog.h"
|
|
#include "cgi.h"
|
|
#include "input.h"
|
|
#include "wrenchboard_api.h"
|
|
#include "reco_engine.h" //error in file name
|
|
#include "email.h"
|
|
#include "safestring.h"
|
|
#include <string>
|
|
#include "pgsql.h"
|
|
#include "pgsql_wrapper.h"
|
|
#include <curl/curl.h>
|
|
#include "account.h"
|
|
#include "cards.h"
|
|
#include "twilo.h"
|
|
#include "mobile.h"
|
|
#include "jobs_manager.h"
|
|
|
|
|
|
long WrenchJobManagerList( CVars in, CVars &out){
|
|
logfmt(logINFO, "ENTER CALL long WrenchJobManagerList");
|
|
char vname[30];
|
|
long ret = PHP_API_BAD_PARAM;
|
|
const char * loc = getenv("REMOTE_ADDR");
|
|
const PGresult *res;
|
|
|
|
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";
|
|
res = pgsql_query("SELECT id FROM members_jobs WHERE member_id = %lu AND status=1 ORDER BY id DESC", in["member_id"].Long());
|
|
out["total_record"] = pgsql_num_rows(res);
|
|
|
|
res = pgsql_query("SELECT id AS job_id, * FROM members_jobs WHERE member_id = %lu AND status=1 "
|
|
"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);
|
|
|
|
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);
|
|
|
|
snprintf(vname, sizeof (vname), "job_id_%05d", i);
|
|
out[vname] = rec["job_id"];
|
|
|
|
snprintf(vname, sizeof (vname), "title_%05d", i);
|
|
out[vname] = rec["title"];
|
|
|
|
snprintf(vname, sizeof (vname), "description_%05d", i);
|
|
out[vname] = rec["description"];
|
|
|
|
snprintf(vname, sizeof (vname), "job_detail_%05d", i);
|
|
out[vname] = rec["job_detail"];
|
|
|
|
snprintf(vname, sizeof (vname), "timeline_days_%05d", i);
|
|
out[vname] = rec["timeline_days"];
|
|
|
|
snprintf(vname, sizeof (vname), "price_%05d", i);
|
|
out[vname] = rec["price"];
|
|
|
|
snprintf(vname, sizeof (vname), "country_%05d", i);
|
|
out[vname] = rec["country"];
|
|
|
|
snprintf(vname, sizeof (vname), "job_uid_%05d", i);
|
|
out[vname] = rec["uid"];
|
|
}
|
|
}
|
|
ret = PHP_API_OK;
|
|
out["status"] = "OK";
|
|
/*
|
|
wrenchboard=> \d members_jobs
|
|
Table "public.members_jobs"
|
|
Column | Type | Collation | Nullable | Default
|
|
---------------+-----------------------------+-----------+----------+------------------------------------------
|
|
id | integer | | not null | nextval('members_jobs_id_seq'::regclass)
|
|
member_id | integer | | |
|
|
title | character varying(150) | | |
|
|
description | character varying(300) | | |
|
|
job_detail | text | | |
|
|
timeline_days | integer | | not null |
|
|
price | integer | | not null |
|
|
loc | inet | | |
|
|
created | timestamp without time zone | | | now()
|
|
updated | timestamp without time zone | | | now()
|
|
status | integer | | | 1
|
|
country | character varying(2) | | |
|
|
uid | uuid | | | uuid_generate_v4()
|
|
Indexes:
|
|
"members_jobs_id_key" UNIQUE CONSTRAINT, btree (id)
|
|
Foreign-key constraints:
|
|
"members_jobs_country_fkey" FOREIGN KEY (country) REFERENCES country(code)
|
|
"members_jobs_member_id_fkey" FOREIGN KEY (member_id) REFERENCES members(id)
|
|
Referenced by:
|
|
TABLE "members_jobs_offer" CONSTRAINT "members_jobs_offer_job_id_fkey" FOREIGN KEY (job_id) REFERENCES members_jobs(id)
|
|
|
|
wrenchboard=>
|
|
|
|
*/
|
|
|
|
} catch (bad_parameter) {
|
|
logfmt(logINFO, "ERROR CALL long WrenchJobManagerList");
|
|
}
|
|
return 0;
|
|
}
|