selection functions

This commit is contained in:
DESKTOP-GBA0BK8\Admin
2023-04-24 12:50:33 -04:00
parent 2a8d1cabdc
commit 398dca2a2f
+116 -3
View File
@@ -133,7 +133,44 @@ long getAccountTypeCombo( CVars in, CVars &out ) {
$option_value = $this->optionValueObject($q->result(), "type_value", "type_name", $curVal);
*/
return 0;
char vname[30];
long ret = PHP_API_BAD_PARAM;
logfmt( logINFO, "getAccountTypeCombo()" );
out["result"] = "Yes i go to this back end";
try {
out["total_record"] = "0";
const PGresult *res;
res = pgsql_query("SELECT id,category "
"FROM account_types "
"WHERE status = 1 ORDER BY type_name 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), "value_%05d", i);
out[vname] = rec["type_value"];
snprintf(vname, sizeof (vname), "name_%05d", i);
out[vname] = rec["type_name"];
}
}
ret = PHP_API_OK;
out["status"] = "OK";
} catch (bad_parameter) {
logfmt(logINFO, "ERROR CALL long getAccountTypeCombo(CVars in, CVars &out)");
}
logfmt( logINFO, "/getAccountTypeCombo()" );
return ret;
}
long getGeneralSkillCombo( CVars in, CVars &out ) {
@@ -145,7 +182,44 @@ long getGeneralSkillCombo( CVars in, CVars &out ) {
->get('skill_category');
$option_value = $this->optionValueObject($q->result(), "id", "category", $curVal);
*/
return 0;
char vname[30];
long ret = PHP_API_BAD_PARAM;
logfmt( logINFO, "getGeneralSkillCombo()" );
out["result"] = "Yes i go to this back end";
try {
out["total_record"] = "0";
const PGresult *res;
res = pgsql_query("SELECT id,category "
"FROM skill_category "
"WHERE status = 1 ORDER BY lorder DESC");
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), "id_%05d", i);
out[vname] = rec["id"];
snprintf(vname, sizeof (vname), "category_%05d", i);
out[vname] = rec["category"];
}
}
ret = PHP_API_OK;
out["status"] = "OK";
} catch (bad_parameter) {
logfmt(logINFO, "ERROR CALL long getGeneralSkillCombo(CVars in, CVars &out)");
}
logfmt( logINFO, "/getGeneralSkillCombo()" );
return ret;
}
long getUserNewSkillCombo( CVars in, CVars &out ) {
@@ -157,7 +231,46 @@ long getUserNewSkillCombo( CVars in, CVars &out ) {
->get('skill_types');
$option_value = $this->optionValueObject($q->result(), "id", "skill", $curVal);
*/
return 0;
char vname[30];
long ret = PHP_API_BAD_PARAM;
logfmt( logINFO, "getUserNewSkillCombo()" );
out["result"] = "Yes i go to this back end";
try {
long category_id = REQ_LONG( in, "category_id", 1, -1 );
out["total_record"] = "0";
const PGresult *res;
res = pgsql_query("SELECT id,skill "
"FROM skill_types "
"WHERE category_id = %lu AND status = 1 ORDER BY lorder DESC", category_id);
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), "id_%05d", i);
out[vname] = rec["id"];
snprintf(vname, sizeof (vname), "skill_%05d", i);
out[vname] = rec["skill"];
}
}
ret = PHP_API_OK;
out["status"] = "OK";
} catch (bad_parameter) {
logfmt(logINFO, "ERROR CALL long getUserNewSkillCombo(CVars in, CVars &out)");
}
logfmt( logINFO, "/getUserNewSkillCombo()" );
return ret;
}
long getCountryCombo( CVars in, CVars &out ) {