Added ticketregel from ticket button

This commit is contained in:
OpenXE 2023-08-02 14:25:38 +02:00
parent 5557c54fd6
commit 0262c31e93
3 changed files with 105 additions and 76 deletions

View File

@ -49,6 +49,7 @@
<legend>{|Aktionen|}</legend>
<td><button name="submit" value="speichern" class="ui-button-icon" style="width:100%;">Speichern</button></td></tr>
<td><button name="submit" value="neue_email" class="ui-button-icon" style="width:100%;">Neue E-Mail</button></td></tr>
<td><button name="submit" formaction="index.php?module=ticketregeln&action=create" value="regel" class="ui-button-icon" style="width:100%;">Ticketregel erstellen</button><input hidden type="text" name="ticketid" value="[ID]"></td></tr>
</table>
</fieldset>
</div>
@ -61,4 +62,3 @@
</div>
</div>

View File

@ -17,18 +17,18 @@
<div class="col-xs-12 col-md-12 col-md-height">
<div class="inside inside-full-height">
<fieldset>
<legend>{|Ticketregeln|}</legend><i>Ticketregeln f&uuml; die Verarbeitung bei Ticketeingang. Platzhalter werden mit % angegeben.</i>
<legend>{|Ticketregeln|}</legend><i>Ticketregeln f&uuml;r die Verarbeitung bei Ticketeingang. Platzhalter werden mit % angegeben.</i>
<table width="100%" border="0" class="mkTableFormular">
<tr><td>{|E-Mail Empf&auml;nger|}:</td><td><input type="text" name="empfaenger_email" value="[EMPFAENGER_EMAIL]" size="40"></td></tr>
<tr><td>{|E-Mail Verfasser|}:</td><td><input type="text" name="sender_email" value="[SENDER_EMAIL]" size="40"></td></tr>
<tr><td>{|Verfasser Name|}:</td><td><input type="text" name="name" value="[NAME]" size="40"></td></tr>
<tr><td>{|Betreff|}:</td><td><input type="text" name="betreff" value="[BETREFF]" size="40"></td></tr>
<tr><td>{|Papierkorb|}:</td><td><input type="text" name="spam" value="[SPAM]" size="40"></td></tr>
<tr><td>{|Pers&ouml;nlich|}:</td><td><input type="text" name="persoenlich" value="[PERSOENLICH]" size="40"></td></tr>
<tr><td>{|Prio|}:</td><td><input type="text" name="prio" value="[PRIO]" size="40"></td></tr>
<tr><td>{|DSGVO|}:</td><td><input type="text" name="dsgvo" value="[DSGVO]" size="40"></td></tr>
<tr><td>{|Papierkorb|}:</td><td><input type="checkbox" name="spam" value="1" [SPAM] size="40"></td></tr>
<tr><td>{|Pers&ouml;nlich|}:</td><td><input type="checkbox" name="persoenlich" value="1" [PERSOENLICH] size="40"></td></tr>
<tr><td>{|Prio|}:</td><td><input type="checkbox" name="prio" value="1" [PRIO] size="40"></td></tr>
<tr><td>{|DSGVO|}:</td><td><input type="checkbox" name="dsgvo" value="1" [DSGVO] size="40"></td></tr>
<tr><td>{|Verantwortliche Warteschlange|}:</td><td><input type="text" name="warteschlange" id="warteschlange" value="[WARTESCHLANGE]" size="40"></td></tr>
<tr><td>{|Aktiv|}:</td><td><input type="text" name="aktiv" value="[AKTIV]" size="40"></td></tr>
<tr><td>{|Aktiv|}:</td><td><input type="checkbox" name="aktiv" value="1" [AKTIV] size="40"></td></tr>
</table>
</fieldset>
@ -36,31 +36,6 @@
</div>
</div>
</div>
<!-- Example for 2nd row
<div class="row">
<div class="row-height">
<div class="col-xs-12 col-md-12 col-md-height">
<div class="inside inside-full-height">
<fieldset>
<legend>{|Another legend|}</legend>
<table width="100%" border="0" class="mkTableFormular">
<tr><td>{|Empfaenger_email|}:</td><td><input type="text" name="empfaenger_email" value="[EMPFAENGER_EMAIL]" size="40"></td></tr>
<tr><td>{|Sender_email|}:</td><td><input type="text" name="sender_email" value="[SENDER_EMAIL]" size="40"></td></tr>
<tr><td>{|Name|}:</td><td><input type="text" name="name" value="[NAME]" size="40"></td></tr>
<tr><td>{|Betreff|}:</td><td><input type="text" name="betreff" value="[BETREFF]" size="40"></td></tr>
<tr><td>{|Spam|}:</td><td><input type="text" name="spam" value="[SPAM]" size="40"></td></tr>
<tr><td>{|Persoenlich|}:</td><td><input type="text" name="persoenlich" value="[PERSOENLICH]" size="40"></td></tr>
<tr><td>{|Prio|}:</td><td><input type="text" name="prio" value="[PRIO]" size="40"></td></tr>
<tr><td>{|Dsgvo|}:</td><td><input type="text" name="dsgvo" value="[DSGVO]" size="40"></td></tr>
<tr><td>{|Warteschlange|}:</td><td><input type="text" name="warteschlange" value="[WARTESCHLANGE]" size="40"></td></tr>
<tr><td>{|Aktiv|}:</td><td><input type="text" name="aktiv" value="[AKTIV]" size="40"></td></tr>
</table>
</fieldset>
</div>
</div>
</div>
</div> -->
<input type="submit" name="submit" value="Speichern" style="float:right"/>
</form>
</div>

View File

@ -98,67 +98,121 @@ class Ticketregeln {
if (empty($id)) {
// New item
$id = 'NULL';
// Check for ticketid
$ticketid = $this->app->Secure->GetPOST('ticketid');
if (!empty($ticketid)) {
$sql = "
SELECT
n.id,
n.betreff,
n.bearbeiter,
n.verfasser,
n.mail,
t.quelle,
t.warteschlange,
".$this->app->erp->FormatDateTimeShort('n.zeit','zeit').",
".$this->app->erp->FormatDateTimeShort('n.zeitausgang','zeitausgang').",
n.versendet,
n.text,
n.textausgang,
n.verfasser_replyto,
n.mail_replyto,
n.mail_cc,
(SELECT GROUP_CONCAT(value SEPARATOR ', ') FROM ticket_header th WHERE th.ticket_nachricht = n.id AND th.type = 'cc') as mail_cc_recipients,
(SELECT GROUP_CONCAT(value SEPARATOR ', ') FROM ticket_header th WHERE th.ticket_nachricht = n.id AND th.type = 'to') as mail_recipients
FROM ticket_nachricht n INNER JOIN ticket t ON t.schluessel = n.ticket
WHERE t.id = ".$ticketid." ORDER BY n.zeit DESC LIMIT 1";
$last_message = $this->app->DB->SelectArr($sql)[0];
$input['empfaenger_email'] = $last_message['mail_recipients'];
$input['sender_email'] = $last_message['mail'];
$input['name'] = $last_message['verfasser'];
$input['betreff'] = $last_message['betreff'];
$input['warteschlange'] = $last_message['warteschlange'];
$from_ticket = true;
$result = array(
'empfaenger_email' => $last_message['mail_recipients'],
'sender_email' => $last_message['mail'],
'name' => $last_message['verfasser'],
'betreff' => $last_message['betreff'],
'warteschlange' => $last_message['warteschlange'],
'aktiv' => 1
);
}
}
if ($submit != '')
{
if (!$from_ticket) {
// Write to database
if ($submit != '')
{
// Add checks here
$input['warteschlange'] = explode(" ",$input['warteschlange'])[0]; // Just the label
// Write to database
$columns = "id, ";
$values = "$id, ";
$update = "";
// Add checks here
$input['warteschlange'] = explode(" ",$input['warteschlange'])[0]; // Just the label
$fix = "";
$columns = "id, ";
$values = "$id, ";
$update = "";
foreach ($input as $key => $value) {
$columns = $columns.$fix.$key;
$values = $values.$fix."'".$value."'";
$update = $update.$fix.$key." = '$value'";
$fix = "";
$fix = ", ";
foreach ($input as $key => $value) {
$columns = $columns.$fix.$key;
$values = $values.$fix."'".$value."'";
$update = $update.$fix.$key." = '$value'";
$fix = ", ";
}
// echo($columns."<br>");
// echo($values."<br>");
// echo($update."<br>");
$sql = "INSERT INTO ticket_regeln (".$columns.") VALUES (".$values.") ON DUPLICATE KEY UPDATE ".$update;
// echo($sql);
$this->app->DB->Update($sql);
if ($id == 'NULL') {
$msg = $this->app->erp->base64_url_encode("<div class=\"success\">Das Element wurde erfolgreich angelegt.</div>");
header("Location: index.php?module=ticketregeln&action=list&msg=$msg");
// $this->app->Tpl->Set('MESSAGE', "<div class=\"success\">Das Element wurde erfolgreich angelegt.</div>");
// $id = $this->app->DB->GetInsertID();
} else {
$this->app->Tpl->Set('MESSAGE', "<div class=\"success\">Die Einstellungen wurden erfolgreich &uuml;bernommen.</div>");
}
}
// echo($columns."<br>");
// echo($values."<br>");
// echo($update."<br>");
$sql = "INSERT INTO ticket_regeln (".$columns.") VALUES (".$values.") ON DUPLICATE KEY UPDATE ".$update;
// echo($sql);
$this->app->DB->Update($sql);
if ($id == 'NULL') {
$msg = $this->app->erp->base64_url_encode("<div class=\"success\">Das Element wurde erfolgreich angelegt.</div>");
header("Location: index.php?module=ticketregeln&action=list&msg=$msg");
} else {
$this->app->Tpl->Set('MESSAGE', "<div class=\"success\">Die Einstellungen wurden erfolgreich &uuml;bernommen.</div>");
}
// Load values again from database
$result = $this->app->DB->SelectArr("SELECT t.id, t.empfaenger_email, t.sender_email, t.name, t.betreff, t.spam, t.persoenlich, t.prio, t.dsgvo, CONCAT(w.label,' ',w.warteschlange) as warteschlange, t.aktiv, t.id FROM ticket_regeln t LEFT JOIN warteschlangen w on t.warteschlange = w.label WHERE t.id=$id")[0];
}
// Load values again from database
$result = $this->app->DB->SelectArr("SELECT t.id, t.empfaenger_email, t.sender_email, t.name, t.betreff, t.spam, t.persoenlich, t.prio, t.dsgvo, t.warteschlange, t.aktiv, t.id FROM ticket_regeln t"." WHERE id=$id");
foreach ($result[0] as $key => $value) {
foreach ($result as $key => $value) {
$this->app->Tpl->Set(strtoupper($key), $value);
}
/*
* Add displayed items later
*
$this->app->Tpl->Add('KURZUEBERSCHRIFT2', $email);
$this->app->Tpl->Add('EMAIL', $email);
$this->app->Tpl->Add('ANGEZEIGTERNAME', $angezeigtername);
*/
$this->app->YUI->AutoComplete("warteschlange","warteschlangename");
$this->app->Tpl->Set('PRIO', $result['prio']==1?"checked":"");
$this->app->Tpl->Set('SPAM', $result['spam']==1?"checked":"");
$this->app->Tpl->Set('PERSOENLICH', $result['persoenlich']==1?"checked":"");
$this->app->Tpl->Set('DSGVO', $result['dsgvo']==1?"checked":"");
$this->app->Tpl->Set('AKTIV', $result['aktiv']==1?"checked":"");
$this->app->YUI->AutoComplete("warteschlange","warteschlangename");
// $this->SetInput($input);
$this->app->Tpl->Parse('PAGE', "ticketregeln_edit.tpl");