delete job
This commit is contained in:
@@ -271,6 +271,67 @@ long WrenchJobPostNotifyOffer(CVars in, CVars &out){
|
||||
}
|
||||
|
||||
long WrenchJobPostCancelOffer(CVars in, CVars &out){
|
||||
// case OFFER_CANCEL: // note status 4
|
||||
logfmt(logINFO, "WrenchJobPostCancelOffer()");
|
||||
long ret = PHP_API_BAD_PARAM;
|
||||
try {
|
||||
|
||||
REQ_LONG(in, "member_id", 1, -1);
|
||||
long offer_result = REQ_LONG(in, "offer_result", 1, -1);
|
||||
REQ_STRING(in, "offer_code", 1, 15, "(.*)");
|
||||
long job_id = 0;
|
||||
long owner_member_id = 0;
|
||||
long offer_id = 0;
|
||||
|
||||
long rc = 0;
|
||||
CVars outx;
|
||||
// rc = 0 + load_db_record( out, "SELECT * FROM members_jobs_offer WHERE offer_code='%s' AND status = 1", in["offer_code"].c_str() );
|
||||
const PGresult *res = pgsql_query("SELECT *,member_id AS owner_member_id, id AS offer_id "
|
||||
" FROM members_jobs_offer WHERE offer_code='%s' AND status = 1", in["offer_code"].c_str());
|
||||
if (res != NULL && pgsql_num_rows(res) > 0) {
|
||||
|
||||
// now job is valid
|
||||
// good to continue
|
||||
map<const char*, const char*>f = pgsql_fetch_assoc(res, 0);
|
||||
if (!f.empty()) {
|
||||
CVars rec;
|
||||
map_to_cvars(f, rec);
|
||||
job_id = rec["job_id"];
|
||||
offer_id = rec["offer_id"];
|
||||
owner_member_id = rec["owner_member_id"];
|
||||
}
|
||||
|
||||
logfmt(logINFO, "WrenchConcludeJobsOffer() rc=OFFER_CANCEL");
|
||||
if (load_db_record(out, " SELECT id AS offer_id,*,(CASE WHEN payment_id IS NULL THEN 0 ELSE payment_id END ) AS payment_id_val"
|
||||
" FROM members_jobs_offer WHERE offer_code ='%s' AND status = 1", in["offer_code"].c_str())) {
|
||||
// valid load of offer needed
|
||||
CVars y;
|
||||
y["member_id"] = out["member_id"];
|
||||
y["member_id"].set_valid(true);
|
||||
y["offer_id"] = out["offer_id"];
|
||||
y["offer_id"].set_valid(true);
|
||||
y["code"] = "OFRFD";
|
||||
y["code"].set_valid(true);
|
||||
y["dir"] = DIR_SOURCE;
|
||||
y["dir"].set_valid(true);
|
||||
y["payment_id"] = out["payment_id_val"];
|
||||
y["payment_id"].set_valid(true);
|
||||
|
||||
// if (WrenchRefundoffer(y, out) == PHP_CREATED_OK) {
|
||||
pgsql_exec("UPDATE members_jobs_offer SET status = 4 WHERE id = %lu AND offer_code='%s' ", offer_id, in["offer_code"].c_str());
|
||||
// REFUND THE MONEY
|
||||
ret = PHP_CREATED_OK;
|
||||
job_email(JOBS_OFFER_CANCEL_MAIL, y, out); // the email will come from offer table
|
||||
// }
|
||||
}
|
||||
}
|
||||
} catch (bad_parameter) {
|
||||
out["log_status"] = "Error WrenchJobPostCancelOffer";
|
||||
}
|
||||
logfmt(logINFO, "/WrenchJobPostCancelOffer()");
|
||||
return ret;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user