-
Notifications
You must be signed in to change notification settings - Fork 3
/
EmailConfirmation.php
299 lines (278 loc) · 11.9 KB
/
EmailConfirmation.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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
<?php
/* $Id$*/
include('includes/session.inc');
include('includes/SQL_CommonFunctions.inc');
//Get Out if we have no order number to work with
if (!isset($_GET['TransNo']) OR $_GET['TransNo']==""){
$title = _('Select Order To Print');
include('includes/header.inc');
echo '<div class="centre"><br /><br /><br />';
prnMsg( _('Select an Order Number to Print before calling this page') , 'error');
echo '<br /><br /><br /><table class="table_index"><tr><td class="menu_group_item">
<li><a href="'. $rootpath . '/SelectSalesOrder.php">' . _('Outstanding Sales Orders') . '</a></li>
<li><a href="'. $rootpath . '/SelectCompletedOrder.php">' . _('Completed Sales Orders') . '</a></li>
</td></tr></table></div><br /><br /><br />';
include('includes/footer.inc');
exit();
}
$MailTo = $_GET['EMail'];
$headers = 'From: Bethany Manufacturing <[email protected]>' . '\n';
$headers .= 'MIME-Version: 1.0\n' . 'Content-Type: text/html; charset="utf-8"\n';
/*retrieve the order details from the database to print */
$ErrMsg = _('There was a problem retrieving the order header details for Order Number') . ' ' . $_GET['TransNo'] . ' ' . _('from the database');
$sql = "SELECT salesorders.debtorno,
salesorders.customerref,
salesorders.comments,
salesorders.orddate,
salesorders.deliverto,
salesorders.deladd1,
salesorders.deladd2,
salesorders.deladd3,
salesorders.deladd4,
salesorders.deladd5,
salesorders.deladd6,
salesorders.deliverblind,
debtorsmaster.name,
debtorsmaster.address1,
debtorsmaster.address2,
debtorsmaster.address3,
debtorsmaster.address4,
debtorsmaster.address5,
debtorsmaster.address6,
shippers.shippername,
salesorders.printedpackingslip,
salesorders.datepackingslipprinted,
locations.locationname,
salesorders.deliverydate
FROM salesorders,
debtorsmaster,
shippers,
locations
WHERE salesorders.debtorno=debtorsmaster.debtorno
AND salesorders.shipvia=shippers.shipper_id
AND salesorders.fromstkloc=locations.loccode
AND salesorders.orderno=" . $_GET['TransNo'];
$result=DB_query($sql,$db, $ErrMsg);
//If there are no rows, there's a problem.
if (DB_num_rows($result)==0){
$title = _('Print Packing Slip Error');
include('includes/header.inc');
echo '<div class="centre"><br /><br /><br />';
prnMsg( _('Unable to Locate Order Number') . ' : ' . $_GET['TransNo'] . ' ', 'error');
echo '<br /><br /><br /><table class="table_index"><tr><td class="menu_group_item">
<li><a href="'. $rootpath . '/SelectSalesOrder.php">' . _('Outstanding Sales Orders') . '</a></li>
<li><a href="'. $rootpath . '/SelectCompletedOrder.php">' . _('Completed Sales Orders') . '</a></li>
</td></tr></table></div><br /><br /><br />';
include('includes/footer.inc');
exit();
} elseif (DB_num_rows($result)==1){ /*There is only one order header returned - thats good! */
$myrow = DB_fetch_array($result);
/* Place the deliver blind variable into a hold variable to used when
producing the packlist */
$DeliverBlind = $myrow['deliverblind'];
$DeliveryDate = $myrow['salesorders.deliverydate'];
if ($myrow['printedpackingslip']==1 AND ($_GET['Reprint']!='OK' OR !isset($_GET['Reprint']))){
$title = _('Print Packing Slip Error');
include('includes/header.inc');
echo '<br />';
prnMsg( _('The packing slip for order number') . ' ' . $_GET['TransNo'] . ' ' .
_('has previously been printed') . '. ' . _('It was printed on'). ' ' . ConvertSQLDate($myrow['datepackingslipprinted']) .
'<br />' . _('This check is there to ensure that duplicate packing slips are not produced and dispatched more than once to the customer'), 'warn' );
echo '<p><a href="' . $rootpath . '/PrintCustOrder.php?TransNo=' . $_GET['TransNo'] . '&Reprint=OK">'
. _('Do a Re-Print') . ' (' . _('On Pre-Printed Stationery') . ') ' . _('Even Though Previously Printed') . '</a></p>' .
'<a href="' . $rootpath. '/PrintCustOrder_generic.php?TransNo=' . $_GET['TransNo'] . '&Reprint=OK">'. _('Do a Re-Print') . ' (' . _('Plain paper') . ' - ' . _('A4') . ' ' . _('landscape') . ') ' . _('Even Though Previously Printed'). '</a>';
echo '<br /><br /><br />';
echo _('Or select another Order Number to Print');
echo '<table class="table_index"><tr><td class="menu_group_item">
<li><a href="'. $rootpath . '/SelectSalesOrder.php">' . _('Outstanding Sales Orders') . '</a></li>
<li><a href="'. $rootpath . '/SelectCompletedOrder.php">' . _('Completed Sales Orders') . '</a></li>
</td></tr></table></div><br /><br /><br />';
include('includes/footer.inc');
exit;
}//packing slip has been printed.
$MailSubject = "Order Confirmation-Sales Order " . $_GET['TransNo'] . " - Your PO " .
$myrow['customerref'] ;
}
/*retrieve the order details from the database to print */
/* Then there's an order to print and its not been printed already (or its been flagged for reprinting/ge_Width=807;
)
LETS GO */
$MailMessage = "<html><head><title>Email Confirmation</title></head><body>" .
"<table cellpadding='2' cellspacing='2'><tr>" .
"<td align='center' colspan='4'><h1>" . $_SESSION['CompanyRecord']['coyname'] . "</h1>" ;
$MailMessage = $MailMessage . "</td></tr>";
$MailMessage = $MailMessage . "<tr><td colspan='4'> <b>" .
$_SESSION['CompanyRecord']['regoffice1'] . "</b></td></tr>";
$MailMessage = $MailMessage . "<tr><td colspan='4'> <b>" .
$_SESSION['CompanyRecord']['regoffice4'] . "</b>,";
$MailMessage = $MailMessage . "<b>" .
$_SESSION['CompanyRecord']['regoffice5'] . "</b></td></tr>";
$MailMessage = $MailMessage . "<tr><td colspan='4'> <b>" .
$_SESSION['CompanyRecord']['telephone'] . ' ' . _('Fax'). ': ' .
$_SESSION['CompanyRecord']['fax'] . "</b></td></tr>";
$MailMessage = $MailMessage . "<tr><td colspan='4'> <b>" .
$_SESSION['CompanyRecord']['email'] . "</b><br /><br /><br /></td></tr>";
$MailMessage = $MailMessage . "<table><tr><td align='center' colspan='4'>
<h2> Order Acknowledgement</h2></td></tr>";
$MailMessage = $MailMessage . "<tr><td align='center' colspan='4'> <b>Order Number " .
$_GET['TransNo'] . "</b><br /><br /><br /></td></tr>";
$MailMessage = $MailMessage . "<tr><td colspan='4'> <b>Delivered To:</b></td></tr>";
$MailMessage = $MailMessage . "<tr><td colspan='4'> <b>" .
$myrow['deliverto'] . "</b></td></tr>";
$MailMessage = $MailMessage . "<tr><td colspan='4'> <b>" .
$myrow['deladd1'] . "</b></td></tr>";
if(strlen(trim($myrow['deladd2'])))
{
$MailMessage = $MailMessage . "<tr><td> <b>" . $myrow['deladd2'] . "</b></td></tr>";
$MailMessage = $MailMessage . "<tr><td> <b>" . $myrow['deladd3'] .
' ' . $myrow['deladd4'] . ' ' . $myrow['deladd5']. "</b><br /><br /><br /></td></tr>";
}
else
{
$MailMessage = $MailMessage . "<tr><td> <b>" . $myrow['deladd3'] . ' ' .
$myrow['deladd4'] . ' ' . $myrow['deladd5'] . "</b><br /><br /><br /></td></tr>";
}
$MailMessage = $MailMessage . "</table><table border='1' width='50%'><tr>";
if($_REQUEST['POLine'] == 1){
$MailMessage = $MailMessage . " <td>PO Line</td>";
}
$MailMessage = $MailMessage . "<td>Stock Code</td>
<td>Description</td>
<td>Quantity Ordered</td>
<td>Due Date</td></tr>";
$sql = "SELECT salesorderdetails.stkcode,
stockmaster.description,
salesorderdetails.quantity,
salesorderdetails.qtyinvoiced,
salesorderdetails.unitprice,
salesorderdetails.narrative,
salesorderdetails.poline,
salesorderdetails.decimalplaces,
salesorderdetails.itemdue
FROM salesorderdetails
INNER JOIN stockmaster
ON salesorderdetails.stkcode=stockmaster.stockid
WHERE salesorderdetails.orderno=" . $_GET['TransNo'] . "
ORDER BY poline";
$result=DB_query($sql,$db, $ErrMsg);
$i=0;
if (DB_num_rows($result)>0){
while ($myrow2=DB_fetch_array($result)){
$DisplayQty = locale_number_format($myrow2['quantity'],$myrow2['decimalplaces']);
$DisplayPrevDel = locale_number_format($myrow2['qtyinvoiced'],$myrow2['decimalplaces']);
$DisplayQtySupplied = locale_number_format($myrow2['quantity'] - $myrow2['qtyinvoiced'],$myrow2['decimalplaces']);
$StkCode[$i] = $myrow2['stkcode'];
$DscCode[$i] = $myrow2['description'];
$QtyCode[$i] = $DisplayQty ;
$POLine[$i] = $myrow2['poline'];
if($myrow2['itemdue'] =='')
{
$ItemDue[$i] = date('M d, Y',strtotime($DeliveryDate));
}
else
{
$ItemDue[$i] = date('M d, Y',strtotime($myrow2['itemdue']));
}
$MailMessage = $MailMessage . '<tr>';
if($_REQUEST['POLine'] == 1){
$MailMessage = $MailMessage . '<td align="right">' . $POLine[$i] . '</td>';
}
$MailMessage = $MailMessage . '<td>' . $myrow2['stkcode'] . '</td>
<td>' . $myrow2['description'] . '</td>
<td align="right">' . $DisplayQty . '</td>
<td align="center">' . $ItemDue[$i] . '</td>
</tr>';
$i = $i + 1;
} //end while there are line items to print out
} /*end if there are order details to show on the order*/
$MailMessage = $MailMessage . '</table></body></html>';
// echo $MailMessage . "=mailMessage<br />";
if(mail( $MailTo, $MailSubject, $MailMessage, $headers )){
echo ' The following E-Mail was sent to $MailTo:';
}
?>
<html>
<head>
<title>Email Confirmation</title>
</head>
<body>
<table width='60%'>
<tr>
<td align='center' colspan='4'> <?php
echo '<img src="' . $rootpath . '/' . $_SESSION['LogoFile'] . '" alt="Logo"' . 'width="500" height="100" align="center" border="0" />' ?>
</td>
</tr>
<tr>
<td align='center' colspan='4'> <h2> Order Acknowledgement</h2></td>
</tr>
<tr>
<td align='center' colspan='4'> <b>Order Number <?=$_GET['TransNo']?> </b><br /><br /><br /></td>
</tr>
<tr>
<td colspan='2' nowrap width="50%"> <b><?=$_SESSION['CompanyRecord']['coyname']?></b></td>
<td colspan='2' nowrap width="50%"> <b>Delivered To:</b></td>
</tr>
<tr>
<td colspan='2' nowrap width="50%"> <b><?=$_SESSION['CompanyRecord']['regoffice1']?> </b></td>
<td colspan='2' nowrap width="50%"> <b><?=$myrow['deliverto']?></b></td>
</tr>
<tr>
<td colspan='2' nowrap width="50%">
<b><?=$_SESSION['CompanyRecord']['regoffice4']?>,
<?=$_SESSION['CompanyRecord']['regoffice5']?> </b>
</td>
<td colspan='2' nowrap width="50%"> <b><?=$myrow['deladd1']?></b></td>
</tr>
<tr>
<td colspan='2' nowrap width="50%">
<b><?=$_SESSION['CompanyRecord']['telephone']?>
Fax:<?=$_SESSION['CompanyRecord']['fax']?></b>
</td>
<td nowrap width="50%"><b><?=$myrow['deladd2']?></b></td>
</tr>
<tr>
<td colspan='2' nowrap width="50%">
<b><?=$_SESSION['CompanyRecord']['email']?></b><br /><br /><br />
</td>
<td nowrap width="50%">
<b><?=$myrow['deladd3']?> <?=$myrow['deladd4'] ?> <?=$myrow['deladd5']?></b><br /><br /><br />
</td>
</tr>
</table>
<table border='1' width='60%' cellpadding="2" cellspacing='2'>
<tr>
<?
if($_REQUEST['POLine'] == 1){
?>
<td align="center">PO Line</td>
<?
}
?>
<td align="center">Stock Code</td>
<td align="center">Description</td>
<td align="center">Quantity Ordered</td>
<td align="center">Due Date</td>
</tr>
<?
for( $j=0; $j<$i; $j++)
{
?>
<tr>
<?
if($_REQUEST['POLine']){
?>
<td align='right'><?=$POLine[$j]?></td>
<?
}
?>
<td><?=$StkCode[$j]?></td>
<td><?=$DscCode[$j]?></td>
<td align="right"><?=$QtyCode[$j]?></td>
<td align="center"><?=$ItemDue[$j]?></td>
</tr>
<?
}
?>
</table>
</body>
</html>