From d9532dbdbe6619b5ad9a1db59b81854b028e0f86 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Sat, 9 Dec 2023 12:49:46 -0500 Subject: [PATCH] help contents --- wrenchboard/src/include/account_mngt.h | 1 + wrenchboard/src/include/wrenchboard_api.h | 1 + wrenchboard/src/shared_tool/account.cc | 4 + wrenchboard/src/shared_tool/account_mngt.cc | 60 +++++++++++++ www-api/app/Config/Constants.php | 1 + www-api/app/Controllers/WrenchFaq.php | 95 +++++++++++++++------ 6 files changed, 134 insertions(+), 28 deletions(-) diff --git a/wrenchboard/src/include/account_mngt.h b/wrenchboard/src/include/account_mngt.h index c8108965..b6481c3d 100644 --- a/wrenchboard/src/include/account_mngt.h +++ b/wrenchboard/src/include/account_mngt.h @@ -16,6 +16,7 @@ long WrenchMemberActiveJobs(CVars in, CVars &out); long WrenchReturnMemberPaymentHx(CVars in, CVars &out); long WrenchReturnMemberBankAccount(CVars in, CVars &out); long WrenchReturnMemberNotifications(CVars in, CVars &out); +long WrenchReturnHelpItems(CVars in, CVars &out); long WrenchAccountSettings( CVars in, CVars &out ); #endif diff --git a/wrenchboard/src/include/wrenchboard_api.h b/wrenchboard/src/include/wrenchboard_api.h index 1054e76e..e83e8c6e 100644 --- a/wrenchboard/src/include/wrenchboard_api.h +++ b/wrenchboard/src/include/wrenchboard_api.h @@ -222,6 +222,7 @@ enum { PARTNER_STRIPE }; #define WRECNH_CREDIT_HOOKS_FULUTTER 11045 #define WRENCHBOARD_ACCT_NOTIFICATIONS 11046 +#define WRENCHBOARD_ACCT_HELPITEMS 11047 #define WRENCHBOARD_USER_GETBANKLIST 11050 #define WRENCHBOARD_USER_SENDMONEY 11051 diff --git a/wrenchboard/src/shared_tool/account.cc b/wrenchboard/src/shared_tool/account.cc index 7d418544..6df5cce7 100644 --- a/wrenchboard/src/shared_tool/account.cc +++ b/wrenchboard/src/shared_tool/account.cc @@ -345,6 +345,10 @@ long account_calls(CVars in, CVars &out) { return WrenchReturnMemberNotifications(in, out); break; + case WRENCHBOARD_ACCT_HELPITEMS: + return WrenchReturnHelpItems( in, out); + break; + case WRENCHBOARD_ACCOUNT_DASHDATA: return WrenchLoadDashData(in, out); break; diff --git a/wrenchboard/src/shared_tool/account_mngt.cc b/wrenchboard/src/shared_tool/account_mngt.cc index 6d21a563..ab15ca0e 100644 --- a/wrenchboard/src/shared_tool/account_mngt.cc +++ b/wrenchboard/src/shared_tool/account_mngt.cc @@ -14,6 +14,66 @@ #include "payments.h" #include "account.h" +long WrenchReturnHelpItems(CVars in, CVars &out){ + logfmt(logINFO, "WrenchReturnHelpItems()"); + char vname[30]; + long ret = PHP_API_BAD_PARAM; +/* +wrenchboard=> SELECT * FROM help_items WHERE status=1 ORDER BY lorder ASC; + id | uid | icon | title | contents | lorder | status | added +----+--------------------------------------+-------------+----------------------------+--------------------------------------+--------+--------+---------------------------- + 1 | 82fabd0f-91c9-4472-9e84-8425010db4b4 | message.svg | What is WrenchBoard? | Coming soon - Contents will be fixed | 1 | 1 | 2023-12-09 12:27:14.68754 + 2 | 10392635-0098-42df-b338-9a8ec98cae93 | message.svg | Family Account | Coming soon - Contents will be fixed | 1 | 1 | 2023-12-09 12:27:14.692123 + 3 | d4e84174-5586-47b1-84fe-a2a339a33a8d | message.svg | How does Wrenchboard work? | Coming soon - Contents will be fixed | 1 | 1 | 2023-12-09 12:27:14.694878 + +*/ + try { + long limit = REQ_LONG(in, "limit", 1, -1); + long member_id = REQ_LONG(in, "member_id", 1, -1); + REQ_LONG(in, "page", 1, -1); + + out["total_record"] = "0"; + + const PGresult *res; + + res = pgsql_query("SELECT * FROM help_items WHERE status=1 ORDER BY lorder 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), "uid_%05d", i); + out[vname] = rec["uid"]; + + snprintf(vname, sizeof (vname), "icon_%05d", i); + out[vname] = rec["icon"]; + + snprintf(vname, sizeof (vname), "title_%05d", i); + out[vname] = rec["title"]; + + snprintf(vname, sizeof (vname), "contents_%05d", i); + out[vname] = rec["contents"]; + + snprintf(vname, sizeof (vname), "added_%05d", i); + out[vname] = rec["added"]; + } + } + ret = PHP_API_OK; + out["status"] = "OK"; + } catch (bad_parameter) { + logfmt(logINFO, "ERROR CALL long WrenchReturnHelpItems(CVars in, CVars &out)"); + } + logfmt(logINFO, "/WrenchReturnHelpItems()"); + return ret; + +return ret; +} + long WrenchReturnMemberNotifications(CVars in, CVars &out){ /* diff --git a/www-api/app/Config/Constants.php b/www-api/app/Config/Constants.php index b890f9c6..bcd71f64 100644 --- a/www-api/app/Config/Constants.php +++ b/www-api/app/Config/Constants.php @@ -230,6 +230,7 @@ define('WRENCHBOARD_SAVE_GALLERY', 11042); define('WRENCHBOARD_ACCOUNT_PENDJOB', 11043); define('WRENCHBOARD_ACCT_NOTIFICATIONS', 11046); +define('WRENCHBOARD_ACCT_HELPITEMS' , 11047); const WRECNH_CREDIT_HOOKS_FULUTTER = 11045; diff --git a/www-api/app/Controllers/WrenchFaq.php b/www-api/app/Controllers/WrenchFaq.php index 8506856a..50e0a485 100644 --- a/www-api/app/Controllers/WrenchFaq.php +++ b/www-api/app/Controllers/WrenchFaq.php @@ -146,36 +146,75 @@ class WrenchFaq extends BaseController } private function apiHelpData() { - $total = 20; - - $data = array( - "status" => 100, - "total_record" => ($total - 1), - "internal_return" => 0, - "result_list" => array(), - ); - - - for ($i = 0; $i < $total; $i++) { - $key = sprintf("%05d", $i); - $msg=''; - $msgS = "

Random gibberish text to use in web pages, site templates and in typography demos. - Get rid of Lorem Ipsum forever. A tool for web designers who want to save time.

"; - $txL = rand(1,5); - for($ii=1; $ii<$txL; $ii++){ - $msg = $msg.$msgS; - } - - $data["result_list"][] = array( - "uid" => $key, - "public" => "1", - "title" => "This is faq title dummy text ".$key, - "vid" => (rand(0,1)> 0) ? "https://www.youtube.com/embed/xZ4o180KFNk?si=zGuIgpfTb-Tc0o3H":'', - "msg" => $msg - ); + $local_out =[]; + $call_backend = true; + // $local_out = $this->dummyData(); + $in["action"]=WRENCHBOARD_ACCT_HELPITEMS; + if ( $call_backend == true && $in["action"] !='' ){ + $wrenchboard = new \App\Models\BackendModel(); + $ret = $wrenchboard->wrenchboard_api($in, $out); + $out['internal_return'] = $ret; + } + else + { + $out = $local_out; } - return $data; + $total = $out["total_record"]; + $res = array( + "status" => $out["status"], + "total_record" => ($total - 1), + "internal_return" => $out["internal_return"], + "result_list" => array(), + ); + for ($i = 0; $i < $total; $i++) { + $key = sprintf("%05d", $i); + $res["result_list"][] = array( + "title" => $out["msg_${key}"], + "uid" => $out["uid_${key}"], + "public" => "1", + "vid" => (rand(0,1)> 0) ? "https://www.youtube.com/embed/xZ4o180KFNk?si=zGuIgpfTb-Tc0o3H":'', + "icon" => $out["icon_${key}"], + "msg" => $out["contents_${key}"], + "date" => $out["added_${key}"], + + ); + } + + + + return $res; +// +// $total = 20; +// +// $data = array( +// "status" => 100, +// "total_record" => ($total - 1), +// "internal_return" => 0, +// "result_list" => array(), +// ); +// +// +// for ($i = 0; $i < $total; $i++) { +// $key = sprintf("%05d", $i); +// $msg=''; +// $msgS = "

Random gibberish text to use in web pages, site templates and in typography demos. +// Get rid of Lorem Ipsum forever. A tool for web designers who want to save time.

"; +// $txL = rand(1,5); +// for($ii=1; $ii<$txL; $ii++){ +// $msg = $msg.$msgS; +// } +// +// $data["result_list"][] = array( +// "uid" => $key, +// "public" => "1", +// "title" => "This is faq title dummy text ".$key, +// "vid" => (rand(0,1)> 0) ? "https://www.youtube.com/embed/xZ4o180KFNk?si=zGuIgpfTb-Tc0o3H":'', +// "msg" => $msg +// ); +// } +// +// return $data; }