Odyssey
dashboard.prg
1 <script type="text/javascript">
2 
3 <?php
4 // Get common JS functions here.
5 getShowWaitFunctions(); ?>
6 
7 <?php
8 /**
9  * This function initializes the dashboard.
10  */ ?>
11 function InitDashboard() {
12  $("body").addClass("dashboardBody");
13 
14  $.homecuValidator.setup({formValidate: "dashboardForm", formStatusField: "dashboardFormStatus"});
15  var grid = $("#dashboardGrid").kendoGrid({
16  dataSource: {
17  transport: {
18  read: {
19  url: "index.prg?operation=readDashboard",
20  dataType: "json",
21  type: "POST"
22  },
23  parameterMap: function(data, type) {
24  showWaitWindow();
25  return {};
26  }
27  },
28  schema: {
29  model: {
30  id: "templateId",
31  fields: {
32  sortingId: {type: "number"},
33  templateId: {type: "number"},
34  textDescription: {type: "string"},
35  statusLabel: {type: "string"},
36  billHalf: {type: "boolean"},
37  initialCosts: {type: "string"},
38  recurringCosts: {type: "string"},
39  cu: {type: "string"},
40  cuName: {type: "string"},
41  salesItemDescr: {type: "string"},
42  orderId: {type: "number"}
43  }
44  },
45  parse: function (data) {
46  hideWaitWindow();
47  if (data.status !== "000") {
48  $.homecuValidator.displayMessage(data.error, $.homecuValidator.settings.statusError );
49  return [];
50  } else {
51  return data.record;
52  }
53  }
54  },
55  group: {field: "cu"},
56  sort: {field: "sortingId", dir: "asc"}
57  },
58  columns: [
59  {title: "Item Name"},
60  {title: "Split", width: "75px"},
61  {title: "Status", width: "20%"},
62  {title: "Initial Costs", width: "20%"},
63  {title: "recurring Costs", width: "20%"},
64  {field: "cu", hidden: true}
65  ],
66  rowTemplate: kendo.template($("#rowTemplate").html()),
67  altRowTemplate: kendo.template($("#altRowTemplate").html()),
68  dataBound: function (e) {
69  $("#dashboardGrid .k-grid-header").remove();
70 
71  $("#dashboardGrid .k-grouping-row").each(function () {
72  $(this).find("td").html($(this).next().find(".tempGroupLine").html());
73  $(this).hover(function () {
74  $(this).toggleClass("k-state-hover");
75  });
76  $(this).after($("#headerRowTemplate").html());
77  $(this).prev().find("td:not(.spacerTd)").css({borderBottom: "1px solid black"});
78  $(this).next().find("td:not(.spacerTd)").css({borderTop: "1px solid black"});
79  });
80 
81  $("#dashboardGrid .tempGroupLine").remove();
82  }
83  }).data("kendoGrid");
84 }
85 
86 <?php // Sets up a three-second timer to open the status popup. ?>
87 function OnMouseEnter(td) {
88  $(td).data("timer", setTimeout($.proxy(function() { OpenStatusPopup($(td))}, $(td)), 3000));
89 }
90 
91 <?php // Clears the three-second timer. ?>
92 function OnMouseExit(td) {
93  clearTimeout($(td).data("timer"));
94 }
95 
96 <?php // This function fetches the data for more information on the workflow. ?>
97 function OpenStatusPopup(td) {
98  clearTimeout($(td).data("timer"));
99  if ($(td).data("hasNotification") == true) {
100  return;
101  }
102 
103  var notification = $("<div></div>").kendoNotification({
104  position: {
105  pinned: false,
106  top: $(td).offset().top - $("body").scrollTop(),
107  left: $(td).offset().left - $("body").scrollLeft()
108  },
109  autoHideAfter: 0,
110  show: function () {
111  $(td).data("hasNotification", true);
112  $(".k-icon.k-i-note").remove();
113  $(".k-notification:last").mouseleave(function () {
114  notification.hide();
115  });
116  },
117  hide: function () {
118  $(td).data("hasNotification", false);
119  }
120  }).data("kendoNotification");
121 
122  showWaitWindow();
123  $.post("index.prg?operation=readWorkflowStatusInfo", {featureId: $(td).parent().data("template_id")}, function (data) {
124  hideWaitWindow();
125  if (data.status !== "000") {
126  $.homecuValidator.displayMessage(data.error, $.homecuValidator.settings.statusError );
127  } else {
128  if (data.record.length == 0) {
129  notification.info("No workflow attached");
130  } else {
131  var firstColumn = "grid_5 alpha";
132  var secondColumn = "grid_7 omega";
133  var preRow = "<div class='grid_12'><div class='" + firstColumn + "'><b>";
134  var midRow = "</b></div> <div class='" + secondColumn + "'>";
135  var postRow = "</div></div>";
136  var message = "<br><div class='container_12 workflowStatusInfo'>";
137  message += preRow + "Job Id:" + midRow + data.record[0].trackId + postRow;
138  message += preRow + "Job:" + midRow + data.record[0].issue + postRow;
139  message += preRow + "Job Owner:" + midRow + data.record[0].issueOwner + postRow;
140  message += preRow + "Job Status:" + midRow + data.record[0].issueStatus + postRow;
141  message += preRow + "Next Task:" + midRow + data.record[0].nextTask + postRow;
142  message += preRow + "Next Task Owner:" + midRow + data.record[0].nextTaskOwner + postRow;
143  message += preRow + "Entry Date:" + midRow + kendo.toString(new Date(data.record[0].entryDate), "MM/dd/yyyy") + postRow;
144  message += preRow + "Last Activity Date:" + midRow + kendo.toString(new Date(data.record[0].lastActivityDate), "MM/dd/yyyy") + postRow;
145  message += "<div class='grid_12'>&nbsp;</div>";
146  message += "<div class='grid_12'><a href='/hcuadm/cuissues_edit.prg?trackId=" + data.record[0].trackId + "' target='_blank'>Go to job</a></div></div>";
147  notification.info(message);
148  }
149 
150  }
151  });
152 }
153 
154 $(document).ready(function () {
155  InitDashboard();
156 })
157 </script>
158 <script id="headerRowTemplate" type="text/k-kendo-template">
159  <tr class="header" onclick="addNewRow();">
160  <td class="spacerTd">&nbsp;</td>
161  <td>Item Name</td>
162  <td>Split</td>
163  <td>Status</td>
164  <td>Initial</td>
165  <td>Recurring</td>
166  </tr>
167 </script>
168 <script id="rowTemplate" type="text/x-kendo-template">
169  <tr class="normalRow" data-uid="#: uid #" data-template_id="#: templateId #">
170  <td class="spacerTd">&nbsp;</td>
171  <td>#: salesItemDescr #</td>
172  <td># if (billHalf) { # Yes # } else { # No # } #</td>
173  # if (statusLabel == "Pending") { #
174  <td class="statusLabel" onclick="OpenStatusPopup(this);" onmouseenter="OnMouseEnter(this);" onmouseleave="OnMouseExit(this);">#: statusLabel #</td>
175  # } else { #
176  <td>#: statusLabel #</td>
177  # } #
178  <td>#: initialCosts #</td>
179  <td>#: recurringCosts #</td>
180  <td class="tempGroupLine"><a href="<?php echo $produrl . GetBillingURL(); ?>?page=salesOrderDetails&salesOrderId=#: orderId #">#: cuName # (#: cu #)</a></td>
181  </tr>
182 </script>
183 <script id="altRowTemplate" type="text/x-kendo-template">
184  <tr class="k-alt normalRow" data-uid="#: uid #" data-template_id="#: templateId #">
185  <td class="spacerTd">&nbsp;</td>
186  <td>#: salesItemDescr #</td>
187  <td># if (billHalf) { # Yes # } else { # No # } #</td>
188  # if (statusLabel == "Pending") { #
189  <td class="statusLabel" onclick="OpenStatusPopup(this);" onmouseenter="OnMouseEnter(this);" onmouseleave="OnMouseExit(this);">#: statusLabel #</td>
190  # } else { #
191  <td>#: statusLabel #</td>
192  # } #
193  <td>#: initialCosts #</td>
194  <td>#: recurringCosts #</td>
195  </tr>
196 </script>
197 <div class="container_12" id="dashboardForm">
198  <div id="dashboardFormStatus"></div>
199  <div class="grid_12">
200  <div id="formValidateMainDiv" class="k-block k-error-colored" style="display:none;"></div>
201  </div>
202  <div class="grid_12">
203  <div id="dashboardGrid" class="cuIndexGrid"></div>
204  </div>
205 </div>