Odyssey
sFeatureMnu.i
1 <?php
2 /**
3  * mFeatureMnu.i
4  *
5  * This script declare functions needed for the mFeatureMnu scripts
6  *
7  * MWS 10/25/2016
8  *
9  */
10 
11  /**
12  *
13  * Return list of default Icons to use for the Feature Menu screen
14  *
15  * no parameters
16  *
17  * @return array this will return an array with icon names to use
18  *
19  */
20 function GetFeatureMenuIcons() {
21  $retVal = array("code"=>"000", "data"=>Array());
22 
23  $iconListBase = Array(["icon_name" => "bank"], ["icon_name" => "exchange"], ["icon_name" => "money"], ["icon_name" => "dollar"],
24  ["icon_name" => "globe"], ["icon_name" => "file-text"], ["icon_name" => "power-off"], ["icon_name" => "comments"],
25  ["icon_name" => "caret-down"], ["icon_name" => "balance-scale"], ["icon_name" => "bar-chart"], ["icon_name" => "cogs"],
26  ["icon_name" => "coffee"], ["icon_name" => "comment-o"], ["icon_name" => "compass"], ["icon_name" => "crosshairs"],
27  ["icon_name" => "edit"], ["icon_name" => "ellipsis-h"], ["icon_name" => "ellipsis-v"],
28  ["icon_name" => "user"], ["icon_name" => "usd"], ["icon_name" => "table"], ["icon_name" => "list"]);
29  asort($iconListBase);
30  $iconListBase = array_values($iconListBase);
31 
32  $retVal['data'] = $iconListBase;
33 
34  return $retVal;
35  }
36 
37  /**
38  *
39  * Return list of available platforms for the system
40  *
41  * no parameters
42  *
43  * @return array standard return array with code, data, error(if code != 000)
44  *
45  */
46 function GetFeatureMenuPlatforms() {
47  $retVal = array("code"=>"000", "data"=>Array());
48 
49  $platformList = Array(Array("code" => "All", "display" => "All"), Array("code" => "D" , "display" => "Desktop"), Array("code" => "M", "display" => "Mobile"), Array( "code" => "A", "display" => "Apps"));
50 
51  $retVal['data'] = $platformList;
52 
53  return $retVal;
54 }
55 
56 /**
57  *
58  * Return list of Features in the system
59  *
60  * @param integer $pDbh - Database connection
61  *
62  * @return array - Array of {code, data }
63  */
64 function GetFeatureList ($pDbh) {
65  $retVal = array("code"=>"000", "data"=>Array());
66 
67  try {
68  if (db_connection_status($pDbh) !== PGSQL_CONNECTION_BAD) {
69  $sql = "SELECT feature_code as featurecode, description as description FROM cu_feature ORDER BY description;";
70 
71  $featureRs = db_query($sql, $pDbh);
72 
73  if ($featureRs) {
74  $featureRows = db_fetch_all($featureRs);
75  $retVal['data'] = $featureRows;
76  } else {
77  throw new Exception ('Database Request Error');
78  }
79 
80  } else {
81  throw new ErrorException ('Database Not Connected');
82  }
83  } catch (ErrorException $e ) {
84  $retVal['code'] = '999';
85  $retVal['error'] = Array($e->getMessage());
86  }
87 
88  return $retVal;
89 }
90 
91 /**
92  *
93  * Return list of HomeCU Banking (Homer) scripts
94  *
95  * @return array - stanadard array {code, data}
96  */
97 function GetBankingScripts() {
98  $retVal = Array("code"=>"000", "data"=>Array());
99 
100  $screenList = Array(
101  Array('screenname' => 'hcuAccounts.prg', 'description' => 'Account Balances'),
102  Array('screenname' => 'hcuACHSingle.prg', 'description' => 'ACH Payments'),
103  Array('screenname' => 'hcuACHSingle.prg', 'description' => 'ACH Collections'),
104  Array('screenname' => 'hcuACHPartners.prg', 'description' => 'ACH Partners'),
105  Array('screenname' => 'hcuActivate.prg', 'description' => 'Member Activation'),
106  Array('screenname' => 'hcuAlerts.prg', 'description' => 'Alerts'),
107  Array('screenname' => 'hcuArchiveCheck.prg', 'description' => 'Archive Check'),
108  Array('screenname' => 'hcuConnect.prg', 'description' => 'Vendor Connect'),
109  Array('screenname' => 'hcuDisclosures.prg', 'description' => 'Disclosures'),
110  Array('screenname' => 'hcuDownload.prg', 'description' => 'Download Transactions'),
111  Array('screenname' => 'hcuLogout.prg', 'description' => 'Logout'),
112  Array('screenname' => 'hcuProfileAlias.prg', 'description' => 'Profile Alias'),
113  Array('screenname' => 'hcuProfileDesc.prg', 'description' => 'Profile Account Descriptions'),
114  Array('screenname' => 'hcuProfileEmail.prg', 'description' => 'Profile Email'),
115  Array('screenname' => 'hcuProfilePwd.prg', 'description' => 'Profile Password'),
116  Array('screenname' => 'hcuForms.prg', 'description' => 'Profile Address'),
117  Array('screenname' => 'hcuProfileSecurity.prg', 'description' => 'Profile MFA'),
118  Array('screenname' => 'hcuSecureMail.prg', 'description' => 'Secure Mail'),
119  Array('screenname' => 'hcuStatement.prg', 'description' => 'eStatements'),
120  Array('screenname' => 'hcuTransfer.prg', 'description' => 'Account Transfers'),
121  Array('screenname' => 'hcuTransferSchedule.prg', 'description' => 'Scheduled Transfers'),
122  Array("screenname" => "hcuUserActivity.prg", "description" => "User Activity"),
123  Array('screenname' => 'hcuExternalAccts.prg', 'description' => 'External Accounts'),
124  Array('screenname' => 'hcuM2MAccts.prg', 'description' => 'M2M Accounts'),
125  Array('screenname' => 'hcuMobilePay.prg', 'description' => 'Mobile Bill Pay')
126  );
127 
128  $retVal['data'] = $screenList;
129  return $retVal;
130 }
131 
132 /**
133  * Returns the list of languages available for the credit union
134  * Unsure where this will be saved at this time.
135  * In the past it was in the ~/public_html/bankingIncludes/css/siteSettings.css
136  * This may be moved to a database
137  *
138  * ** THIS SHOULD ALWAYS DEFAULT WITH AT LEAST en_US
139  *
140  * @param integer $pDbh - The database connection
141  * @param string $pCuCode - The Credit Union Code
142  *
143  * @return array Returns the items from the table
144  */
145 function GetSelectLang($pDbh, $pCuCode) {
146  $retVal = Array("code"=>"000", "data"=>Array());
147 
148  $retVal['data']['en_US'] = true;
149  $retVal['data']['es_US'] = true;
150 
151 
152  return $retVal;
153 }
154 
155 /**
156  *
157  * FetchDefaultFeatureMenu
158  *
159  * This will load a default menu schema.
160  * Currently this will be loaded from this function, can be later moved to a different location
161  *
162  * @param integer $pDbh - The database connection
163  * @param string $pCuCode - The Credit Union Code
164  *
165  * @return array Returns the default items
166  */
167 function FetchDefaultFeatureMenu ($pDbh, $pCuCode) {
168  $retVal = Array("code"=>"000", "data"=>Array());
169 
170 
171 
172  /**
173  * Accounts
174  * Balances
175  * e-Statements
176  * Download Transactions
177  * Alerts
178  * My MoneyDesktop
179  * Transfer
180  * Account Transfers
181  * Edit Scheduled Transfers
182  * User Activity
183  * Pay Bills
184  * Settings
185  * User Alias
186  * Email
187  * Password
188  * Security Settings
189  * Descriptions
190  * Communications
191  * Secure Mail
192  * TXT Banking
193  * Disclosures
194  * Digital Banking Terms
195  * Logout
196  */
197 
198 $retVal['data'] = [
199 
200  ['MenuItemId' => -1, 'Cu' => $pCuCode, 'DisplayOrder' => 1, 'ParentId' => null, 'FeatureCode' => '', 'FeatureDesc' => '', 'MenuItemType' => 'H', 'MenuItemPlatform' => ["M","D","A"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_platform_app' => true, 'details_display_en_US' => 'Account', 'details_display_es_US' => '', 'details_fa_icon' => 'bank'],
201  ['MenuItemId' => -2, 'Cu' => $pCuCode, 'DisplayOrder' => 2, 'ParentId' => -1, 'FeatureCode' => 'BASIC', 'MenuItemType' => 'D', 'MenuItemPlatform' => ["M","D","A"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_platform_app' => true, 'details_display_en_US' => 'Balances','details_display_es_US' => '', 'details_href' => 'hcuAccounts.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 0, 'details_hrefExtraParam' => ''],
202  ['MenuItemId' => -3, 'Cu' => $pCuCode, 'DisplayOrder' => 3, 'ParentId' => -1, 'FeatureCode' => 'BASIC', 'MenuItemType' => 'D', 'MenuItemPlatform' => ["M","D"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_display_en_US' => 'History','details_display_es_US' => '', 'details_href' => 'hcuHistory.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 0, 'details_hrefExtraParam' => ''],
203  ['MenuItemId' => -4, 'Cu' => $pCuCode, 'DisplayOrder' => 4, 'ParentId' => -1, 'FeatureCode' => 'ESTMT', 'MenuItemType' => 'D', 'MenuItemPlatform' => ["M","D","A"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_platform_app' => true, 'details_display_en_US' => 'eStatements','details_display_es_US' => '', 'details_href' => 'hcuStatement.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 0, 'details_hrefExtraParam' => ''],
204  ['MenuItemId' => -5, 'Cu' => $pCuCode, 'DisplayOrder' => 5, 'ParentId' => -1, 'FeatureCode' => 'TRNDOWN', 'MenuItemType' => 'D', 'MenuItemPlatform' => ["M","D"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_display_en_US' => 'Download Transactions','details_display_es_US' => '', 'details_href' => 'hcuDownload.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 0, 'details_hrefExtraParam' => ''],
205  ['MenuItemId' => -6, 'Cu' => $pCuCode, 'DisplayOrder' => 6, 'ParentId' => -1, 'FeatureCode' => 'ALERT', 'MenuItemType' => 'D', 'MenuItemPlatform' => ["M","D","A"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_platform_app' => true, 'details_display_en_US' => 'Alerts','details_display_es_US' => '', 'details_href' => 'hcuAlerts.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 0, 'details_hrefExtraParam' => ''],
206  ['MenuItemId' => -7, 'Cu' => $pCuCode, 'DisplayOrder' => 7, 'ParentId' => -1, 'FeatureCode' => 'PFM', 'MenuItemType' => 'D', 'MenuItemPlatform' => ["M","D"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_display_en_US' => 'MoneyDesktop','details_display_es_US' => '', 'details_href' => 'hcuConnect.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 1, 'details_hrefExtraParam' => 'mode=MDesk3'],
207 
208  ['MenuItemId' => -8, 'Cu' => $pCuCode, 'DisplayOrder' => 8, 'ParentId' => null, 'FeatureCode' => '', 'MenuItemType' => 'H', 'MenuItemPlatform' => ["M","D","A"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_platform_app' => true, 'details_display_en_US' => 'Transfers','details_display_es_US' => '', 'details_fa_icon' => 'exchange'],
209  ['MenuItemId' => -9, 'Cu' => $pCuCode, 'DisplayOrder' => 9, 'ParentId' => -8, 'FeatureCode' => 'TRN', 'MenuItemType' => 'D', 'MenuItemPlatform' => ["M","D","A"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_platform_app' => true, 'details_display_en_US' => 'Transfer','details_display_es_US' => '', 'details_href' => 'hcuTransfer.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 0, 'details_hrefExtraParam' => ''],
210  ['MenuItemId' => -10, 'Cu' => $pCuCode, 'DisplayOrder' => 10, 'ParentId' => -8, 'FeatureCode' => 'TRNSCHED', 'MenuItemType' => 'D', 'MenuItemPlatform' => ["M","D"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_display_en_US' => 'Scheduled Transactions','details_display_es_US' => '', 'details_href' => 'hcuTransferSchedule.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 0, 'details_hrefExtraParam' => ''],
211  ['MenuItemId' => -11, 'Cu' => $pCuCode, 'DisplayOrder' => 11, 'ParentId' => -8, 'FeatureCode' => 'TRN', 'MenuItemType' => 'D', 'MenuItemPlatform' => ["M","D","A"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_platform_app' => true, 'details_display_en_US' => 'User Activity','details_display_es_US' => '', 'details_href' => 'hcuUserActivity.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 0, 'details_hrefExtraParam' => ''],
212  ['MenuItemId' => -12, 'Cu' => $pCuCode, 'DisplayOrder' => 12, 'ParentId' => -8, 'FeatureCode' => 'TRNEXT', 'MenuItemType' => 'D', 'MenuItemPlatform' => ["M","D","A"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_platform_app' => true, 'details_display_en_US' => 'External Funds Transfer','details_display_es_US' => '', 'details_href' => 'hcuExternalAccts.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 0, 'details_hrefExtraParam' => ''],
213  ['MenuItemId' => -13, 'Cu' => $pCuCode, 'DisplayOrder' => 13, 'ParentId' => -8, 'FeatureCode' => 'TRNM2M', 'MenuItemType' => 'D', 'MenuItemPlatform' => ["M","D","A"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_platform_app' => true, 'details_display_en_US' => 'Member to Member Transfer','details_display_es_US' => '', 'details_href' => 'hcuM2MAccts.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 0, 'details_hrefExtraParam' => ''],
214 
215  ['MenuItemId' => -14, 'Cu' => $pCuCode, 'DisplayOrder' => 14, 'ParentId' => null, 'FeatureCode' => 'BILLPAY', 'MenuItemType' => 'S', 'MenuItemPlatform' => ["D"], 'details_platform_dsk' => true, 'details_platform_mbl' => false, 'details_display_en_US' => 'Pay Bills','details_display_es_US' => '', 'details_fa_icon' => 'money', 'details_href' => 'hcuConnect.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 1, 'details_hrefExtraParam' => 'mode=IPAY_V3'],
216  ['MenuItemId' => -15, 'Cu' => $pCuCode, 'DisplayOrder' => 15, 'ParentId' => null, 'FeatureCode' => 'MBILLPAY', 'MenuItemType' => 'S', 'MenuItemPlatform' => ["M"], 'details_platform_dsk' => false, 'details_platform_mbl' => true, 'details_display_en_US' => 'Pay Bills','details_display_es_US' => '', 'details_fa_icon' => 'money', 'details_href' => 'hcuMobilePay.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 0, 'details_hrefExtraParam' => 'mpVendor=IPAYBPS'],
217 
218  ['MenuItemId' => -16, 'Cu' => $pCuCode, 'DisplayOrder' => 16, 'ParentId' => null, 'FeatureCode' => 'ACHCOL', 'MenuItemType' => 'D', 'MenuItemPlatform' => ["M","D","A"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_platform_app' => true, 'details_display_en_US' => 'ACH Collection','details_display_es_US' => '', 'details_fa_icon' => '', 'details_href' => 'hcuACHSingle.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 0, 'details_hrefExtraParam' => 'ach_feature=choose_single_collection'],
219  ['MenuItemId' => -17, 'Cu' => $pCuCode, 'DisplayOrder' => 17, 'ParentId' => null, 'FeatureCode' => 'ACHPMT', 'MenuItemType' => 'D', 'MenuItemPlatform' => ["M","D","A"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_platform_app' => true, 'details_display_en_US' => 'ACH Payments','details_display_es_US' => '', 'details_fa_icon' => '', 'details_href' => 'hcuACHSingle.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 0, 'details_hrefExtraParam' => 'ach_feature=choose_single_collection'],
220  ['MenuItemId' => -18, 'Cu' => $pCuCode, 'DisplayOrder' => 18, 'ParentId' => null, 'FeatureCode' => 'ACHPYRL', 'MenuItemType' => 'D', 'MenuItemPlatform' => ["M","D","A"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_platform_app' => true, 'details_display_en_US' => 'ACH Payroll','details_display_es_US' => '', 'details_fa_icon' => '', 'details_href' => 'hcuACHSingle.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 0, 'details_hrefExtraParam' => 'ach_feature=choose_single_collection'],
221 
222  ['MenuItemId' => -19, 'Cu' => $pCuCode, 'DisplayOrder' => 19, 'ParentId' => null, 'FeatureCode' => '', 'MenuItemType' => 'H', 'MenuItemPlatform' => ["M","D","A"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_platform_app' => true, 'details_display_en_US' => 'Profile', 'details_display_es_US' => '', 'details_fa_icon' => 'cogs', 'details_collapse_group' => 1],
223  ['MenuItemId' => -20, 'Cu' => $pCuCode, 'DisplayOrder' => 20, 'ParentId' => -19, 'FeatureCode' => 'BASIC', 'MenuItemType' => 'D', 'MenuItemPlatform' => ["M","D","A"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_platform_app' => true, 'details_display_en_US' => 'User Name','details_display_es_US' => '', 'details_href' => 'hcuProfileAlias.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 0, 'details_hrefExtraParam' => ''],
224  ['MenuItemId' => -21, 'Cu' => $pCuCode, 'DisplayOrder' => 21, 'ParentId' => -19, 'FeatureCode' => 'BASIC', 'MenuItemType' => 'D', 'MenuItemPlatform' => ["M","D","A"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_platform_app' => true, 'details_display_en_US' => 'Email','details_display_es_US' => '', 'details_href' => 'hcuProfileEmail.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 0, 'details_hrefExtraParam' => ''],
225  ['MenuItemId' => -22, 'Cu' => $pCuCode, 'DisplayOrder' => 22, 'ParentId' => -19, 'FeatureCode' => 'BASIC', 'MenuItemType' => 'D', 'MenuItemPlatform' => ["M","D","A"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_platform_app' => true, 'details_display_en_US' => 'Password','details_display_es_US' => '', 'details_href' => 'hcuProfilePwd.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 0, 'details_hrefExtraParam' => ''],
226  ['MenuItemId' => -23, 'Cu' => $pCuCode, 'DisplayOrder' => 23, 'ParentId' => -19, 'FeatureCode' => 'BASIC', 'MenuItemType' => 'D', 'MenuItemPlatform' => ["M","D","A"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_platform_app' => true, 'details_display_en_US' => 'Address','details_display_es_US' => '', 'details_href' => 'hcuForms.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 0, 'details_hrefExtraParam' => 'target=AddChangeForm.html'],
227  ['MenuItemId' => -24, 'Cu' => $pCuCode, 'DisplayOrder' => 24, 'ParentId' => -19, 'FeatureCode' => 'BASIC', 'MenuItemType' => 'D', 'MenuItemPlatform' => ["M","D","A"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_platform_app' => true, 'details_display_en_US' => 'Settings','details_display_es_US' => '', 'details_href' => 'hcuProfileSecurity.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 0, 'details_hrefExtraParam' => ''],
228  ['MenuItemId' => -25, 'Cu' => $pCuCode, 'DisplayOrder' => 25, 'ParentId' => -19, 'FeatureCode' => 'BASIC', 'MenuItemType' => 'D', 'MenuItemPlatform' => ["M","D","A"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_platform_app' => true, 'details_display_en_US' => 'Descriptions','details_display_es_US' => '', 'details_href' => 'hcuProfileDesc.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 0, 'details_hrefExtraParam' => ''],
229 
230  ['MenuItemId' => -26, 'Cu' => $pCuCode, 'DisplayOrder' => 26, 'ParentId' => null, 'FeatureCode' => '', 'MenuItemType' => 'H', 'MenuItemPlatform' => ["M","D","A"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_platform_app' => true, 'details_display_en_US' => 'Communications', 'details_display_es_US' => '', 'details_fa_icon' => 'sliders', 'details_collapse_group' => 1],
231  ['MenuItemId' => -27, 'Cu' => $pCuCode, 'DisplayOrder' => 27, 'ParentId' => -26, 'FeatureCode' => 'SECUREMSG', 'MenuItemType' => 'D', 'MenuItemPlatform' => ["M","D","A"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_platform_app' => true, 'details_display_en_US' => 'Notices','details_display_es_US' => '', 'details_href' => 'hcuSecureMail.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 0, 'details_hrefExtraParam' => 'msgService=MSGECO'],
232 
233  ['MenuItemId' => -28, 'Cu' => $pCuCode, 'DisplayOrder' => 28, 'ParentId' => null, 'FeatureCode' => '', 'MenuItemType' => 'H', 'MenuItemPlatform' => ["M","D"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_display_en_US' => 'Disclosures', 'details_display_es_US' => '', 'details_fa_icon' => 'file-text-o', 'details_collapse_group' => 1],
234  ['MenuItemId' => -29, 'Cu' => $pCuCode, 'DisplayOrder' => 29, 'ParentId' => -28, 'FeatureCode' => 'BASIC', 'MenuItemType' => 'D', 'MenuItemPlatform' => ["M","D"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_display_en_US' => 'Digital Banking Terms','details_display_es_US' => '', 'details_href' => 'hcuDisclosures.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 0, 'details_hrefExtraParam' => ''],
235 
236  ['MenuItemId' => -30, 'Cu' => $pCuCode, 'DisplayOrder' => 30, 'ParentId' => null, 'FeatureCode' => '','MenuItemType' => 'S', 'MenuItemPlatform' => ["M","D"], 'details_platform_dsk' => true, 'details_platform_mbl' => true, 'details_display_en_US' => 'Sign Off','details_display_es_US' => '', 'details_fa_icon' => 'power-off', 'details_href' => 'hcuLogout.prg', 'details_hrefUrlQuery' => 1, 'details_target' => 0, 'details_hrefExtraParam' => '']
237 
238 ];
239 
240 
241 
242 
243  return $retVal;
244 }
245 
246 /**
247  * Returns the list of current Feature Menu Records
248  * These records should be in the correct display order
249  * an optional platform value may be passed in to only retrieve those menu items
250  *
251  * @param integer $pDbh - The database connection
252  * @param string $pCuCode - The Credit Union Code
253  * @param mixed $pPlatForm - (optional) This can be a string or an array of platforms to return
254  * {D, M, A} -- This can be a string for one value,
255  * or an array of strings for multiple
256  *
257  * @return array Returns the items from the table
258  */
259 function FetchFeatureMenu ($pDbh, $pCuCode, $adminOnly=false, $pPlatForm='') {
260  $retVal = Array("code"=>"000", "data"=>Array());
261 
262  $menuData = Array();
263  $adminOnlySQL= array("Account", "Balances", "History", "Sign Off"); // Only show these menu items.
264  $adminOnlySQL= !$adminOnly ? "" : 'and menu_item_attr ~* \'^.*"display"\\s*:\\s*\\{[a-z_":,\\s]*"en_US"\\s*:\\s*"((' . implode(")|(", $adminOnlySQL) . '))".*$\'';
265 
266  try {
267 
268  $sqlPlatform = '';
269 
270  // **
271  if ($pPlatForm != '') {
272 
273  // menu_item_platform::jsonb @> ANY ( ARRAY [ '["M"]'::jsonb, '["A"]'::jsonb ] )
274  if (is_array($pPlatForm)) {
275  for ($idx = 0; $idx < count($pPlatForm); $idx++) {
276  $anyPlatform .= ($anyPlatform != '' ? ', ' : '') . "'[\"{$pPlatForm[$idx]}\"]'::jsonb";
277  }
278  } else {
279  // ** We have only one value
280  $anyPlatform = "'[\"{$pPlatForm}\"]'::jsonb";
281  }
282 
283  $sqlPlatform = " AND menu_item_platform::jsonb @> ANY ( ARRAY [ {$anyPlatform} ] ) ";
284  }
285 
286  $sql = "SELECT *
287  FROM cu_featuremenu
288  WHERE cu = '" . prep_save($pCuCode, 10) . "' $adminOnlySQL
289  $sqlPlatform
290  ORDER BY display_order; ";
291 
292  $menuRs = db_query($sql, $pDbh);
293 
294 
295  /**
296  * This is the list of platforms that will be returned
297  * the key is the value that is returned, the value is the value that is must be found in menu_item_platform
298  */
299  $platformCodeList = Array("details_platform_dsk" => "D",
300  "details_platform_mbl" => "M",
301  "details_platform_app" => "A"
302  );
303  // * the language is nested -- So I will separate out the attribute logic into two different arrays
304  $displayCodeList = Array("details_display_en_US" => "en_US",
305  "details_display_es_US" => "es_US",
306  "details_display_pl_US" => "pl_US");
307 
308  $attrCodeList = Array("details_fa_icon" => "fa-icon",
309  "details_href" => "href",
310  "details_hrefUrlQuery" => "hrefUrlQuery",
311  "details_target" => "target",
312  "details_message" => "externalMsg",
313  "details_hrefExtraParam" => "hrefExtraParam",
314  "details_collapse_group" => "collapseGroup",
315  "details_memacct_filter" => "memAcctFilter"
316  );
317 
318  if ($menuRs) {
319  // ** Loop through the recordset and create an array of items to return
320  // * If a platform was specified, then only return those items
321  while ($menuRecord = db_fetch_assoc($menuRs)) {
322  // *
323 
324  // ** Some of the data fields are broken down as part of the returned information
325  /*
326  * ** RETURNED RECORD
327  * ** Structure Value -- Data Source
328  * ** MenuItemId -- menu_item_id column
329  * ** Cu -- cu column
330  * ** DisplayOrder -- display_order column
331  * ** ParentId -- parent_item_id column
332  * ** FeatureCode -- feature_code column
333  * ** MenuItemType -- menu_item_type column (this column is a json encoded string)
334  * ** details_platform_dsk -- if (menu_item_platform) contains the array value of D, then true, otherwise false
335  * ** details_platform_mbl -- if (menu_item_platform) contains the array value of M, then true, otherwise false
336  * ** details_platform_app -- if (menu_item_platform) contains the array value of A, then true, otherwise false
337  * ** *** NOTE FOR THE FOLLOWING IT WILL GET INFORMATION FROM THE JSON ENCODED COLUMN menu_item_attr ***
338  * ** details_display_en_US -- value display['en_US'] from menu_item_attr
339  * ** details_display_es_US -- value display['es_US'] from menu_item_attr
340  * ** details_display_pl_US -- value display['pl_US'] from menu_item_attr
341  * ** details_fa_icon -- value display['fa-icon'] from menu_item_attr
342  * ** details_href -- value display['href'] from menu_item_attry
343  * ** details_hrefUrlQuery -- value display['hrefUrlQuery'] from menu_item_attr
344  * ** details_target -- value display['target'] from menu_item_attr
345  * ** details_message -- value display['externalMsg'] from menu_item_attr
346  * ** details_hrefExtraParam -- value display['hrefExtraParam'] from menu_item_attr
347  */
348 
349  // ** Reset the Array
350  $newRecord = Array();
351 
352  $newRecord['MenuItemId'] = $menuRecord['menu_item_id'];
353  $newRecord['Cu'] = $menuRecord['cu'];
354  $newRecord['DisplayOrder'] = $menuRecord['display_order'];
355  $newRecord['ParentId'] = $menuRecord['parent_item_id'];
356  $newRecord['FeatureCode'] = $menuRecord['feature_code'];
357  $newRecord['MenuItemType'] = $menuRecord['menu_item_type'];
358 
359  // ** By default set these values to value
360 
361 
362  /* ** CALC PLATFORM ** */
363  $platform = HCU_JsonDecode($menuRecord['menu_item_platform']);
364  foreach ($platformCodeList as $platKey => $platValue) {
365  // ** set the default value
366  $newRecord[$platKey] = false;
367  // ** Lookup the platValue in platform
368  if (is_array($platform)) {
369  if (in_array($platValue, $platform)) {
370  $newRecord[$platKey] = true; // ** FOUND
371  }
372  }
373  }
374 
375  $itemAttr = HCU_JsonDecode($menuRecord['menu_item_attr']);
376 
377  /* ** DISPLAY DESCRIPTIONS ** */
378  $displayDbValue = HCU_array_key_value('display', $itemAttr);
379  foreach ($displayCodeList as $dispKey => $dispValue) {
380  // ** set the default value
381  $newRecord[$dispKey] = HCU_array_key_value($dispValue, $displayDbValue);
382  }
383 
384  /* ** ATTRIBUTES ** */
385  foreach ($attrCodeList as $attrKey => $attrValue) {
386  // ** set the default value
387  $newRecord[$attrKey] = HCU_array_key_value($attrValue, $itemAttr);
388  $newRecord[$attrKey] = !$newRecord[$attrKey] && $attrValue == "memAcctFilter" ? "" : $newRecord[$attrKey]; // Default for memAcctFilter is blank meaning no filter.
389  }
390 
391  // ** MEETS CRITERIA ** ADD TO LIST **
392  $menuData[] = $newRecord;
393 
394  }
395  $retVal['data'] = $menuData;
396  } else {
397  throw new ErrorException("Unable to retrieve records");
398  }
399  } catch (ErrorException $e) {
400  $retVal['code'] = '999';
401  $retVal['data'] = Array(); // Clear out data
402  }
403  return $retVal;
404 }
405 
406 
407 /**
408  *
409  * Delete a menu item for the cu_featuremenu table
410  *
411  * @param integer $pDbh - Current database resource
412  * @param array $pRecordAry - Array containing the values for record to delete
413  * cu - required
414  * menu_item_id - required
415  * @param string $pCu - Credit Union Code
416  * @param integer $pMenuId - Menu Item Id of record to be deleted
417  *
418  * @return boolean - {true/false} Did the request result in an error
419  *
420  */
421 function FeatureMenuDeleteItem ($pDbh, $pRecordAry) {
422  $bolRet = false;
423 
424  if (is_array($pRecordAry) && db_connection_status($pDbh) === PGSQL_CONNECTION_OK) {
425  // ** Technically the CU code isn't needed as the menu_item_id will only exist for one record, but want to ensure some
426  // * Sort of safety
427  $sql = "DELETE FROM cu_featuremenu
428  WHERE
429  cu = '" . prep_save(HCU_array_key_value('cu', $pRecordAry), 10) . "'
430  AND menu_item_id = " . intval(HCU_array_key_value('menu_item_id', $pRecordAry)) . "; ";
431 
432  $updRs = db_query($sql, $pDbh);
433 
434  $bolRet = ($updRs !== false);
435  }
436 
437  return $bolRet;
438 }
439 
440 /**
441  *
442  * Insert/Update the record into the cu_featuremenu table
443  *
444  * @param integer $pDbh - Current database resource
445  * @param string $pType - {INSERT/UPDATE}
446  * @param array $pRecordAry - Array of the values to insert -- Data should ALREADY be sanitized for insertion with appropriate data type, BUT NOT ESCAPED!!
447  *
448  * @return mixed On success this will return the the data record from the database with the updated values
449  * On failure this will return false
450  */
451 function FeatureMenuUpdateItem ($pDbh, $pType, $pRecordAry) {
452  $retVal = false;
453 
454 
455  if (is_array($pRecordAry) && db_connection_status($pDbh) === PGSQL_CONNECTION_OK) {
456  if ($pType == 'INSERT') {
457  /* ** Create SQL FOR INSERT ** */
458  $sql = "INSERT INTO cu_featuremenu
459  (cu, display_order, feature_code, parent_item_id, menu_item_type, menu_item_platform, menu_item_attr )
460  VALUES
461  (
462  '" . prep_save(HCU_array_key_value('cu', $pRecordAry), 10) . "',
463  " . prep_save(HCU_array_key_value('display_order', $pRecordAry)) . ",
464  '" . prep_save(HCU_array_key_value('feature_code', $pRecordAry), 10) . "',
465  " . prep_save(HCU_array_key_value('parent_item_id', $pRecordAry)) . ",
466  '" . prep_save(HCU_array_key_value('menu_item_type', $pRecordAry)) . "',
467  '" . prep_save(HCU_array_key_value('menu_item_platform', $pRecordAry)) . "',
468  '" . prep_save(HCU_array_key_value('menu_item_attr', $pRecordAry)) . "'
469  ) RETURNING * ";
470  } elseif ($pType == 'UPDATE') {
471  /* ** Create SQL FOR UPDATE ** */
472  $sql = "UPDATE cu_featuremenu
473  SET
474  display_order = " . prep_save(HCU_array_key_value('display_order', $pRecordAry)) . ",
475  feature_code = '" . prep_save(HCU_array_key_value('feature_code', $pRecordAry), 10) . "',
476  parent_item_id = " . prep_save(HCU_array_key_value('parent_item_id', $pRecordAry)) . ",
477  menu_item_type = '" . prep_save(HCU_array_key_value('menu_item_type', $pRecordAry)) . "',
478  menu_item_platform = '" . prep_save(HCU_array_key_value('menu_item_platform', $pRecordAry)) . "',
479  menu_item_attr = '" . prep_save(HCU_array_key_value('menu_item_attr', $pRecordAry)) . "'
480 
481  WHERE
482  menu_item_id = " . intval(HCU_array_key_value('menu_item_id', $pRecordAry)) . "
483  AND cu = '" . prep_save(HCU_array_key_value('cu', $pRecordAry), 10) . "'
484  RETURNING * ";
485  } else {
486  // ** EXIT
487  return $retVal;
488  }
489 
490  $updRs = db_query($sql, $pDbh);
491 
492  if ($updRs) {
493  $updRecord = db_fetch_assoc($updRs);
494  $retVal = $updRecord;
495  }
496  }
497 
498  return $retVal;
499 }
500 
501 /**
502  * FetchMenuFeatureList, this function returns the list of
503  * features that the specified credit union has access to
504  * in their banking menu.
505  *
506  * @param $pEnv array holds environment data
507  * @param $pParams array holds all necessary data
508  * parameters for the function to work with.
509  *
510  * @return $retVal array return array with status code,
511  * error messages and data: feature list.
512  */
513 function FetchMenuFeatureList($pEnv, $pParams) {
514  $retVal = Array("code"=>"000", "error"=>"", "data"=>Array());
515 
516  try {
517  $dbh = $pEnv['dbh'];
518  $cu = prep_save($pParams['Cu'], 10);
519 
520  // Select Distinct, there could be multiple menu items with the same feature.
521  // where feature_code not empty or null.
522  $sql = "
523  SELECT DISTINCT feature_code
524  FROM cu_featuremenu
525  WHERE cu='{$cu}'
526  AND feature_code IS NOT NULL
527  AND feature_code <> ''";
528  $sqlRs = db_query($sql, $dbh);
529  if (!$sqlRs) {
530  throw new Exception("Failed to read feature list", 100);
531  }
532 
533  $sqlData = array();
534  $sqlIndex = 0;
535  // db_fetch_ functions return multi-level associative arrays
536  // we need to return just a single array list of the feature
537  // code values.
538  while ($row = db_fetch_assoc($sqlRs, $sqlIndex)) {
539  $sqlData[] = trim($row['feature_code']);
540  $sqlIndex ++;
541  }
542 
543  $retVal['data'] = $sqlData;
544  } catch (Exception $ex) {
545  $retVal['code'] == '999';
546  $retVal['error'] = $ex->getMessage();
547  }
548 
549  return $retVal;
550 }