-
Notifications
You must be signed in to change notification settings - Fork 0
/
insert.php
165 lines (138 loc) · 4.32 KB
/
insert.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
<?php
require('fpdf.php');
$name = $_POST["pat"];
$refer = $_POST["refer"];
$numberOfTest = $_POST["hiddens"] - 1;
$gender = $_POST["gender"];
$age = $_POST["age"];
$user = $_POST["hiddens2"];
$discount = $_POST["discount"];
//echo $name ." ".$refer." ".$age." ". $numberOfTest . " ". $user ." ".$discount;
$testNames = [$numberOfTest];
$price = [$numberOfTest];
$duration = [$numberOfTest];
for ($i=0; $i < $numberOfTest; $i++)
{
$a = $i+1;
$testNames[$i]=$_POST["testname".$a];
$price[$i] = $_POST["price".$a];
$duration[$i] = $_POST["duration".$a];
}
$disprice = array_sum($price) * $discount / 100 ;
$GrandTotal = array_sum($price) - $disprice;
require ('databaseconnection.php');
$sql ="insert into customer(name,gender,user,referby,testcount)values('$name','$gender','$user','$refer','$numberOfTest')";
$result = $conn->query($sql);
$sql = "select id from customer";
$result = $conn->query($sql);
$lastId;
while($row=$result->fetch_assoc())
{
$lastId=$row["id"];
}
for( $b=0; $b<$numberOfTest; $b++ )
{
$sql ="insert into patienttest(pid,testName)values('$lastId','$testNames[$b]')";
$result = $conn->query($sql);
}
$sumprice = array_sum($price);
$date = date("Y-m-d");
$sql ="insert into recepdetail(user,totalamount,Discount,Grandtotal,Date)values('$user',' $sumprice','$discount','$GrandTotal','$date')";
$result = $conn->query($sql);
class PDF extends FPDF
{
// Page header
function Header()
{
// Logo
$this->Image('logo.jpeg',10,6,30);
// Arial bold 15
$this->SetFont('Arial','B',16);
// Move to the right
$this->Cell(80);
// Title
$this->Cell(30,10,'Ali Diagnostic Center',0,0,'C');
$this->Ln(8);
$this->Cell(88);
$this->SetFont('Arial','B',6);
$this->Cell(10,5,'Khawaja Plaza,Near King Abdullah Teaching Hospital,Mansehra',0,0,'C');
// Line break
$this->Ln(13);
}
// Colored table
function FancyTable($header, $names, $price , $duration)
{
$this->cell(20);
// Colors, line width and bold font
$this->SetFillColor(255,0,0);
$this->SetTextColor(255);
$this->SetDrawColor(128,0,0);
$this->SetLineWidth(.3);
$this->SetFont('','B');
// Header
$w = array(40, 35, 40);
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],1,0,'C',true);
$this->Ln();
$this->cell(20);
// Color and font restoration
$this->SetFillColor(224,235,255);
$this->SetTextColor(0);
$this->SetFont('');
// Data
$fill = false;
for ($i=0; $i < count($names); $i++) {
$this->Cell($w[0],6,$names[$i],'LR',0,'L',$fill);
$this->Cell($w[1],6,$price[$i],'LR',0,'L',$fill);
$this->Cell($w[2],6,$duration[$i],'LR',0,'L',$fill);
//$this->Cell($w[2],6,,'LR',0,'R',$fill);
$this->Ln();
$this->cell(20);
$fill = !$fill;
}
// Closing line
$this->Cell(array_sum($w),0,'','T');
}
}
// Instanciation of inherited class
$pdf = new PDF();
$pdf->addPage();
$pdf->AliasNbPages();
$pdf->SetFont('Times','B',10);
$pdf->cell(120);
$pdf->cell(10,5,"Patient Id: ".$lastId);
$pdf->Ln(6);
$pdf->SetFont('Times','B',10);
$pdf->cell(120);
$pdf->cell(10,5,"Patient Name: ".$name);
$pdf->Ln(6);
$pdf->cell(120);
$pdf->cell(10,5,"Age: ".$age);
$pdf->Ln(6);
$pdf->cell(120);
$pdf->cell(10,5,"Gender: ".$gender);
$pdf->Ln(6);
$pdf->cell(120);
$pdf->cell(10,5,"Refer By: ".$refer);
$pdf->Ln(6);
$pdf->cell(120);
$pdf->cell(10,5,"Printed By: ".$user);
$pdf->Ln(15);
$header = array('Test Name', 'Price (RS)', 'Duration');
$data= array();
$pdf->FancyTable($header,$testNames,$price,$duration);
$pdf->SetFont('Times','B',10);
$pdf->Ln(8);
$pdf->cell(120);
$pdf->cell(10,5,"Total Amount:".array_sum($price));
$pdf->Ln(8);
$pdf->cell(120);
$pdf->cell(10,5,"Discount:".$discount."%");
$pdf->Ln(8);
$pdf->cell(120);
$pdf->cell(10,5,"Grand Total:".$GrandTotal);
$pdf->Ln(8);
$pdf->cell(5);
$pdf->cell(10,5,"If you have any complaint regarding to service or any other fell free to contact us at complaint.ADS@gamil.com");
$pdf->Output();
?>