-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiary-dec.php
229 lines (207 loc) · 9.99 KB
/
diary-dec.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
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="css/mili-style.css">
<!--<link rel="stylesheet" href="css/tabel-style.css">-->
<title>reports</title>
</head>
<body>
<div id="header">
<img src="css/milimix.png" alt="milimix" width="50" height="50"><br>
diary
</div>
<?php
function my_conn() {
// echo 'verbinding maken met kassa : ';
// $dbase = 'mili'; // DATABASE NAME
$dbase = 'chromis2'; // DATABASE NAME
//$dbase = 'loja';
$host = 'localhost'; //DATABASE HOST LOCATION/SERVER
$user = 'root'; //USER NAME
$pass = 'welkom'; //PASSWORD
$link = @mysqli_connect($host, $user, $pass, $dbase);
if (!$link) {
die("connection failed : " . mysqli_connect_error());
}
return $link;
}
?>
<!--// echo 'voorraadInvoer';
// categorie opgeven zodat per categorie kan worden gekeken-->
<!-- <form name="voorraadInvoer" action="voorraad.php" method="POST">
geef de begindatum JJJJ-MM-DD HH:MM:SS : <input type="text" name="begindatum" value="2016- 00:00:00" /><br>
geef de einddatum JJJJ-MM-DD HH:MM:SS : <input type="text" name="einddatum" value="2016- 24:00:00" /><br>
<input type="submit" name="voorraadName" value="voorraad" />
</form>-->
<div class="container">
<form name="index" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" value="1" name="zendform" />
<div class="left">
selecteer reason: <br><select name="reason" size="12" >
<?php
print " <option selected value=\" \"></option> ";
// while ($row = mysqli_fetch_assoc($resultcat)) {
// echo ("<option value=\"" . $reason["1"] . "\">" . $reason["stock.in.purchase"] . "</option>\n");
echo ("<option value = '1' >stock in purchase </option>\n");
echo ("<option value = '2' >stock in refund </option>\n");
echo ("<option value = '4' >stock in movement </option>\n");
echo ("<option value = '-1' >stock out sale </option>\n");
echo ("<option value = '-2' >stock out refund </option>\n");
echo ("<option value = '-3' >stock out break </option>\n");
echo ("<option value = '-4' >stock out movement </option>\n");
echo ("<option value = '-5' >stock out sample </option>\n");
echo ("<option value = '-6' >stock out free </option>\n");
echo ("<option value = '-7' >stock out used </option>\n");
echo ("<option value = '-8' >stock out subtract </option>\n");
// }
?>
</select><br><br>
</div>
<div class="float">
geef de begindatum JJJJ-MM-DD HH:MM:SS : <input type="text" name="begindatum" value="2019 00:00:00" /><br>
geef de einddatum JJJJ-MM-DD HH:MM:SS : <input type="text" name="einddatum" value="2019 24:00:00" /><br>
</div>
<div class="bottom">
<input type="submit" name="submit" value="selectie"/>
</div>
</form>
</div>
<?php
if (isset($_POST['zendform'])) {
$reason = $_POST['reason'];
echo "reason " . $reason . "<br>";
if ($reason == -1) {echo 'stock out sale' ."<br>" ;}
$begindatum = $_POST['begindatum'];
echo 'begindatum' . $begindatum . "<br>";
$einddatum = $_POST['einddatum'];
echo 'einddatum' . $einddatum . "<br><br>";
?>
<?php
$sql = "Select
categories.NAME as cat,
products.NAME As product,
PRODUCTS.ID as productID,
stockdiary.DATENEW datum,
stockdiary.REASON,
stockcurrent.units as magazijn,
locations.NAME As loc,
locations.id as locid,
stockdiary.UNITS as units,
PRODUCTS.CODE as EAN
From categories
Inner Join products On products.CATEGORY = categories.ID
Inner Join stockdiary On stockdiary.PRODUCT = products.ID
Inner Join locations On stockdiary.LOCATION = locations.ID
inner join stockcurrent on stockcurrent.PRODUCT = products.id
Where
stockcurrent.LOCATION = '0' and
stockdiary.DATENEW > '" . $_POST["begindatum"] . "' AND stockdiary.DATENEW < '" . $_POST["einddatum"] . "' and
stockdiary.REASON = $reason
Order By
stockdiary.DATENEW,
categories.NAME,
products.NAME";
//stockdiary.DATENEW > '" . $_POST["begindatum"] . "' AND stockdiary.DATENEW < '" . $_POST["einddatum"] . "' and
//stockdiary.DATENEW > '2017-07-04' and
//products.REFERENCE as productID
// and categories.NAME = 'test stock' order by products.name ";
// PRODUCTS.NAME LIKE '%chocolaat%';";
// echo $sql . "<br>";
// echo $sel;
$con = my_conn();
$result = mysqli_query($con, $sql);
if ($result) {
?>
<table>
<tr>
<td><strong>catagorie</strong></td>
<td><strong>EAN </strong></td>
<td><strong>produkt </strong></td>
<td><strong>magazijn </strong></td>
<td><strong>lilina </strong></td>
<td><strong>am </strong></td>
<td><strong>mipi </strong></td>
<td></td>
</tr>
<?php
$i = 0;
$arResult = array();
while ($row = \mysqli_fetch_assoc($result)) {
$arResult[$i] = $row;
$arResult[$i]['lilina'] = '';
$arResult[$i]['am'] = '';
$arResult[$i]['mipi'] = '';
$i++;
}
// echo "<pre>";
// print_r($arResult);
// echo "<pre>";
$varProductID = array();
$resultaat = array(); //hulparray
$duplicates = array();
$count = 0;
for ($j = 0; $j < count($arResult); $j++) {
if (!in_array($arResult[$j]['productID'], $resultaat)) {
// $varProductID[$j] = $arResult[$j]['productID'];
$varProductID[$j] = $arResult[$j]; //zijn unieke waarden
if ($varProductID[$j]['locid'] == 'f8f72452-f51c-40c0-a930-b38e47275590') {
$varProductID[$j]['lilina'] = $varProductID[$j]['units'];
}
if ($varProductID[$j]['locid'] == '2') {
$varProductID[$j]['am'] = $varProductID[$j]['units'];
}
if ($varProductID[$j]['locid'] == 'bc68d81f-df91-473d-a48f-666bfe130215') {
$varProductID[$j]['mipi'] = $varProductID[$j]['units'];
}
}
if (in_array($arResult[$j]['productID'], $resultaat)) {
$duplicates[$j] = $arResult[$j]; //zijn dubbele waarden
$count++;
}
$resultaat[$j] = $arResult[$j]['productID'];
}
}
// echo "<pre>";
// print_r($duplicates);
// echo "<pre>";
$duplicates = array_values($duplicates);
$varProductID = array_values($varProductID);
// echo 'aantal varproductid' . count($varProductID);
for ($i = 0; $i < count($varProductID); $i++) {
foreach ($duplicates as $dub) {
if ($dub['productID'] == $varProductID[$i]['productID']) {
if ($dub['locid'] == 'f8f72452-f51c-40c0-a930-b38e47275590') {
$varProductID[$i]['lilina'] = $varProductID[$i]['lilina'] + $dub['units'];
}
if ($dub['locid'] == '2') {
$varProductID[$i]['am'] = $varProductID[$i]['am'] + $dub['units'];
}
if ($dub['locid'] == 'bc68d81f-df91-473d-a48f-666bfe130215') {
$varProductID[$i]['mipi'] = $varProductID[$i]['mipi'] + $dub['units'];
}
}
}
}
foreach ($varProductID as $uniek) {
echo("<tr>\n<td>" . $uniek['cat'] . "</td> ");
echo("<td>" . $uniek['EAN'] . "</td> ");
echo("<td>" . $uniek['product'] . "</td> ");
echo("<td>" . $uniek['magazijn'] . "</td> ");
echo("<td>" . $uniek['lilina'] . "</td>");
echo("<td>" . $uniek['am'] . "</td>");
echo("<td>" . $uniek['mipi'] . "</td>");
}
}
?>
</table>
<form name="hoofdmenu" action="index.php" method="POST">
<input type="submit" value="hoofdmenu" />
</form>
</body>
</html>