assign task layers
This commit is contained in:
@@ -69,6 +69,10 @@ long WrenchPromoAssignTask( CVars in, CVars &out )
|
||||
{
|
||||
long ret = PHP_API_BAD_PARAM;
|
||||
CVars outX;
|
||||
CVars inj;
|
||||
CVars p;
|
||||
const PGresult *res;
|
||||
long member_id = 0;
|
||||
|
||||
logfmt( logINFO, "WrenchPromoAssignTask()" );
|
||||
try {
|
||||
@@ -77,12 +81,6 @@ long WrenchPromoAssignTask( CVars in, CVars &out )
|
||||
REQ_STRING (in, "member_uid", 5, 120, "(.*)");
|
||||
OPTIONAL( in, "loc" ) REQ_STRING (in, "loc", 3, 15, "(.*)");
|
||||
|
||||
|
||||
|
||||
const PGresult *res;
|
||||
// res = pgsql_query("SELECT count(id) FROM promo_member WHERE admin_id = %lu", admin_id);
|
||||
// out["sum_total_record"] = pgsql_num_rows(res);
|
||||
|
||||
res = pgsql_query("SELECT * FROM promo_member"
|
||||
" WHERE admin_id = %lu AND uid = '%s' ",admin_id,in["member_uid"].c_str());
|
||||
|
||||
@@ -92,11 +90,11 @@ long WrenchPromoAssignTask( CVars in, CVars &out )
|
||||
map_to_cvars(f, rec);
|
||||
out = rec;
|
||||
|
||||
long retF = load_db_record( outX, "SELECT *,id AS promo_admin_id "
|
||||
long retF = load_db_record( outX, "SELECT *,id AS member_id "
|
||||
"FROM members WHERE (username)=LOWER('%s') ", out["email"].c_str() );
|
||||
if (retF && outX["promo_admin_id"].Long() > 0) {
|
||||
out["status_message"] = "Error Already Signup";
|
||||
|
||||
out["status_message"] = "Good Already Signup";
|
||||
member_id = outX["member_id"].Long();
|
||||
}else{
|
||||
ret = PHP_API_OK;
|
||||
out["status"] = "OK";
|
||||
@@ -104,6 +102,41 @@ long WrenchPromoAssignTask( CVars in, CVars &out )
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ( member_id == 0 ){
|
||||
out["status"] = "OK";
|
||||
out["task_result"] = "Cannot find user to assign to";
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ( load_db_record(p, "SELECT count(id) AS offer_count FROM members_jobs_offer WHERE client_id = %lu ", member_id)> 0){
|
||||
if (p["offer_count"].Long() > 0){
|
||||
out["status"] = "OK";
|
||||
out["task_result"] = "There is offer in place already";
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
if ( load_db_record(p, "SELECT count(id) AS contract_count FROM members_jobs_contract WHERE client_id = %lu ", member_id)> 0){
|
||||
if (p["offer_count"].Long() > 0){
|
||||
out["status"] = "OK";
|
||||
out["task_result"] = "Previous job found";
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
if ( load_db_record(p, "SELECT * FROM promo_admin WHERE uid::text ='%s' ", in["admin_uid"].c_str())> 0){
|
||||
|
||||
if ( load_db_record(inj, "SELECT j.member_id, j.uid AS job_uid, j.id AS job_id, j.title,j.description,j.country, m.uid,j.job_detail "
|
||||
" FROM members_jobs j LEFT JOIN members m ON m.id = j.member_id WHERE j.uid::text ='%s'",p["first_job"].c_str())> 0){
|
||||
inj["promo"] = in["promo"]; inj["promo"].set_valid( true );
|
||||
inj["strict_timeline"] = "10"; inj["strict_timeline"].set_valid( true );
|
||||
inj["email"] = out["email"]; inj["email"].set_valid( true ); // email
|
||||
inj["job_description"] = inj["job_detail"]; inj["job_description"].set_valid( true );
|
||||
inj["action"] = WRENCHBOARD_JOB_OFFER_SYSTEM; inj["action"].set_valid( true );
|
||||
inj["assign_mode"] = ASSIGN_MODE_EMAIL; inj["assign_mode"].set_valid( true );
|
||||
out["assign_id"] = WrenchJobOfferSystems(inj, outX);
|
||||
}
|
||||
}
|
||||
|
||||
ret = PHP_API_OK;
|
||||
out["status"] = "OK";
|
||||
|
||||
Reference in New Issue
Block a user