Parents suggested list

This commit is contained in:
CHIEFSOFT\ameye
2023-07-04 11:22:36 -04:00
parent af42a41725
commit 0f03f943f9
6 changed files with 74 additions and 2 deletions
+64 -1
View File
@@ -24,6 +24,7 @@ long WrenchFamilyManage(CVars in, CVars &out);
long WrenchSampleTasks(CVars in, CVars &out);
long WrenchSuggestTasks(CVars in, CVars &out);
long WrenchSuggestList(CVars in, CVars &out);
long WrenchSuggestWaitingList(CVars in, CVars &out);
long family_calls(CVars in, CVars &out){
logfmt(logINFO, "family_calls()");
@@ -65,11 +66,73 @@ long family_calls(CVars in, CVars &out){
logfmt(logINFO, "ENTER CALL long WRENCHBOARD_FAMILY_SGGESTLIST");
return WrenchSuggestList(in, out);
break;
//long WrenchSuggestWaitingList(CVars in, CVars &out)
case WRENCHBOARD_FAMILY_SGGESTWAITING:
logfmt(logINFO, "ENTER CALL long WRENCHBOARD_FAMILY_SGGESTWAITING");
return WrenchSuggestWaitingList(in, out); // this now the parent
break;
}
return 0;
}
long WrenchSuggestWaitingList(CVars in, CVars &out){ // this is the parent now
logfmt(logINFO, "ENTER CALL long WrenchSuggestWaitingList");
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 members_family_suggesttask WHERE member_id = %lu AND status IN ( 1,2,3,4,5) "
" ORDER BY created DESC LIMIT %lu OFFSET %lu", member_id, 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), "family_uid_%05d", i);
out[vname] = rec["family_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["created"];
snprintf(vname, sizeof (vname), "status_%05d", i);
out[vname] = rec["status"];
}
}
ret = PHP_API_OK;
out["status"] = "OK";
} catch (bad_parameter) {
logfmt(logINFO, "ERROR CALL long WrenchSuggestWaitingList");
}
logfmt(logINFO, "WrenchSuggestList()");
return ret;
}
long WrenchSuggestList(CVars in, CVars &out){
logfmt(logINFO, "ENTER CALL long WrenchSuggestList");
char vname[30];