26 define(
"FEATURE_ALERTS",
"ALERT" );
27 define(
"FEATURE_BASIC",
"BASIC" );
28 define(
"FEATURE_BILLPAY",
"BILLPAY" );
29 define(
"FEATURE_MOBILE_BILLPAY",
"MBILLPAY" );
30 define(
"FEATURE_MOBILE_RDC",
"MRDC" );
31 define(
"FEATURE_ONLINE_LOAN_APP",
"ONLINEAPP" );
32 define(
"FEATURE_PFM",
"PFM" );
33 define(
"FEATURE_RDC",
"RDC" );
34 define(
"FEATURE_SECURE_MSG",
"SECUREMSG" );
35 define(
"FEATURE_SMS",
"SMS" );
36 define(
"FEATURE_STOP",
"STOP" );
37 define(
"FEATURE_DOWNLOAD_HISTORY",
"TRNDOWN" );
38 define(
"FEATURE_EXTERNAL_TRANSFERS",
"TRNEXT" );
39 define(
"FEATURE_WIRE_TRANSFERS",
"TRNWIRE" );
40 define(
"FEATURE_M2M_TRANSFERS",
"TRNM2M" );
42 define(
"FEATURE_TRANSFERS",
"TRN" );
43 define(
"FEATURE_SCHEDULED_TRANSFERS",
"TRNSCHED" );
44 define(
"FEATURE_ESTATEMENTS",
"ESTMT" );
45 define(
"FEATURE_ACH_PAYMENTS",
"ACHPMT" );
46 define(
"FEATURE_ACH_COLLECTIONS",
"ACHCOL" );
47 define(
"FEATURE_PAYROLL",
"ACHPYRL" );
51 define(
"PERM_ERROR_AMOUNT_EXCEED_TRANSACTION", 1200 );
52 define(
"PERM_ERROR_AMOUNT_EXCEED_DAILY", 1201 );
53 define(
"PERM_ERROR_AMOUNT_EXCEED_ACCT_PER_DAY", 1202 );
54 define(
"PERM_ERROR_AMOUNT_EXCEED_MONTHLY", 1203 );
55 define(
"PERM_ERROR_COUNT_EXCEED_DAILY", 1204 );
56 define(
"PERM_ERROR_COUNT_EXCEED_ACCT_PER_DAY", 1205 );
57 define(
"PERM_ERROR_COUNT_EXCEED_MONTHLY", 1206 );
58 define(
"PERM_ERROR_ALERT_EXCEED_LIMIT", 1207 );
61 define(
"PERM_ERROR_GROUP_AMOUNT_EXCEED_TRANSACTION", 1208 );
62 define(
"PERM_ERROR_GROUP_AMOUNT_EXCEED_DAILY", 1209 );
63 define(
"PERM_ERROR_GROUP_AMOUNT_EXCEED_ACCT_PER_DAY", 1210 );
64 define(
"PERM_ERROR_GROUP_AMOUNT_EXCEED_MONTHLY", 1211 );
65 define(
"PERM_ERROR_GROUP_COUNT_EXCEED_DAILY", 1212 );
66 define(
"PERM_ERROR_GROUP_COUNT_EXCEED_ACCT_PER_DAY", 1213 );
67 define(
"PERM_ERROR_GROUP_COUNT_EXCEED_MONTHLY", 1214 );
69 define(
"PERM_ERROR_GETTING_LIMITS", 1250 );
70 define(
"PERM_ERROR_COUNTING_ALERTS", 1251 );
83 function Perm_AccessRights( $pDbh, $pHBEnv, $pPermInputs ) {
85 $rights = privPermGetFeatureRights( $pDbh, $pHBEnv, $pPermInputs[
"feature"] );
86 }
catch (Exception $ex) {
87 $logInfo = array(
"message" => $ex->getMessage(),
"code" => $ex->getCode() );
108 function Perm_MemberAccess($pDbh, $pHBEnv, $pUserId, $pMbrAcct) {
115 $SQL =
"SELECT allowed 116 FROM " . prep_save($pHBEnv[
'Cu'], 10) .
"memberacctrights as mar 117 WHERE user_id = " . intval($pUserId) .
" 118 AND accountnumber = '" . prep_save($pMbrAcct, 12) .
"' 119 AND whichright = 'ACCESS' ";
121 $accessRS = db_query( $SQL, $pDbh );
122 $accessRow = db_fetch_assoc( $accessRS);
124 if (HCU_array_key_exists(
'allowed', $accessRow)) {
125 $retVal = ($accessRow[
'allowed'] ===
't');
128 }
catch (Exception $ex) {
146 function Perm_CheckConfirmReq( $pDbh, $pHBEnv, $pPermInputs ) {
148 $required = privPermCheckConfirmReq( $pDbh, $pHBEnv, $pPermInputs[
"feature"] );
149 }
catch (Exception $ex) {
150 $logInfo = array(
"message" => $ex->getMessage(),
"code" => $ex->getCode() );
168 function Perm_CheckLimits( $pDbh, $pHBEnv, $pPermInputs ) {
171 $feature = $pPermInputs[
"feature"];
173 $amounts = privPermGetAllowedLimits( $pDbh, $pHBEnv, $feature );
174 if ( $amounts ===
false ) {
176 throw new exception(
"Error getting allowed limits", PERM_ERROR_GETTING_LIMITS);
185 if ( $pPermInputs[
"amount"] > $amounts[
"amount_per_transaction"] ) {
186 throw new exception(
"Exceeds amount per transaction limit", PERM_ERROR_AMOUNT_EXCEED_TRANSACTION);
190 $currentAmounts = privPermGetCurrentActivity( $pDbh, $pHBEnv, $feature );
194 if ( ($currentAmounts[
"amount"][
"day"] + $pPermInputs[
"amount"]) > $amounts[
"amount_per_day"] ) {
195 throw new exception(
"Exceeds daily amount", PERM_ERROR_AMOUNT_EXCEED_DAILY);
199 $accountNumber = trim( $pPermInputs[
"account"] );
200 $accountType = trim( $pPermInputs[
"accounttype"] );
202 $accountAmount = isset( $currentAmounts[
"amount"][
"account"][
"$accountNumber|$accountType"] ) ? $currentAmounts[
"amount"][
"account"][
"$accountNumber|$accountType"] : 0;
203 if ( ($accountAmount + $pPermInputs[
"amount"]) > $amounts[
"amount_per_account_per_day"] ) {
204 throw new exception(
"Exceeds daily amount for selected account", PERM_ERROR_AMOUNT_EXCEED_ACCT_PER_DAY);
208 if ( ($currentAmounts[
"amount"][
"month"] + $pPermInputs[
"amount"]) > $amounts[
"amount_per_month"] ) {
209 throw new exception(
"Exceeds monthly amount", PERM_ERROR_AMOUNT_EXCEED_MONTHLY);
213 if ( $currentAmounts[
"count"][
"day"] >= $amounts[
"count_per_day"] ) {
214 throw new exception(
"Exceeds daily count", PERM_ERROR_COUNT_EXCEED_DAILY);
218 $countAmount = isset( $currentAmounts[
"count"][
"account"][
"$accountNumber|$accountType"] ) ? $currentAmounts[
"count"][
"account"][
"$accountNumber|$accountType"] : 0;
219 if ( $countAmount >= $amounts[
"count_per_account_per_day"] ) {
220 throw new exception(
"Exceeds daily count for selected account", PERM_ERROR_COUNT_EXCEED_ACCT_PER_DAY);
224 if ( $currentAmounts[
"count"][
"month"] >= $amounts[
"count_per_month"] ) {
225 throw new exception(
"Exceeds monthly count", PERM_ERROR_COUNT_EXCEED_MONTHLY);
242 $groupUserCount = privGetGroupUserCount($pDbh, $pHBEnv, array(
"Uid" => $pHBEnv[
'Uid']));
244 if ($groupUserCount > 1) {
246 $groupLimits = HCU_array_key_value(
"group", $amounts);
249 $groupActivityAmounts = privPermGetCurrentActivity( $pDbh, $pHBEnv, $feature,
"GROUP" );
253 if ( ($groupActivityAmounts[
"amount"][
"day"] + $pPermInputs[
"amount"]) > floatval(HCU_array_key_value(
"amount_per_day", $groupLimits)) ) {
254 throw new exception(
"Exceeds daily group amount", PERM_ERROR_GROUP_AMOUNT_EXCEED_DAILY);
258 $accountAmount = floatval(HCU_array_key_value(
"$accountNumber|$accountType", $groupActivityAmounts[
"amount"][
"account"]));
259 if ( ($accountAmount + $pPermInputs[
"amount"]) > floatval(HCU_array_key_value(
"amount_per_account_per_day", $groupLimits)) ) {
260 throw new exception(
"Exceeds daily group amount for selected account", PERM_ERROR_GROUP_AMOUNT_EXCEED_ACCT_PER_DAY);
264 if ( ($groupActivityAmounts[
"amount"][
"month"] + $pPermInputs[
"amount"]) > floatval(HCU_array_key_value(
"amount_per_month", $groupLimits)) ) {
265 throw new exception(
"Exceeds monthly group amount", PERM_ERROR_GROUP_AMOUNT_EXCEED_MONTHLY);
268 if ( $groupActivityAmounts[
"count"][
"day"] >= intval(HCU_array_key_value(
"count_per_day", $groupLimits)) ) {
269 throw new exception(
"Exceeds daily group count", PERM_ERROR_GROUP_COUNT_EXCEED_DAILY);
273 $countAmount = intval(HCU_array_key_value(
"$accountNumber|$accountType", $groupActivityAmounts[
"count"][
"account"]));
274 if ( $countAmount >= intval(HCU_array_key_value(
"count_per_account_per_day", $groupLimits)) ) {
275 throw new exception(
"Exceeds daily group count for selected account", PERM_ERROR_GROUP_COUNT_EXCEED_ACCT_PER_DAY);
279 if ( $groupActivityAmounts[
"count"][
"month"] >= intval(HCU_array_key_value(
"count_per_month", $groupLimits)) ) {
280 throw new exception(
"Exceeds monthly group count", PERM_ERROR_GROUP_COUNT_EXCEED_MONTHLY);
286 $success[
"status"][
"code"] =
"000";
287 }
catch (Exception $ex) {
289 $logInfo = array(
"message" => $ex->getMessage(),
"code" => $ex->getCode() );
293 $success[
"status"][
"code"] = $ex->getCode();
294 $success[
"status"][
"severity"] =
"ERROR";
295 $success[
"status"][
"error"] = $ex->getMessage();
312 function Perm_GetValidationLimits( $pDbh, $pHBEnv, $pPermInputs ) {
314 $amounts = privPermGetAllowedLimits( $pDbh, $pHBEnv, $pPermInputs[
"feature"] );
315 }
catch (Exception $ex) {
316 $logInfo = array(
"message" => $ex->getMessage(),
"code" => $ex->getCode() );
341 function Perm_FeatureAccessList($pDbh, $pHBEnv, $permInputs=
null) {
343 $retVal = Array(
"status" => Array(
"code"=>
"000",
"error"=>
""),
"data"=>Array());
348 if (is_null($permInputs) || !HCU_array_key_exists(
'Uid', $permInputs)) {
350 $userId = $pHBEnv[
"Uid"];
352 $userId = HCU_array_key_value(
"Uid", $permInputs);
356 if (intval($userId) > 0) {
357 $modList = Array(
"Uid" => $userId);
359 $userAccessList = privPermGetAllFeatureRights($pDbh, $pHBEnv, $modList);
360 if ($userAccessList[
'status'][
'code'] !=
'000') {
362 throw new Exception (
"Unable to retrieve access list");
365 if (!HCU_array_key_exists(
"data", $userAccessList)) {
366 throw new Exception (
"Unable to retrieve access list");
370 $retVal[
'data'] = $userAccessList[
'data'];
373 throw new Exception(
"Invalid User Id");
377 }
catch (Exception $ex) {
378 $retVal[
'status'][
'code'] =
'999';
379 $retVal[
'status'][
'error'] = $ex->getMessage();
380 $retVal[
'data'] = Array();
399 function Perm_GetLimitErrDesc($pMc, $pPermErrCode=
'', $pDispFor=HCU_DISPLAY_AS_HTML) {
401 $retStr = $pMc->msg(
'Perm Limit - Request over authorized limit', $pDispFor);
403 switch ($pPermErrCode) {
408 $retStr = $pMc->msg(
'Perm Limit - Amount Exceeds Transaction', $pDispFor);
412 $retStr = $pMc->msg(
'Perm Limit - Amount Exceeds Daily', $pDispFor);
416 $retStr = $pMc->msg(
'Perm Limit - Amount Exceeds Account Per Day', $pDispFor);
420 $retStr = $pMc->msg(
'Perm Limit - Amount Exceeds Monthly', $pDispFor);
424 $retStr = $pMc->msg(
'Perm Limit - Count Exceeds Daily', $pDispFor);
428 $retStr = $pMc->msg(
'Perm Limit - Count Exceeds Account Per Day', $pDispFor);
432 $retStr = $pMc->msg(
'Perm Limit - Count Exceeds Monthly', $pDispFor);
436 $retStr = $pMc->msg(
'Perm Limit - Exceeds Alert Limit', $pDispFor);
445 $retStr = $pMc->msg(
'Perm Limit - Amount Exceeds Group Transaction', $pDispFor);
449 $retStr = $pMc->msg(
'Perm Limit - Amount Exceeds Group Daily', $pDispFor);
453 $retStr = $pMc->msg(
'Perm Limit - Amount Exceeds Group Account Per Day', $pDispFor);
457 $retStr = $pMc->msg(
'Perm Limit - Amount Exceeds Group Monthly', $pDispFor);
461 $retStr = $pMc->msg(
'Perm Limit - Count Exceeds Group Daily', $pDispFor);
465 $retStr = $pMc->msg(
'Perm Limit - Count Exceeds Group Account Per Day', $pDispFor);
469 $retStr = $pMc->msg(
'Perm Limit - Count Exceeds Group Monthly', $pDispFor);
476 $retStr = $pMc->msg(
'Perm Limit - Error Getting Limits', $pDispFor);
480 $retStr = $pMc->msg(
'Perm Limit - Error Getting Alerts', $pDispFor);
505 function privPermGetAllFeatureRights($pDbh, $pHBEnv, $permInputs) {
506 $retVal = Array(
"status"=>Array(
"code"=>
"000",
"error"=>
""),
"data"=>Array());
511 if (HCU_array_key_exists(
'Uid', $permInputs)) {
512 $lUid = intval(HCU_array_key_value(
'Uid', $permInputs));
514 throw new Exception(
"Invalid User");
529 $SQL =
"SELECT cu_u.user_id, 531 deny_create as create, 532 deny_access as access, 533 deny_confirm as confirm, 534 deny_decline as decline, 535 deny_report as report 536 FROM cu_profilerights cu_pr 537 JOIN cu_profile as cu_p on cu_p.profile_id = cu_pr.profile_id 538 LEFT JOIN " . prep_save($pHBEnv[
'Cu'], 10) .
"group as cu_g on cu_g.profile_id = cu_pr.profile_id 539 LEFT JOIN " . prep_save($pHBEnv[
'Cu'], 10) .
"user as cu_u on cu_u.group_id = cu_g.group_id 540 LEFT JOIN " . prep_save($pHBEnv[
'Cu'], 10) .
"userrights as cu_ur on cu_ur.user_id = cu_u.user_id 541 AND cu_ur.feature_code = cu_pr.feature_code 542 WHERE cu_p.cu = '" . prep_save($pHBEnv[
'Cu'], 10) .
"' 543 AND cu_u.user_id = {$lUid} 544 ORDER BY cu_u.user_id, cu_pr.feature_code; ";
547 $accessRS = db_query( $SQL, $pDbh );
548 $accessRows = db_fetch_all( $accessRS);
550 for ($idx = 0; $idx < count($accessRows); $idx++) {
552 $accessRow = $accessRows[$idx];
558 $access= !($accessRow[
"access"] ===
't');
559 $fromAdmin= isset( $pHBEnv[
"Ca"] ) && ($pHBEnv[
"Ca"] !=
"");
560 $retData[trim($accessRow[
'feature_code'])] = array(
"access" => $access,
561 "create" => $fromAdmin ?
false : !($accessRow[
"create"] ===
't'),
562 "confirm" => !($accessRow[
"confirm"] ===
't'),
563 "decline" => !($accessRow[
"decline"] ===
't'),
564 "report" => !($accessRow[
"report"] ===
't'),
565 "readonly" => $fromAdmin && $access);
568 $retVal[
'data'] = Array(intval($pHBEnv[
'Uid']) => $retData);
570 }
catch (Exception $ex) {
572 $retVal[
'status'][
'code'] =
'999';
573 $retVal[
'status'][
'error'] = $ex->getMessage();
574 $retVal[
'data'] = Array();
588 function privPermGetFeatureRights( $pDbh, $pHBEnv, $pFeature ) {
593 deny_create AS create, 594 deny_access AS access, 595 deny_confirm AS confirm, 596 deny_decline AS decline, 597 deny_report AS report 598 FROM cu_profilerights cu_pr 599 JOIN cu_profile cu_p ON cu_p.profile_id = cu_pr.profile_id 600 LEFT JOIN " . prep_save($pHBEnv[
'Cu'], 10) .
"group as cu_g on cu_g.profile_id = cu_pr.profile_id 601 LEFT JOIN " . prep_save($pHBEnv[
'Cu'], 10) .
"user as cu_u on cu_u.group_id = cu_g.group_id 602 LEFT JOIN " . prep_save($pHBEnv[
'Cu'], 10) .
"userrights as cu_ur on cu_ur.user_id = cu_u.user_id 603 AND cu_ur.feature_code = cu_pr.feature_code 604 WHERE cu_p.cu = '" . prep_save($pHBEnv[
'Cu'], 10) .
"' 605 AND cu_u.user_id = {$pHBEnv["Uid
"]} 606 AND cu_pr.feature_code = '{$pFeature}' 607 ORDER BY cu_u.user_id, cu_pr.feature_code;";
609 $accessRS = db_query( $SQL, $pDbh );
610 $accessRows = db_num_rows($accessRS);
611 if ($accessRows > 0) {
612 $accessRow = db_fetch_array( $accessRS, 0 );
615 $access= !($accessRow[
"access"] ===
't');
616 $fromAdmin= HCU_array_key_value(
'Ca', $pHBEnv) !=
"";
619 "create" => $fromAdmin ?
false : !($accessRow[
"create"] ===
't'),
620 "confirm" => !($accessRow[
"confirm"] ===
't'),
621 "decline" => !($accessRow[
"decline"] ===
't'),
622 "report" => !($accessRow[
"report"] ===
't'),
623 "readonly" => $fromAdmin && $access);
634 }
catch (Exception $ex) {
652 function privPermGetCurrentActivity( $pDbh, $pHBEnv, $pFeature, $pType=
"USER") {
662 $lUid = intval(HCU_array_key_value(
"Uid", $pHBEnv));
665 $firstOfMonth = date(
"Y-m-01" );
666 $firstOfNextMonth = date(
"Y-m-d", strtotime(
"first day of next month" ) );
668 if ($pType ==
'GROUP') {
671 SELECT transhdr_id, sum(amount) AS amount, 672 min(transdata::json->>'acct_source') AS acct_source, 673 min(transdata::json->>'acct_dest') AS acct_dest 674 FROM {$pHBEnv["Cu
"]}transdtl GROUP BY 1 677 date(hdr.posted_date) AS date, dtl.amount, 678 CASE WHEN LEFT(hdr.transactioncode, 1) = '2' THEN split_part(dtl.acct_dest, '|', 2) ELSE split_part(dtl.acct_source, '|', 2) END AS accountnumber, 679 CASE WHEN LEFT(hdr.transactioncode, 1) = '2' THEN split_part(dtl.acct_dest, '|', 3) ELSE split_part(dtl.acct_source, '|', 3) END AS accounttype 680 FROM {$pHBEnv["Cu
"]}transhdr AS hdr 681 INNER JOIN dtl ON hdr.id = dtl.transhdr_id 682 JOIN {$pHBEnv["Cu
"]}user AS cur_user ON cur_user.user_id = {$lUid} 683 JOIN {$pHBEnv["Cu
"]}user AS group_user ON group_user.group_id = cur_user.group_id 684 WHERE hdr.posted_by = group_user.user_id 685 AND hdr.feature_code = '$pFeature' 686 AND posted_date >= '$firstOfMonth' 687 AND posted_date < '$firstOfNextMonth' ";
691 SELECT transhdr_id, sum(amount) AS amount, 692 min(transdata::json->>'acct_source') AS acct_source, 693 min(transdata::json->>'acct_dest') AS acct_dest from {$pHBEnv["Cu
"]}transdtl 697 date(hdr.posted_date) AS date, dtl.amount, 698 CASE WHEN LEFT(hdr.transactioncode, 1) = '2' THEN split_part(dtl.acct_dest, '|', 2) ELSE split_part(dtl.acct_source, '|', 2) END AS accountnumber, 699 CASE WHEN LEFT(hdr.transactioncode, 1) = '2' THEN split_part(dtl.acct_dest, '|', 3) ELSE split_part(dtl.acct_source, '|', 3) END AS accounttype 700 FROM {$pHBEnv["Cu
"]}transhdr hdr 701 INNER JOIN dtl ON hdr.id = dtl.transhdr_id 702 WHERE hdr.posted_by = {$lUid} 703 AND hdr.feature_code = '$pFeature' 704 AND posted_date >= '$firstOfMonth' 705 AND posted_date < '$firstOfNextMonth' ";
708 $rs = db_query( $SQL, $pDbh );
711 $return = array(
"amount" => array(
"day" => 0,
713 "account" => array() ),
714 "count" => array(
"day" => 0,
716 "account" => array() ) );
719 $today = date(
"Y-m-d" );
723 while ( $transRow = db_fetch_array( $rs, $row++ ) ) {
725 $thisAmount = $transRow[
"amount"];
726 if ( $transRow[
"date"] == $today ) {
727 $return[
"amount"][
"day"] += $thisAmount;
728 $return[
"count"][
"day"]++;
731 $accountNumber = trim( $transRow[
"accountnumber"] );
732 $accountType = trim( $transRow[
"accounttype"] );
733 if ( isset( $return[
"amount"][
"account"][
"$accountNumber|$accountType"] ) ) {
734 $return[
"amount"][
"account"][
"$accountNumber|$accountType"] += $thisAmount;
737 $return[
"amount"][
"account"][
"$accountNumber|$accountType"] = $thisAmount;
739 if ( isset( $return[
"count"][
"account"][
"$accountNumber|$accountType"] ) ) {
740 $return[
"count"][
"account"][
"$accountNumber|$accountType"]++;
743 $return[
"count"][
"account"][
"$accountNumber|$accountType"] = 1;
749 $return[
"amount"][
"month"] += $thisAmount;
750 $return[
"count"][
"month"]++;
752 }
catch (Exception $ex) {
760 function privPermGetAllowedLimits( $pDbh, $pHBEnv, $pFeature ) {
763 $maxAmount = FEATURE_LIMIT_MAX_AMOUNT;
764 $maxCount = FEATURE_LIMIT_MAX_COUNT;
770 $SQL =
"SELECT COALESCE( u.amount_per_transaction, $maxAmount) as u_apt, 771 COALESCE( u.amount_per_day, $maxAmount) as u_apd, 772 COALESCE( u.amount_per_month, $maxAmount) as u_apm, 773 COALESCE( u.amount_per_account_per_day, $maxAmount) as u_apapd, 774 COALESCE( g.amount_per_transaction, $maxAmount) as g_apt, 775 COALESCE( g.amount_per_day, $maxAmount) as g_apd, 776 COALESCE( g.amount_per_month, $maxAmount) as g_apm, 777 COALESCE( g.amount_per_account_per_day, $maxAmount) as g_apapd, 778 COALESCE( p.amount_per_transaction, $maxAmount) as p_apt, 779 COALESCE( p.amount_per_day, $maxAmount) as p_apd, 780 COALESCE( p.amount_per_month, $maxAmount) as p_apm, 781 COALESCE( p.amount_per_account_per_day, $maxAmount) as p_apapd, 782 COALESCE( u.count_per_day, $maxCount) as u_cpd, 783 COALESCE( u.count_per_month, $maxCount) as u_cpm, 784 COALESCE( u.count_per_account_per_day, $maxCount) as u_cpapd, 785 COALESCE( g.count_per_day, $maxCount) as g_cpd, 786 COALESCE( g.count_per_month, $maxCount) as g_cpm, 787 COALESCE( g.count_per_account_per_day, $maxCount) as g_cpapd, 788 COALESCE( p.count_per_day, $maxCount) as p_cpd, 789 COALESCE( p.count_per_month, $maxCount) as p_cpm, 790 COALESCE( p.count_per_account_per_day, $maxCount) as p_cpapd, 791 COALESCE( u.confirm_required, false) as u_cr, 792 COALESCE( g.confirm_required, false) as g_cr, 793 COALESCE( p.confirm_required, false) as p_cr 794 FROM {$pHBEnv["Cu
"]}user usr 795 INNER JOIN {$pHBEnv["Cu
"]}group grp ON grp.group_id = usr.group_id 796 INNER JOIN cu_profilerights p ON p.profile_id = grp.profile_id 797 AND p.feature_code = '$pFeature' 798 LEFT JOIN {$pHBEnv["Cu
"]}grouprights g ON g.group_id = usr.group_id 799 AND g.feature_code = '$pFeature' 800 LEFT JOIN {$pHBEnv["Cu
"]}userrights u ON u.user_id = usr.user_id 801 AND u.feature_code = '$pFeature' 802 WHERE usr.user_id = {$pHBEnv["Uid
"]}";
805 $rs = db_query( $SQL, $pDbh );
806 $amountsRow = db_fetch_array( $rs, 0 );
810 $apt = min( min( $amountsRow[
"u_apt"], $amountsRow[
"g_apt"] ), $amountsRow[
"p_apt"] );
811 $apd = min( min( $amountsRow[
"u_apd"], $amountsRow[
"g_apd"] ), $amountsRow[
"p_apd"] );
812 $apm = min( min( $amountsRow[
"u_apm"], $amountsRow[
"g_apm"] ), $amountsRow[
"p_apm"] );
813 $apapd = min( min( $amountsRow[
"u_apapd"], $amountsRow[
"g_apapd"] ), $amountsRow[
"p_apapd"] );
815 $cpd = min( min( $amountsRow[
"u_cpd"], $amountsRow[
"g_cpd"] ), $amountsRow[
"p_cpd"] );
816 $cpm = min( min( $amountsRow[
"u_cpm"], $amountsRow[
"g_cpm"] ), $amountsRow[
"p_cpm"] );
817 $cpapd = min( min( $amountsRow[
"u_cpapd"], $amountsRow[
"g_cpapd"] ), $amountsRow[
"p_cpapd"] );
820 $gapt = min( $amountsRow[
"g_apt"], $amountsRow[
"p_apt"] );
821 $gapd = min( $amountsRow[
"g_apd"], $amountsRow[
"p_apd"] );
822 $gapm = min( $amountsRow[
"g_apm"] , $amountsRow[
"p_apm"] );
823 $gapapd = min( $amountsRow[
"g_apapd"], $amountsRow[
"p_apapd"] );
825 $gcpd = min( $amountsRow[
"g_cpd"], $amountsRow[
"p_cpd"] );
826 $gcpm = min( $amountsRow[
"g_cpm"], $amountsRow[
"p_cpm"] );
827 $gcpapd = min( $amountsRow[
"g_cpapd"], $amountsRow[
"p_cpapd"] );
830 $cr = ($amountsRow[
"u_cr"] ==
't') || ($amountsRow[
"g_cr"] ==
't') || ($amountsRow[
"p_cr"] ==
't') ?
true :
false;
832 $return = array(
"amount_per_transaction" => $apt,
833 "amount_per_day" => $apd,
834 "amount_per_month" => $apm,
835 "amount_per_account_per_day" => $apapd,
836 "count_per_day" => $cpd,
837 "count_per_month" => $cpm,
838 "count_per_account_per_day" => $cpapd,
839 "group" => array(
"amount_per_transaction" => $gapt,
840 "amount_per_day" => $gapd,
841 "amount_per_month" => $gapm,
842 "amount_per_account_per_day" => $gapapd,
843 "count_per_day" => $gcpd,
844 "count_per_month" => $gcpm,
845 "count_per_account_per_day" => $gcpapd
847 "confirm_required" => $cr
850 }
catch (Exception $ex) {
858 function privGetCurrentAlertCount( $pDbh, $pHBEnv ) {
860 $SQL =
"SELECT count(*) as count FROM cu_alerts WHERE cu = '{$pHBEnv["Cu
"]}' AND user_id = {$pHBEnv["Uid
"]}";
862 $rs = db_query( $SQL, $pDbh );
863 $countRow = db_fetch_array( $rs, 0 );
865 $result = $countRow[
"count"];
866 }
catch (Exception $ex) {
874 function privPermCheckConfirmReq( $pDbh, $pHBEnv, $pFeature ) {
877 $SQL =
"SELECT count( u.*) as user_count 878 FROM {$pHBEnv["Cu
"]}user usr 879 INNER JOIN {$pHBEnv["Cu
"]}user u ON u.group_id = usr.group_id 880 WHERE usr.user_id = {$pHBEnv["Uid
"]}";
881 $rs = db_query( $SQL, $pDbh );
882 $countRow = db_fetch_array( $rs, 0 );
884 if ( $countRow[
"user_count"] == 1 ) {
891 $SQL =
"SELECT COALESCE( u.confirm_required, false) as u_cr, 892 COALESCE( g.confirm_required, false) as g_cr, 893 COALESCE( p.confirm_required, false) as p_cr 894 FROM {$pHBEnv["Cu
"]}user usr 895 INNER JOIN {$pHBEnv["Cu
"]}group grp ON grp.group_id = usr.group_id 896 INNER JOIN cu_profilerights p ON p.profile_id = grp.profile_id 897 AND p.feature_code = '$pFeature' 898 LEFT JOIN {$pHBEnv["Cu
"]}grouprights g ON g.group_id = usr.group_id 899 AND g.feature_code = '$pFeature' 900 LEFT JOIN {$pHBEnv["Cu
"]}userrights u ON u.user_id = usr.user_id 901 AND u.feature_code = '$pFeature' 902 WHERE usr.user_id = {$pHBEnv["Uid
"]}";
905 $rs = db_query( $SQL, $pDbh );
906 $confirmRow = db_fetch_array( $rs, 0 );
909 $cr = ($confirmRow[
"u_cr"] ==
't') || ($confirmRow[
"g_cr"] ==
't') || ($confirmRow[
"p_cr"] ==
't') ?
true :
false;
914 }
catch (Exception $ex) {
936 function privGetGroupUserCount($pDbh, $pHBEnv, $permInputs) {
941 if (HCU_array_key_exists(
'Uid', $permInputs)) {
942 $lUid = intval(HCU_array_key_value(
'Uid', $permInputs));
944 throw new Exception(
"Invalid User");
949 $sql =
"SELECT count(group_user.user_id) as user_count 950 FROM {$pHBEnv["Cu
"]}user as cur_user 951 JOIN {$pHBEnv["Cu
"]}user as group_user on group_user.group_id = cur_user.group_id 952 WHERE cur_user.user_id = {$lUid} ";
954 $rs = db_query( $sql, $pDbh );
957 $countRow = db_fetch_array( $rs );
958 $retVal = intval($countRow[
'user_count']);
960 throw new Exception(
"Group User Count sql failed");
963 }
catch (Exception $ex) {