Odyssey
index.prg
1 <?php
2 /* File: index.php
3  * Purpose: every address call in this project goes through this file. It then includes the right file. It also has some global variables and outputs the main HTML template for the page.
4  */
5 
6 // All necessary includes
7 $monLibrary = dirname(__FILE__) . "/../../monitor/library";
8 $billingLibrary = dirname(__FILE__) . "/../library";
9 $billingIncludes = dirname(__FILE__) . "/../includes";
10 $sharedLibrary = dirname(__FILE__) . "/../../shared/library";
11 require_once("$monLibrary/cu_top.i");
12 require_once("$monLibrary/ck_hticket.i");
13 require_once("$billingLibrary/globals.i");
14 require_once("$sharedLibrary/commonJsFunctions.i");
15 require_once("$sharedLibrary/commonPhpFunctions.i");
16 require_once("$billingLibrary/configuration.i");
17 
18 // Needed for data.prg and runBilling.prg.
19 require_once("$sharedLibrary/errormail.i");
20 require_once("$billingLibrary/billingEmailFunctions.i");
21 require_once("$billingLibrary/data.i");
22 require_once("$billingLibrary/runBilling.i");
23 
24 if (!CheckPerm($link, $Hu, "billing", $_SERVER['REMOTE_ADDR'])) {
25  // ** Permissions failed
26  // ** redirect to new page
27  header("Location: /hcuadm/hcu_noperm.prg");
28  exit;
29 }
30 
31 $string = array("filter" => FILTER_SANITIZE_STRING, 'options' => array('flags' => FILTER_FLAG_NO_ENCODE_QUOTES));
32 $int = array("filter" => FILTER_SANITIZE_NUMBER_INT);
33 $json = array("filter" => FILTER_DEFAULT);
34 
35 HCU_ImportVars( $SYSENV, "BILL", array(
36  // Common
37  // -------------------------------
38  "page" => $string, "operation" => $string,
39 
40  // Dashboard
41  // -------------------------------
42  "featureId" => $string,
43 
44  // Monthly billing page & run billing
45  // -------------------------------
46  "reportDate" => $string, "monthBit" => $string, "cutoffDate" => $string, "cutoffTime" => $string, "callMy" => $string,
47  "sid" => $string, "childType" => $string, "onlyCookie" => $string,
48 
49  // Sales Item page
50  // -------------------------------
51  "prodName" => $string, "description" => $string, "billingId" => $string, "calcId" => $string, "billsOn" => $string,
52 
53  // Sales Order page
54  // -------------------------------
55  "cu" => $string, "initializeDDLs" => $string, "cuNumber" => $string, "refNo" => $string, "emailable" => $string,
56 
57 
58  // Order Detail page
59  // -------------------------------
60 
61  // JSONs
62  "orderDetailIds" => $json, "dataItem" => $json, "productsSelected" => $json, "includeIds" => $json,
63  "excludeIds" => $json,
64 
65  // Ids
66  "orderDetailId" => $string, "salesOrderId" => $string, "salesItemId" => $string,
67  "productId" => $string, "featureDetailId" => $string,
68 
69  // Other values
70  "workflowValue" => $string, "frequencyValue" => $string, "billsOn1Value" => $string, "billsOn2Value" => $string,
71  "billHalfValue" => $string, "overrideDescription" => $string, "startDate" => $string, "endDate" => $string,
72  "fixed" => $string, "variable" => $string, "qty1" => $string, "qty2" => $string, "aDNID" => $string,
73  "partiallyBilledDate" => $string, "partiallyBilledAmount" => $string
74  ));
75 $htmlFile = "";
76 $scriptOnly = false;
77 $scriptFile = "";
78 $selectedSelector = "#leftMenuPanelBar";
79 $title = "Billing";
80 
81 $operation = HCU_array_key_value("operation", $SYSENV["BILL"]);
82 $operation = $operation !== false ? trim($operation) : "";
83 $page = HCU_array_key_value("page", $SYSENV["BILL"]);
84 $page = $page !== false ? trim($page) : "";
85 if ($operation != "") {
86 
87  $canEdit = GetIsInEditList($dbh, $Hu);
88  $canBill = GetAbleToRunBilling($dbh, $Hu);
89 
90  // This one is for permission checking. Use the second switch statement for calling functions.
91  $valid = true;
92  switch ($operation) {
93  case "gatherBillingInfoOdyssey":
94  $valid = $SYSENV["devmode"] == 1 && $canBill;
95  break;
96  case "getPotentiallyFromDifferentServer":
97  case "gatherBillingInfo":
98  case "gatherBillingInfoChildren":
99  case "checkBillingInfo":
100  case "runBilling":
101  case "runBillingCleanup":
102  case "downloadRunBillingFiles":
103  $valid = $canBill;
104  break;
105  case "salesOrderCreate":
106  case "salesOrderUpdate":
107  case "salesItemCreate":
108  case "salesItemUpdate":
109  case "salesItemRemove":
110 
111  // New salesOrderDetail details
112  case "createBillingFeature":
113  case "updatePendingBillingFeature":
114  case "updateActiveBillingFeature":
115  case "removeBillingFeature":
116  case "createSalesOrderDetails":
117  $valid = $canEdit;
118  break;
119  }
120 
121  if ($valid) {
122  switch ($operation) {
123  // Run Billing
124  case "getPotentiallyFromDifferentServer":
125  $returnArray = GetPotentiallyFromDifferentServer($dbh, $SYSENV);
126  break;
127  case "gatherBillingInfo":
128  $returnArray = GatherBillingInfo($dbh, $SYSENV, $Hu, "regular");
129  break;
130  case "gatherBillingInfoOdyssey":
131  $returnArray = GatherBillingInfo($dbh, $SYSENV, $Hu, "odyssey");
132  break;
133  case "gatherBillingInfoChildren":
134  $returnArray = gatherBillingInfoChildren($dbh, $SYSENV, $Hu);
135  break;
136  case "checkBillingInfo":
137  $returnArray = CheckBillingInfo($dbh, $SYSENV, $Hu);
138  break;
139  case "runBilling":
140  $returnArray = RunBillingMonth($dbh, $SYSENV, $Hu);
141  break;
142  case "runBillingCleanup":
143  $returnArray = RunBillingCleanup($dbh, $SYSENV, $Hu);
144  break;
145 
146  // Monthly Billing
147  case "monthlyBillingLoad":
148  $returnArray = MonthlyBillingLoad($dbh, false, null);
149  break;
150  case "monthReportCSV":
151  $returnArray = MonthReport($dbh, $SYSENV, true);
152  break;
153  case "monthlyProgressLoad":
154  $returnArray = GetMonthlyProgressBars($dbh, $SYSENV);
155  break;
156  case "downloadRunBillingFiles":
157  DownloadRunBillingFiles($dbh, $SYSENV);
158  break;
159 
160  // Sales Order
161  case "salesOrderLoad":
162  $returnArray = SalesOrderLoad($dbh, $SYSENV, $Hu);
163  break;
164  case "salesOrderCreate":
165  $returnArray = SalesOrderCreateOrUpdate($dbh, $Hu, true, $SYSENV);
166  break;
167  case "salesOrderUpdate":
168  $returnArray = SalesOrderCreateOrUpdate($dbh, $Hu, false, $SYSENV);
169  break;
170  case "cuView":
171  $returnArray = GetCuView($dbh, $SYSENV);
172  break;
173 
174  // Dashboard
175  case "readDashboard":
176  $returnArray = ReadDashboard($dbh);
177  break;
178  case "readWorkflowStatusInfo":
179  $returnArray = ReadWorkflowStatusInfo($dbh, $SYSENV);
180  break;
181 
182  // Sales Items
183  case "salesItemLoad":
184  $returnArray = SalesItemLoad($dbh);
185  break;
186  case "salesItemCreate":
187  $returnArray = SalesItemCreateOrUpdate($dbh, true, $SYSENV);
188  break;
189  case "salesItemUpdate":
190  $returnArray = SalesItemCreateOrUpdate($dbh, false, $SYSENV);
191  break;
192  case "salesItemRemove":
193  $returnArray = SalesItemRemove($dbh, $SYSENV);
194  break;
195  case "getDeletedSalesItems":
196  $returnArray = GetDeletedSalesItems($dbh);
197  break;
198 
199  // Sales Order Detail Reads
200  case "readPendingDetailsTop":
201  $returnArray = ReadPendingDetailsTop($dbh, $SYSENV, $Hu);
202  break;
203  case "readPendingDetailsBottom":
204  $returnArray = ReadPendingDetailsBottom($dbh, $SYSENV, $Hu);
205  break;
206  case "readSalesOrderDetailInit":
207  $returnArray = ReadSalesOrderDetailInit($dbh, $SYSENV, $Hu);
208  break;
209  case "readActiveDetails":
210  $returnArray = ReadActiveDetails($dbh, $SYSENV, $Hu);
211  break;
212  case "readCompletedDetails":
213  $returnArray = ReadCompletedDetails($dbh, $SYSENV, $Hu);
214  break;
215  case "readSalesOrderDetailLineItem":
216  $returnArray = ReadSalesOrderLineItem($dbh, $SYSENV, $Hu, false);
217  break;
218  case "readSalesOrderActiveLineItem":
219  $returnArray = ReadSalesOrderLineItem($dbh, $SYSENV, $Hu, true);
220  break;
221  case "readSalesOrderDetailWarnings":
222  $returnArray = ReadSalesOrderDetailWarnings($dbh, $SYSENV, $Hu);
223  break;
224 
225  // Sales Order Detail Modifies
226  case "createBillingFeature":
227  $returnArray = ModifyBillingFeature($dbh, $SYSENV, $Hu, true, false);
228  break;
229  case "updatePendingBillingFeature":
230  $returnArray = ModifyBillingFeature($dbh, $SYSENV, $Hu, false, false);
231  break;
232  case "updateActiveBillingFeature":
233  $returnArray = ModifyBillingFeature($dbh, $SYSENV, $Hu, false, true);
234  break;
235  case "removeBillingFeature":
236  $returnArray = RemoveBillingFeature($dbh, $SYSENV, $Hu);
237  break;
238  case "removeSalesOrderDetail":
239  $returnArray = RemoveSalesOrderDetail($dbh, $SYSENV, $Hu);
240  break;
241  case "createSalesOrderDetails": // This replaces BOTH add single product and add multiple product.
242  $returnArray = CreateSalesOrderDetails($dbh, $SYSENV, $Hu);
243  break;
244  case "modifyStatus":
245  $returnArray = ModifyStatus($dbh, $SYSENV, $Hu);
246  break;
247 
248  default: $valid = false;
249  }
250  }
251 
252  if (!$valid) {
253  $returnArray = array("status" => "999", "error" => array("You don't have permissions."), "record" => array(), "operation" => "");
254  }
255 
256  header('Content-type: application/json');
257  print HCU_JsonEncode($returnArray);
258  exit;
259 }
260 
261 switch($page) {
262  case "salesOrder":
263  $htmlFile = "salesOrder.prg";
264  $selectedSelector .= " > li:eq(1)";
265  $title .= " - Contract";
266  break;
267  case "salesOrderDetails":
268  $htmlFile = "salesOrderDetail.prg";
269  $selectedSelector .= " > li:eq(1)";
270  $title .= " - Contract Details";
271  break;
272  case "salesItemMaintenance":
273  $htmlFile = "salesItemMaintenance.prg";
274  $selectedSelector .= " > li:eq(2)";
275  $title .= " - Sales Item";
276  break;
277  case "monthlyBilling":
278  $htmlFile = "monthlyBilling.prg";
279  $selectedSelector .= " > li:eq(3)";
280  $title .= " - Months";
281  break;
282  case "monthReport":
283  $htmlFile = "monthReport.prg";
284  $selectedSelector .= " > li:eq(3)";
285  $title .= " - Month Report";
286  break;
287  case "invoiceView":
288  $htmlFile = "invoiceView.prg";
289  $selectedSelector .= " > li:eq(1)";
290  $title .= " - Invoice";
291  break;
292  case "returnToMonitor":
293  // header redirect
294  break;
295  case "dashboard":
296  $htmlFile = "dashboard.prg";
297  $selectedSelector .= " > li:eq(0)";
298  break;
299  default:
300  $htmlFile = "dashboard.prg";
301  $selectedSelector .= " > li:eq(0)";
302  break;
303 }
304 
305 printMonitorPageTop($title, $homecuKendoVersion, $cloudfrontDomainName); ?>
306 
307 <link href="<?php echo $produrl; ?>/billing/static/css/billing.css" type="text/css" rel="stylesheet">
308 
309 <script type="text/javascript">
310 function initMenuBar() {
311  <?php
312  /* For future reference, do not try to set data in the dataSource because it WILL NOT WORK (and that limitation is only for the panelBar).
313  * The only VALID way of doing it is this way with all the menu items in the HTML and using the expand and select operator on JQuery that already exist!
314  * There is no DataBound event or changed event! There is no transport objects available here! Therefore to get from data, you have to wrap the entire
315  * object in an AJAX call and then a function to repeatedly call the expand and select functions until the data inside the panel bar exists.
316  * That is an incredibly ugly way of doing things.
317  */ ?>
318  var panelBar = $("#leftMenuPanelBar").kendoPanelBar({
319  expandMode: "single",
320  width: "100%",
321  dataSource: [
322  {
323  text: "Dashboard",
324  url: "<?php echo $produrl . GetBillingURL(); ?>?page=dashboard"
325  },
326  {
327  text: "Contracts",
328  url: "<?php echo $produrl . GetBillingURL(); ?>?page=salesOrder"
329  },
330  {
331  text: "Sales Items",
332  url: "<?php echo $produrl . GetBillingURL(); ?>?page=salesItemMaintenance"
333  },
334  {
335  text: "Monthly Billing",
336  url: "<?php echo $produrl . GetBillingURL(); ?>?page=monthlyBilling"
337  },
338  {
339  text: "Return to Monitor",
340  url: "<?php echo $produrl; ?>/hcuadm/cuilist.prg"
341  }
342  ]
343  }).data("kendoPanelBar");
344 
345  panelBar.expand($("<?php echo $selectedSelector; ?>"), false);
346  panelBar.select($("<?php echo $selectedSelector; ?>"));
347 }
348  $(document).ready(function () {
349  initMenuBar();
350  });
351 </script>
352 
353 <?php printMonitorPageMiddle($title); ?>
354  <input type="hidden" id="invalidRequestClientSide">
355  <input type="hidden" id="invalidRequestServerSide">
356  <input type="hidden" id="gridIdToDelete">
357  <textarea id="htmlDecoder" style="display: none;"></textarea>
358  <div id="deleteConfirmDialog"></div>
359  <div id='hideSubmitWait' style='position:relative; left:-2000px;top:-2000px;'>
360  <div id='homecuSubmitWait' class='k-block' >
361  <div class='k-loading-image'></div>
362  </div>
363  </div>
364  <div id="billingBody">
365  <div class="container_12">
366  <div class="grid_12">
367  <div class="grid_3 alpha homecu-menu">
368  <div id="panelErrorDiv" class="k-block k-error-colored" style="display:none;"></div>
369  <ul id="leftMenuPanelBar"></ul>
370  </div>
371  <div id="billingMainContents" class="grid_9 omega">
372  <?php include_once("$billingIncludes/$htmlFile"); ?>
373  </div>
374  </div>
375  </div>
376  </div>
377 
378 <?php printMonitorPageBottom(); ?>