-
Notifications
You must be signed in to change notification settings - Fork 1
/
pdf_template.php
129 lines (122 loc) · 6.96 KB
/
pdf_template.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
$json=file_get_contents('https://www.gumtrue.co.uk/api4/report_test.php?access_token=eyJ0eXAiOiJKV1QiLCAiYWxnIjoiSFMyNTYifQ.eyJqdGkiOiJ4VFVZaFwvVkhtNVRQTlRsSXVtOUtCUzhYUkxnRVd6NUROSWJcL3hFUWJVN1U9IiwiaXNzIjoiZ3VtdHJ1ZS5jby51ayIsImlhdCI6MTU1MTU0NDUzOSwibmJmIjoxNTUxNTQ0NTM5LCJleHAiOjE2MTQ2MTY1MzksImRhdGEiOnsiY2xpZW50SUQiOiJ0ZXN0Iiwic2Vzc2lvbklEIjozLCJjbGllbnRVc2VyTmFtZSI6ImQiLCJjbGllbnRQYXNzd29yZCI6ImQiLCJkYlNlcnZlciI6Imd1bXRydWUuY28udWsiLCJkYk5hbWUiOiJndW1tb2JpbGUiLCJkYlVzZXIiOiJndW1tb2JpbGUiLCJkYlBhc3N3b3JkIjoiR3VtdHJ1ZTIhIn19.gSwKMC_Gbut7vtRoVLu1wV-6q_BjQs7Nr9qHQnr6URM&roundNo=22');
$data = json_decode($json);
//echo "<pre>"; print_r($data); echo "</pre>";
$input_data = $data->data;
//Function to get start and end of the week
$first_day_of_the_week = 'Sunday';
$start_of_the_week = strtotime("Last $first_day_of_the_week");
if ( strtolower(date('l')) === strtolower($first_day_of_the_week) )
{
$start_of_the_week = strtotime('today');
}
$end_of_the_week = $start_of_the_week + (60 * 60 * 24 * 7) - 1;
//$date_format = 'l jS \of F Y h:i:s A';
// This prints out Sunday 7th of December 2014 12:00:00 AM
$date_format = 'd M Y';
// This prints out 02 Mar 2019
// See PHP: date - Manual
// for ways to format the date
//echo date($date_format, $start_of_the_week);
// This prints out Saturday 13th of December 2014 11:59:59 PM
//echo date($date_format, $end_of_the_week);
$endofweek = date($date_format, $end_of_the_week);
?>
<style type="text/css">
td, th {
padding-top: 8px;
padding-bottom: 8px;
}
td {
border-top: 1px solid #000000;
}
</style>
<page backtop="33mm" backbottom="8mm" style="font-size:8.5pt;">
<page_header>
<table cellspacing="0" style="width: 100%; font-weight:bold;font-size:10pt;">
<tr>
<td colspan="4" style="border-top:none;text-align:center;font-size:16pt;">Round Reconciliation Report</td>
<td style="border-top:none;text-align:right;">Week Ending: <?php echo $endofweek; ?></td>
</tr>
<tr>
<td style="width: 25%;border-top:none;border-bottom:solid 2px black; text-align:left">For TUE</td>
<td style="width: 17%;border-top:none;border-bottom:solid 2px black; text-align:center">
</td>
<td style="width: 16%;border-top:none;border-bottom:solid 2px black;">
<div style="background-color:#464646;color:#fff;text-align:center;padding:2px;">Round: 001</div>
</td>
<td style="width: 17%;border-top:none;border-bottom:solid 2px black; text-align:center">
</td>
<td style="width: 25%;border-top:none;border-bottom:solid 2px black;text-align:right">Name: R 01</td>
</tr>
</table>
<table style="width: 100%; text-align:right;">
<tr style="font-size:8pt;">
<th style="text-align:left;width: 8%">Code</th>
<th style="text-align:left;width: 20%">Description</th>
<th style="width: 8%">Opening</th>
<th style="width: 8%">Booked</th>
<th style="width: 8%">Sales</th>
<th style="width: 8%">C. Ret. &<br/>Damages</th>
<th style="width: 8%">Depot<br/>Returns</th>
<th style="width: 8%">TRF+/-</th>
<th style="width: 8%">Theory</th>
<th style="width: 8%">Closing</th>
<th style="width: 8%">Diff(+/-)</th>
</tr>
</table>
</page_header>
<page_footer>
<table style="width: 100%;font-size: 8pt;">
<tr>
<td style="border-top:none;text-align:left; width: 70%">Report Generated by Gumtrue and Printed on <?php echo date("d M Y h:i").' '.strtoupper(date("a")); ?></td>
<td style="border-top:none;text-align:right; width: 30%">page [[page_cu]] of [[page_nb]]</td>
</tr>
</table>
</page_footer>
<?php if (count($input_data->records)) { ?>
<table cellspacing="0" style="width: 100%; text-align:right;">
<?php foreach ($input_data->records as $idx => $items) { ?>
<?php if (count($items->products)) {
$sum = 0;
foreach ($items->products as $pd => $product) { $sum += $product->Difference; ?>
<tr>
<td style="text-align:left;width: 8%;"><?php echo str_pad($product->ProductCode, 5, '0', STR_PAD_LEFT); ?></td>
<td style="text-align:left;width: 20%"><?php echo $product->ProductDescription; ?></td>
<td style="width: 8%"><?php if ($product->Opening != null) {echo number_format($product->Opening, 2, '.', '');} else {echo "- -";} ?></td>
<td style="width: 8%"><?php if ($product->Bookout != null) {echo number_format($product->Bookout, 2, '.', '');} else {echo "- -";} ?></td>
<td style="width: 8%"><?php if ($product->Sales != null) {echo number_format($product->Sales, 2, '.', '');} else {echo "- -";} ?></td>
<td style="width: 8%"><?php if ($product->CustomerReturns != null) {echo number_format($product->CustomerReturns, 2, '.', '');} else {echo "- -";} ?></td>
<td style="width: 8%"><?php if ($product->Damages != null) {echo number_format($product->Damages, 2, '.', '');} else {echo "- -";} ?></td>
<td style="width: 8%"><?php if ($product->Returns != null) {echo number_format($product->Returns, 2, '.', '');} else {echo "- -";} ?></td>
<td style="width: 8%"><?php if ($product->Theory != null) {echo number_format($product->Theory, 2, '.', '');} else {echo "- -";} ?></td>
<td style="width: 8%"><?php if ($product->Closing != null) {echo number_format($product->Closing, 2, '.', '');} else {echo "- -";} ?></td>
<td style="width: 8%"><?php if ($product->Difference != null) {echo number_format($product->Difference, 2, '.', '');} else {echo "- -";} ?></td>
</tr>
<?php }} ?>
<tr style="font-weight:bold;">
<td colspan="10" style="border-top:solid 2px black;"><?php echo $items->Category; ?> Total : </td>
<td style="border-top:solid 2px black;"><?php echo number_format($sum, 2, '.', ''); ?></td>
</tr>
<tr>
<td colspan="11" style="border-top:none;"> </td>
</tr>
<?php } ?>
<?php
$total = 0;
$sum = 0;
foreach ($input_data->records as $idx => $items) {
foreach ($items->products as $pd => $product){
$sum += $product->Difference;
}
$total += count($items->products);
}
?>
<tr>
<td style="text-align:left;font-size:10pt;font-weight:bold;border-top:solid 3px black">Total:</td>
<td style="text-align:left;font-size:10pt;font-weight:bold;border-top:solid 3px black"><?php echo $total; ?> Product(s)</td>
<td colspan="9" style="font-size:10pt;font-weight:bold;border-top:solid 3px black"><?php echo $sum; ?></td>
</tr>
</table>
<?php } ?>
</page>