-
Notifications
You must be signed in to change notification settings - Fork 35
/
EmailConfirmation.php
369 lines (346 loc) · 11.7 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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
<?php
include('includes/session.php');
include('includes/SQL_CommonFunctions.inc');
$ViewTopic = 'SalesOrders';
$BookMark = '';
//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.php');
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">
<ul>
<li><a href="'. $RootPath . '/SelectSalesOrder.php">' . _('Outstanding Sales Orders') . '</a></li>
<li><a href="'. $RootPath . '/SelectCompletedOrder.php">' . _('Completed Sales Orders') . '</a></li>
</ul>
</td>
</tr>
</table>
</div>
<br />
<br />
<br />';
include('includes/footer.php');
exit;
}
$MailTo = $_GET['EMail'];
$headers = 'From: weberp.org <[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
INNER JOIN locationusers ON locationusers.loccode=salesorders.fromstkloc AND locationusers.userid='" . $_SESSION['UserID'] . "' AND locationusers.canupd=1,
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, $ErrMsg);
//If there are no rows, there's a problem.
if (DB_num_rows($result)==0){
$Title = _('Print Packing Slip Error');
include('includes/header.php');
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">
<ul>
<li><a href="'. $RootPath . '/SelectSalesOrder.php">' . _('Outstanding Sales Orders') . '</a></li>
<li><a href="'. $RootPath . '/SelectCompletedOrder.php">' . _('Completed Sales Orders') . '</a></li>
</ul>
</td>
</tr>
</table>
</div>
<br />
<br />
<br />';
include('includes/footer.php');
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.php');
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><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></p>';
echo '<br />
<br />
<br />';
echo _('Or select another Order Number to Print');
echo '<table class="table_index">
<tr>
<td class="menu_group_item">
<ul>
<li><a href="'. $RootPath . '/SelectSalesOrder.php">' . _('Outstanding Sales Orders') . '</a></li>
<li><a href="'. $RootPath . '/SelectCompletedOrder.php">' . _('Completed Sales Orders') . '</a></li>
</ul>
</td>
</tr>
</table>
</div>
<br />
<br />
<br />';
include('includes/footer.php');
exit;
}//packing slip has been printed.
$MailSubject = _('Order Confirmation-Sales Order') . ' ' . $_GET['TransNo'] . ' - '. _('Your PO') . ' ' . $myrow['customerref'] ;
}
$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></td>
</tr>
<tr>
<td colspan="4"> <b>' . $_SESSION['CompanyRecord']['regoffice1'] . '</td>
</tr>
<tr>
<td colspan="4"> <b>' . $_SESSION['CompanyRecord']['regoffice4'] . ',<b>' . $_SESSION['CompanyRecord']['regoffice5'] . '</td>
</tr>
<tr>
<td colspan="4"> <b>' . $_SESSION['CompanyRecord']['telephone'] . ' ' . _('Fax'). ': ' . $_SESSION['CompanyRecord']['fax'] . '</td>
</tr>
<tr>
<td colspan="4"> <b>' . $_SESSION['CompanyRecord']['email'] . '
<br />
<br />
<br /></td>
</tr>
</table>
<table>
<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="4"> <b>' . _('Delivered To') . ':</b></td>
</tr>
<tr>
<td colspan="4"> <b>' . $myrow['deliverto'] . '</td>
</tr>
<tr>
<td colspan="4"> <b>' . $myrow['deladd1'] . '</td>
</tr>';
if(mb_strlen(trim($myrow['deladd2']))) {
$MailMessage .= '<tr>
<td> <b>' . $myrow['deladd2'] . '</td>
</tr>
<tr>
<td> <b>' . $myrow['deladd3'] . ' ' . $myrow['deladd4'] . ' ' . $myrow['deladd5']. '
<br />
<br />
<br /></td>
/tr>';
} else {
$MailMessage .= '<tr>
<td> <b>' . $myrow['deladd3'] . ' ' . $myrow['deladd4'] . ' ' . $myrow['deladd5'] . '
<br />
<br />
<br /></td>
</tr>';
}
$MailMessage .= '</table>
<table border="1" width="50%"><tr>';
if($_GET['POLine'] == 1){
$MailMessage .= '<td>' . _('PO Line') . '</td>';
}
$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.itemdue
FROM salesorderdetails INNER JOIN stockmaster
ON salesorderdetails.stkcode=stockmaster.stockid
WHERE salesorderdetails.orderno=" . $_GET['TransNo'] . "
ORDER BY poline";
$result=DB_query($sql, $ErrMsg);
$i=0;
if (DB_num_rows($result)>0){
while ($myrow2=DB_fetch_array($result)){
$DisplayQty = locale_number_format($myrow2['quantity'],0);
$DisplayPrevDel = locale_number_format($myrow2['qtyinvoiced'],0);
$DisplayQtySupplied = locale_number_format($myrow2['quantity'] - $myrow2['qtyinvoiced'],0);
$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 .= '<tr>';
if($_GET['POLine'] == 1){
$MailMessage .= '<td align="right">' . $POLine[$i] . '</td>';
}
$MailMessage .= '<td>' . $myrow2['stkcode'] . '</td>
<td>' . $myrow2['description'] . '</td>
<td align="right">' . $DisplayQty . '</td>
<td align="center">' . $ItemDue[$i] . '</td>
</tr>';
$i++;
} //end while there are line items to print out
} /*end if there are order details to show on the order*/
$MailMessage .= '</table>
</body>
</html>';
// echo $MailMessage . "=mailMessage<br />";
if($_SESSION['SmtpSetting']==0){
$result = mail( $MailTo, $MailSubject, $MailMessage, $headers );
}else{
include('includes/htmlMimeMail.php');
$mail = new htmlMimeMail();
$mail->setSubject($mailSubject);
$mail->setHTML($MailMessage);
$result = SendmailBySmtp($mail,array($MailTo));
}
if($result){
echo ' ' ._('The following E-Mail was sent to') . ' ' . $MailTo . ' :';
}
echo '<html>
<head>
<title>' . _('Email Confirmation') . '</title>
</head>
<body>
<table width="60%">
<tr>
<td align="center" colspan="4"><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'] . '</td>
</tr>
<tr>
<td colspan="2" nowrap width="50%">
<b>' . $_SESSION['CompanyRecord']['regoffice4'] . ',
<br />' . $_SESSION['CompanyRecord']['regoffice5'] . '</b>
</td>
<td colspan="2" nowrap width="50%"> <b>' . $myrow['deladd1'] . '</td>
</tr>
<tr>
<td colspan="2" nowrap width="50%">
<b>' . $_SESSION['CompanyRecord']['telephone'] . '
<br />' . _('Fax') . ': ' . $_SESSION['CompanyRecord']['fax'] . '</b>
</td>
<td nowrap width="50%"><b>' . $myrow['deladd2'] . '</td>
</tr>
<tr>
<td colspan="2" nowrap width="50%">
<b>' . $_SESSION['CompanyRecord']['email'] . '
<br />
<br />
<br />
</td>
<td nowrap width="50%">
<b>' . $myrow['deladd3'] . ' ' . $myrow['deladd4'] . ' ' . $myrow['deladd5'] . '
<br />
<br />
<br />
</td>
</tr>
</table>
<table border="1" width="60%" cellpadding="2" cellspacing="2">
<tr>';
if($_GET['POLine'] == 1){
echo '<td align="center">' . _('PO Line') . '</td>';
}
echo '<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++){
echo '<tr>';
if($_GET['POLine']){
echo '<td align="right">' . $POLine[$j] . '</td>';
}
echo '<td>' . $StkCode[$j] . '</td>
<td>' . $DscCode[$j] . '</td>
<td align="right">' . $QtyCode[$j] . '</td>
<td align="center">' . $ItemDue[$j] . '</td>
</tr>';
}
echo '</table>
</body>
</html>';
?>