Odyssey
monthReport.prg
1 <?php
2 /* File: monthReport.html
3  * Purpose: provides a simple report for a month without any fluff introduced by Kendo. You cannot do anything with this besides view it.
4  */
5 
6 $returnArray = MonthReport($dbh, $SYSENV, false);
7 
8 if (!isset($returnArray)) { ?>
9  <h1>No data available</h1>
10 <?php } else {
11  $monthRecord = $returnArray["record"][0];
12 
13  try {
14  $dateTime = new DateTime($monthRecord["month"]);
15  $month = $dateTime->format("F Y");
16  } catch (exception $e) {
17  $month = "(No Month)";
18  }
19 ?>
20 
21 <div class="container_12">
22  <div class="grid_12">
23  <div id="formValidateMainDiv" class="k-block k-error-colored" style="display:none;">
24  <?php if ($returnArray["status"] !== "000") { ?>
25  <p>The following errors were detected:</p>
26  <ul>
27  <li><?php echo $returnArray["error"]; ?></li>
28  </ul>
29  <?php } ?>
30  </div>
31  </div>
32 
33  <table class="plainGrid">
34  <tr class="monthHeader">
35  <th colspan="6"><?php echo $month; ?></th>
36  </tr>
37  <tr>
38  <td colspan="6">&nbsp;</td>
39  </tr>
40  <?php $outerIndex = 1;
41  $grandTotal = 0;
42 
43  if (isset($monthRecord["cus"])) {
44  foreach($monthRecord["cus"] as $cuRecord) {
45  $grandTotal += $cuRecord["totalAmount"];
46  $totalFormatted = $cuRecord["totalAmount"] < 0 ? "$(" . number_format(abs($cuRecord["totalAmount"]), 2) . ")"
47  : "$" . number_format($cuRecord["totalAmount"], 2);
48  ?>
49  <tr class="cuHeader">
50  <td colspan="6"><?php echo $cuRecord["cuName"]; ?> (<?php echo $cuRecord["cu"]; ?>)</td>
51  </tr>
52  <tr class="invoiceHeader">
53  <td></td>
54  <td>Product</td>
55  <td>Feature</td>
56  <td style="text-align:right;">Quantity</td>
57  <td></td>
58  <td style="text-align:right;">Amount</td>
59  </tr>
60  <?php $innerIndex = 1;
61  foreach($cuRecord["invoices"] as $invoiceRecord) {
62  $innerClass = $innerIndex++ % 2 == 0 ? "innerEven" : "innerOdd";
63  $amountFormatted = $invoiceRecord["amount"] < 0 ? "$(" . number_format(abs($invoiceRecord["amount"]), 2) . ")"
64  : "$" . number_format($invoiceRecord["amount"], 2);
65  ?>
66  <tr class="<?php echo "$innerClass"; ?>">
67  <td></td>
68  <td><?php echo $invoiceRecord["productDescription"]; ?></td>
69  <td><?php echo $invoiceRecord["featureDescription"]; ?></td>
70  <td style="text-align:right;"><?php echo $invoiceRecord["quantity"]; ?></td>
71  <td></td>
72  <td style="text-align:right;"><?php echo $amountFormatted; ?></td>
73  </tr>
74  <?php } ?>
75  <tr class="cuFooter">
76  <td colspan="4"></td>
77  <td style="text-align:right;">Total: </td>
78  <td style="text-align:right;"><?php echo $totalFormatted; ?></td>
79  </tr>
80  <tr>
81  <td colspan="6">&nbsp;</td>
82  </tr>
83  <?php }
84  }
85  $grandTotalFormatted = $grandTotal < 0 ? "$(" . number_format(abs($grandTotal), 2) . ")" : "$" . number_format($grandTotal, 2);
86  ?>
87  <tr>
88  <td colspan="6">&nbsp;</td>
89  </tr>
90  <tr class="grandTotalFooter">
91  <td colspan="4"></td>
92  <td style="text-align:right;">Grand Total: </td>
93  <td style="text-align:right;"><?php echo $grandTotalFormatted; ?></td>
94  </tr>
95  </table>
96 </div>
97 
98 <?php }