|
@@ -17,36 +17,33 @@ switch ($_REQUEST['a']) {
|
|
|
$datum = $_REQUEST['datum'];
|
|
|
$start = ($_REQUEST['start'] == "null") ? '00:00:00' : $_REQUEST['start'];
|
|
|
|
|
|
- if (count($data) > 0) {
|
|
|
+ $q = $dbh->query("SELECT sm.*, k.whitelist FROM status_meldung sm
|
|
|
+ INNER JOIN kunden k USING (kunde)
|
|
|
+ WHERE sm.datum = '{$datum}' AND sm.kunde = '{$kunde}' AND sm.start = '{$start}' LIMIT 1");
|
|
|
+ $result = $q->fetch(PDO::FETCH_ASSOC);
|
|
|
+ if ($result) {
|
|
|
+ $result['fehlerbericht'] = str_replace("\r\`", "`", str_replace("\r\"", "\"", str_replace("\r\n", "", $result['fehlerbericht'])));
|
|
|
+ $fehlerbericht = json_decode($result['fehlerbericht'], true);
|
|
|
+ if ($fehlerbericht != "") {
|
|
|
+ $result['fehlerbericht'] = $fehlerbericht;
|
|
|
+ }
|
|
|
|
|
|
+ $result['whitelist'] = (isset($result['whitelist'])) ? json_decode(stripslashes($result['whitelist']), true) : null;
|
|
|
} else {
|
|
|
- $q = $dbh->query("SELECT sm.*, k.whitelist FROM status_meldung sm
|
|
|
- INNER JOIN kunden k USING (kunde)
|
|
|
- WHERE sm.datum = '{$datum}' AND sm.kunde = '{$kunde}' AND sm.start = '{$start}' LIMIT 1");
|
|
|
- $result = $q->fetch(PDO::FETCH_ASSOC);
|
|
|
- if ($result) {
|
|
|
- $result['fehlerbericht'] = str_replace("\r\`", "`", str_replace("\r\"", "\"", str_replace("\r\n", "", $result['fehlerbericht'])));
|
|
|
- $fehlerbericht = json_decode($result['fehlerbericht'], true);
|
|
|
- if ($fehlerbericht) {
|
|
|
- $result['fehlerbericht'] = $fehlerbericht;
|
|
|
- }
|
|
|
-
|
|
|
- $result['whitelist'] = (isset($result['whitelist'])) ? json_decode(stripslashes($result['whitelist']), true) : null;
|
|
|
- } else {
|
|
|
- $result = array();
|
|
|
- }
|
|
|
- if (isset($result['kommentar_id']) && $result['kommentar_id'] > 0) {
|
|
|
- $q = $dbh->query("SELECT sk.* FROM status_kommentar sk
|
|
|
- WHERE sk.id = '{$result['kommentar_id']}' ");
|
|
|
- $comment = $q->fetch(PDO::FETCH_ASSOC);
|
|
|
- } else {
|
|
|
- $q = $dbh->query("SELECT sk.* FROM status_kommentar sk
|
|
|
- WHERE sk.datum = '{$datum}' AND sk.kunde = '{$kunde}' AND sk.start = '{$start}'
|
|
|
- ORDER BY cdate DESC LIMIT 1");
|
|
|
- $comment = $q->fetch(PDO::FETCH_ASSOC);
|
|
|
- }
|
|
|
- $result['kommentar'] = ($comment) ? $comment : array();
|
|
|
+ $result = array();
|
|
|
}
|
|
|
+ if (isset($result['kommentar_id']) && $result['kommentar_id'] > 0) {
|
|
|
+ $q = $dbh->query("SELECT sk.* FROM status_kommentar sk
|
|
|
+ WHERE sk.id = '{$result['kommentar_id']}' ");
|
|
|
+ $comment = $q->fetch(PDO::FETCH_ASSOC);
|
|
|
+ } else {
|
|
|
+ $q = $dbh->query("SELECT sk.* FROM status_kommentar sk
|
|
|
+ WHERE sk.datum = '{$datum}' AND sk.kunde = '{$kunde}' AND sk.start = '{$start}'
|
|
|
+ ORDER BY cdate DESC LIMIT 1");
|
|
|
+ $comment = $q->fetch(PDO::FETCH_ASSOC);
|
|
|
+ }
|
|
|
+ $result['kommentar'] = ($comment) ? $comment : array();
|
|
|
+
|
|
|
break;
|
|
|
|
|
|
case 'zeit':
|
|
@@ -119,7 +116,7 @@ switch ($_REQUEST['a']) {
|
|
|
|
|
|
break;
|
|
|
case 'kunden':
|
|
|
- if (count($data) > 0) {
|
|
|
+ if ($data != null && count($data) > 0) {
|
|
|
foreach ($data as $kunde) {
|
|
|
if (isset($kunde['kunde'])) {
|
|
|
$q = $dbh->exec("UPDATE kunden SET system = '{$kunde['system']}', start_soll = '{$kunde['start_soll']}', ende_soll = '{$kunde['ende_soll']}',
|
|
@@ -137,7 +134,7 @@ switch ($_REQUEST['a']) {
|
|
|
break;
|
|
|
|
|
|
case 'tickets':
|
|
|
- if (count($data) > 0) {
|
|
|
+ if ($data != null && count($data) > 0) {
|
|
|
if ($data['id'] == '') {
|
|
|
$q = $dbh->exec("INSERT INTO tickets (datum, benutzer, kunde, kontakt, beschreibung, termin, dauer, status, prioritaet, fortschritt, kategorie, programm, kommentar)
|
|
|
VALUES ('{$data['datum']}', '{$data['benutzer']}', '{$data['kunde']}', '{$data['kontakt']}', '{$data['beschreibung']}', '{$data['termin']}', '{$data['dauer']}',
|
|
@@ -152,6 +149,7 @@ switch ($_REQUEST['a']) {
|
|
|
}
|
|
|
$q = $dbh->query("SELECT * FROM tickets");
|
|
|
$result = $q->fetchAll(PDO::FETCH_ASSOC);
|
|
|
+ //print_r($result);
|
|
|
break;
|
|
|
|
|
|
case 'config':
|
|
@@ -180,7 +178,7 @@ switch ($_REQUEST['a']) {
|
|
|
case 'kommentar':
|
|
|
$id = (isset($_REQUEST['id']) && $_REQUEST['id'] != "undefined") ? $_REQUEST['id'] : '';
|
|
|
|
|
|
- if (count($data) > 0) {
|
|
|
+ if ($data != null && count($data) > 0) {
|
|
|
if ($id == '') {
|
|
|
$now = date('Y-m-d H:i:s');
|
|
|
$q = $dbh->exec("INSERT INTO status_kommentar (kunde, datum, start, benutzer, fehler, status, kommentar, cdate)
|
|
@@ -257,4 +255,5 @@ switch ($_REQUEST['a']) {
|
|
|
}
|
|
|
}
|
|
|
echo json_encode($result);
|
|
|
+// print_r($result);
|
|
|
// echo json_last_error();
|