country list
This commit is contained in:
@@ -586,6 +586,66 @@ logfmt(logINFO, "WrenchGetRecentDash()");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
Called directly for country list at signup
|
||||
|
||||
wrenchboard=> SELECT code,country,phone_code,jobs FROM country
|
||||
WHERE allow is not null AND status = 1 ORDER BY country ASC;
|
||||
code | country | phone_code | jobs
|
||||
------+---------------+------------+----------------------------
|
||||
GH | Ghana | 233 |
|
||||
NG | Nigeria | 234 | 2022-04-09 20:43:48.007359
|
||||
US | United States | 1 |
|
||||
(3 rows)
|
||||
|
||||
*/
|
||||
long WrenchSignUpCountry(CVars in, CVars &out) {
|
||||
char vname[30];
|
||||
long ret = PHP_API_BAD_PARAM;
|
||||
logfmt(logINFO, "WrenchSignUpCountry()");
|
||||
|
||||
|
||||
try {
|
||||
out["total_record"] = "0";
|
||||
const PGresult *res;
|
||||
res = pgsql_query("SELECT code,country,phone_code,jobs,uid FROM country "
|
||||
" WHERE allow is not null AND status = 1 ORDER BY country ASC");
|
||||
|
||||
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), "code_%05d", i);
|
||||
out[vname] = rec["code"];
|
||||
|
||||
snprintf(vname, sizeof (vname), "country_%05d", i);
|
||||
out[vname] = rec["country"];
|
||||
|
||||
snprintf(vname, sizeof (vname), "phone_code_%05d", i);
|
||||
out[vname] = rec["phone_code"];
|
||||
|
||||
snprintf(vname, sizeof (vname), "jobs_%05d", i);
|
||||
out[vname] = rec["jobs"];
|
||||
|
||||
snprintf(vname, sizeof (vname), "uid_%05d", i);
|
||||
out[vname] = rec["uid"];
|
||||
|
||||
}
|
||||
}
|
||||
ret = PHP_API_OK;
|
||||
out["status"] = "OK";
|
||||
} catch (bad_parameter) {
|
||||
logfmt(logINFO, "ERROR CALL long WrenchSignUpCountry(CVars in, CVars &out)");
|
||||
}
|
||||
logfmt(logINFO, "/WrenchSignUpCountry()");
|
||||
return ret;
|
||||
}
|
||||
|
||||
long WrenchRegisterMyFileUpload(CVars in, CVars &out) {
|
||||
long ret = PHP_API_BAD_PARAM;
|
||||
logfmt(logINFO, "WrenchRegisterMyFileUpload()");
|
||||
|
||||
@@ -56,6 +56,9 @@ long wrenchboard_api_main(CVars in, CVars &out) {
|
||||
return SendSMSMessage(in, out);
|
||||
}
|
||||
|
||||
if(action == WRENCHBOARD_SIGNUP_COUNTRY){
|
||||
return WrenchSignUpCountry(in, out);
|
||||
}
|
||||
|
||||
if( action == WRENCHBOARD_SAVE_MEDIA ){
|
||||
return WrenchSaveStoredMedia(in, out);
|
||||
|
||||
Reference in New Issue
Block a user