-
Notifications
You must be signed in to change notification settings - Fork 0
/
generateInvoicePDF.php
60 lines (45 loc) · 1.46 KB
/
generateInvoicePDF.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
<?php
require_once('dbconn.php');
$input = json_decode(base64_decode($_POST["q"]));
$fmt = $_POST["inv_fmt"];
$con=getConnection();
$x1 = "";
$arr = array();
foreach(explode("$" , $fmt) as $x){
$y = substr($x,0,2);
if($y == "TX"){
$x1 .= explode("#",substr($x,2))[1];
}
if($y == "FY"){
if(date("m") <= 3 ){
$x1 .=strval(date("y") - 1)."-".strval(date("y"));
}
else{
$x1 .=strval(date("y"))."-".strval(date("y")+1);
}
}
if($y == "RN"){
$a = explode("#",substr($x,2))[1];
$sql="
select seq_no from inc_seq where seq_code = '{$a}'
";
$result = mysqli_query($con,$sql) or debug($sql." failed <br/><br/>");
$row = mysqli_fetch_array($result);
$x1 .= substr("000".strval($row["seq_no"]),-3);
$sql = "update inc_seq set seq_no = seq_no + 1 where seq_code = '{$a}'";
$result = mysqli_query($con,$sql) or debug($sql." failed <br/><br/>");
}
}
foreach($input->invList as $invl){
$sql = "update project_invoice set status = 'INVOICED' ,
invoice_no = '{$x1}',
invoiced_date = '{$input->invDate}',
invoiced_on = CURRENT_TIMESTAMP()
where invoice_id = '{$invl->id}'";
$result = mysqli_query($con,$sql) or debug($sql." failed <br/><br/>");
}
$input->invNO = $x1 ;
$_GET["q"] = base64_encode(json_encode($input));
$xpdf = include "invoice.php";
echo base64_decode($xpdf);
?>