diff --git a/phpwf/plugins/class.yui.php b/phpwf/plugins/class.yui.php index 9def3ac9..ecf58f9c 100644 --- a/phpwf/plugins/class.yui.php +++ b/phpwf/plugins/class.yui.php @@ -28,6 +28,15 @@ class YUI { $this->app = $app; } + function dateien_module_objekt_map($module) : string { + $dateien_module_objekt_map_array = array( + 'adresse' => 'adressen', + 'ticket' => 'ticket_header' + ); + + return (isset($dateien_module_objekt_map_array[$module]) ? $dateien_module_objekt_map_array[$module] : $module); + } + function PasswordCheck($passwordFieldID, $repassFieldID, $accountNameFieldID, $submitButtonID, $extra = ''){ $this->app->Tpl->Add('JQUERYREADY', " function checkPassword(){ @@ -4074,6 +4083,7 @@ url:strUrl, success:function(html){strReturn = html;}, async:false $allowed['wiki'] = array('dateien'); $allowed['geschaeftsbrief_vorlagen'] = array('dateien'); $allowed['kasse'] = array('dateien'); + $allowed['ticket'] = array('dateien'); $id = $this->app->Secure->GetGET("id"); $sid = $this->app->Secure->GetGET("sid"); @@ -4082,13 +4092,8 @@ url:strUrl, success:function(html){strReturn = html;}, async:false } parse_str(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY), $queries); - switch($queries['module']) - { - case "adresse": $objekt="adressen"; break; - default: $objekt=$queries['module']; - } - //if(!ctype_alpha($objekt))$objekt=""; + $objekt = $this->dateien_module_objekt_map($queries['module']); if(!preg_match('/[A-Za-z_]/', $objekt)) { $objekt=''; @@ -14067,11 +14072,7 @@ source: "index.php?module=ajax&action=filter&filtername=' . $filter . $extendurl $sid = (int)$this->app->Secure->GetPOST("sid"); $sort = $this->app->DB->Select("SELECT sort FROM datei_stichwoerter WHERE id = '$sid' LIMIT 1"); $id = (int)$this->app->Secure->GetGET("id"); - switch($module) - { - case "adresse": $objekt="adressen"; break; - default: $objekt=$module; - } + $objekt = $this->dateien_module_objekt_map($module); if(!preg_match('/[A-Za-z_]/', $objekt))$objekt=""; $parameter=$id; @@ -14100,11 +14101,7 @@ source: "index.php?module=ajax&action=filter&filtername=' . $filter . $extendurl $sid = (int)$this->app->Secure->GetPOST("sid"); $sort = $this->app->DB->Select("SELECT sort FROM datei_stichwoerter WHERE id = '$sid' LIMIT 1"); $id = (int)$this->app->Secure->GetGET("id"); - switch($module) - { - case "adresse": $objekt="adressen"; break; - default: $objekt=$module; - } + $objekt = $this->dateien_module_objekt_map($module); if(!preg_match('/[A-Za-z_]/', $objekt))$objekt=""; $parameter=$id; @@ -14203,7 +14200,7 @@ source: "index.php?module=ajax&action=filter&filtername=' . $filter . $extendurl $this->app->Tpl->Add('MESSAGE','
Keine Dateien ausgewählt!
'); }else{ $objekt = $this->app->Secure->GetGET('module'); - if($objekt == 'adresse')$objekt = 'adressen'; + $objekt = $this->dateien_module_objekt_map($objekt); $parameter = (int)$this->app->Secure->GetGET('id'); $alledateien = $this->app->DB->SelectArr("SELECT v.datei, v.id FROM datei d INNER JOIN datei_stichwoerter s ON d.id=s.datei INNER JOIN datei_version v ON v.datei=d.id WHERE s.objekt LIKE '$objekt' AND s.parameter='$parameter' AND d.geloescht=0 "); @@ -14270,7 +14267,7 @@ source: "index.php?module=ajax&action=filter&filtername=' . $filter . $extendurl $this->app->Tpl->Add('MESSAGE','
Keine Dateien ausgewählt!
'); }else{ $objekt = $this->app->Secure->GetGET('module'); - if($objekt == 'adresse')$objekt = 'adressen'; + $objekt = $this->dateien_module_objekt_map($objekt); $typmodul = $this->app->Secure->GetPOST('typ'); if($objekt == 'dateien' && $typmodul == 'geschaeftsbrief_vorlagen'){ $objekt = $typmodul; diff --git a/www/pages/ajax.php b/www/pages/ajax.php index a2c7e04b..7c9ae905 100644 --- a/www/pages/ajax.php +++ b/www/pages/ajax.php @@ -350,9 +350,9 @@ class Ajax { $id = $this->app->Secure->GetPOST('id'); $objekt = $this->app->Secure->GetPOST('typ'); $parameter = $this->app->Secure->GetPOST('parameter'); - if($objekt === 'adresse'){ - $objekt = 'Adressen'; - } + + $module = strtolower($objekt); + $objekt = $this->app->YUI->dateien_module_objekt_map($objekt); $data = $this->app->DB->SelectRow( "SELECT d.*, s.subjekt @@ -363,12 +363,6 @@ class Ajax { LIMIT 1" ); - - $module = strtolower($objekt); - if($module === 'adressen'){ - $module = 'adresse'; - } - $typen = $this->app->erp->getDateiTypen($module); $found = false; foreach($typen as $typ) { @@ -431,10 +425,10 @@ class Ajax { $titel = $this->app->Secure->GetPOST('titel'); $beschreibung = $this->app->Secure->GetPOST('beschreibung'); $subjekt = $this->app->Secure->GetPOST('subjekt'); - if($objekt == 'adresse') - { - $objekt = 'Adressen'; - } + + $module = strtolower($objekt); + $objekt = $this->app->YUI->dateien_module_objekt_map($module); + $ersteller = $this->app->DB->real_escape_string($this->app->User->GetName()); $datei = $this->app->DB->SelectArr("SELECT d.id, s.id as sid FROM datei d LEFT JOIN datei_stichwoerter s ON d.id=s.datei LEFT JOIN datei_version v ON v.datei=d.id WHERE s.objekt LIKE '$objekt' AND s.parameter='$parameter' AND d.geloescht=0 AND d.id = '$id' LIMIT 1"); if($datei) @@ -654,6 +648,9 @@ class Ajax { $cmd = trim($this->app->Secure->GetGET('cmd')); $id = (int)$this->app->Secure->GetGET('id'); + $module = strtolower($cmd); + $cmd = $this->app->YUI->dateien_module_objekt_map($cmd); + if(!empty($cmd) && $id && (!in_array($cmd, $cmds) || (in_array($cmd, $cmds) && $this->app->erp->RechteVorhanden($cmd,'dateien')))) { $datei = $this->app->DB->SelectRow( @@ -661,7 +658,7 @@ class Ajax { "SELECT dv.id, ds.parameter, dv.dateiname FROM datei_version AS dv INNER JOIN datei_stichwoerter ds ON ds.datei = dv.datei - WHERE dv.datei = %d AND (ds.objekt like '%s'".($cmd === 'adresse'?" OR ds.objekt like 'Adressen' ":'').") + WHERE dv.datei = %d AND (ds.objekt like '%s') ORDER BY dv.datei DESC, dv.version DESC LIMIT 1", $id, $cmd @@ -694,7 +691,7 @@ class Ajax { $projekt = $this->app->DB->Select( sprintf( 'SELECT `projekt` FROM `%s` WHERE `id` = %d LIMIT 1', - $cmd, $datei[0]['parameter'] + $module, $datei[0]['parameter'] ) ); if(!$this->app->erp->UserProjektRecht($projekt)) { diff --git a/www/pages/content/ticket_edit.tpl b/www/pages/content/ticket_edit.tpl index ec757efd..6313aa1f 100644 --- a/www/pages/content/ticket_edit.tpl +++ b/www/pages/content/ticket_edit.tpl @@ -25,6 +25,7 @@ {|Adresse|}: {|Tags|}: {|Letzte Aktion|}:[ZEIT] + [TICKET_ANHANG] diff --git a/www/pages/ticket.php b/www/pages/ticket.php index a67432b6..34836a41 100644 --- a/www/pages/ticket.php +++ b/www/pages/ticket.php @@ -23,6 +23,7 @@ class Ticket { $this->app->ActionHandler("text_ausgang", "ticket_text_ausgang"); // Output text for iframe display $this->app->ActionHandler("statusfix", "ticket_statusfix"); // Xentral 20 compatibility set all ticket status to latest ticket_nachricht status $this->app->ActionHandler("datefix", "ticket_datefix"); // Xentral 20 compatibility set all ticket dates to latest ticket_nachricht date + $this->app->ActionHandler("dateien", "ticket_dateien"); $this->app->DefaultActionHandler("list"); $this->app->ActionHandlerListen($app); } @@ -305,6 +306,27 @@ class Ticket { } } + function add_attachments_header_html($ticket_id, $templatepos) { + $file_attachments = $this->app->erp->GetDateiSubjektObjekt('%','ticket_header',$ticket_id); + + if (!empty($file_attachments)) { + $this->app->Tpl->Add($templatepos,"{|Anhänge|}:
"); + foreach ($file_attachments as $file_attachment) { + + $this->app->Tpl->Add($templatepos, + "". + htmlentities($this->app->erp->GetDateiName($file_attachment)). + " (". + $this->app->erp->GetDateiSize($file_attachment). + ")". + "". + "
"); + } + $this->app->Tpl->Add($templatepos,"
"); + } + } + function add_messages_tpl($messages, $showdrafts) { // Add Messages now @@ -590,6 +612,19 @@ class Ticket { $this->app->Tpl->Parse('PAGE', "ticket_create.tpl"); } + + function ticket_menu($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"); + $anzahldateien = $this->app->erp->AnzahlDateien("ticket_header",$id); + if ($anzahldateien > 0) { + $anzahldateien = " (".$anzahldateien.")"; + } else { + $anzahldateien=""; + } + $this->app->erp->MenuEintrag("index.php?module=ticket&action=dateien&id=$id", "Dateien".$anzahldateien); + } + function ticket_edit() { $id = $this->app->Secure->GetGET('id'); @@ -597,10 +632,10 @@ class Ticket { return; } + $this->ticket_menu($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'); $cmd = $this->app->Secure->GetGET('cmd'); $input = $this->GetInput(); @@ -901,11 +936,19 @@ class Ticket { } $this->add_messages_tpl($messages, false); - + $this->add_attachments_header_html($id,'TICKET_ANHANG'); $this->app->Tpl->Set('MESSAGE', $msg); $this->app->Tpl->Parse('PAGE', "ticket_edit.tpl"); } + function ticket_dateien() + { + $id = $this->app->Secure->GetGET("id"); + $this->ticket_menu($id); + $this->app->Tpl->Add('UEBERSCHRIFT'," (Dateien)"); + $this->app->YUI->DateiUpload('PAGE',"ticket_header",$id); + } + /** * Get all paramters from html form and save into $input */