diff --git a/wrenchboard/email/FAMILY/family_suggest_task.mailfile b/wrenchboard/email/FAMILY/family_suggest_task.mailfile new file mode 100644 index 00000000..20a816e9 --- /dev/null +++ b/wrenchboard/email/FAMILY/family_suggest_task.mailfile @@ -0,0 +1,220 @@ +Subject: {{subject}} + + + + + + +{{subject}} + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+WrenchBoard +
+ + + + + +
+ + + + + + + + +
+{{site_name}} +
+{{site_trade_name}} +
+
+ +
+ + + + + + + +
+Message from {{firstname}}, +
+The task at {{site_name}} shown below is fast approaching deadline. +
+
+ + + + +
+ +
+ + + + + + + + +
+ + + + + + + + + + + + + + + +
+Title: + +{{title}} +
+Job ID: +{{contract}} +
+This task will be due very soon. After the due date, the task will be past due, and only the owner can extend it is for a short time before the task is closed permanently. +
+Delivery Date: + +{{delivery_date}} +
+

Please login into your account to manage this task.

+
+ +
+ +
+Please contact us at https://www.wrenchboard.com/contact if you have any question about this email. +
+{{site_name}} Team +
+{{server_name}} +
+ +
+ + + \ No newline at end of file diff --git a/wrenchboard/src/include/email.h b/wrenchboard/src/include/email.h index 41b9ca72..6e99f386 100644 --- a/wrenchboard/src/include/email.h +++ b/wrenchboard/src/include/email.h @@ -39,6 +39,7 @@ long alert_email(long mailtype, CVars in, CVars &out) ; long SendmarketMessage(CVars in, CVars &out); long cron_email(long mailtype, CVars in, CVars &out); long coupon_email(long mailtype, CVars in, CVars &out); +long family_email(long mailtype, CVars in, CVars &out); long SignupPendingAlertMailfile(CVars in); long SignupCompletedAlertMailfile(CVars in); diff --git a/wrenchboard/src/shared_tool/email.cc b/wrenchboard/src/shared_tool/email.cc index ca6117b3..0a9a3988 100644 --- a/wrenchboard/src/shared_tool/email.cc +++ b/wrenchboard/src/shared_tool/email.cc @@ -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) { diff --git a/wrenchboard/src/shared_tool/family_acc.cc b/wrenchboard/src/shared_tool/family_acc.cc index 39dd21b9..5822c0d7 100644 --- a/wrenchboard/src/shared_tool/family_acc.cc +++ b/wrenchboard/src/shared_tool/family_acc.cc @@ -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) { + mapf = 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"; }