-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint.php
173 lines (141 loc) · 3.76 KB
/
print.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<?php
//print.php
require_once('class/pdf.php');
include('rms.php');
$object = new rms();
if(!$object->is_login())
{
header("location:".$object->base_url."");
}
if(!$object->is_cashier_user() && !$object->is_master_user())
{
header("location:".$object->base_url."dashboard.php");
}
$file_name = '';
if(isset($_GET["order_id"]))
{
$output = '
<table width="100%" border="0" cellpadding="5" cellspacing="5" style="font-family:Arial, san-sarif">';
$object->query = "
SELECT * FROM restaurant_table
";
$restaurant_data = $object->get_result();
foreach($restaurant_data as $row)
{
$output .= '
<tr>
<td align="center">
<b style="font-size:32px">'.$row["restaurant_name"].'</b>
<br />
<span style="font-size:20px;">'.$row["restaurant_tag_line"].'</span>
<br /><br />
<span style="font-size:16px;">'.$row["restaurant_address"].'</span>
<br />
<span style="font-size:16px;"><b>Contact No. - </b>'.$row["restaurant_contact_no"].'</span>
<br />
<span style="font-size:16px;"><b>Email - </b>'.$row["restaurant_email"].'</span>
<br /><br />
</td>
</tr>
';
}
$object->query = "
SELECT * FROM order_table
WHERE order_id = '".$_GET["order_id"]."'
";
$order_result = $object->get_result();
foreach($order_result as $order)
{
$file_name = $order["order_number"] . '.pdf';
$output .= '
<tr>
<td>
<table width="100%" border="0" cellpadding="5" cellspacing="5">
<tr>
<td width="30%"><b>Bill No:- </b>'.$order["order_number"].'</td>
<td width="30%"><b>Table No:- </b>'.$order["order_table"].'</td>
<td width="20%" align="right"><b>Date:- </b>'.$order["order_date"].'</td>
<td width="20%" align="right"><b>Time:- </b>'.$order["order_time"].'</td>
</tr>
</table>
</td>
</tr>
';
$object->query = "
SELECT * FROM order_item_table
WHERE order_id = '".$_GET["order_id"]."'
ORDER BY order_item_id ASC
";
$order_item_result = $object->get_result();
$output .= '
<tr>
<td>
<table width="100%" border="1" cellpadding="10" cellspacing="0">
<tr>
<th width="10%">Sr#</th>
<th width="45%">Item</th>
<th width="10%">Qty.</th>
<th width="20%">Price</th>
<th width="15%">Amount</th>
</tr>';
$count = 0;
foreach($order_item_result as $item)
{
$count++;
$output .= '
<tr>
<td>'.$count.'</td>
<td>'.$item["product_name"].'</td>
<td>'.$item["product_quantity"].'</td>
<td>'.$object->cur . $item["product_rate"].'</td>
<td>'.$object->cur . $item["product_amount"].'</td>
</tr>
';
}
$object->query = "
SELECT * FROM order_tax_table
WHERE order_id = '".$_GET["order_id"]."'
";
$tax_result = $object->execute();
$total_tax_row = $object->row_count();
$rowspan = 2 + $total_tax_row;
$tax_result = $object->statement_result();
$output .= '
<tr>
<td rowspan="'.$rowspan.'" colspan="3">
<b>Cashier : </b>'.$order["order_cashier"].'
</td>
<td align="right"><b>Gross Total</b></td>
<td>'.$object->cur . $order["order_gross_amount"].'</td>
</tr>
';
foreach($tax_result as $tax)
{
$output .= '
<tr>
<td align="right"><b>'.$tax["order_tax_name"].' ('.$tax["order_tax_percentage"].'%)</b></td>
<td>'.$object->cur . $tax["order_tax_amount"].'</td>
</tr>
';
}
$output .= '
<tr>
<td align="right"><b>Net Amount</b></td>
<td>'.$object->cur . $order["order_net_amount"].'</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center">Thank you, Please come again</td>
</tr>
';
}
$output .= '</table>';
$pdf = new Pdf();
$pdf->loadHtml($output, 'UTF-8');
$pdf->render();
$pdf->stream($file_name, array( 'Attachment'=>0 ));
exit(0);
}
?>