-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReport_CustomerItems_query.php
154 lines (139 loc) · 6.69 KB
/
Report_CustomerItems_query.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
<?php
set_time_limit(300); //300 seconds, 5 minutes
include('dbconnect.php');
function refreshRecords() {
echo '<div class="panel panel-default">';
echo '<table class="table table-striped">';
echo '<thead>';
echo '<tr>';
echo '<th>INVOICE</th>';
echo '<th>CUSTOMER</th>';
echo '<th class="text-center">INVOICE AMOUNT</th>';
echo '<th class="text-center">INVOICE DATE</th>';
echo '<th class="text-center">PAY METHOD</th>';
echo '</tr>';
echo '</thead>';
$conn = dbConn();
//========================================================================================================
//below code generated with workbench plugin for php under tools > utilities
$query = "select * from view_customer_item_search where NAME LIKE \"%%\" AND PRODUCT LIKE \"%%\"; ";
if ($stmt = $conn->prepare($query)) {
$stmt->execute();
$stmt->bind_result($TICKETID, $NAME, $INVAMOUNT, $INVDATE, $PAYMETHOD);
$GRAND_TOTAL = 0;
while ($stmt->fetch()) {
//printf("%s, %s, %s, %s, %s, %s, %s, %s\n", $CODE, $REFERENCE, $NAME, $PRICESELL, $PRICEBUY, $NAME1, $UNITS, $NAME3);
echo '<tbody>';
echo "<tr><td><a href=\"javascript:void(0);\" data-href=\"ticketdetails.php?ticketid=$TICKETID\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Click for INV#$TICKETID details\" data-title=\"$TICKETID\" class=\"openTicket\">$TICKETID</a></td>";
echo "<td>". $NAME ."</td>";
echo "<td class=\"text-center\">". number_format($INVAMOUNT,2,'.','') ."</td>";
echo "<td class=\"text-center\">". $INVDATE ."</td>";
echo "<td class=\"text-center\">". $PAYMETHOD ."</td>";
echo "</tr>";
echo '</tbody';
$GRAND_TOTAL+=$INVAMOUNT;
}
$stmt->close();
}
echo '<tbody>';
echo "<tr><td></td>";
echo "<td></td>";
//echo "<td align=\"right\" bgcolor=\"#32cb00\"><font color=\"white\"><b>$GRAND_TOTAL_COST</b></font></td>";
echo "<td align=\"right\" bgcolor=\"#32cb00\"><font color=\"white\"><b>". number_format($GRAND_TOTAL,2,'.','') ."</b></font></td>";
echo "<td></td>";
echo "<td></td>";
echo "</tr>";
echo '</tbody';
//========================================================================================================
echo '</table>';
echo '</div>';
mysqli_close($conn);
$conn=null;
$sql="";
}
//function refreshrecords()
function filterRecords($CUSTNAME,$PRODUCT)
{
echo '<div class="panel panel-default">';
echo '<table class="table table-striped">';
echo '<thead>';
echo '<tr>';
echo '<th>INVOICE</th>';
echo '<th>CUSTOMER</th>';
echo '<th>PRODUCT</th>';
echo '<th>QTY</th>';
echo '<th class="text-center">UNIT PRICE</th>';
echo '<th class="text-center">ITEM TOTAL</th>';
echo '<th class="text-center">INVOICE DATE</th>';
echo '<th class="text-center">INV. TOTAL</th>';
echo '</tr>';
echo '</thead>';
$conn = dbConn();
//========================================================================================================
//below code generated with workbench plugin for php under tools > utilities
$query = "select * from view_customer_item_search where NAME LIKE \"%$CUSTNAME%\" AND PRODUCT LIKE \"%$PRODUCT%\"; ";
if ($stmt = $conn->prepare($query)) {
$stmt->execute();
$stmt->bind_result($TICKETID,$CUSTOMER,$PRODUCT,$QTY,$UNITPRICE,$TOTAL,$INVDATE, $INVAMOUNT);
echo '<tbody>';
$noRecord=false;
$GRAND_TOTAL = 0;
while ($stmt->fetch()) {
$noRecord = true;
echo '<tbody>';
echo "<tr><td><a href=\"javascript:void(0);\" data-href=\"ticketdetails.php?ticketid=$TICKETID\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Click for INV#$TICKETID details\" data-title=\"$TICKETID\" class=\"openTicket\">$TICKETID</a></td>";
echo "<td>". $CUSTOMER ."</td>";
echo "<td>". $PRODUCT ."</td>";
echo "<td class=\"text-center\">". $QTY ."</td>";
echo "<td class=\"text-center\">". number_format($UNITPRICE,2,'.','') ."</td>";
echo "<td class=\"text-center\">". number_format($TOTAL,2,'.','') ."</td>";
echo "<td class=\"text-center\">". $INVDATE ."</td>";
echo "<td class=\"text-center\">". number_format($INVAMOUNT,2,'.','') ."</td>";
echo "</tr>";
echo '</tbody';
$GRAND_TOTAL+=$TOTAL;
}
echo '<tbody>';
echo "<tr><td></td>";
echo "<td></td>";
echo "<td></td>";
echo "<td></td>";
echo "<td></td>";
//echo "<td align=\"right\" bgcolor=\"#32cb00\"><font color=\"white\"><b>$GRAND_TOTAL_COST</b></font></td>";
echo "<td class=\"text-center\" bgcolor=\"#32cb00\"><font color=\"white\"><b>". number_format($GRAND_TOTAL,2,'.','') ."</b></font></td>";
echo "<td></td>";
echo "<td></td>";
echo "</tr>";
echo '</tbody';
if ($noRecord == false)
{
echo "<tr><td class='bg-info text-center' colspan='8'>No records found!</td></tr>";
}
echo '</table>';
echo '</div>';
$stmt->close();
}
}
function putEmptyRow()
{
echo '<div class="panel panel-default">';
echo '<table class="table table-striped">';
echo '<thead>';
echo '<tr>';
echo '<th>BARCODE</th>';
echo '<th>REFERENCE</th>';
echo '<th>ITEM</th>';
echo '<th>PRICE</th>';
echo '<th>COST</th>';
echo '<th>CATEGORY</th>';
echo '<th>STOCK</th>';
echo '<th>TAX TYPE</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
echo "<tr><td class='bg-info text-center' colspan='8'></td></tr>";
echo '</tbody';
echo '</table>';
echo '</div>';
}
?>