family sugggest tasks
This commit is contained in:
@@ -282,6 +282,48 @@ wrenchboard=> SELECT substring(ca.code,0,4)||'XXXXXXXX' as code, ca.amount,m.ema
|
||||
return 0;
|
||||
}
|
||||
|
||||
long family_email(long mailtype, CVars in, CVars &out) {
|
||||
|
||||
//REQ_LONG( in, "member_id", 1, -1 );
|
||||
CVars x;
|
||||
C_CGI_Form form("", "");
|
||||
|
||||
CGIList * inv_list = new CGIList(&form, "inv_items");
|
||||
char listing_items[1024];
|
||||
const PGresult *res;
|
||||
bool exclude_email = true;
|
||||
// char * server_name = getenv("SERVER_NAME");
|
||||
// form.LetStr("server_name", "https://dashboard.wrenchboard.com");
|
||||
|
||||
in["server_name"] = CfgReadChar("system.server_name");
|
||||
form.LetStr("server_name", in["server_name"].c_str());
|
||||
|
||||
form.LetStr("site_name", "WrenchBoard");
|
||||
form.LetStr("site_trade_name", "Connecting Opportunities");
|
||||
|
||||
try {
|
||||
|
||||
switch (mailtype) {
|
||||
|
||||
case WRENCHBOARD_FAMILY_SGGESTTASKS:
|
||||
REQ_LONG(in, "suggest_id", 1, -1);
|
||||
if (load_db_record(x, "SELECT s.*,m.email AS parent_email FROM members_family_suggesttask s "
|
||||
" LEFT JOIN members_family f ON f.family_member_id = s.member_id "
|
||||
" LEFT JOIN members m ON m.id=f.member_id WHERE s.id = %lu", in["suggest_id"].Long())) {
|
||||
vars2form(x, form);
|
||||
form.LetStr("email", x["parent_email"].c_str());
|
||||
form.Email("FAMILY/family_suggest_task.mailfile");
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
} catch (bad_parameter) {
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
long account_email(long mailtype, CVars in, CVars &out) {
|
||||
|
||||
@@ -214,7 +214,7 @@ long WrenchSuggestTaskStatus(CVars in, CVars &out){
|
||||
long member_id = REQ_LONG(in, "member_id", 1, -1);
|
||||
REQ_STRING(in, "uid", 3, 150, "(.*)");
|
||||
REQ_STRING(in, "suggest_uid", 3, 150, "(.*)");
|
||||
REQ_STRING(in, "suggest_action", 3, 25, "(.*)");
|
||||
long suggest_action = REQ_LONG(in, "suggest_action", 1, -1);
|
||||
|
||||
out["suggested_task_id"] ="0";// we will set if all okay
|
||||
const PGresult *res = pgsql_query("SELECT m.*,mf.uid AS family_uid FROM members m "
|
||||
@@ -231,11 +231,25 @@ long WrenchSuggestTaskStatus(CVars in, CVars &out){
|
||||
// NOW LET US FIND THIS TASK
|
||||
logfmt(logINFO, "ERROR CALL long WrenchSuggestTaskStatus- NOW LET US FIND THIS TASK");
|
||||
|
||||
const PGresult *res0 = pgsql_query("SELECT id AS suggest_id,* FROM members_family_suggesttask "
|
||||
" WHERE member_id = %lu AND uid='%s' AND status IN (1,2)", member_id, in["suggest_uid"].c_str());
|
||||
if (res0 != NULL && pgsql_num_rows(res0) > 0) {
|
||||
map<const char*, const char*>f = pgsql_fetch_assoc(res, 0);
|
||||
CVars rec2;
|
||||
map_to_cvars(f, rec2);
|
||||
|
||||
if (suggest_action == 555 ){
|
||||
pgsql_exec("UPDATE members_family_suggesttask SET status=0,updated=now() "
|
||||
" WHERE id=%lu AND uid='%s'", rec2["suggest_id"].Long(),in["suggest_uid"].c_str() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
if (suggest_action == 222 ){
|
||||
pgsql_exec("UPDATE members_family_suggesttask SET remind=now(),updated=now() "
|
||||
" WHERE id=%lu AND uid='%s'", rec2["suggest_id"].Long(),in["suggest_uid"].c_str() );
|
||||
family_email(WRENCHBOARD_FAMILY_SGGESTTASKS, rec2, rec2); //
|
||||
}
|
||||
}
|
||||
] }
|
||||
}
|
||||
} catch (bad_parameter) {
|
||||
logfmt(logINFO, "ERROR CALL long WrenchSuggestTaskStatus");
|
||||
@@ -282,6 +296,10 @@ long WrenchSuggestTasks(CVars in, CVars &out){
|
||||
xx["banner"].set_valid(true);
|
||||
|
||||
out["suggested_task_id"] = insert_db_record(DBS_VALID, "members_family_suggesttask", "members_family_suggesttask_id_seq", xx);
|
||||
if(out["suggested_task_id"].Long() > 0 ){
|
||||
load_db_record( out, "SELECT id AS suggest_id,* FROM members_family_suggesttask WHERE id = %lu ", out["suggested_task_id"].Long());
|
||||
family_email(WRENCHBOARD_FAMILY_SGGESTTASKS, out, out); //
|
||||
}
|
||||
ret = PHP_API_OK;
|
||||
out["status"] = "OK";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user