From 398dca2a2f542e210e24b0c03db7c7130c47dabb Mon Sep 17 00:00:00 2001 From: "DESKTOP-GBA0BK8\\Admin" Date: Mon, 24 Apr 2023 12:50:33 -0400 Subject: [PATCH] selection functions --- wrenchboard/src/shared_tool/sel_data.cc | 119 +++++++++++++++++++++++- 1 file changed, 116 insertions(+), 3 deletions(-) diff --git a/wrenchboard/src/shared_tool/sel_data.cc b/wrenchboard/src/shared_tool/sel_data.cc index 68af821a..9302c98e 100644 --- a/wrenchboard/src/shared_tool/sel_data.cc +++ b/wrenchboard/src/shared_tool/sel_data.cc @@ -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++) { + mapf = 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++) { + mapf = 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++) { + mapf = 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 ) {