-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsend.php
507 lines (429 loc) · 20.4 KB
/
send.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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
<?php
/****************************************************************************
included files
****************************************************************************/
include('includes/common-functions.php');
include('includes/thumbnail.php');
include('includes/classess/generate.php');
$message = '';
if(!isset($_POST['AccessFlag'])){
header("location:index.php");
return false;
}
if(isset($_POST['sendEmail']) || isset($_POST['send']))
{
/****************************************************************************
header post
****************************************************************************/
$titleVal = $_POST['title'];
$invocieNo = $_POST['invocieNo'];
$billingDate = $_POST['billingDate'];
$dueDate = $_POST['dueDate'];
/****************************************************************************
From post
****************************************************************************/
$frmBizName = $_POST['frmBizName'];
$frmAddress1 = $_POST['frmAddress1'];
$frmAddress2 = $_POST['frmAddress2'];
$frmPhone = $_POST['frmPhone'];
$frmEmail = $_POST['frmEmail'];
$frmAddInfo = $_POST['frmAddInfo'];
$toBizName = $_POST['toBizName'];
/****************************************************************************
To post
****************************************************************************/
$toAddress1 = $_POST['toAddress1'];
$toAddress2 = $_POST['toAddress2'];
$toPhone = $_POST['toPhone'];
$toEmail = $_POST['toEmail'];
$toAddInfo = $_POST['toAddInfo'];
/****************************************************************************
Settings post
****************************************************************************/
$currency = $_POST['currency'];
$taxformat = $_POST['taxformat'];
$discountFormat = $_POST['discountFormat'];
$pdfColor = $_POST['pdfColor'];
$subtotal = $_POST['subtotal'];
$totalBill = $_POST['totalBill'];
$applyDiscount = $_POST['applyDiscount'];
$applyTax = $_POST['applyTax'];
$extraNotes = $_POST['extraNotes'];
$addBadge = $_POST['addBadge'];
$notesTitle = $_POST['notesTitle'];
/****************************************************************************
items listing
****************************************************************************/
$proNameArray = $_POST['proName'];
$proDescArray = $_POST['proDesc'];
$amountArray = $_POST['amount'];
$vatArray = $_POST['vat'];
$priceArray = $_POST['price'];
$discountArray = $_POST['discount'];
$totalArray = $_POST['total'];
if(isset($_POST['send'])) {
$proNameArray = explode("|", $proNameArray);
$proDescArray = explode("|", $proDescArray);
$amountArray = explode("|", $amountArray);
$vatArray = explode("|", $vatArray);
$priceArray = explode("|", $priceArray);
$discountArray = explode("|", $discountArray);
$totalArray = explode("|", $totalArray);
}
$proName = implode("|",$proNameArray);
$proDesc = implode("|",$proDescArray);
$amountVal = implode("|",$amountArray);
$vatVal = implode("|",$vatArray);
$priceVal = implode("|",$priceArray);
$discountVal = implode("|",$discountArray);
$totalVal = implode("|",$totalArray);
/****************************************************************************
pdf generate
****************************************************************************/
//Set default date timezone
date_default_timezone_set('America/Los_Angeles');
//Create a new instance
$invoice = new generate("A4",$currency,"en");
//Set tax format
$invoice->setTaxFormat($taxformat);
//Set Discount format
$invoice->setDiscountFormat($discountFormat);
$image = '';
if(isset($_POST['sendEmail']))
{
//Set your logo
if (isset($_FILES["image"]["name"]) && $_FILES["image"]["name"] != '')
{
$imagePath = 'uploads/' . $_FILES["image"]["name"];
moveUplaod('uploads');
$invoice->setLogo($imagePath, 180, 100);
//set the hidden input value
$image = $_FILES["image"]["name"];
}
}else{
$image = $_POST['image'];
if($image != '')
{
$imagePath = 'uploads/' . $image;
$invoice->setLogo($imagePath, 180, 100);
}
}
//Set theme color
$invoice->setColor($pdfColor);
//Set type
$invoice->setType($titleVal);
//Set reference
$invoice->setReference($invocieNo);
//Set date
$invoice->setDate($billingDate);
//Set due date
$invoice->setDue($dueDate);
//Set from
$invoice->setFrom(array($frmBizName,$frmAddress1,$frmAddress2,$frmPhone,$frmEmail,$frmAddInfo));
//Set to
$invoice->setTo(array($toBizName,$toAddress1,$toAddress2,$toPhone,$toEmail,$toAddInfo));
foreach( $proNameArray as $key => $productName )
{
$proDes =$proDescArray[$key];
$amount =$amountArray[$key];
$price =$priceArray[$key];
if($applyDiscount == 'yes')
{
$discount =$discountArray[$key];
}
else
{
$discount = false;
}
if($applyTax == 'yes')
{
$vat = $vatArray[$key];
}
else
{
$vat = false;
}
$total =$totalArray[$key];
$invoice->addItem($productName,$proDes,$amount,$vat,$price,$discount,$total);
}
//Add sub totals
$invoice->addTotal("Sub Total",$subtotal);
//add taxes
if(isset($_POST['sendEmail']))
{
if(isset($_POST['taxTitle']) || isset($_POST['taxValue']))
{
$taxTitleArray = $_POST['taxTitle'];
$taxValueArray = $_POST['taxValue'];
$taxTitle = implode("|",$taxTitleArray);
$taxValues = implode("|",$taxValueArray);
}else
{
$taxTitle = '';
$taxValues = '';
}
}
if(isset($_POST['send']))
{
$taxTitleArray = explode("|", $_POST['taxTitle']);
$taxValueArray = explode("|", $_POST['taxValue']);
$taxTitle = implode("|",$taxTitleArray);
$taxValues = implode("|",$taxValueArray);
}
if(isset($taxTitle) && $taxTitle != '')
{
$taxTitleArray = array();
$taxValueArray= array();
foreach( $taxTitleArray as $key => $title )
{
$taxValue = $taxValueArray[$key];
$invoice->addTotal($title,$taxValue);
}
}
//Add total bill
$invoice->addTotal("Total",$totalBill,TRUE);
if($addBadge != ''){
//Add badge
$invoice->addBadge($addBadge);
}
//Add signature
if($_POST['sig_name'] == '') {
$sig_name = '';
}else{
$sig_name = $_POST['sig_name'];
}
$invoice->setSigName($sig_name);
if($_POST['sig_designation'] == '') {
$designation = '';
}else{
$designation = $_POST['sig_designation'];
}
$invoice->setSigDesig($designation);
//Add title
if($_POST['extraNotes'] == '') {
$noteTitle = '';
}else{
$noteTitle = $notesTitle;
}
$invoice->addTitle($noteTitle);
//Add paragraph
if($_POST['extraNotes'] == '')
{
$extraNotes = '';
}else{
$extraNotes = $_POST['extraNotes'];
}
$invoice->addParagraph($extraNotes);
//Set footer note
$invoice->setFooternote("#");
}
if(isset($_POST['send']))
{
$to = $_POST["to"];
$from = $_POST['from'];
$nameVal = $_POST['name'];
$subject = 'You\'ve received an invoice from '.$nameVal;
$message = $_POST['mesg'];
if(isset($_POST['sendToMe']))
{
$sendToMe = $_POST['sendToMe'];
}else
{
$sendToMe = 'no';
}
$invoice->SendEmail($to,$from,$subject,$message,$sendToMe,$nameVal);
$message = "Your invoice has just been sent to ". $to ."!";
}
?>
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Invoice Generator - PDF Invoices Generator App by PDF Invoice Generator</title>
<link href='http://fonts.googleapis.com/css?family=Lato' rel='stylesheet' type='text/css'>
<link rel="icon" type="image/x-icon" href="favicon.png">
<link href="css/colorpicker.css" rel="stylesheet" type="text/css" />
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="css/calender.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/custom.js"></script>
<script src="js/colorpicker.js"></script>
<script src="js/eye.js"></script>
<script src="js/calender.js"></script>
<!--[if lt IE 9]>
<script type="text/javascript" src="js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<header>
<div class="container">
<img class="ilogo" src="images/icon.png" alt=""/>
<h1>
Invoice Generator
<small>PDF Invoices Generator App by <a href="#">PDF Invoice Generator</a></small>
</h1>
<a class="logo" href="#"><img src="images/logo.png" alt="PDF Invoice Generator Logo"/></a>
</div>
</header>
<form method="post" action="send.php" id="myform">
<div class="container sending-panel">
<div class="row">
<div class="col-lg-12">
<h2>SEND INVOICE</h2>
<h4>Send a professional crafted email with your invoice attached to anyone in the world, for free.</h4>
<?PHP
if($message !='')
{
?>
<div class="alert alert-success" role="alert"><span class="glyphicon glyphicon-ok" style="font-size: 16px"> </span><?PHP echo $message?></div>
<?PHP
}else
{
?>
<div class="alert alert-info" role="alert"><span class="glyphicon glyphicon-lock"> </span>We do not to save, use, or spam your client's email address beyond sending this invoice.</div>
<?PHP
}
?>
</div>
<div class="col-sm-6 emailForm-panel">
<h4>Sender information</h4>
<div class="form-group">
<label for="to" class="caption">What email address do you want to send this to?</label>
<input type="text" class="form-control email " name="to" id="to" onkeyup="changePreValue()" placeholder="[email protected]" autocomplete="off">
</div>
<div class="form-group">
<label for="name" class="caption">What is the name of you or your company?</label>
<input type="text" class="form-control" value="PDF Invoice Generator" name="name" id="name" onkeyup="changePreValue()" autocomplete="off">
</div>
<div class="form-group">
<label for="from" class="caption">What is your email address?</label>
<input type="email" class="form-control email" name="from" id="from" onkeyup="changePreValue()" autocomplete="off" placeholder="[email protected]">
</div>
<div class="form-group">
<label for="EmailMesg" class="caption">Custom Message</label>
<label for="mesg"></label><textarea class="form-control" name="mesg" rows="4" id="mesg" onkeyup="changePreValue()"></textarea>
</div>
<div class="checkbox">
<label>
<input type="checkbox" value="yes" name="sendToMe"> <span class="caption" style="float:left; margin-top: 2px">Send a copy to me</span>
</label>
</div>
<!--pdf information start-->
<input type="hidden" name="title" value="<?PHP echo (isset($titleVal))?$titleVal:"" ?>">
<input type="hidden" name="invocieNo" value="<?PHP echo (isset($invocieNo))?$invocieNo:"" ?>">
<input type="hidden" name="billingDate" value="<?PHP echo (isset($billingDate))?$billingDate:"" ?>">
<input type="hidden" name="dueDate" value="<?PHP echo (isset($dueDate))?$dueDate:"" ?>">
<!--from info-->
<input type="hidden" name="frmBizName" value="<?PHP echo (isset($frmBizName))?$frmBizName:"" ?>">
<input type="hidden" name="frmAddress1" value="<?PHP echo (isset($frmAddress1))?$frmAddress1:"" ?>">
<input type="hidden" name="frmAddress2" value="<?PHP echo (isset($frmAddress2))?$frmAddress2:"" ?>">
<input type="hidden" name="frmPhone" value="<?PHP echo (isset($frmPhone))?$frmPhone:"" ?>">
<input type="hidden" name="frmEmail" value="<?PHP echo (isset($frmEmail))?$frmEmail:"" ?>">
<input type="hidden" name="frmAddInfo" value="<?PHP echo (isset($frmAddInfo))?$frmAddInfo:"" ?>">
<!--To info-->
<input type="hidden" name="toBizName" value="<?PHP echo (isset($toBizName))?$toBizName:"" ?>">
<input type="hidden" name="toAddress1" value="<?PHP echo (isset($toAddress1))?$toAddress1:"" ?>">
<input type="hidden" name="toAddress2" value="<?PHP echo (isset($toAddress2))?$toAddress2:"" ?>">
<input type="hidden" name="toPhone" value="<?PHP echo (isset($toPhone))?$toPhone:"" ?>">
<input type="hidden" name="toEmail" value="<?PHP echo (isset($toEmail))?$toEmail:"" ?>">
<input type="hidden" name="toAddInfo" value="<?PHP echo (isset($toAddInfo))?$toAddInfo:"" ?>">
<!--items list-->
<input type="hidden" name="proName" value="<?PHP echo (isset($proName))?$proName:"" ?>">
<input type="hidden" name="proDesc" value="<?PHP echo (isset($proDesc))?$proDesc:"" ?>">
<input type="hidden" name="amount" value="<?PHP echo (isset($amountVal))?$amountVal:"" ?>">
<input type="hidden" name="vat" value="<?PHP echo (isset($vatVal))?$vatVal:"" ?>">
<input type="hidden" name="price" value="<?PHP echo (isset($priceVal))?$priceVal:"" ?>">
<input type="hidden" name="discount" value="<?PHP echo (isset($discountVal))?$discountVal:"" ?>">
<input type="hidden" name="total" value="<?PHP echo (isset($totalVal))?$totalVal:"" ?>">
<!--others-->
<input type="hidden" name="currency" value="<?PHP echo (isset($currency))?$currency:"" ?>">
<input type="hidden" name="taxformat" value="<?PHP echo (isset($taxformat))?$taxformat:"" ?>">
<input type="hidden" name="discountFormat" value="<?PHP echo (isset($discountFormat))?$discountFormat:"" ?>">
<input type="hidden" name="pdfColor" value="<?PHP echo (isset($pdfColor))?$pdfColor:"" ?>">
<input type="hidden" name="subtotal" value="<?PHP echo (isset($subtotal))?$subtotal:"" ?>">
<input type="hidden" name="totalBill" value="<?PHP echo (isset($totalBill))?$totalBill:"" ?>">
<input type="hidden" name="applyDiscount" value="<?PHP echo (isset($applyDiscount))?$applyDiscount:"" ?>">
<input type="hidden" name="applyTax" value="<?PHP echo (isset($applyTax))?$applyTax:"" ?>">
<input type="hidden" name="extraNotes" value="<?PHP echo (isset($extraNotes))?$extraNotes:"" ?>">
<input type="hidden" name="taxTitle" value="<?PHP echo (isset($taxTitle))?$taxTitle:"" ?>">
<input type="hidden" name="taxValue" value="<?PHP echo (isset($taxValues))?$taxValues:"" ?>">
<input type="hidden" name="image" value="<?PHP echo (isset($image))?$image:"" ?>">
<input type="hidden" name="addBadge" value="<?PHP echo (isset($addBadge))?$addBadge:"" ?>">
<input type="hidden" name="notesTitle" value="<?PHP echo (isset($notesTitle))?$notesTitle:"" ?>">
<input type="hidden" name="sig_name" value="<?PHP echo (isset($sig_name))?$sig_name:"" ?>">
<input type="hidden" name="sig_designation" value="<?PHP echo (isset($designation))?$designation:"" ?>">
<input type="hidden" value="true" name="AccessFlag">
<div class="form-group">
<label for="submit"></label>
<button type="submit" name="send" class="btn btn-default sub-btn">Send Email</button>
</div>
</div>
<div class="col-sm-6">
<h4>Preview</h4>
<div class="preview-panel">
<div class="form-group">
<label for="exampleInputEmail1" class="caption">To</label>
<p class="form-control-static"><span id="prevToEmail">[email protected]</span></p>
</div>
<div class="form-group">
<label for="exampleInputEmail1" class="caption">From</label>
<p class="form-control-static"><span id="prevFrmEmail">[email protected]</span></p>
</div>
<div class="form-group">
<label for="exampleInputEmail1" class="caption">Subject</label>
<p class="form-control-static">You've received an invoice from <span id="prevName">PDF Invoice Generator</span></p>
</div>
<div class="form-group">
<label for="exampleInputEmail1" class="caption">Message</label>
<div class="preview-msg-pnl">
<div class="preview-msg">
<h2><span id="emailHeading">PDF Invoice Generator</span></h2>
<p>Greetings</p>
<p>You've received an invoice from <span id="emailSub">PDF Invoice Generator</span></p>
<p>You will find a PDF attached.</p>
<p id="prevMesg"></p>
<p><small><strong>Invoice Generator</strong> - App by <a href="#" target="_blank">PDF Invoice Generator</a></small></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
<footer>
<div class="container">
<p class="pull-left">© 2019. All rights are reserved to the developers.</p>
<p class="pull-right">Developed by <a href="#" target="_blank">PDF Invoice Generator</a>.</p>
</div>
</footer>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.validate.min.js"></script>
<script>
$.validator.setDefaults({
debug: false
});
$( "#myform" ).validate({
rules: {
to: {
required: true,
email: true
},
from: {
required: true,
email: true
},
name: "required"
},
messages: {
to: "Please enter a valid email address.",
from: "Please enter a valid email address.",
name: "Please enter the name of you or your company."
}
});
</script>
</body>
</html>