2 $previousScript=
"showflags.prg";
3 require_once(
"adm_reports.prg");
4 require_once(
"cu_flagconst.i");
6 dms_import(array(
"report" =>
"string",
"operation" =>
"string",
"servers" =>
"string",
"showServer" =>
"string"));
9 $title=
"Processing Flag Settings";
10 $cookieName=
"showFlags";
11 $colMap= array(
"flagset",
"flagset2",
"flagset3");
12 $url= $_SERVER[
"PHP_SELF"];
13 $defaultDateFormat=
"MM/dd/yyyy";
15 $showFlagsSQLTemplate=
"select cu, orgname, # from cuadmin where livebatch <> 'C' ";
17 $flagsets= array(array(), array(), array());
19 foreach(get_defined_vars() as $varName => $num)
21 if (strpos($varName,
'DEFAULT') !==
false)
23 $firstPartOfVar= explode(
"_", $varName);
24 switch($firstPartOfVar[0])
27 $flagsets[0][$num]= $varName;
30 $flagsets[1][$num]= $varName;
33 $flagsets[2][$num]= $varName;
38 $createReportList=
true;
43 if (isset($_COOKIE[$cookieName]))
45 parse_str($_COOKIE[$cookieName]);
49 if (trim($usedFlags1Encoded) !=
"")
51 $usedFlags1= json_decode($usedFlags1Encoded,
true);
53 if (trim($usedFlags2Encoded) !=
"")
55 $usedFlags2= json_decode($usedFlags2Encoded,
true);
57 if (trim($usedFlags3Encoded) !=
"")
59 $usedFlags3= json_decode($usedFlags3Encoded,
true);
61 $usedFlags[]= is_array($usedFlags1) ? $usedFlags1 : array();
62 $usedFlags[]= is_array($usedFlags2) ? $usedFlags2 : array();
63 $usedFlags[]= is_array($usedFlags3) ? $usedFlags3 : array();
64 createReportListFromFlags($link, $showSQL, $reportList, $errors, $sqls, $flagsets, $usedFlags, $colMap, $cookieName, $showFlagsSQLTemplate);
66 else $usedFlags= array(array(), array(), array());
68 function createReportListFromFlags($link, $showSQL, &$reportList, &$errors, &$sqls, $flagsets, $usedFlags, $colMap, $cookieName, $showFlagsSQLTemplate)
73 $colList= array(
"CU" =>
"string",
"Org Name" =>
"string");
74 $colSelectList= array();
77 foreach($usedFlags as $i => $usedFlagSet)
79 foreach($usedFlagSet as $num)
81 $text= $flagsets[$i][$num];
82 if (!is_numeric($num))
84 $errors[]=
"Used Flags " . $i+1 .
" needs to be an array of integers.";
87 else if (!isset($text))
89 $errors[]=
"Used Flags " . $i+1 .
" has numbers not in list.";
94 $colList[$text]=
"string";
95 $colSelectList[]=
"coalesce(" . $colMap[$i] .
", 0) & $num";
96 $values[$text]= array(array(
"text" =>
"+",
"value" => $num), array(
"text" =>
" ",
"value" => 0));
102 if (count($errors) == 0 && count($colSelectList) == 0)
104 foreach($flagsets as $i => $flags)
106 foreach($flags as $num => $text)
108 $colList[$text]=
"string";
109 $colSelectList[]=
"coalesce(" . $colMap[$i] .
", 0) & $num";
110 $values[$text]= array(array(
"text" =>
"+",
"value" => $num), array(
"text" =>
" ",
"value" => 0));
115 $reportList= array(
"flagSettings" => array(
"title" =>
"Processing Flag Settings",
"sql" => str_replace(
"#", implode(
", ", $colSelectList), $showFlagsSQLTemplate),
116 "cols" => $colList,
"values" => $values));
119 function outputFlagRows($flagsets, $colMap)
121 foreach($flagsets as $i => $flags)
123 $flagName= $colMap[$i];
125 print
"<div class='grid_16 flagHeader'>$flagName</div>\n";
129 foreach($flags as $num => $text)
131 $modulus= $index % 4;
133 $row=
"<div class='grid_16'> 134 <div class='grid_4 alpha'>#0#</div> 135 <div class='grid_4'>#1#</div> 136 <div class='grid_4'>#2#</div> 137 <div class='grid_4 omega'>#3#</div> 139 $row= str_replace(
"#$modulus#",
"<input class='f$i' type='checkbox' value=$num>$text</input>", $row);
150 $row= preg_replace(
"/#[0-3]#/",
" ", $row);
153 print
"<div class='grid_16'><hr></div><div class='grid_16'> </div>\n";
157 function outputLegend($flagsets, $colMap, $usedFlags)
162 foreach($usedFlags as $i => $used)
164 $flagName= $colMap[$i];
165 $flags= $flagsets[$i];
167 $toPrintRecord= array(
"toolbar" =>
"gridDefinition.toolbar= '$flagName';\n");
172 foreach($used as $index => $value)
174 $modulus= $index % $cols;
176 $row= array(
"rowIndex" => ++$rowIndex);
177 $row[
"property$modulus"]= $flags[$value];
178 $row[
"value$modulus"]= $value;
180 if ($modulus == $cols-1)
187 if ($row !=
"not started")
190 if (count($data) > 0)
196 $toPrintRecord[
"data"]=
"gridDefinition.dataSource.data= " . json_encode($data) .
";\n";
197 $toPrintRecord[
"setGrid"]=
"var flagset${i}LegendGrid= \$(\"#flagset${i}LegendGrid\").kendoGrid(gridDefinition).data(\"kendoGrid\"); \n";
198 $toPrint[]= $toPrintRecord;
201 foreach($toPrint as $i => $toPrintRecord)
209 foreach($flagsets[$i] as $value => $text)
211 $modulus= $index % $cols;
213 $row= array(
"rowIndex" => ++$rowIndex);
214 $row[
"property$modulus"]= $text;
215 $row[
"value$modulus"]= $value;
217 if ($modulus == $cols-1)
226 if ($row !=
"not started")
228 $toPrintRecord[
"data"]=
"gridDefinition.dataSource.data= " . json_encode($data) .
";\n";
231 print $toPrintRecord[
"toolbar"];
232 print $toPrintRecord[
"data"];
233 print $toPrintRecord[
"setGrid"];
237 function getAdditionalUrlFromFlags()
239 $flags= array(
"flagset1" =>
"usedFlags1",
"flagset2" =>
"usedFlags2",
"flagset3" =>
"usedFlags3");
240 for($i=0; $i != 3; $i++)
242 print
"var flags$i= []; 243 \$(\".f$i\").each(function () { 244 if (\$(this).prop('checked')) 246 flags$i.push(Number(\$(this).val())); 249 url+= \"&flags$i=\" + kendo.stringify(flags$i);\n";
253 if (!isset($operation)) { $operation =
"";}
254 if ($operation ==
"setReportCookie")
256 $parameters= array();
257 dms_import_v2($parameters,
"BOTTOM_LEVEL", array(
"flags0" =>
"string",
"flags1" =>
"string",
"flags2" =>
"string"));
259 $usedFlags1= $parameters[
"BOTTOM_LEVEL"][
"flags0"];
260 $usedFlags2= $parameters[
"BOTTOM_LEVEL"][
"flags1"];
261 $usedFlags3= $parameters[
"BOTTOM_LEVEL"][
"flags2"];
263 $expiresInDay= time()+86400;
264 $cookie=
"usedFlags1Encoded=$usedFlags1&usedFlags2Encoded=$usedFlags2&usedFlags3Encoded=$usedFlags3";
265 HCU_setcookie_env($SYSENV, $cookieName, $cookie, $expiresInDay);
267 header(
"Location: $url?report=flagSettings&servers=$servers&showServer=$showServer");
270 else if ($operation !=
"")
279 readReport($link, $showSQL, $errors, $sqls, $reportList, $defaultDateFormat, $cookieName);
281 case "readReportSQL":
282 readReport($link,
true, $errors, $sqls, $reportList, $defaultDateFormat, $cookieName);
285 generateCSV($link, $errors, $sqls, $reportList, $defaultDateFormat, $cookieName);
288 header(
'Content-type: application/json');
289 $errors[]=
"Operation not specified: '$operation'";
290 $returnArray= array(
"error" => $errors,
"record" =>
"",
"operation" =>
"");
291 print json_encode($returnArray);
301 if (!isset($report)) {$report =
"";}
302 $report= trim($report);
304 $reportMenuDDL= array(
"REDIRECT" => array(
"list" => array(
"Selection List" => array(
"url" => $presentationFile))),
305 "Download CSV" => array(
"id" =>
"downloadCSVBtn"),
"Help <img src=\"/monitor/images/q1.gif\" border=\"0\" alt=\"View Help\" align=\"top\">" => array(
"id" =>
"helpBtn"));
311 printMonitorPageTop($title, $homecuKendoVersion, $cloudfrontDomainName);
316 background-color: #9BAFBE !important;
317 text-align: center !important;
321 background-color: #B2B3C2 !important;
325 <script type=
"text/javascript">
327 getErrorsAreShownFunction();
328 getEscapeHTMLFunction();
330 function initReportSelectPage()
332 var localServer =
"<?php echo $_SERVER['SERVER_NAME']; ?>";
333 var serverMultiselect= $(
"#serverMultiselect").kendoMultiSelect({
335 data: [
"www3",
"www5",
"www6", localServer]
337 value: [
"www3",
"www5",
"www6", localServer]
338 }).data(
"kendoMultiSelect");
340 $(
"#serverMultiselect").prev().css({height: 25});
342 $(
"#runReportBtn").click(
function() {
344 var data= {error: []};
345 if (!errorsAreShown(data,
"formValidateMainDiv"))
347 var url=
"<?php echo $url; ?>?operation=setReportCookie";
348 var showServer= $(
"#showServerCheckbox:checked").length > 0 ?
"Y" :
"N";
349 var servers= kendo.stringify(serverMultiselect.value());
351 url+=
"&showServer=" + showServer +
"&servers=" + servers;
352 <?php getAdditionalUrlFromFlags(); ?>
353 window.location.href= url;
362 $(document).ready(
function () {
363 initReportSelectPage();
366 <?php printMonitorPageMiddle($title); ?>
367 <div
id=
'hideSubmitWait' style=
'position:relative; left:-2000px;top:-2000px;'>
368 <div
id=
'homecuSubmitWait' class=
'k-block' >
369 <div
class=
'k-loading-image'></div>
372 <div
class=
"container_16">
373 <?php outputFlagRows($flagsets, $colMap); ?>
374 <div
class=
"grid_16">
375 Include Data From: <div
id=
"serverMultiselect"></div>
377 <div
class=
"grid_16">
378 Show Server: <input type=
"checkbox" id=
"showServerCheckbox">
380 <div
class=
"grid_16">
381 <a href=
"#" class=
"k-button k-button-icontext" id=
"runReportBtn">Go</a>
389 printMonitorPageTop($title, $homecuKendoVersion, $cloudfrontDomainName);
393 #legendDiv .k-grid-toolbar { 394 background-color: #9BAFBE !important;
395 font-weight: bold !important;
396 text-align: center !important;
398 #legendDiv .firstGridToolbar { 399 background-color: #B2B3C2 !important;
403 border: 1px solid black;
413 <script type=
"text/javascript">
417 getErrorsAreShownFunction();
418 getEscapeHTMLFunction();
419 getShowSQLFunction($showSQL);
420 getShowWaitFunctions();
421 getIsFilterChanged();
422 initReportClientSide($presentationFile, $report, $title, array(
"servers" => $servers,
"showServer" => $showServer),
true,
"addWidthsPre",
"addWidthsPost");
425 function addWidthsPre(gridDefinition)
427 gridDefinition.columns[0].width=
"100px";
428 gridDefinition.columns[1].width=
"200px";
431 function addWidthsPost(grid)
433 for(var i=2, length=grid.columns.length; i!=length; i++)
435 grid.autoFitColumn(i);
437 $(
"#reportGrid").css({width: $(
"#reportGrid table").css(
"width")});
440 function initOptions()
442 var gridDefinition= {
448 rowIndex: {type:
"number"},
449 property0: {type:
"string"},
450 value0: {type:
"string"},
451 property1: {type:
"string"},
452 value1: {type:
"string"},
453 property2: {type:
"string"},
454 value2: {type:
"string"}
460 {field:
"property0", title:
"Flag"},
461 {field:
"value0", title:
"Value", width:
"100px"},
462 {title:
" ",
template:
" ", width:
"3px"},
463 {field:
"property1", title:
"Flag"},
464 {field:
"value1", title:
"Value", width:
"100px"},
465 {title:
" ",
template:
" ", width:
"3px"},
466 {field:
"property2", title:
"Flag"},
467 {field:
"value2", title:
"Value", width:
"100px"}
470 <?php outputLegend($flagsets, $colMap, $usedFlags); ?>
471 $(
"#legendDiv .k-grid-toolbar:eq(0)").addClass(
"firstGridToolbar");
473 $(
"#includeLegend").click(
function () {
474 if ($(
this).is(
":checked"))
475 $(
"#legendDiv").show();
477 $(
"#legendDiv").hide();
480 var cuOptionsDDL= $(
"#cuOptionsDDL").kendoDropDownList({
482 data: [{text:
"Show Selected Flags for All Credit Unions", value: 1}, {text:
"Show Credit Unions w/ All Selected Flags Set", value: 2},
483 {text:
"Show Credit Unions w/ Any Selected Flag Set", value: 3}]
485 dataTextField:
"text",
486 dataValueField:
"value",
489 var dataRows = $(
"#reportGrid").data(
"kendoGrid").dataSource.data();
490 var dataColumns = $(
"#reportGrid").data(
"kendoGrid").columns;
492 if (this.value() != 1) {
494 for (var i = 0; i < dataRows.length; i++) {
498 var row = dataRows[i];
502 for (var j = 0; j < dataColumns.length; j++) {
503 var column = dataColumns[j];
504 var columnName = column.field.trim();
507 if (columnName ==
"cu" || columnName ==
"orgName" || columnName ==
"server") {
512 if (row[columnName] == 0) {
522 if (this.value() == 2 && hasAll) {
523 filter.push({field:
"cu",
operator:
"eq", value: rowCu});
524 }
else if (this.value() == 3 && (hasOne || hasAll)) {
525 filter.push({field:
"cu",
operator:
"eq", value: rowCu});
534 if (filter.length == 0) {
535 filter.push({field:
"cu",
operator:
"eq", value:
""});
538 filter= {logic:
"or", filters: filter};
540 $(
"#reportGrid").data(
"kendoGrid").dataSource.filter(filter);
542 }).data(
"kendoDropDownList");
544 cuOptionsDDL.value(1);
547 $(document).ready(
function () {
553 $legendStyle=
"style='width:1000px;'";
554 printMonitorPageMiddle($title, $reportMenuDDL); ?>
555 <div
id=
'hideSubmitWait' style=
'position:relative; left:-2000px;top:-2000px;'>
556 <div
id=
'homecuSubmitWait' class=
'k-block' >
557 <div
class=
'k-loading-image'></div>
561 <div
id=
"notification"></div>
562 <div
class=
"container_12">
563 <div
class=
"grid_12">
564 <div
id=
"sqlOutput"></div>
566 <fieldset
id=
"optionsDiv">
567 <div
class=
"grid_12">
568 <div
class=
"grid_3">Include Legend:</div>
569 <div
class=
"grid_9"><input
id=
"includeLegend" type=
"checkbox"></div>
572 <div
class=
"grid_12">
573 <div
class=
"grid_3">Filter: </div>
574 <div
class=
"grid_9"><div
id=
"cuOptionsDDL" style=
"width:100%"></div></div>
577 <div
class=
"grid_12" id=
"legendDiv" style=
"display:none;">
578 <div
id=
"flagset0LegendGrid" <?php echo $legendStyle; ?>></div>
579 <div
id=
"flagset1LegendGrid" <?php echo $legendStyle; ?>></div>
580 <div
id=
"flagset2LegendGrid" <?php echo $legendStyle; ?>></div>
582 <div
class=
"grid_12" style=
"margin-bottom:5px;">
583 <div
id=
"formValidateMainDiv" class=
"k-block k-error-colored" style=
"display:none;"></div>
585 <div
class=
"grid_12">
586 <div
id=
"reportGrid"></div>
589 <?php printMonitorPageBottom();