family suggested

This commit is contained in:
CHIEFSOFT\ameye
2023-07-02 16:47:45 -04:00
parent 9c32972fbb
commit 706495a978
+62
View File
@@ -21,6 +21,7 @@ long WrenchFamilyList(CVars in, CVars &out);
long WrenchFamilyAdd(CVars in, CVars &out);
long WrenchFamilyUpdate(CVars in, CVars &out);
long WrenchFamilyManage(CVars in, CVars &out);
long WrenchSampleTasks(CVars in, CVars &out);
long family_calls(CVars in, CVars &out){
logfmt(logINFO, "family_calls()");
@@ -37,6 +38,10 @@ long family_calls(CVars in, CVars &out){
return WrenchFamilyList(in, out);
break;
case WRENCHBOARD_FAMILY_SAMPLETASKS:
return WrenchSampleTasks(in, out);
break;
case WRENCHBOARD_FAMILY_ADD:
return WrenchFamilyAdd(in, out);
break;
@@ -52,6 +57,63 @@ long family_calls(CVars in, CVars &out){
return 0;
}
long WrenchSampleTasks(CVars in, CVars &out){
logfmt(logINFO, "ENTER CALL long WrenchSampleTasks");
char vname[30];
long ret = PHP_API_BAD_PARAM;
const PGresult *res;
try{
long member_id = REQ_LONG(in, "member_id", 1, -1);
long offset = REQ_LONG(in, "offset", 1, -1);
long limit = REQ_LONG(in, "limit", 1, -1);
out["total_record"] = "0";
res = pgsql_query("SELECT id FROM family_task_suggestion WHERE status=1 ");
out["total_record"] = pgsql_num_rows(res);
res = pgsql_query(" SELECT * FROM family_task_suggestion WHERE status = 1 "
" ORDER BY title DESC LIMIT %lu OFFSET %lu", limit, offset);
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), "uid_%05d", i);
out[vname] = rec["uid"];
snprintf(vname, sizeof (vname), "title_%05d", i);
out[vname] = rec["title"];
snprintf(vname, sizeof (vname), "description_%05d", i);
out[vname] = rec["description"];
snprintf(vname, sizeof (vname), "added_%05d", i);
out[vname] = rec["added"];
snprintf(vname, sizeof (vname), "age_%05d", i);
out[vname] = rec["age"];
snprintf(vname, sizeof (vname), "banner_%05d", i);
out[vname] = rec["banner"];
}
}
ret = PHP_API_OK;
out["status"] = "OK";
} catch (bad_parameter) {
logfmt(logINFO, "ERROR CALL long WrenchSampleTasks");
}
logfmt(logINFO, "WrenchSampleTasks()");
}
long WrenchFamilyList(CVars in, CVars &out){
logfmt(logINFO, "ENTER CALL long WrenchFamilyList");
char vname[30];