8 $string= array(
"filter" => HCUFILTER_INPUT_STRING);
9 HCU_ImportVars($parameters,
"a", array(
"operation" => $string,
"payload" => $string,
"ft" => $string,
"userId" => $string));
10 extract($parameters[
"a"]);
12 $showSQL= $SYSENV[
"devmode"];
13 $operation= is_null($operation) ?
"" : trim($operation);
20 $returnArray= saveUserRights($dbh, $Cu, $userId, $Cn);
23 $returnArray= deleteRights($dbh, $Cu, $userId, $Cn);
26 $returnArray= array(
"error" => array(
"Operation not specified: '$operation'"),
"record" => array(),
"sql" => array());
29 header(
'Content-type: application/json');
31 unset($returnArray[
"sql"]);
32 print HCU_JsonEncode($returnArray);
38 $userId = HCU_PayloadDecode($Cu, $payload);
42 <div
class=
'noUserFound'><div>No
User Found</div></div>
45 printPage(
"$menu_link?ft=$ft", $userId[
"user_id"], getUserRights($dbh, $Cu, $userId[
"user_id"], $showSQL));
58 function getUserRights($dbh, $Cu, $userId, $showSQL)
63 $sql=
"select f.feature_code, f.description as fdescription, g.group_name, p.profile_code, least(pr.amount_per_transaction, gr.amount_per_transaction) as max_apt, 64 ur.feature_code as exists, least(pr.amount_per_day, gr.amount_per_day) as max_apd, least(pr.amount_per_month, gr.amount_per_month) as max_apm, 65 least(pr.amount_per_account_per_day, gr.amount_per_account_per_day) as max_apapd, least(pr.count_per_day, gr.count_per_day) as max_cpd, least(pr.count_per_month, 66 gr.count_per_month) as max_cpm, least(pr.count_per_account_per_day, gr.count_per_account_per_day) as max_cpapd, f.limit_type, 67 coalesce(pr.confirm_required, false) or coalesce(gr.confirm_required, false) as bool_max_cr, ur.amount_per_transaction as apt, ur.amount_per_day as apd, 68 ur.amount_per_month as apm, ur.amount_per_account_per_day as apapd, ur.count_per_day as cpd, ur.count_per_month as cpm, ur.count_per_account_per_day as cpapd, 69 ur.deny_create as bool_fcreate, ur.deny_confirm as bool_fconfirm, ur.deny_decline as bool_fdecline, 70 ur.deny_report as bool_freport, coalesce(ur.confirm_required,false) as bool_crequired, ur.deny_access as bool_faccess from 71 (select user_id, group_id from ${Cu}user where user_id= $userId) as u 72 inner join ${Cu}group g on u.group_id = g.group_id 73 inner join cu_profile p on g.profile_id = p.profile_id and p.cu= '$Cu' 74 inner join cu_profilerights pr on p.profile_id = pr.profile_id 75 inner join cu_feature f on pr.feature_code = f.feature_code and f.enabled 76 left join ${Cu}userrights ur on u.user_id= ur.user_id and pr.feature_code = ur.feature_code 77 left join ${Cu}grouprights gr on pr.feature_code = gr.feature_code and g.group_id = gr.group_id";
79 $sth= db_query($sql, $dbh);
81 throw new exception(
"Select query failed!", 1);
83 $unusedFeatures= array();
84 for($i=0; $array= db_fetch_assoc($sth, $i); $i++)
86 foreach($array as $key => $value)
88 $value= is_null($value) ?
"" : trim($value);
92 else if ($key ==
"bool_crequired" || $key ==
"bool_max_cr")
93 $value= $value ==
"t";
94 else if (strpos($key,
"bool_") !==
false)
95 $value= $value !=
"t";
96 else if (isset($array[
"max_${key}"]))
98 $maxValue= floatval($array[
"max_${key}"]);
99 $value= floatval($value) >= $maxValue ?
"" : $value;
101 $array[$key]= $value;
105 $returnArray= array(
"code" => 0,
"error" => array(),
"data" => $data,
"sql" => $sqls);
109 $returnArray= array(
"code" => $e->getCode(),
"error" => array($e->getMessage()),
"sql" => $sqls);
113 unset($returnArray[
"sql"]);
132 function saveUserRights($dbh, $Cu, $userId, $Cn)
135 $string= array(
"filter" => HCUFILTER_INPUT_STRING);
136 HCU_ImportVars($parameters,
"a", array(
"deletes" => $string,
"updates" => $string,
"adds" => $string));
137 extract($parameters[
"a"]);
140 $deletes= is_null($deletes) ?
"" : trim($deletes);
141 $updates= is_null($updates) ?
"" : trim($updates);
142 $adds= is_null($adds) ?
"" : trim($adds);
144 $officialDelete= array();
145 $officialUpdate= array();
146 $officialAdd= array();
147 $notSoOfficialUpdate= array();
148 $notSoOfficialAdd= array();
152 if ($deletes !=
"" && $deletes !=
"[]")
154 $deletes= HCU_JsonDecode($deletes);
155 if (count($deletes) == 0)
156 throw new exception(
"Delete array is invalid!", 1);
157 foreach($deletes as $featureCode)
159 $officialDelete[]= array(
"_action" =>
"delete",
"user_id" => $userId,
"feature_code" => $featureCode);
164 $updateCodes= array();
165 if ($updates !=
"" && $updates !=
"[]")
167 $updates= HCU_JsonDecode($updates);
168 if (count($updates) == 0)
169 throw new exception(
"Update array is invalid!", 2);
171 foreach($updates as $update)
173 if (!isset($update[
"feature_code"]))
174 throw new exception(
"Update row needs the feature code!", 3);
175 $code= trim($update[
"feature_code"]);
176 $updateCodes[$code]=
true;
177 $code= prep_save($code, 10);
178 $codes[]=
"('$code','update')";
179 $update[
"_action"]=
"update";
180 $update[
"user_id"]= $userId;
182 $notSoOfficialUpdate[]= $update;
188 if ($adds !=
"" && $adds !=
"[]")
191 $adds= HCU_JsonDecode($adds);
192 if (count($adds) == 0)
193 throw new exception(
"Add array is invalid!", 2);
194 foreach($adds as $add)
196 if (!isset($add[
"feature_code"]))
197 throw new exception(
"Add row needs the feature code!", 6);
198 $code= trim($add[
"feature_code"]);
199 $addCodes[$code]=
true;
200 $code= prep_save($code, 10);
201 $codes[]=
"('$code', 'add')";
202 $add[
"_action"]=
"create";
203 $add[
"user_id"]= $userId;
204 $notSoOfficialAdd[]= $add;
210 if (count($codes) > 0)
212 $sql=
"select v.* from ${Cu}userrights r inner join (values " . implode(
",", $codes) .
") as v (code, type) on r.feature_code = v.code and r.user_id = $userId";
214 $sth= db_query($sql, $dbh);
216 throw new exception(
"Check query failed!", 7);
218 $officialUpdate= array();
219 $officialAdd= array();
221 $actualUpdateCodes= array();
222 $actualAddCodes= array();
224 for($i=0; $array= db_fetch_assoc($sth, $i); $i++)
226 if ($array[
"type"] ==
"add")
227 $actualAddCodes[$array[
"code"]]=
true;
229 $actualUpdateCodes[$array[
"code"]]=
true;
232 if (count($actualUpdateCodes) == count($updateCodes) && count($actualAddCodes) == 0)
234 $officialUpdate= $notSoOfficialUpdate;
235 $officialAdd= $notSoOfficialAdd;
239 foreach($notSoOfficialUpdate as $row)
241 $feature= $row[
"feature_code"];
242 if (!isset($actualUpdateCodes[$feature]))
244 $row[
"_action"]=
"create";
245 $officialAdd[]= $row;
248 $officialUpdate[]= $row;
251 foreach($notSoOfficialAdd as $row)
253 $feature= $row[
"feature_code"];
254 if (isset($actualAddCodes[$feature]))
256 $row[
"_action"]=
"update";
257 $officialUpdate[]= $row;
260 $officialAdd[]= $row;
267 $sql=
"select email from cuadminusers where user_name= '$Cn' and cu= '$Cu'";
269 $sth = db_query($sql, $dbh);
271 throw new exception(
"email query failed!", 9);
272 $email= db_fetch_row($sth)[0];
275 $script=
"userSupportRights.prg";
276 $addr= trim($_SERVER[
"REMOTE_ADDR"]);
277 $vars= array(
"cu" => $Cu);
279 if ($deletes !=
"" && $deletes !=
"[]")
281 $official= array(
"userrights" => $officialDelete);
282 if (DataUserTableUpdate($dbh, $vars,
null, $official, $userId,
"UR_DELETE", $context, $script,
"A",
"Rights Delete", $Cn, $email, $addr) ===
false)
283 throw new exception(
"Deleting failed!", 10);
286 if ($updates !=
"" && $updates !=
"[]")
288 $official= array(
"userrights" => $officialUpdate);
289 if (DataUserTableUpdate($dbh, $vars,
null, $official, $userId,
"UR_UPDATE", $context, $script,
"A",
"Rights Update", $Cn, $email, $addr) ===
false)
290 throw new exception(
"Updating failed!", 11);
293 if ($adds !=
"" && $adds !=
"[]")
295 $official= array(
"userrights" => $officialAdd);
296 if (DataUserTableUpdate($dbh, $vars,
null, $official, $userId,
"UR_ADD", $context, $script,
"A",
"Rights Add", $Cn, $email, $addr) ===
false)
297 throw new exception(
"Adding failed!", 12);
303 return array(
"error" => array($e->getMessage()),
"code" => $e->getCode(),
"sql" => $sqls);
305 return array(
"error" => array(),
"code" => 0,
"sql" => $sqls);
317 function printPage($self, $userId, $readData)
319 <script type=
"text/javascript">
322 var userSupportContents= {};
324 userSupportContents.labels= [
325 {code:
"apt", description:
"Amount per transaction", popup:
"Transaction", type:
"amount"},
326 {code:
"apapd", description:
"Amount per account per day", popup:
"Account / Day", type:
"amount"},
327 {code:
"apd", description:
"Amount per day", popup:
"Day", type:
"amount"},
328 {code:
"apm", description:
"Amount per month", popup:
"Month", type:
"amount"},
329 {code:
"cpapd", description:
"Count per account per day", popup:
"Account / Day", type:
"count"},
330 {code:
"cpd", description:
"Count per day", popup:
"Day", type:
"count"},
331 {code:
"cpm", description:
"Count per month", popup:
"Month", type:
"count"},
332 {code:
"bool_faccess", description:
"Has access", popup:
"Access", type:
"boolean", isAccess:
true},
333 {code:
"bool_fcreate", description:
"Create feature", popup:
"Create", type:
"boolean"},
334 {code:
"bool_fconfirm", description:
"Needs confirmation", popup:
"Confirm", type:
"boolean"},
335 {code:
"bool_fdecline", description:
"Can decline", popup:
"Decline", type:
"boolean"},
336 {code:
"bool_freport", description:
"Has Report", popup:
"Report", type:
"boolean"},
337 {code:
"bool_crequired", description:
"Confirmation required", popup:
"Required", type:
"boolean", isConfirmation:
true}
339 userSupportContents.rightsData= [];
340 userSupportContents.defaultRowTemplate=
"";
352 function dirtify(dirty, container)
356 $(container).addClass(
"k-dirty-cell");
357 $(container).prepend(
"<span class='k-dirty'></span>");
361 $(container).removeClass(
"k-dirty-cell");
362 $(container).find(
".k-dirty").remove();
376 function numericEditor(container, options, rightsGrid)
378 if ($(container).hasClass(
"vsgDisabled"))
380 rightsGrid.closeCell();
383 switch(options.model.limit_type)
385 case "B":
break; <?php
387 if (!$(container).hasClass(
"bb"))
389 rightsGrid.closeCell();
394 if (!$(container).hasClass(
"cc"))
396 rightsGrid.closeCell();
401 rightsGrid.closeCell();
407 for(var i=0; i!= userSupportContents.labels.length; i++)
409 var item= userSupportContents.labels[i];
410 if (item.code == options.field)
416 var max= (options.model[
"max_"+options.field]+
"").trim();
417 max= max ==
"" ? (label.type ==
"amount" ?
"<?php echo FEATURE_LIMIT_MAX_AMOUNT; ?>" :
"<?php echo FEATURE_LIMIT_MAX_COUNT; ?>") : max;
418 max= Math.round(max);
419 var value= options.model[options.field];
420 value= value ==
null ? null : Math.round(value);
421 var orgValue= options.model[
"org_"+options.field];
422 var ntb= $(
"<input>").appendTo(container).kendoNumericTextBox({
424 format: label.type ==
"amount" ?
"c0" :
"n0",
428 upArrowText:
"Set to Default",
429 downArrowText:
"Set to 0",
431 var value= this.value() >= max ? null : Math.round(this.value());
435 options.model[options.field]= value;
437 options.model.dirty= orgValue != value;
439 dirtify(options.model.dirty, container);
441 }).data(
"kendoNumericTextBox");
454 function radioClick(value, rightsGrid)
456 var showBoolean=
false, booleanIndex= 2;
457 var showCounts=
false, countIndex= 4;
458 var showAmounts=
false, amountIndex= 3;
478 showBoolean ? $(
"#userRightsGrid").removeClass(
"hideAA") : $(
"#userRightsGrid").addClass(
"hideAA");
479 showCounts ? $(
"#userRightsGrid").removeClass(
"hideCC") : $(
"#userRightsGrid").addClass(
"hideCC");
480 showAmounts ? $(
"#userRightsGrid").removeClass(
"hideBB") : $(
"#userRightsGrid").addClass(
"hideBB");
482 if (typeof(resizingAndWhatnot) ==
"function")
483 (resizingAndWhatnot)($(
"#externalTabWindow").data(
"kendoWindow"));
495 function clearRecord(item)
506 item.bool_faccess=
true;
507 item.bool_fcreate=
true;
508 item.bool_fconfirm=
true;
509 item.bool_fdecline=
true;
510 item.bool_freport=
true;
511 item.bool_crequired=
true;
523 function createSnapshot(item)
525 item.org_apt= item.apt;
526 item.org_apd= item.apd;
527 item.org_apm= item.apm;
528 item.org_apapd= item.apapd;
529 item.org_cpd= item.cpd;
530 item.org_cpm= item.cpm;
531 item.org_cpapd= item.cpapd;
532 item.org_bool_faccess= item.bool_faccess;
533 item.org_bool_fcreate= item.bool_fcreate;
534 item.org_bool_fconfirm= item.bool_fconfirm;
535 item.org_bool_fdecline= item.bool_fdecline;
536 item.org_bool_freport= item.bool_freport;
537 item.org_bool_crequired= item.bool_crequired;
551 function updateGrid(options, rightsGrid)
556 var data= options.data.models;
557 for(var i=0; i!= data.length; i++)
561 deletes.push(item.feature_code);
564 var record= {feature_code: item.feature_code, amount_per_transaction: item.apt, amount_per_day: item.apd, amount_per_month: item.apm,
565 amount_per_account_per_day: item.apapd, count_per_day: item.cpd, count_per_month: item.cpm, count_per_account_per_day: item.cpapd, deny_report: !item.bool_freport,
566 deny_access: !item.bool_faccess, deny_create: !item.bool_fcreate, deny_confirm: !item.bool_fconfirm, deny_decline: !item.bool_fdecline,
567 confirm_required: item.bool_crequired};
569 updates.push(record);
574 if (deletes.length > 0 || updates.length > 0 || adds.length > 0)
576 var parameters= {userId:
"<?php echo $userId; ?>", deletes: kendo.stringify(deletes), updates: kendo.stringify(updates), adds: kendo.stringify(adds)};
578 $.post(
"<?php echo $self; ?>&operation=saveRights", parameters,
function(data) {
580 if (data.error.length > 0)
582 $.homecuValidator.displayMessage(data.error, $.homecuValidator.settings.statusError );
583 options.error(data.error);
587 var data= options.data.models;
588 for(var i=0; i!= data.length; i++)
596 createSnapshot(item);
598 options.success(data);
612 function openGroupRights()
614 var groupRightWindow= $(
"#groupRightWindow").data(
"kendoWindow");
615 if (groupRightWindow ==
null)
617 groupRightWindow= $(
"<div id='groupRightWindow'></div>").appendTo(
"body").kendoWindow({
619 title:
"Group Rights",
626 if (window.activeWindows !=
null)
627 window.activeWindows.pop();
630 if (window.activeWindows !=
null)
631 window.activeWindows.push(
this);
632 var kWindow= $(this.wrapper);
634 $(kWindow).css({position:
"absolute", top:
"10px", overflow:
"hidden"});
635 $(
"#groupRightWindow").css({overflow:
"hidden", padding: 0, paddingBottom: 15});
637 }).data(
"kendoWindow");
639 groupRightWindow.content(kendo.template($(
"#groupRightsWindowTemplate").html()));
641 var fields= {feature_code: {type:
"string"}, fdescription: {type:
"string"}};
643 for (var i=0; i!= userSupportContents.labels.length; i++)
645 var item= userSupportContents.labels[i];
649 if (item.code ==
"bool_crequired")
650 fields.bool_max_cr= {type:
"boolean"};
654 fields[
"max_"+item.code]= {type:
"number"};
659 var groupRightsGrid= $(
"#groupRightsGrid").kendoGrid({
661 data: userSupportContents.rightsData,
670 {field:
"fdescription", title:
"Feature", attributes: {
"class":
"showEllipsis"}, width:
"200px"},
671 {title:
"Description",
template: $(
"#groupRightsCellTemplate").html()}
674 template:
"<tr><td colspan='2'>No Records Found</td></tr>" 676 }).data(
"kendoGrid");
678 $(
"#groupRightsGrid").css({border:
"none", maxHeight: 500, overflowX:
"hidden", overflowY:
"auto"});
679 $(
"#groupRightsGrid:not(:has(.k-grid-norecords) .k-grid-content").css({overflowX:
"hidden", overflowY:
"auto"});
680 $(
"#groupRightsGrid:has(.k-grid-norecords) .k-grid-content").css({overflow:
"hidden"});
682 $(
"#groupRightWindow").on(
"click",
".closeBtn",
function() {
683 groupRightWindow.close();
687 var toolTipProps= homecuTooltip.defaults;
688 toolTipProps.filter=
".showEllipsis:overflown";
689 toolTipProps.content=
function(e) {
690 return $(e.target).text().trim();
693 $(
"#groupRightsGrid").kendoTooltip(toolTipProps);
695 groupRightWindow.open();
707 $.homecuValidator.setup({formValidate:
'userRightsDiv', formStatusField:
'formValidateDiv'});
708 $(
"#externalTabWindow").data(
"preferredHeight",
"auto");
709 $(
"#externalTabWindow").data(
"preferredWidth", 1100);
711 {title:
"Feature", columns: [{locked:
true, field:
"fdescription", title:
" ", width: 200, attributes: {
"class":
"showEllipsis"}}]},
712 {title:
"Reset", columns: [{locked:
true,
template:
"<input type='checkbox' class='rowCheckbox' # if (!exists) { # disabled style='display:none;' # } #>",
713 attributes: {
"class":
"checkboxTD"}, headerTemplate:
"<input type='checkbox' class='allCheckbox'>", width: 75, sortable:
false, filterable:
false, field:
"checked"}]}
717 kendoIndex: {type:
"number", editable:
false},
718 feature_code: {type:
"string", editable:
false},
719 checked: {type:
"boolean", editable:
false},
720 fdescription: {type:
"string", editable:
false},
721 limit_type: {type:
"string", editable:
false},
722 exists: {type:
"boolean", editable:
false}
726 var confirmation= [];
729 var rightsGrid=
null;
730 var booleanWidth= 75, amountWidth= 150, countWidth= 150;
731 var defaultT= [
"<td class='showEllipsis' role='gridcell'>#: fdescription #</td>",
732 "<td class='checkboxTD' role='gridcell'><input type='checkbox' class='rowCheckbox' checked # if (!exists) { # disabled style='display:none;' # } #></td>"];
736 var templateTemplate= kendo.template(
"# if (code != 'bool_faccess') { # \\# if (limit_type == 'A') { \\# <div class='accessOnly'> </div> \\# } else { \\# # } #" 737 +
"<center> \\# if (#: code #) { \\# <div class='restriction allow hcu-all-100'><i class='fa fa-check'></i></div> \\# } else { \\#" 738 +
"<div class='restriction ban hcu-all-100'><i class='fa fa-ban'></i></div> \\# } \\# </center> # if (code != 'bool_faccess') { # \\# } \\# # } #");
739 for (var i=0; i!= userSupportContents.labels.length; i++)
741 var item= userSupportContents.labels[i];
745 if (item.isConfirmation)
747 var thisRow= {field: item.code, title: item.popup, attributes: {
"class":
"aa"}, headerAttributes: {
"class":
"aa"},
748 template:
"# if (limit_type == 'A') { # <div class='accessOnly'> </div> # } else if (checked) { # Yes # } " 749 +
"else if (bool_max_cr) { # <div class='vsgDisabled'>Yes</div> # } else if (bool_crequired) { # " 750 +
"<div class='crequired showClickable hcu-all-100'>Yes</div> # } else { # <div class='crequired showClickable hcu-all-100'>No</div> # } #",
752 confirmation.push(thisRow);
753 fields[item.code]= {type:
"boolean", editable:
false};
754 defaultTB.push(
"# if (limit_type == 'A') { # <td class='accessOnly aa'> </td> # } else { #<td class='aa vsgDisabled k-group-cell' role='gridcell'>Yes</td># } #");
758 var thisRow= {field: item.code, headerTemplate:
"<center>"+item.popup+
"</center>", attributes: {
"class":
"aa restrictionTD",
"data-name": item.code},
759 headerAttributes: {
"class":
"aa"},
template: templateTemplate({code: item.code}), width: booleanWidth};
760 booleans.push(thisRow);
761 fields[item.code]= {type:
"boolean", editable:
false};
762 var defaultThis= item.isAccess ?
"<td class='aa vsgDisabled'><center><i class='fa fa-check'></i></center></td>" :
763 "# if (limit_type == 'A') { # <td class='accessOnly aa'> </td> # } else { #<td class='aa vsgDisabled'><center><i class='fa fa-check'></i></center></td> # } #";
764 defaultTB.push(defaultThis);
768 amounts.push({field: item.code, title: item.popup, editor:
function(container, options) { numericEditor(container, options, rightsGrid); },
769 attributes: {
"class":
"bb"}, headerAttributes: {
"class":
"bb"},
template:
"# if (limit_type != 'B' && limit_type != 'D') { # <div class='notAmount'> </div> # } " 770 +
"else if (checked) { # Default # } else if ("+ item.code+
" == null) { #" 771 +
"<div class='showClickable hcu-all-100'>Default</div> # } else { # <div class='showClickable hcu-all-100'>#= kendo.toString ("+ item.code+
", 'c0') #</div> # } #",
772 width: amountWidth});
773 fields[item.code]= {type:
"number"};
774 defaultTA.push(
"# if (limit_type != 'B' && limit_type != 'D') { # <td class='bb notAmount'> </td> # }" 775 +
"else { # <td class='bb vsgDisabled' role='gridcell'>Default</td> # } #");
778 counts.push({field: item.code, title: item.popup, editor:
function(container, options) { numericEditor(container, options, rightsGrid); },
779 attributes: {
"class":
"cc"}, headerAttributes: {
"class":
"cc"},
template:
"# if (limit_type != 'B' && limit_type != 'Q') { # <div class='notCount'> </div> # } " 780 +
"else if (checked) { # Default # } else if ("+ item.code+
" == null) { #" 781 +
"<div class='showClickable hcu-all-100'>Default</div> # } else { # <div class='showClickable hcu-all-100'>#= kendo.toString ("+ item.code+
", 'n0') #</div> # } #",
783 fields[item.code]= {type:
"number"};
784 defaultTC.push(
"# if (limit_type != 'B' && limit_type != 'Q') { # <td class='cc notCount'> </td> # } else {" 785 +
"# <td class='cc vsgDisabled' role='gridcell'>Default</td> # } #");
790 userSupportContents.defaultRowTemplate= defaultT.concat(defaultTB).concat(defaultTA).concat(defaultTC).join(
" ");
792 columns.push({headerTemplate:
"<center>Restrictions</center>", columns: booleans, headerAttributes: {
"class":
"topHeader aa"}});
793 columns.push({title:
"Confirmation", columns: confirmation, headerAttributes: {
"class":
"topHeader aa"}});
794 columns.push({title:
"Count Per", columns: counts, headerAttributes: {
"class":
"topHeader cc"}});
795 columns.push({title:
"Amount Per", columns: amounts, headerAttributes: {
"class":
"topHeader bb"}});
798 var data= <?php echo HCU_JsonEncode($readData); ?>;
799 if (data.error.length > 0)
800 $.homecuValidator.displayMessage(data.error, $.homecuValidator.settings.statusError );
803 for(var i=0; i!= data.data.length; i++)
805 data.data[i].kendoIndex= i+1;
806 data.data[i].checked=
false;
807 createSnapshot(data.data[i]);
809 userSupportContents.rightsData=
new kendo.data.ObservableArray(data.data);
813 rightsGrid= $(
"#userRightsGrid").kendoGrid({
816 read:
function(options) {
817 options.success(userSupportContents.rightsData);
819 create:
function(options) {},
820 update:
function(options) {
821 updateGrid(options,
this);
830 sort: [{field:
"specialAddRow", dir:
"asc"}, {field:
"fdescription", dir:
"asc"}, {field:
"feature_code", dir:
"asc"}],
835 template:
"<tr><td colspan='3'>No Records Found</td></tr>" 841 }).data(
"kendoGrid");
843 $(
"#userRightsGrid:has(.k-grid-norecords) .k-grid-content").css({overflow:
"hidden !important"});
844 $(
"#userRightsGrid").addClass(
"hideBB hideCC");
847 $(
"#userRightsGrid colgroup").each(
function(i) {
848 $(
this).find(
"col").each(
function(index) {
852 $(
this).addClass(
"aa");
854 $(
this).addClass(
"bb");
856 $(
this).addClass(
"cc");
860 $(
".userRightsDiv").on(
"click",
".showGroupRightsBtn",
function() {
865 $(
".userRightsDiv").on(
"mouseup",
".cancelBtn",
function() {
866 potentiallyCancelChanges();
870 $(
".userRightsDiv").on(
"mouseup",
".updateBtn",
function() {
872 var data= rightsGrid.dataSource.data();
874 for(var i=0; i!= data.length; i++)
878 item.dirty=
true; <?php
882 doUpdate ? rightsGrid.dataSource.sync() : postPostPostPost();
886 <?php printCheckboxEvents(
"#userRightsGrid",
"",
"",
".allCheckbox",
".rowCheckbox",
"doDefaultRow"); ?>
888 $(
"#userRightsGrid").on(
"click",
".checkboxTD",
function(e) {
889 if (e.target !==
this)
891 $(
this).find(
"[type='checkbox']").click();
894 $(
"#userRightsGrid").on(
"click",
".crequired.showClickable",
function(e) {
895 $(
"#userRightsGrid .crequiredTD").each(
function(ei) {
896 var td= $(
this).closest(
"td");
897 var tr= $(td).closest(
"tr");
898 var dirty= $(td).hasClass(
"k-dirty-cell");
899 var dataItem= $(
"#userRightsGrid").data(
"kendoGrid").dataItem(tr);
901 $(td).removeClass(
"crequiredTD");
902 $(td).removeClass(
"k-edit-cell");
903 $(tr).removeClass(
"k-grid-edit-row");
904 $(td).html(
"<div class='crequired showClickable hcu-all-100'>" + (dataItem.bool_crequired ?
"Yes" :
"No") +
"</div>");
908 var isTrue= $(
this).text().trim() ==
"Yes";
909 var td= $(
this).closest(
"td");
910 var tr= $(td).closest(
"tr");
911 $(td).html(
"<input class='crrr' type='checkbox' "+ (isTrue ?
"checked" :
"") +
">");
912 $(td).addClass(
"crequiredTD");
913 $(td).addClass(
"k-edit-cell");
914 $(tr).addClass(
"k-grid-edit-row");
918 $(
"#userRightsGrid").on(
"click",
".crequiredTD",
function(e) {
919 if ($(e.target).is(
"input"))
921 var td= $(
this).closest(
"td");
922 var tr= $(td).closest(
"tr");
923 var dirty= $(td).hasClass(
"k-dirty-cell");
924 var dataItem= $(
"#userRightsGrid").data(
"kendoGrid").dataItem(tr);
926 $(td).removeClass(
"crequiredTD");
927 $(td).removeClass(
"k-edit-cell");
928 $(tr).removeClass(
"k-grid-edit-row");
929 $(td).html(
"<div class='crequired showClickable hcu-all-100'>" + (dataItem.bool_crequired ?
"Yes" :
"No") +
"</div>");
934 $(
"#userRightsGrid").on(
"click",
".crrr",
function(e) {
935 var td= $(
this).closest(
"td");
936 var tr= $(td).closest(
"tr");
937 var dataItem= $(
"#userRightsGrid").data(
"kendoGrid").dataItem(tr);
938 dataItem.dirty=
true;
939 dataItem.bool_crequired= $(
this).is(
":checked");
940 dirtify(dataItem.bool_crequired != dataItem.org_bool_crequired, td);
943 $(
"body").on(
"click.userSupportHubNamespace",
function(e) {
944 if ($(e.target).hasClass(
"crrr") || $(e.target).hasClass(
"crequiredTD") || $(e.target).hasClass(
"cancelBtn"))
947 $(
"#userRightsGrid .crequiredTD").each(
function(ei) {
948 var td= $(
this).closest(
"td");
949 var tr= $(td).closest(
"tr");
950 var dirty= $(td).hasClass(
"k-dirty-cell");
951 var dataItem= $(
"#userRightsGrid").data(
"kendoGrid").dataItem(tr);
953 $(td).removeClass(
"crequiredTD");
954 $(td).removeClass(
"k-edit-cell");
955 $(tr).removeClass(
"k-grid-edit-row");
956 $(td).html(
"<div class='crequired showClickable hcu-all-100'>" + (dataItem.bool_crequired ?
"Yes" :
"No") +
"</div>");
961 $(
"#userRightsGrid").on(
"click",
".restriction.allow",
function() {
962 var td= $(
this).closest(
"td");
963 var name= $(td).data(
"name");
964 $(td).html(
"<center><div class='restriction ban hcu-all-100'><i class='fa fa-ban'></i></div></center>");
965 var tr= $(td).closest(
"tr");
966 var dataItem= rightsGrid.dataItem(tr);
967 dataItem.dirty=
true;
968 dataItem[name]=
false;
969 dirtify(dataItem[name] != dataItem[
"org_"+name], td);
972 $(
"#userRightsGrid").on(
"click",
".restriction.ban",
function() {
973 var td= $(
this).closest(
"td");
974 var name= $(td).data(
"name");
975 $(td).html(
"<center><div class='restriction allow hcu-all-100'><i class='fa fa-check'></i></div></center>");
976 var tr= $(td).closest(
"tr");
977 var dataItem= rightsGrid.dataItem(tr);
978 dataItem.dirty=
true;
979 dataItem[name]=
true;
981 dirtify(dataItem[name] != dataItem[
"org_"+name], td);
984 $(
".userRightsDiv").on(
"click",
"[name='gridShowOption']",
function() {
985 radioClick($(
this).val().trim());
988 <?php printExtendShowOverflown(); ?>
990 var toolTipProps= homecuTooltip.defaults;
991 toolTipProps.filter=
".showEllipsis:overflown";
992 toolTipProps.content=
function(e) {
993 return $(e.target).text().trim();
996 $(
"#userRightsGrid").kendoTooltip(toolTipProps);
998 $(
"#userRightsGrid").kendoTooltip(toolTipProps);
1000 toolTipProps= homecuTooltip.defaults;
1001 toolTipProps.filter=
".aa:has(.vsgDisabled)";
1002 toolTipProps.content=
"Set at the group or profile level.";
1004 $(
"#userRightsGrid").kendoTooltip(toolTipProps);
1006 toolTipProps= homecuTooltip.defaults;
1007 toolTipProps.filter=
"td.vsgDisabled";
1008 toolTipProps.content=
"Set to Default.";
1010 $(
"#userRightsGrid").kendoTooltip(toolTipProps);
1012 toolTipProps= homecuTooltip.defaults;
1013 toolTipProps.filter=
"td:has(.notAmount)";
1014 toolTipProps.content=
"Feature doesn't have amounts.";
1016 $(
"#userRightsGrid").kendoTooltip(toolTipProps);
1018 toolTipProps= homecuTooltip.defaults;
1019 toolTipProps.filter=
"td:has(.notCount)";
1020 toolTipProps.content=
"Feature doesn't have counts.";
1022 $(
"#userRightsGrid").kendoTooltip(toolTipProps);
1024 toolTipProps= homecuTooltip.defaults;
1025 toolTipProps.filter=
"td:has(.accessOnly)";
1026 toolTipProps.content=
"Feature is access only.";
1028 $(
"#userRightsGrid").kendoTooltip(toolTipProps);
1032 function doDefaultRow (checked, checkboxInput)
1034 var savedRows= $(
"#userRightsGrid").data(
"savedRows");
1035 savedRows= savedRows ==
null ? {} : savedRows;
1036 var tr= $(checkboxInput).closest(
"tr");
1037 var rightsGrid= $(
"#userRightsGrid").data(
"kendoGrid");
1041 savedRows[$(tr).index()]= $(tr).html();
1042 $(
"#userRightsGrid").data(
"savedRows", savedRows);
1043 var
template= kendo.template(userSupportContents.defaultRowTemplate);
1044 $(tr).removeClass(
"k-grid-edit-row");
1045 $(tr).html(
template(rightsGrid.dataItem($(tr))));
1049 var row= savedRows[$(tr).index()];
1052 $(tr).addClass(
"k-grid-edit-row");
1065 function postPostPostPost()
1067 $(
"#externalTabWindow").data(
"isClosing",
true);
1068 $(
"#externalTabWindow").data(
"kendoWindow").close();
1069 $(
"#externalTabWindow").data(
"isClosing",
false);
1078 function userSupportDoOnClose()
1080 potentiallyCancelChanges();
1081 $(
"#externalTabWindow").data(
"shouldClose",
false);
1090 function potentiallyCancelChanges()
1092 if ($(
"#userRightsGrid .k-dirty-cell .k-dirty").length == 0 && $(
"#userRightsGrid .checkboxTD [type='checkbox']:checked").length == 0)
1096 var discardChangesDialog= $(
"#discardChangesDialog").data(
"kendoDialog");
1097 if (discardChangesDialog ==
null)
1099 discardChangesDialog= $(
"<div id='discardChangesDialog'></div>").appendTo(
"body").kendoDialog({
1100 title:
"Discard Changes",
1101 content:
"<p>Changes have been made to this user's rights.</p><p>Do you wish to discard your changes?</p>",
1104 {text:
"Yes", primary:
true, action:
function() {
1110 if (window.activeWindows !=
null)
1111 window.activeWindows.push(
this);
1114 if (window.activeWindows !=
null)
1115 window.activeWindows.pop();
1117 }).data(
"kendoDialog");
1119 discardChangesDialog.open();
1127 <script type=
"text/x-kendo-template" id=
"groupRightsWindowTemplate">
1128 <div
class=
"hcu-template container hcu-all-100 hcu-no-padding">
1129 <div
id=
"groupRightsGrid" class=
"hcu-all-100"></div>
1130 <div
class=
"hcu-edit-buttons k-state-default row hcu-all-100">
1131 <div
class=
"col-xs-12">
1132 <a
class=
"closeBtn k-button k-primary" href=
"\\#"><i
class=
"fa fa-times"></i>Close</a>
1138 <script type=
"text/x-kendo-template" id=
"groupRightsCellTemplate">
1139 # var fullDescription= []; 1140 for (var i=0; i!= userSupportContents.labels.length; i++)
1142 var item= userSupportContents.labels[i];
1143 var code= item.code ==
"bool_crequired" ?
"bool_max_cr" :
"max_"+item.code;
1144 var value= data[code];
1145 if (value !=
null && (value+
"").trim() !=
"")
1147 var fullValue= item.description +
": ";
1151 fullValue+= kendo.toString(value,
"c2");
1154 fullValue+= kendo.toString(value,
"n0");
1157 fullValue+= value ==
"Y" ?
"true" :
"false";
1160 fullDescription.push(fullValue);
1163 #= fullDescription.join(", <br>") # 1165 <script type=
"text/x-kendo-template" id=
"defaultRowTemplate">
1169 <div
class=
"container-fluid userRightsDiv hcu-template vsgPrimary" id=
"userRightsDiv">
1171 <div
id=
"formValidateDiv" class=
"col-xs-12 k-block k-error-colored formValidateDiv" style=
"display:none;"></div>
1173 <div
class=
"well well-sm">
1174 <div
class=
"row hcuSpacer">
1175 <div
class=
"col-xs-12">
1176 <div
class=
"floatRight">
1177 <a href=
"#" class=
"showGroupRightsBtn">Show Group Rights</a>
1183 <div
class=
"radio-inline radio-spacer"><label><input type=
"radio" name=
"gridShowOption" value=
"boolean" checked> Restrictions</label></div>
1184 <div
class=
"radio-inline radio-spacer"><label><input type=
"radio" name=
"gridShowOption" value=
"count"> Quantity</label></div>
1185 <div
class=
"radio-inline radio-spacer"><label><input type=
"radio" name=
"gridShowOption" value=
"amount"> Amount</label></div>
1186 <div
class=
"radio-inline radio-spacer"><label><input type=
"radio" name=
"gridShowOption" value=
"all"> All</label></div>
1190 <div
class=
"row"> </div>
1192 <div
class=
"col-xs-12 hcu-secondary">
1193 <div
class=
"small vsgSecondary">Click on field to edit</div>
1197 <div
class=
"col-xs-12">
1198 <div
id=
"userRightsGrid"></div>
1201 <div
class=
"hcu-edit-buttons k-state-default">
1202 <a
class=
"cancelBtn" href=
"#">Cancel</a>
1204 <a
class=
"updateBtn k-button k-primary" href=
"#"><i
class=
"fa fa-check"></i>Update</a>