Odyssey
TrustedReport.prg
1 <?php
2  /*
3  * File: TrustedReport
4  *
5  * Purpose: To show trusted vendor master and detail settings
6  * Changes:
7  * SPB 9/28/2015-- Added aggregateData function to get values from a proxy file that gathers all TrustedReport.data from all applicable servers versus a call to TrustedReport.data.
8  * SPB 9/28/2015-- Added calls to common header.
9  * ENR 2/26/2019-- Added small form to export clients and trusted detail values to csv
10  */
11 $monLibrary= dirname(__FILE__) . "/../library";
12 require_once("$monLibrary/cu_top.i");
13 require_once("$monLibrary/ck_hticket.i");
14 require_once("$sharedLibrary/cu_func.i");
15 require_once("$monLibrary/monitorView.i");
16 
17  if (!CheckPerm($link, $Hu, basename($_SERVER['SCRIPT_NAME']), $_SERVER['REMOTE_ADDR'])) {
18  // ** Permissions failed
19  // ** redirect to new page
20  header("Location: /hcuadm/hcu_noperm.prg");
21  exit;
22  }
23 
24  printMonitorPageTop("Trusted Vendor Report", $homecuKendoVersion, $cloudfrontDomainName);
25 ?>
26 <style>
27  body {
28  font-family: Arial, Helvetica, sans-serif;
29  background-color: #EFEFEF;
30  }
31  .k-grid .k-hierarchy-col {
32  width: 10px;
33  }
34  #currentStatus {
35  position: fixed;
36  right: 20px;
37  top:50px;
38  width: 250px;
39  padding: 10px;
40  }
41  .settingStatus {
42  width: 500px;
43  min-height: 50px;
44  padding-top: 10px;
45  z-index: 10010;
46  }
47  .settingStatus .section,
48  .settingStatus .section-clean,
49  .settingStatus .section-dirty {
50  margin-bottom: 20px;
51  }
52  #currentStatus.dirty .section-dirty {
53  display: block;
54  }
55  #currentStatus.clean .section-clean {
56  display: block;
57  }
58 
59  #gridProxy {
60  font-size: 12px;
61  width: 500px;
62  }
63  .k-tooltip-content { text-align: left;
64  font-size: 12px;
65  max-width: 300px;
66  }
67 
68  .Clients .k-hierarchy-col {
69  width: 50px;
70  }
71 
72  .k-grid td {
73  border-width: 0;
74  }
75 
76  #exportForm {
77  margin: .5em;
78  }
79 
80 </style>
81 
82 <?php printMonitorPageMiddle("Trusted Vendor Report"); ?>
83 
84 <div style='font-size:12px;'>
85  <script id="masterpropTempl" type="text/x-kendo-template">
86  <div class="tabstrip">
87  <ul>
88  <li class="k-state-active">#=trustedid # Properties</li>
89  <li>Clients</li>
90  </ul>
91  <div class="k-block">
92  <table>
93  # for (var i = 0; i < trustedprops.length; i++){ #
94  <tr>
95  <td width="20%">#=trustedprops[i].vname #</td>
96  <td width="20%">#=trustedprops[i].vtype #</td>
97  <td width="*">#=trustedprops[i].vdefault #</td>
98  </tr>
99  # } #
100  </table>
101  </div>
102  <div>
103  <div class="Clients"></div>
104  </div>
105  </div>
106  </script>
107 </div>
108  <script id="clientpropTempl" type="text/x-kendo-template">
109  <div class="k-block">
110  <table>
111  # for (var i = 0; i < trustedprops.length; i++){ #
112  <tr>
113  <td>#=trustedprops[i].propname #</td>
114  <td>#=trustedprops[i].propval #</td>
115  </tr>
116  # } #
117  </table>
118  </div>
119 </script>
120 <form id="exportForm" action="TrustedReport.proxy.data" method="POST">
121 <label for="trustedid" class="k-label">Enter a Trusted ID:</label>
122 <input id="trustedid" name="trustid" class="k-textbox" type="text" required/>
123 <input id="action" name="action" class="k-hidden" type="hidden" value="export_clients"/>
124 <input type="submit" id="exportBtn" class="k-button" value="Export"/>
125 </form>
126 <div id="mastergrid"></div>
127 
128 <script>
129  $(document).ready(function() {
130 
131  //autocomplete for Vendor IDs input
132  $("#trustedid").kendoAutoComplete({
133  minlength: 2,
134  clearButton: false,
135  dataTextField: "trustedid",
136  dataSource: new kendo.data.DataSource({
137  transport: {
138  read: function(options) {
139  aggregateData(options, "read_master");
140  }
141  },
142  schema: {
143  data: "homecuData"
144  }
145  }),
146  placeholder: "Start typing...",
147  change: function() {
148  var found = false;
149  var value = $("#trustedid").val();
150  var data = this.dataSource.view();
151  for( var i = 0, length = data.length; i < length; i++ ) {
152  if( data[i].trustedid === value) {
153  found = true;
154  break;
155  }
156  }
157 
158  if( !found ) {
159  this.value("");
160  alert("Please select a value from the list.");
161  }
162  }
163  });
164 
165  $("#mastergrid").kendoGrid({
166  dataSource: {
167  pageSize: 10,
168  serverPaging: false,
169  transport: {
170  read: function(options) {
171  aggregateData(options, "read_master");
172  }
173  },
174  schema: {
175  data: "homecuData",
176  total: "homecuCount",
177  model: {
178  fields: {
179  trustedid : {type: "string"},
180  trustedvendor : {type: "string"},
181  trustedtype : {type: "string"},
182  trustedprops : {Type : {type: "string"}, Default : {type: "string"}}
183  }
184  }
185  },
186  sort: [{field: "trustedid", dir: "asc"}]
187  },
188  sortable: true,
189  pageable: {
190  pageSizes: [10, 20, 50],
191  info: true,
192  refresh: true,
193  messages: {
194  display: "Showing {0}-{1} from {2} data items"
195  }
196  },
197  columns: [
198  {
199  field: "trustedid",
200  title: "Trusted ID",
201  width: "50px"
202  },
203  {
204  field: "trustedvendor",
205  title: "Vendor",
206  width: "50px"
207  },
208  {
209  field: "trustedtype",
210  title: "Type",
211  width: "45px"
212  },
213  ],
214  detailTemplate: kendo.template($("#masterpropTempl").html()),
215  detailInit: function(e) {
216  var detailRow = e.detailRow;
217  detailRow.find(".tabstrip").kendoTabStrip({
218  animation: {
219  open: { effects: "fadeIn" }
220  }
221  });
222  detailRow.find(".Clients").kendoGrid({
223  detailTemplate: kendo.template($("#clientpropTempl").html()),
224  detailInit: function(e) {
225  // without this line, detail template bindings will not work
226  kendo.bind(e.detailRow, e.data);
227  },
228 
229  dataSource: {
230  autoSync: false,
231  batch: false,
232  serverPaging: false,
233  pageSize: 10,
234  transport: {
235  read: function(options) {
236  aggregateData(options, "read_clients", e.data.trustedid);
237  }
238  },
239  schema: {
240  data: "homecuData",
241  total: "homecuCount",
242  model: {
243  fields: {
244  cu : {type: "string"},
245  trustedid : {type: "string"},
246  trustedprops : {propname : {type: "string"}, propval : {type: "string"}},
247  server: {type: "string"}
248  }
249  }
250  },
251  sort: [{field: "cu", dir: "asc"}]
252  },
253  scrollable: false,
254  sortable: true,
255  pageable: {
256  info: true,
257  refresh: true,
258  messages: {
259  display: "Showing {0}-{1} from {2} data items"
260  }
261  },
262  columns: [
263  { field: "server", title: "Server", width: "33%"},
264  { field: "cu", title: "Client", width: "34%"},
265  { field: "trustedid", title:"Trusted ID", width: "33%"}
266  ]
267  });
268  }
269  });
270  });
271 
272 function aggregateData(options, action, trustedid) {
273  $.post("TrustedReport.proxy.data", {action: action, trustid: trustedid}, function (data) {
274  options.success(data);
275  });
276 
277 }
278 
279 
280 
281 </script>
282 
283 <?php printMonitorPageBottom(); ?>