diff --git a/wrenchboard/src/shared_tool/family_acc.cc b/wrenchboard/src/shared_tool/family_acc.cc index 19f7296b..f96bcee7 100644 --- a/wrenchboard/src/shared_tool/family_acc.cc +++ b/wrenchboard/src/shared_tool/family_acc.cc @@ -32,6 +32,7 @@ long WrenchSuggestTaskStatus(CVars in, CVars &out); long WrenchFamilyTransferStart(CVars in, CVars &out); long WrenchFamilyTransfer(CVars in, CVars &out); long WrenchFamilyTransferHx(CVars in, CVars &out); +long WrenchFamilyInvite(CVars in, CVars &out); long family_calls(CVars in, CVars &out){ logfmt(logINFO, "family_calls()"); @@ -102,11 +103,63 @@ long family_calls(CVars in, CVars &out){ case WRENCHBOARD_FAMILY_RELINVITE: logfmt(logINFO, "ENTER CALL long WRENCHBOARD_FAMILY_RELINVITE"); + return WrenchFamilyInvite(in, out); break; } return 0; } +long WrenchFamilyInvite(CVars in, CVars &out){ + long ret = PHP_API_BAD_PARAM; + // const PGresult *res; + try{ + long member_id = REQ_LONG(in, "member_id", 1, -1); + REQ_STRING(in, "firstname", 3, 35, "(.*)"); + REQ_STRING(in, "lastname", 3, 35, "(.*)"); + REQ_STRING(in, "email", 3, 299, "(.*)"); + REQ_STRING(in, "family_type", 3, 25, "(.*)"); + + out["invite_id"] ="0";// we will set if all okay + const PGresult *res = pgsql_query("SELECT m.*,mf.uid AS family_uid FROM members m " + " LEFT JOIN members_family mf ON mf.family_member_id = m.id " + " WHERE m.id=%lu AND m.uid='%s'", member_id, in["uid"].c_str()); + if (res != NULL && pgsql_num_rows(res) > 0) { + mapf = pgsql_fetch_assoc(res, 0); + CVars rec; + map_to_cvars(f, rec); + ret = PHP_API_OK; + out["status"] = "ACCOUNT FOUND"; + //out = rec; + if (rec["family_uid"] != ""){ // we are sure you are a family now + + CVars xx; + xx["member_id"] = member_id; + xx["member_id"].set_valid(true); + xx["firstname"] = in["firstname"]; + xx["firstname"].set_valid(true); + xx["lastname"] = in["lastname"]; + xx["lastname"].set_valid(true); + xx["email"] = rec["email"]; + xx["email"].set_valid(true); + xx["family_type"] = in["family_type"]; + xx["family_type"].set_valid(true); + + out["invite_id"] = insert_db_record(DBS_VALID, "members_family_relative", "members_family_relative_id_seq", xx); + if(out["invite_id"].Long() > 0 ){ + // load_db_record( out, "SELECT id AS suggest_id,* FROM members_family_suggesttask WHERE id = %lu ", out["suggested_task_id"].Long()); + // family_email(WRENCHBOARD_FAMILY_SGGESTTASKS, out, out); // + } + ret = PHP_API_OK; + out["status"] = "OK"; + } + } + } catch (bad_parameter) { + logfmt(logINFO, "ERROR CALL long WrenchFamilyInvite"); + } + + logfmt(logINFO, "WrenchFamilyInvite()"); + return ret; +} long WrenchSuggestWaitingList(CVars in, CVars &out){ // this is the parent now logfmt(logINFO, "ENTER CALL long WrenchSuggestWaitingList"); diff --git a/wrenchboard/src/shared_tool/reco_egine.cc b/wrenchboard/src/shared_tool/reco_egine.cc index f1e3f742..e8f4d84d 100644 --- a/wrenchboard/src/shared_tool/reco_egine.cc +++ b/wrenchboard/src/shared_tool/reco_egine.cc @@ -86,83 +86,6 @@ long WrenchHomeBanners(CVars in, CVars &out) { if( RecoOffersInterest( itm_count, in, out ) != PHP_API_BAD_PARAM ) { itm_count++; } if( RecoReferAFreind( itm_count, in, out ) != PHP_API_BAD_PARAM ) { itm_count++; } -//long RecoReferAFreind(int itm_count, CVars in, CVars &out ) -// WrenchReturnJobOffersList(in, offV); -// long total_offers = offV["total_record"].Long(); -// if( total_offers > 0){ -// -// for (int i = 0, n = total_offers; i < n; i++) { -// -// snprintf(vname, sizeof (vname), "title_%05d", i); -// out[vname] = offV[vname]; -// -// snprintf(vname, sizeof (vname), "card_style_%05d", i); -// out[vname] = offV[vname]; -// -// snprintf(vname, sizeof (vname), "description_%05d", i); -// out[vname] = offV[vname]; -// -// snprintf(vname, sizeof (vname), "card_type_%05d", i); -// out[vname] = "OFFERS"; -// -// snprintf(vname, sizeof (vname), "offer_id_%05d", i); -// out[vname] = offV[vname]; -// -// snprintf(vname, sizeof (vname), "blog_id_%05d", i); -// out[vname] = "0"; -// -// snprintf(vname, sizeof (vname), "card_icon_%05d", i); -// out[vname] = "icon1"; -// -// snprintf(vname, sizeof (vname), "contract_%05d", i); -// out[vname] = offV[vname];; -// -// } -// } - -out["total_record"] = itm_count; -return 0; -} -// -long RecoOffersInterest(int itm_count, CVars in, CVars &out ){ - logfmt(logINFO, "RecoOffersInterest()"); - long ret = PHP_API_BAD_PARAM; - const PGresult *res; - char vname[30]; - try { - int ic = itm_count; - long member_id = REQ_LONG(in, "member_id", 1, -1); - res = pgsql_query(" SELECT mo.* FROm members_offer_interest mo LEFT JOIN members_jobs_offer mj ON mj.id= mo.offer_id" - " WHERE mj.member_id = %lu AND mj.expire > now() AND mo.status = 1",member_id); - if (res != NULL && pgsql_num_rows(res) > 0) { - - snprintf(vname, sizeof (vname), "title_%05d", ic); - out[vname] = "Users are interested in some of your job(s)"; - - snprintf(vname, sizeof (vname), "description_%05d", ic); - out[vname] = "Some users are interested in your job(s)."; - - snprintf(vname, sizeof (vname), "card_type_%05d", ic); - out[vname] = "INTEREST"; - - snprintf(vname, sizeof (vname), "offer_id_%05d", ic); - out[vname] = "0"; - - snprintf(vname, sizeof (vname), "blog_id_%05d", ic); - out[vname] = "0"; - - snprintf(vname, sizeof (vname), "card_icon_%05d", ic); - out[vname] = "icon1"; - - snprintf(vname, sizeof (vname), "banner_%05d", ic); - out[vname] ="https://www.wrenchboard.com/assets/images/apps/banners/job-interest.jpg"; - - snprintf(vname, sizeof (vname), "banner_location_%05d", ic); - out[vname] ="URL"; - - snprintf(vname, sizeof (vname), "link_path_%05d", ic); - out[vname] = "offer-interest"; - snprintf(vname, sizeof (vname), "button_text_%05d", ic); out[vname] = "Continue"; @@ -204,7 +127,7 @@ long RecoCheckOffers(int itm_count, CVars in, CVars &out ){ out[vname] = "Some offers are waiting for you."; snprintf(vname, sizeof (vname), "description_%05d", ic); - out[vname] = "You have received some offers. View, accept, or reject before the offer(s) expire."; + out[vname] = "You have received some offers. View, accept, or reject before the offer(s) expire."; snprintf(vname, sizeof (vname), "card_type_%05d", ic); out[vname] = "OFFERS"; diff --git a/www-api/app/Controllers/WrenchApi.php b/www-api/app/Controllers/WrenchApi.php index ef6695ac..ff5e35bf 100644 --- a/www-api/app/Controllers/WrenchApi.php +++ b/www-api/app/Controllers/WrenchApi.php @@ -647,6 +647,7 @@ class WrenchApi extends BaseController $final_out["language"] = "en"; $final_out["ip_loc"] = $ip_loc; $final_out["family_types"] = $this->familyTypes(); + $final_out["history_types"] = $this->historyTypes(); //return json_encode( ( new \App\Models\ResultFormatter() )->processOutJson($in, $out)); return json_encode( $final_out ); } @@ -658,5 +659,10 @@ class WrenchApi extends BaseController array("ty"=>"Others", "id"=>"Others", "tag"=>"fam_type_others") ]; } + private function historyTypes(){ + return [ + array("ty"=>"Completed Jobs", "id"=>"COMPLETED_JOBS", "tag"=>"hist_type_completed_jobs"), + ]; + } } diff --git a/www-api/app/Models/ResultFormatter.php b/www-api/app/Models/ResultFormatter.php index 9b6749bb..04fb05a8 100644 --- a/www-api/app/Models/ResultFormatter.php +++ b/www-api/app/Models/ResultFormatter.php @@ -386,6 +386,7 @@ class ResultFormatter extends Model "status" => $out["status"], "total_record" => ($total - 1), "internal_return" => $out["internal_return"], + "family_action" => 0, "result_list" => array(), ); for ($i = 0; $i < $total; $i++) {