My job list
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
#ifndef __mx_jobs_manager_h__
|
||||
#define __mx_jobs_manager_h__
|
||||
|
||||
#include "vars.h"
|
||||
|
||||
long WrenchJobManagerList( CVars in, CVars &out );
|
||||
|
||||
#endif
|
||||
@@ -221,6 +221,8 @@ enum { PARTNER_STRIPE };
|
||||
//**************************************************************
|
||||
#define WRENCHBOARD_JOBS_START 13000
|
||||
|
||||
#define WRENCHBOARD_JOB_LISTJOBS 13005
|
||||
|
||||
#define WRENCHBOARD_JOB_CREATEJOB 13010
|
||||
#define WRENCHBOARD_JOB_DELETEJOB 13011
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include <curl/curl.h>
|
||||
#include "common_tool.h"
|
||||
#include "reco_engine.h"
|
||||
#include "jobs_manager.h"
|
||||
|
||||
|
||||
long WrenchJobsQuestion(CVars in, CVars &out);
|
||||
long WrenchMarketInterestQuestion(CVars in, CVars &out);
|
||||
@@ -25,6 +27,9 @@ long jobs_calls(CVars in, CVars &out) {
|
||||
out["result"] = "YES I GET TO BACK END";
|
||||
long action = REQ_LONG(in, "action", 0, -1);
|
||||
switch (action) {
|
||||
case WRENCHBOARD_JOB_LISTJOBS:
|
||||
return WrenchJobManagerList(in, out);
|
||||
break;
|
||||
case WRENCHBOARD_JOB_CREATEJOB:
|
||||
return WrenchCreateJobs(in, out);
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
// 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){
|
||||
long ret = 0;
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user