forked from MarvinBellmann/SCM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuy.php
68 lines (56 loc) · 2.09 KB
/
buy.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
<?php
header('Content-Type: text/javascript; charset=UTF-8');
$db = mysqli_connect("lvps87-230-14-183.dedicated.hosteurope.de", "bas-erp", "erplogin");
mysqli_query($db, "SET NAMES 'utf8'");
if(!$db)
{
echo "Verbindungsfehler: ".mysqli_connect_error();
}
$pid = $_POST['id'];
$sqlQuery = "SELECT p.id,firma,ort,email,telefon_nr FROM erp.person p LEFT JOIN erp.lieferanten_betriebsmittel l ON (p.id = l.person_id) WHERE l.betriebsmittel_id = '$pid'";
if($_POST['lieferant'] != "") {
$sqlQuery .= "AND firma LIKE '%".$_POST['lieferant']."%'";
}
if($_POST['ort'] != "") {
$sqlQuery .= "AND ort LIKE '%".$_POST['ort']."%'";
}
$result = mysqli_query($db, $sqlQuery);
$rows = $result->num_rows;
$successful = ($rows >= 1);
// Lieferzeit
$sqlQueryDuration = "SELECT lieferdauer,max_bestellmenge,min_bestellmenge FROM erp.kreditor k LEFT JOIN erp.lieferanten_betriebsmittel l ON (k.person_id = l.person_id) WHERE l.betriebsmittel_id = '$pid'";
$resultKreditor = mysqli_query($db, $sqlQueryDuration);
$rowsKreditor = $resultKreditor->num_rows;
$seller = array('successful' => true, 'count' => $rows);
for($i=0; $i < $rows; $i++) {
$mysql_array = mysqli_fetch_array($result, MYSQL_NUM);
array_push($seller, $mysql_array);
$array_Kreditor = mysqli_fetch_array($resultKreditor, MYSQL_NUM);
array_push($seller, $array_Kreditor);
$id = $mysql_array[0];
$sqlQueryRank = "SELECT bewertung FROM erp.auftraege_bestellung b WHERE b.person_id = '$id'";
if($_POST['date'] != "") {
$sqlQueryRank .= "AND bestelldatum >= '".$_POST['date']."'";
}
$resultRank = mysqli_query($db, $sqlQueryRank);
$rowsRank = $resultRank->num_rows;
$ranking = 0;
if ($rowsRank > 0) {
$add = 0;
for($j=0; $j < $rowsRank; $j++) {
$array_Rank = mysqli_fetch_array($resultRank, MYSQL_NUM);
$rank = $array_Rank[0];
$add =+ $rank;
}
$ranking = ($add / $rowsRank);
array_push($seller, $ranking);
}
}
if($successful) {
//$seller = array('successful' => true);
echo $_GET['callback'].'('.json_encode($seller) .')';
} else {
echo $_GET['callback'].'('.json_encode(array('successful' => false)) .')';
}
mysqli_free_result($result);
?>