2022-07-22 17:42:03 +02:00
< ? php
/*
* Copyright ( c ) 2022 Xenomporio project
*/
use Xentral\Components\Database\Exception\QueryFailureException ;
2022-07-29 14:45:16 +02:00
use Xentral\Modules\Ticket\Task ;
2022-07-22 17:42:03 +02:00
class Ticket {
function __construct ( $app , $intern = false ) {
$this -> app = $app ;
if ( $intern )
return ;
$this -> app -> ActionHandlerInit ( $this );
$this -> app -> ActionHandler ( " list " , " ticket_list " );
2022-07-29 14:45:16 +02:00
$this -> app -> ActionHandler ( " create " , " ticket_create " ); // This automatically adds a "New" button
2022-07-22 17:42:03 +02:00
$this -> app -> ActionHandler ( " edit " , " ticket_edit " );
2022-07-24 21:10:33 +02:00
$this -> app -> ActionHandler ( " edit_raw " , " ticket_edit_raw " );
2022-07-22 17:42:03 +02:00
$this -> app -> ActionHandler ( " delete " , " ticket_delete " );
$this -> app -> DefaultActionHandler ( " list " );
$this -> app -> ActionHandlerListen ( $app );
}
public function Install () {
/* Fill out manually later */
}
2022-07-24 21:10:33 +02:00
function ticket_status_icon ( string $status ) {
return ( '<img src="./themes/new/images/status_' . $status . '.png" style="margin-right:1px" title="' . $status . '" border="0">' );
}
2022-07-22 17:42:03 +02:00
static function TableSearch ( & $app , $name , $erlaubtevars ) {
function ticket_iconssql () {
return " CONCAT('<img src= \" ./themes/new/images/status_',`t`.`status`,'.png \" style= \" margin-right:1px \" title= \" ',`t`.`status`,' \" border= \" 0 \" >') " ;
}
2022-07-24 21:10:33 +02:00
2022-07-22 17:42:03 +02:00
switch ( $name ) {
case " ticket_list " :
$allowed [ 'ticket_list' ] = array ( 'list' );
$heading = array ( '' , '' , 'Ticket #' , 'Datum' , 'Adresse' , 'Betreff' , 'Notiz' , 'Tags' , 'Verantwortlich' , 'Anzahl Nachrichten' , 'Status' , 'Alter' , 'Projekt' , 'Menü' );
$width = array ( '1%' , '1%' , '5%' , '5%' , '5%' , '20%' , '20%' , '5%' , '5%' , '1%' , '1%' , '5%' , '5%' , '5%' );
2022-07-26 17:36:24 +02:00
$findcols = array ( 't.id' , 't.id' , 't.schluessel' , 't.zeit' , 't.bearbeiter' , 'a.name' , 't.betreff' , 't.notiz' , 't.tags' , 'w.warteschlange' , 'nachrichten_anz' , 't.status' , 't.projekt' );
2022-07-24 21:10:33 +02:00
$searchsql = array ( 't.schluessel' , 't.zeit' , 't.bearbeiter' , 'a.name' , 't.betreff' , 't.notiz' , 't.tags' , 'w.warteschlange' , 't.status' , 't.projekt' );
2022-07-22 17:42:03 +02:00
$defaultorder = 1 ;
$defaultorderdesc = 0 ;
$menu = " <table cellpadding=0 cellspacing=0><tr><td nowrap> " . " <a href= \" index.php?module=ticket&action=edit&id=%value% \" ><img src= \" ./themes/ { $app -> Conf -> WFconf [ 'defaulttheme' ] } /images/edit.png \" border= \" 0 \" ></a> <a href= \" # \" onclick=DeleteDialog( \" index.php?module=ticket&action=delete&id=%value% \" );> " . " <img src= \" themes/ { $app -> Conf -> WFconf [ 'defaulttheme' ] } /images/delete.svg \" border= \" 0 \" ></a> " . " </td></tr></table> " ;
$timedifference = " if (
TIMESTAMPDIFF ( hour , t . zeit , curdate ()) < 24 ,
CONCAT ( TIMESTAMPDIFF ( hour , t . zeit , curdate ()), 'h ' ),
CONCAT (
TIMESTAMPDIFF ( day , t . zeit , curdate ()), 'd ' , MOD ( TIMESTAMPDIFF ( hour , t . zeit , curdate ()), 24 ), 'h' )) " ;
$dropnbox = " '<img src=./themes/new/images/details_open.png class=details>' AS `open`, CONCAT('<input type= \" checkbox \" name= \" auswahl[] \" value= \" ',t.id,' \" />') AS `auswahl` " ;
2022-07-26 17:36:24 +02:00
$sql = " SELECT t.id, " . $dropnbox . " , t.schluessel, t.zeit, a.name, t.betreff, t.notiz, t.tags, w.warteschlange, (SELECT COUNT(n.id) FROM ticket_nachricht n WHERE n.ticket = t.schluessel) as nachrichten_anz, " . ticket_iconssql () . " , " . $timedifference . " , p.abkuerzung, t.id
2022-07-22 17:42:03 +02:00
FROM ticket t
LEFT JOIN adresse a ON t . adresse = a . id
2022-07-24 21:10:33 +02:00
LEFT JOIN warteschlangen w ON t . warteschlange = w . label
2022-07-22 17:42:03 +02:00
LEFT JOIN projekt p on t . projekt = p . id " ;
$where = " 1 " ;
$moreinfo = true ; // Allow drop down details
$menucol = 13 ; // For moredata
$count = " SELECT count(DISTINCT id) FROM ticket WHERE $where " ;
// $groupby = "";
break ;
}
$erg = false ;
foreach ( $erlaubtevars as $k => $v ) {
if ( isset ( $$v )) {
$erg [ $v ] = $$v ;
}
}
return $erg ;
}
function ticket_list () {
$this -> app -> erp -> MenuEintrag ( " index.php?module=ticket&action=list " , " Übersicht " );
$this -> app -> erp -> MenuEintrag ( " index.php?module=ticket&action=create " , " Neu anlegen " );
$this -> app -> erp -> MenuEintrag ( " index.php " , " Zurück " );
$this -> app -> YUI -> TableSearch ( 'TAB1' , 'ticket_list' , " show " , " " , " " , basename ( __FILE__ ), __CLASS__ );
$this -> app -> Tpl -> Parse ( 'PAGE' , " ticket_list.tpl " );
}
public function ticket_delete () {
$id = ( int ) $this -> app -> Secure -> GetGET ( 'id' );
$this -> app -> DB -> Delete ( " DELETE FROM `ticket` WHERE `id` = ' { $id } ' " );
$this -> app -> Tpl -> Set ( 'MESSAGE' , " <div class= \" error \" >Der Eintrag wurde gelöscht.</div> " );
$this -> ticket_list ();
}
2022-07-29 14:45:16 +02:00
function get_messages_of_ticket ( $ticket_id , $where ) {
return $this -> app -> DB -> SelectArr ( " SELECT n.id, n.betreff, n.verfasser, n.mail, n.mail_cc, n.zeit, n.zeitausgang, n.versendet, n.text, n.verfasser_replyto, mail_replyto FROM ticket_nachricht n INNER JOIN ticket t ON t.schluessel = n.ticket WHERE ( " . $where . " ) AND t.id = " . $ticket_id . " ORDER BY n.zeit DESC " );
2022-07-27 18:05:24 +02:00
}
2022-07-22 17:42:03 +02:00
2022-07-29 14:45:16 +02:00
/**
* @ throws NumberGeneratorException
*
* @ return string
*/
private function generateRandomTicketNumber () : string
{
$random = rand ( 300 , 700 );
$loopCounter = 0 ;
while ( true ) {
$candidate = sprintf ( '%s%04d' , date ( 'Ymd' ), $random ++ );
if ( ! $this -> app -> DB -> Select ( 'SELECT id FROM ticket WHERE schluessel = ' . $candidate )) {
return ( $candidate );
}
if ( $loopCounter > 99 ) {
throw new NumberGeneratorException ( 'ticket number generation failed' );
}
$loopCounter ++ ;
}
}
function ticket_save_to_db ( $id , $input ) {
// Write to database
// Add checks here
2022-07-22 17:42:03 +02:00
if ( empty ( $id )) {
// New item
$id = 'NULL' ;
}
2022-07-29 14:45:16 +02:00
$input [ 'projekt' ] = $this -> app -> erp -> ReplaceProjekt ( true , $input [ 'projekt' ], true ); // Parameters: Target db?, value, from form?
$input [ 'adresse' ] = $this -> app -> erp -> ReplaceAdresse ( true , $input [ 'adresse' ], true ); // Parameters: Target db?, value, from form?
$input [ 'warteschlange' ] = explode ( " " , $input [ 'warteschlange' ])[ 0 ]; // Just the label
2022-07-22 17:42:03 +02:00
2022-07-29 14:45:16 +02:00
$columns = " id, " ;
$values = " $id , " ;
$update = " " ;
2022-07-22 17:42:03 +02:00
2022-07-29 14:45:16 +02:00
$fix = " " ;
2022-07-24 21:10:33 +02:00
2022-07-29 14:45:16 +02:00
foreach ( $input as $key => $value ) {
2022-07-22 17:42:03 +02:00
2022-07-29 14:45:16 +02:00
if ( $this -> app -> DB -> ColumnExists ( 'ticket' , $key )) {
$columns = $columns . $fix . $key ;
$values = $values . $fix . " ' " . $value . " ' " ;
$update = $update . $fix . $key . " = ' $value ' " ;
$fix = " , " ;
}
}
2022-07-26 17:36:24 +02:00
2022-07-29 14:45:16 +02:00
$sql = " INSERT INTO ticket ( " . $columns . " ) VALUES ( " . $values . " ) ON DUPLICATE KEY UPDATE " . $update ;
2022-07-22 17:42:03 +02:00
2022-07-29 14:45:16 +02:00
$this -> app -> DB -> Update ( $sql );
$id = $this -> app -> DB -> GetInsertID ();
return ( $id );
}
2022-07-22 17:42:03 +02:00
2022-07-29 14:45:16 +02:00
function save_draft ( $id , $input ) {
$columns = " id, " ;
$values = " $id , " ;
$update = " " ;
2022-07-22 17:42:03 +02:00
2022-07-29 14:45:16 +02:00
$fix = " " ;
// Translate form to table
$input [ 'betreff' ] = $input [ 'email_betreff' ];
$input [ 'mail' ] = $input [ 'email_an' ];
$input [ 'mail_cc' ] = $input [ 'email_cc' ];
$input [ 'text' ] = $input [ 'email_text' ];
foreach ( $input as $key => $value ) {
if ( $this -> app -> DB -> ColumnExists ( 'ticket_nachricht' , $key )) {
$columns = $columns . $fix . $key ;
$values = $values . $fix . " ' " . $value . " ' " ;
$update = $update . $fix . $key . " = ' $value ' " ;
$fix = " , " ;
}
}
$sql = " INSERT INTO ticket_nachricht ( " . $columns . " ) VALUES ( " . $values . " ) ON DUPLICATE KEY UPDATE " . $update ;
$this -> app -> DB -> Update ( $sql );
}
function ticket_create () {
$submit = $this -> app -> Secure -> GetPOST ( 'submit' );
$input = $this -> GetInput ();
if ( $submit != '' ) {
$input [ 'schluessel' ] = $this -> generateRandomTicketNumber ();
$input [ 'zeit' ] = date ( 'Y-m-d H:i:s' , time ());
$input [ 'kunde' ] = $this -> app -> User -> GetName ();
$id = $this -> ticket_save_to_db ( $id , $input );
header ( " Location: index.php?module=ticket&action=edit&id= $id " );
exit ();
}
$this -> app -> Tpl -> Set ( 'STATUSICON' , $this -> ticket_status_icon ( 'neu' ) . " " );
$this -> app -> YUI -> AutoComplete ( " adresse " , " adresse " );
$this -> app -> YUI -> AutoComplete ( " projekt " , " projektname " , 1 );
$this -> app -> YUI -> AutoComplete ( " status " , " ticketstatus " , 1 );
$this -> app -> Tpl -> Set ( 'STATUS' , $this -> app -> erp -> GetStatusTicketSelect ( 'neu' ));
$this -> app -> YUI -> AutoComplete ( " warteschlange " , " warteschlangename " );
$this -> app -> Tpl -> Parse ( 'PAGE' , " ticket_create.tpl " );
}
function ticket_edit () {
$id = $this -> app -> Secure -> GetGET ( 'id' );
$this -> app -> Tpl -> Set ( 'ID' , $id );
$this -> app -> erp -> MenuEintrag ( " index.php?module=ticket&action=edit&id= $id " , " Details " );
$this -> app -> erp -> MenuEintrag ( " index.php?module=ticket&action=list " , " Zurück zur Übersicht " );
$id = $this -> app -> Secure -> GetGET ( 'id' );
$input = $this -> GetInput ();
$submit = $this -> app -> Secure -> GetPOST ( 'submit' );
$msg = $this -> app -> erp -> base64_url_decode ( $this -> app -> Secure -> GetGET ( 'msg' ));
// Always save
if ( $submit != '' )
{
$this -> ticket_save_to_db ( $id , $input );
$msg = " <div class= \" success \" >Die Einstellungen wurden erfolgreich übernommen.</div> " ;
2022-07-22 17:42:03 +02:00
}
// Load values again from database
2022-07-26 17:36:24 +02:00
$result = $this -> app -> DB -> SelectArr ( " SELECT t.id, t.schluessel, t.zeit, p.abkuerzung as projekt, t.bearbeiter, t.quelle, t.status, t.adresse, t.kunde, CONCAT(w.label,' ',w.warteschlange) as warteschlange, t.mailadresse, t.prio, t.betreff, t.zugewiesen, t.inbearbeitung, t.inbearbeitung_user, t.firma, t.notiz, t.bitteantworten, t.service, t.kommentar, t.privat, t.dsgvo, t.tags, t.nachrichten_anz, t.id FROM ticket t LEFT JOIN adresse a ON t.adresse = a.id LEFT JOIN projekt p on t.projekt = p.id LEFT JOIN warteschlangen w on t.warteschlange = w.label WHERE t.id= $id " );
2022-07-22 17:42:03 +02:00
foreach ( $result [ 0 ] as $key => $value ) {
$this -> app -> Tpl -> Set ( strtoupper ( $key ), $value );
}
2022-07-26 17:36:24 +02:00
$this -> app -> Tpl -> Set ( 'STATUSICON' , $this -> ticket_status_icon ( $result [ 0 ][ 'status' ]) . " " );
2022-07-24 21:10:33 +02:00
$this -> app -> YUI -> AutoComplete ( " adresse " , " adresse " );
$this -> app -> Tpl -> Set ( 'ADRESSE' , $this -> app -> erp -> ReplaceAdresse ( false , $result [ 0 ][ 'adresse' ], false )); // Convert ID to form display
$this -> app -> YUI -> AutoComplete ( " projekt " , " projektname " , 1 );
2022-07-26 17:36:24 +02:00
$this -> app -> YUI -> AutoComplete ( " status " , " ticketstatus " , 1 );
$this -> app -> Tpl -> Set ( 'STATUS' , $this -> app -> erp -> GetStatusTicketSelect ( $result [ 0 ][ 'status' ]));
2022-07-24 21:10:33 +02:00
$input [ 'projekt' ] = $this -> app -> erp -> ReplaceProjekt ( false , $input [ 'projekt' ], false ); // Parameters: Target db?, value, from form?
$this -> app -> YUI -> AutoComplete ( " warteschlange " , " warteschlangename " );
2022-07-29 14:45:16 +02:00
// END Header
// Check for draft
$drafted_messages = $this -> get_messages_of_ticket ( $id , " zeitausgang IS NULL " );
if ( ! empty ( $drafted_messages )) {
// Draft from form?
if ( $submit != '' ) {
$this -> save_draft ( $drafted_messages [ 0 ][ 'id' ], $input );
// Reload
$drafted_messages = $this -> get_messages_of_ticket ( $id , " zeitausgang IS NULL " );
}
// Load the draft for editing
$this -> app -> Tpl -> Set ( 'EMAIL_AN' , $drafted_messages [ 0 ][ 'mail' ]);
$this -> app -> Tpl -> Set ( 'EMAIL_CC' , $drafted_messages [ 0 ][ 'mail_cc' ]);
$this -> app -> Tpl -> Set ( 'EMAIL_BCC' , $drafted_messages [ 0 ][ 'mail_bcc' ]);
$this -> app -> Tpl -> Set ( 'EMAIL_BETREFF' , $drafted_messages [ 0 ][ 'betreff' ]);
$this -> app -> Tpl -> Set ( 'EMAIL_TEXT' , $drafted_messages [ 0 ][ 'text' ]);
// Show new message dialog
$this -> app -> Tpl -> Set ( 'EMAIL_SENDER' , $this -> app -> erp -> GetSelectEmailMitName ( $dokument [ 'von' ]));
$this -> app -> YUI -> AutoComplete ( " email_an " , " emailname " );
$this -> app -> YUI -> AutoComplete ( " email_cc " , " emailname " );
$this -> app -> YUI -> AutoComplete ( " email_bcc " , " emailname " );
$this -> app -> YUI -> CkEditor ( " email_text " , " internal " , null , 'JQUERY' );
$this -> app -> Tpl -> Parse ( 'NEW_MESSAGE' , " ticket_new_message.tpl " );
}
// END Draft
2022-07-24 21:10:33 +02:00
2022-07-29 14:45:16 +02:00
// Get all messsages
$messages = $this -> get_messages_of_ticket ( $id , 1 );
2022-07-24 21:10:33 +02:00
2022-07-26 17:36:24 +02:00
switch ( $submit ) {
case 'neue_email' :
2022-07-29 14:45:16 +02:00
if ( empty ( $drafted_messages )) {
// Create new message and save it for editing
2022-07-26 17:36:24 +02:00
2022-07-29 14:45:16 +02:00
$recv_messages = $this -> get_messages_of_ticket ( $id , " n.versendet != 1 " );
$this -> app -> Tpl -> Set ( 'EMAIL_AN' , $recv_messages [ 0 ][ 'mail' ]);
2022-07-27 21:26:59 +02:00
2022-07-29 14:45:16 +02:00
if ( ! str_starts_with ( strtoupper ( $recv_messages [ 0 ][ 'betreff' ]), " RE: " )) {
$betreff = " RE: " . $recv_messages [ 0 ][ 'betreff' ];
} else {
$betreff = $recv_messages [ 0 ][ 'betreff' ];
}
2022-07-27 21:26:59 +02:00
2022-07-29 14:45:16 +02:00
$anschreiben = $this -> app -> DB -> Select ( " SELECT anschreiben FROM adresse WHERE id=' " . $result [ 0 ][ 'adresse' ] . " ' LIMIT 1 " );
if ( $anschreiben == " " )
{
$anschreiben = $this -> app -> erp -> Beschriftung ( " dokument_anschreiben " ) . " , \n " . $this -> app -> erp -> Grussformel ( $projekt , $sprache );
}
2022-07-26 17:36:24 +02:00
2022-07-29 14:45:16 +02:00
$senderName = $this -> app -> User -> GetName () . " ( " . $this -> app -> erp -> GetFirmaAbsender () . " ) " ;
$senderAddress = $this -> app -> erp -> GetFirmaMail ();
$sql = " INSERT INTO `ticket_nachricht` (
`ticket` , `zeit` , `text` , `betreff` , `medium` , `versendet` ,
`verfasser` , `mail` , `status` , `verfasser_replyto` , `mail_replyto`
) VALUES ( '".$result[0][' schluessel ']."' , NOW (), '".$anschreiben."' , '".$betreff."' , 'email' , '1' , '' , '' , 'neu' , '".$senderName."' , '".$senderAddress."' ); " ;
2022-07-26 17:36:24 +02:00
2022-07-29 14:45:16 +02:00
$this -> app -> DB -> Insert ( $sql );
}
2022-07-26 17:36:24 +02:00
2022-07-29 14:45:16 +02:00
// Show new message dialog
2022-07-26 17:36:24 +02:00
$this -> app -> YUI -> AutoComplete ( " email_an " , " emailname " );
$this -> app -> YUI -> AutoComplete ( " email_cc " , " emailname " );
$this -> app -> YUI -> AutoComplete ( " email_bcc " , " emailname " );
$this -> app -> YUI -> CkEditor ( " email_text " , " internal " , null , 'JQUERY' );
$this -> app -> Tpl -> Parse ( 'NEW_MESSAGE' , " ticket_new_message.tpl " );
break ;
2022-07-29 14:45:16 +02:00
/*
case 'entwurfloeschen' :
if ( ! empty ( $drafted_messages )) {
$sql = " UPDATE ticket_nachricht SET ticket = '' WHERE id= " . $drafted_messages [ 0 ][ 'id' ];
$msg = $this -> app -> erp -> base64_url_encode ( " <div class= \" success \" >Das Element wurde gelöscht..</div> " );
header ( " Location: index.php?module=ticket&action=edit&msg= $msg &id= $id " );
}
break ;
case 'addfile' :
$msg .= $result [ 'userfile' ];
$this -> app -> Tpl -> Set ( 'EMAIL_AN' , $input [ 'email_an' ]);
$this -> app -> Tpl -> Set ( 'EMAIL_TEXT' , $input [ 'email_text' ]);
$this -> app -> Tpl -> Set ( 'EMAIL_BETREFF' , $input [ 'email_betreff' ]);
$this -> app -> Tpl -> Set ( 'EMAIL_SENDER' , $input [ 'email_sender' ]);
$this -> app -> YUI -> AutoComplete ( " email_an " , " emailname " );
$this -> app -> YUI -> AutoComplete ( " email_cc " , " emailname " );
$this -> app -> YUI -> AutoComplete ( " email_bcc " , " emailname " );
$this -> app -> YUI -> CkEditor ( " email_text " , " internal " , null , 'JQUERY' );
$this -> app -> Tpl -> Parse ( 'NEW_MESSAGE' , " ticket_new_message.tpl " );
2022-07-26 17:36:24 +02:00
2022-07-29 14:45:16 +02:00
break ;
*/
case 'absenden' :
if ( empty ( $drafted_messages )) {
break ;
}
2022-07-26 17:36:24 +02:00
// Enforce Ticket #
2022-07-29 14:45:16 +02:00
if ( ! preg_match ( " /Ticket #[0-9] { 12}/i " , $drafted_messages [ 0 ][ 'betreff' ])) {
$drafted_messages [ 0 ][ 'betreff' ] .= " Ticket # " . $result [ 0 ][ 'schluessel' ];
2022-07-26 17:36:24 +02:00
}
2022-07-29 14:45:16 +02:00
echo ( $drafted_messages [ 0 ][ 'id' ] . " <br> " );
echo ( $drafted_messages [ 0 ][ 'verfasser_replyto' ] . " <br> " );
echo ( $drafted_messages [ 0 ][ 'mail_replyto' ] . " <br> " );
echo ( $drafted_messages [ 0 ][ 'mail' ] . " <br> " );
echo ( $drafted_messages [ 0 ][ 'betreff' ] . " <br> " );
echo ( $drafted_messages [ 0 ][ 'text' ] . " <br> " );
2022-07-26 17:36:24 +02:00
if (
$this -> app -> erp -> MailSend (
2022-07-29 14:45:16 +02:00
$drafted_messages [ 0 ][ 'mail_replyto' ],
$drafted_messages [ 0 ][ 'verfasser_replyto' ],
$drafted_messages [ 0 ][ 'mail' ],
$drafted_messages [ 0 ][ 'mail' ],
$drafted_messages [ 0 ][ 'betreff' ],
$drafted_messages [ 0 ][ 'text' ],
2022-07-26 17:36:24 +02:00
'' , 0 , false , '' , '' ,
true
) != 0
) {
2022-07-29 14:45:16 +02:00
// Update message in ticket_nachricht
$sql = " UPDATE `ticket_nachricht` SET `zeitausgang` = NOW(), `betreff` = ' " . $drafted_messages [ 0 ][ 'betreff' ] . " ' WHERE id = " . $drafted_messages [ 0 ][ 'id' ];
2022-07-26 17:36:24 +02:00
$this -> app -> DB -> Insert ( $sql );
2022-07-27 18:05:24 +02:00
$msg = '<div class="info">Die E-Mail wurde erfolgreich versendet an ' . $input [ 'email_an' ] . '. ' . $this -> app -> erp -> mail_error . '</div>' ;
header ( " Location: index.php?module=ticket&action=edit&id= " . $id . " &msg= " . $this -> app -> erp -> base64_url_encode ( $msg ));
2022-07-26 17:36:24 +02:00
}
else {
$msg = '<div class="error">Fehler beim Versenden der E-Mail: ' . $this -> app -> erp -> mail_error . '</div>' ;
}
// Get messsages again
2022-07-29 14:45:16 +02:00
$messages = $this -> get_messages_of_ticket ( $id , 1 );
2022-07-26 17:36:24 +02:00
break ;
2022-07-29 14:45:16 +02:00
}
2022-07-26 17:36:24 +02:00
// Add Messages now
2022-07-24 21:10:33 +02:00
foreach ( $messages as $message ) {
if ( $message [ 'versendet' ] == '1' ) {
2022-07-29 14:45:16 +02:00
if ( is_null ( $message [ 'zeitausgang' ])) {
continue ;
}
2022-07-24 21:10:33 +02:00
$this -> app -> Tpl -> Set ( " NACHRICHT_RICHTUNG " , " An " );
$this -> app -> Tpl -> Set ( " NACHRICHT_FLOAT " , " right " );
2022-07-29 14:45:16 +02:00
$this -> app -> Tpl -> Set ( " NACHRICHT_ZEIT " , $message [ 'zeitausgang' ]);
2022-07-24 21:10:33 +02:00
} else {
$this -> app -> Tpl -> Set ( " NACHRICHT_RICHTUNG " , " Von " );
$this -> app -> Tpl -> Set ( " NACHRICHT_FLOAT " , " left " );
2022-07-29 14:45:16 +02:00
$this -> app -> Tpl -> Set ( " NACHRICHT_ZEIT " , $message [ 'zeit' ]);
2022-07-24 21:10:33 +02:00
}
2022-07-29 14:45:16 +02:00
$this -> app -> Tpl -> Set ( " NACHRICHT_BETREFF " , $message [ 'betreff' ]);
2022-07-24 21:10:33 +02:00
$this -> app -> Tpl -> Set ( " NACHRICHT_NAME " , $message [ 'verfasser' ]);
$this -> app -> Tpl -> Set ( " NACHRICHT_EMAILADRESSE " , $message [ 'mail' ]);
$this -> app -> Tpl -> Set ( " NACHRICHT_TEXT " , $message [ 'text' ]);
2022-07-27 18:05:24 +02:00
$file_attachments = $this -> app -> erp -> GetDateiSubjektObjekt ( 'Anhang' , 'Ticket' , $message [ 'id' ]);
if ( ! empty ( $file_attachments )) {
$this -> app -> Tpl -> Add ( 'NACHRICHT_ANHANG' , " <hr style= \" border-style:solid; border-width:1px \" > " );
foreach ( $file_attachments as $file_attachment ) {
$this -> app -> Tpl -> Add ( 'NACHRICHT_ANHANG' ,
" <a href= \" index.php?module=dateien&action=send&id= " . $file_attachment .
" \" > " .
htmlentities ( $this -> app -> erp -> GetDateiName ( $file_attachment )) .
" ( " .
$this -> app -> erp -> GetDateiSize ( $file_attachment ) .
" ) " .
" </a> " .
" </br> " );
}
}
2022-07-24 21:10:33 +02:00
$this -> app -> Tpl -> Parse ( 'MESSAGES' , " ticket_nachricht.tpl " );
}
2022-07-26 17:36:24 +02:00
$this -> app -> Tpl -> Set ( 'MESSAGE' , $msg );
2022-07-22 17:42:03 +02:00
$this -> app -> Tpl -> Parse ( 'PAGE' , " ticket_edit.tpl " );
}
/**
* Get all paramters from html form and save into $input
*/
public function GetInput () : array {
$input = array ();
//$input['EMAIL'] = $this->app->Secure->GetPOST('email');
2022-07-24 21:10:33 +02:00
$input [ 'projekt' ] = $this -> app -> Secure -> GetPOST ( 'projekt' );
$input [ 'status' ] = $this -> app -> Secure -> GetPOST ( 'status' );
$input [ 'adresse' ] = $this -> app -> Secure -> GetPOST ( 'adresse' );
$input [ 'warteschlange' ] = $this -> app -> Secure -> GetPOST ( 'warteschlange' );
$input [ 'prio' ] = $this -> app -> Secure -> GetPOST ( 'prio' );
$input [ 'notiz' ] = $this -> app -> Secure -> GetPOST ( 'notiz' );
$input [ 'tags' ] = $this -> app -> Secure -> GetPOST ( 'tags' );
2022-07-29 14:45:16 +02:00
$input [ 'betreff' ] = $this -> app -> Secure -> GetPOST ( 'betreff' );
2022-07-26 17:36:24 +02:00
$input [ 'email_sender' ] = $this -> app -> Secure -> GetPOST ( 'email_sender' );
$input [ 'email_an' ] = $this -> app -> Secure -> GetPOST ( 'email_an' );
$input [ 'email_cc' ] = $this -> app -> Secure -> GetPOST ( 'email_cc' );
$input [ 'email_bcc' ] = $this -> app -> Secure -> GetPOST ( 'email_bcc' );
$input [ 'email_betreff' ] = $this -> app -> Secure -> GetPOST ( 'email_betreff' );
$input [ 'email_text' ] = $this -> app -> Secure -> GetPOST ( 'email_text' );
2022-07-24 21:10:33 +02:00
return $input ;
}
2022-07-22 17:42:03 +02:00
2022-07-24 21:10:33 +02:00
public function GetInput_raw () : array {
$input = array ();
//$input['EMAIL'] = $this->app->Secure->GetPOST('email');
$input [ 'schluessel' ] = $this -> app -> Secure -> GetPOST ( 'schluessel' );
$input [ 'zeit' ] = $this -> app -> Secure -> GetPOST ( 'zeit' );
$input [ 'projekt' ] = $this -> app -> Secure -> GetPOST ( 'projekt' );
$input [ 'bearbeiter' ] = $this -> app -> Secure -> GetPOST ( 'bearbeiter' );
$input [ 'quelle' ] = $this -> app -> Secure -> GetPOST ( 'quelle' );
$input [ 'status' ] = $this -> app -> Secure -> GetPOST ( 'status' );
$input [ 'adresse' ] = $this -> app -> Secure -> GetPOST ( 'adresse' );
$input [ 'kunde' ] = $this -> app -> Secure -> GetPOST ( 'kunde' );
$input [ 'warteschlange' ] = $this -> app -> Secure -> GetPOST ( 'warteschlange' );
$input [ 'mailadresse' ] = $this -> app -> Secure -> GetPOST ( 'mailadresse' );
$input [ 'prio' ] = $this -> app -> Secure -> GetPOST ( 'prio' );
$input [ 'betreff' ] = $this -> app -> Secure -> GetPOST ( 'betreff' );
$input [ 'zugewiesen' ] = $this -> app -> Secure -> GetPOST ( 'zugewiesen' );
$input [ 'inbearbeitung' ] = $this -> app -> Secure -> GetPOST ( 'inbearbeitung' );
$input [ 'inbearbeitung_user' ] = $this -> app -> Secure -> GetPOST ( 'inbearbeitung_user' );
$input [ 'firma' ] = $this -> app -> Secure -> GetPOST ( 'firma' );
$input [ 'notiz' ] = $this -> app -> Secure -> GetPOST ( 'notiz' );
$input [ 'bitteantworten' ] = $this -> app -> Secure -> GetPOST ( 'bitteantworten' );
$input [ 'service' ] = $this -> app -> Secure -> GetPOST ( 'service' );
$input [ 'kommentar' ] = $this -> app -> Secure -> GetPOST ( 'kommentar' );
$input [ 'privat' ] = $this -> app -> Secure -> GetPOST ( 'privat' );
$input [ 'dsgvo' ] = $this -> app -> Secure -> GetPOST ( 'dsgvo' );
$input [ 'tags' ] = $this -> app -> Secure -> GetPOST ( 'tags' );
$input [ 'nachrichten_anz' ] = $this -> app -> Secure -> GetPOST ( 'nachrichten_anz' );
2022-07-22 17:42:03 +02:00
return $input ;
}
/*
* Set all fields in the page corresponding to $input
*/
function SetInput ( $input ) {
// $this->app->Tpl->Set('EMAIL', $input['email']);
$this -> app -> Tpl -> Set ( 'SCHLUESSEL' , $input [ 'schluessel' ]);
2022-07-29 14:45:16 +02:00
$this -> app -> Tpl -> Set ( 'ZEIT' , $input [ 'zeit' ]);
$this -> app -> Tpl -> Set ( 'PROJEKT' , $input [ 'projekt' ]);
$this -> app -> Tpl -> Set ( 'BEARBEITER' , $input [ 'bearbeiter' ]);
$this -> app -> Tpl -> Set ( 'QUELLE' , $input [ 'quelle' ]);
$this -> app -> Tpl -> Set ( 'STATUS' , $input [ 'status' ]);
$this -> app -> Tpl -> Set ( 'ADRESSE' , $input [ 'adresse' ]);
$this -> app -> Tpl -> Set ( 'KUNDE' , $input [ 'kunde' ]);
$this -> app -> Tpl -> Set ( 'WARTESCHLANGE' , $input [ 'warteschlange' ]);
$this -> app -> Tpl -> Set ( 'MAILADRESSE' , $input [ 'mailadresse' ]);
$this -> app -> Tpl -> Set ( 'PRIO' , $input [ 'prio' ]);
$this -> app -> Tpl -> Set ( 'BETREFF' , $input [ 'betreff' ]);
$this -> app -> Tpl -> Set ( 'ZUGEWIESEN' , $input [ 'zugewiesen' ]);
$this -> app -> Tpl -> Set ( 'INBEARBEITUNG' , $input [ 'inbearbeitung' ]);
$this -> app -> Tpl -> Set ( 'INBEARBEITUNG_USER' , $input [ 'inbearbeitung_user' ]);
$this -> app -> Tpl -> Set ( 'FIRMA' , $input [ 'firma' ]);
$this -> app -> Tpl -> Set ( 'NOTIZ' , $input [ 'notiz' ]);
$this -> app -> Tpl -> Set ( 'BITTEANTWORTEN' , $input [ 'bitteantworten' ]);
$this -> app -> Tpl -> Set ( 'SERVICE' , $input [ 'service' ]);
$this -> app -> Tpl -> Set ( 'KOMMENTAR' , $input [ 'kommentar' ]);
$this -> app -> Tpl -> Set ( 'PRIVAT' , $input [ 'privat' ]);
$this -> app -> Tpl -> Set ( 'DSGVO' , $input [ 'dsgvo' ]);
$this -> app -> Tpl -> Set ( 'TAGS' , $input [ 'tags' ]);
$this -> app -> Tpl -> Set ( 'NACHRICHTEN_ANZ' , $input [ 'nachrichten_anz' ]);
2022-07-22 17:42:03 +02:00
}
}