-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsert8.php
121 lines (99 loc) · 2.7 KB
/
insert8.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
<?php
//error_reporting(0);
$link = mysqli_connect("localhost", "root", "", "demo");
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$host="localhost";
$user="root";
$password="";
$db="demo";
mysql_connect($host,$user,$password);
mysql_select_db($db);
$startTime = mysqli_real_escape_string($link, $_REQUEST['item_date_1']);
$endTime = mysqli_real_escape_string($link, $_REQUEST['item_date_2']);
$A = strtotime( $startTime,'12:00' );
$B = strtotime( $endTime,'12:00' );
echo "<h1>Kitchen Item</h1>";
echo '<table border="1" width="100%">';
echo '<thead>';
echo '<tr>';
echo '<th>Date</th>';
echo '<th>Item name</th>';
echo '<th>Opening Balance</th>';
echo '<th>Received Item</th>';
echo '<th>Sold Quantity</th>';
echo '<th>Damaged/Broken Item</th>';
echo '<th>Closing Balance</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
for ( $i = $A; $i <= $B; $i = $i + 86400 ) {
$thisDate = date( 'Y-m-d', $i );
echo '<tr>';
echo '<td>';
echo $thisDate;
echo '</td>';
echo '<td>';
echo '<table border="1" width="100%">';
$sql="SELECT Item_name from type where Item_Type='Item from kitchen' ";
$result=mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
$item_name=$row['Item_name'];
echo '<tr>';
echo '<td>';
echo $item_name;
echo '</td>';
echo '</tr>';
}
echo '</table>';
echo '</td>';
echo '<td>';
echo '<table border="1" width="100%">';
$result=mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
$item_name=$row['Item_name'];
$sql2="SELECT Opening_balance from total_quantity where Item_name='$item_name' AND Date='$thisDate' ";
$result2= mysql_query($sql2);
$row2= mysql_fetch_assoc($result2);
echo '<tr>';
echo '<td colspan="5">';
if(mysql_num_rows($result2)==1)
{
echo $row2['Opening_balance'];
}
else
{
$sql2="SELECT MAX(Date) from total_quantity where Item_name='$item_name' AND Date<'$thisDate' ";
$result2 = mysql_query($sql2);
if(mysql_num_rows($result2)==1){
$row2 = mysql_fetch_assoc($result2);
$max_date=$row2['MAX(Date)'];
$sql2="SELECT Opening_balance,Item_received,Sold_quantity,Damaged from total_quantity where Item_name='$item_name' AND Date='$max_date' ";
$result2 = mysql_query($sql2);
$row2 = mysql_fetch_assoc($result2);
$A=$row2['Opening_balance']+$row2['Item_received']-$row2['Sold_quantity']-$row2['Damaged'];
echo $A;
}
else
echo "0";
}
echo '</td>';
echo '</tr>';
}
echo '</table>';
echo '</td>';
echo '<td>';
echo '</td>';
echo '<td>';
echo '</td>';
echo '<td>';
echo '</td>';
echo '<td>';
echo '</td>';
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
mysqli_close($link);
?>