-
Notifications
You must be signed in to change notification settings - Fork 0
/
printer.php
52 lines (41 loc) · 1.43 KB
/
printer.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
<?php
require 'helper/mysqli.php';
header('Content-Type: text/html; charset=utf-8');
if(isset($_GET['pass']) && $_GET['pass'] == "kkpass123"){
if(isset($_GET['error'])){
$myfile = fopen("printerror.txt", "a");
fwrite($myfile, "\r\n". date('Y-m-d H:i:s'). "\r\n");
fwrite($myfile, $_GET['error']);
fclose($myfile);
return;
}else{
$myfile = fopen("log/printerlog.txt", "w");
fwrite($myfile,date('Y-m-d H:i:s'));
fclose($myfile);
}
$id = "";
$str = "NO_DATA";
$mysqli = connect();
if($results = $mysqli->query("SELECT p.id as id, p.amount as amount,pr.name as prod,p.expire as expire, s.name as sup, p.time as time, pr.unit as unit from pallet p,product pr, supplier s WHERE p.deleted = 0 and p.printed = 0 and p.product_id = pr.id and p.supplier_id = s.id")){
while($row = $results->fetch_assoc()) {
if($row['expire'] == "0000-00-00 00:00:00" || $row['expire'] == "" || $row['expire'] == "NULL"){
$expire = " ";
}else{
$expire = "szav. ido: ".substr($row['expire'],0,10);
}
$str = $row['id']."#_#".$row['amount']."#_#".$row['prod']."#_#".$row['time']."#_#".$row['sup']."#_#".$row['unit']."#_#".$expire."#_#";
$id = $row['id'];
break;
}
$results->free();
}else{
$str = "ERROR";
}
if($str != "NO_DATA" && str != "ERROR" && $id != "" && !isset($_GET['test'])){
update("UPDATE pallet SET printed = '1' WHERE id = '".$id."'");
}
// close connection
$mysqli->close();
print $str;
}
?>