ticket system attachments on ticket header

This commit is contained in:
OpenXE 2023-11-19 14:07:16 +01:00
parent dff342276e
commit 2cb1f91a43
4 changed files with 74 additions and 36 deletions

View File

@ -28,6 +28,15 @@ class YUI {
$this->app = $app; $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 = ''){ function PasswordCheck($passwordFieldID, $repassFieldID, $accountNameFieldID, $submitButtonID, $extra = ''){
$this->app->Tpl->Add('JQUERYREADY', " $this->app->Tpl->Add('JQUERYREADY', "
function checkPassword(){ function checkPassword(){
@ -4074,6 +4083,7 @@ url:strUrl, success:function(html){strReturn = html;}, async:false
$allowed['wiki'] = array('dateien'); $allowed['wiki'] = array('dateien');
$allowed['geschaeftsbrief_vorlagen'] = array('dateien'); $allowed['geschaeftsbrief_vorlagen'] = array('dateien');
$allowed['kasse'] = array('dateien'); $allowed['kasse'] = array('dateien');
$allowed['ticket'] = array('dateien');
$id = $this->app->Secure->GetGET("id"); $id = $this->app->Secure->GetGET("id");
$sid = $this->app->Secure->GetGET("sid"); $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); 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)) { if(!preg_match('/[A-Za-z_]/', $objekt)) {
$objekt=''; $objekt='';
@ -14067,11 +14072,7 @@ source: "index.php?module=ajax&action=filter&filtername=' . $filter . $extendurl
$sid = (int)$this->app->Secure->GetPOST("sid"); $sid = (int)$this->app->Secure->GetPOST("sid");
$sort = $this->app->DB->Select("SELECT sort FROM datei_stichwoerter WHERE id = '$sid' LIMIT 1"); $sort = $this->app->DB->Select("SELECT sort FROM datei_stichwoerter WHERE id = '$sid' LIMIT 1");
$id = (int)$this->app->Secure->GetGET("id"); $id = (int)$this->app->Secure->GetGET("id");
switch($module) $objekt = $this->dateien_module_objekt_map($module);
{
case "adresse": $objekt="adressen"; break;
default: $objekt=$module;
}
if(!preg_match('/[A-Za-z_]/', $objekt))$objekt=""; if(!preg_match('/[A-Za-z_]/', $objekt))$objekt="";
$parameter=$id; $parameter=$id;
@ -14100,11 +14101,7 @@ source: "index.php?module=ajax&action=filter&filtername=' . $filter . $extendurl
$sid = (int)$this->app->Secure->GetPOST("sid"); $sid = (int)$this->app->Secure->GetPOST("sid");
$sort = $this->app->DB->Select("SELECT sort FROM datei_stichwoerter WHERE id = '$sid' LIMIT 1"); $sort = $this->app->DB->Select("SELECT sort FROM datei_stichwoerter WHERE id = '$sid' LIMIT 1");
$id = (int)$this->app->Secure->GetGET("id"); $id = (int)$this->app->Secure->GetGET("id");
switch($module) $objekt = $this->dateien_module_objekt_map($module);
{
case "adresse": $objekt="adressen"; break;
default: $objekt=$module;
}
if(!preg_match('/[A-Za-z_]/', $objekt))$objekt=""; if(!preg_match('/[A-Za-z_]/', $objekt))$objekt="";
$parameter=$id; $parameter=$id;
@ -14203,7 +14200,7 @@ source: "index.php?module=ajax&action=filter&filtername=' . $filter . $extendurl
$this->app->Tpl->Add('MESSAGE','<div class="error">Keine Dateien ausgew&auml;hlt!</div>'); $this->app->Tpl->Add('MESSAGE','<div class="error">Keine Dateien ausgew&auml;hlt!</div>');
}else{ }else{
$objekt = $this->app->Secure->GetGET('module'); $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'); $parameter = (int)$this->app->Secure->GetGET('id');
$alledateien = $this->app->DB->SelectArr("SELECT v.datei, v.id FROM $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 "); 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','<div class="error">Keine Dateien ausgew&auml;hlt!</div>'); $this->app->Tpl->Add('MESSAGE','<div class="error">Keine Dateien ausgew&auml;hlt!</div>');
}else{ }else{
$objekt = $this->app->Secure->GetGET('module'); $objekt = $this->app->Secure->GetGET('module');
if($objekt == 'adresse')$objekt = 'adressen'; $objekt = $this->dateien_module_objekt_map($objekt);
$typmodul = $this->app->Secure->GetPOST('typ'); $typmodul = $this->app->Secure->GetPOST('typ');
if($objekt == 'dateien' && $typmodul == 'geschaeftsbrief_vorlagen'){ if($objekt == 'dateien' && $typmodul == 'geschaeftsbrief_vorlagen'){
$objekt = $typmodul; $objekt = $typmodul;

View File

@ -350,9 +350,9 @@ class Ajax {
$id = $this->app->Secure->GetPOST('id'); $id = $this->app->Secure->GetPOST('id');
$objekt = $this->app->Secure->GetPOST('typ'); $objekt = $this->app->Secure->GetPOST('typ');
$parameter = $this->app->Secure->GetPOST('parameter'); $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( $data = $this->app->DB->SelectRow(
"SELECT d.*, s.subjekt "SELECT d.*, s.subjekt
@ -363,12 +363,6 @@ class Ajax {
LIMIT 1" LIMIT 1"
); );
$module = strtolower($objekt);
if($module === 'adressen'){
$module = 'adresse';
}
$typen = $this->app->erp->getDateiTypen($module); $typen = $this->app->erp->getDateiTypen($module);
$found = false; $found = false;
foreach($typen as $typ) { foreach($typen as $typ) {
@ -431,10 +425,10 @@ class Ajax {
$titel = $this->app->Secure->GetPOST('titel'); $titel = $this->app->Secure->GetPOST('titel');
$beschreibung = $this->app->Secure->GetPOST('beschreibung'); $beschreibung = $this->app->Secure->GetPOST('beschreibung');
$subjekt = $this->app->Secure->GetPOST('subjekt'); $subjekt = $this->app->Secure->GetPOST('subjekt');
if($objekt == 'adresse')
{ $module = strtolower($objekt);
$objekt = 'Adressen'; $objekt = $this->app->YUI->dateien_module_objekt_map($module);
}
$ersteller = $this->app->DB->real_escape_string($this->app->User->GetName()); $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"); $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) if($datei)
@ -654,6 +648,9 @@ class Ajax {
$cmd = trim($this->app->Secure->GetGET('cmd')); $cmd = trim($this->app->Secure->GetGET('cmd'));
$id = (int)$this->app->Secure->GetGET('id'); $id = (int)$this->app->Secure->GetGET('id');
$module = strtolower($cmd);
$cmd = $this->app->YUI->dateien_module_objekt_map($cmd);
if(!empty($cmd) && $id if(!empty($cmd) && $id
&& (!in_array($cmd, $cmds) || (in_array($cmd, $cmds) && $this->app->erp->RechteVorhanden($cmd,'dateien')))) { && (!in_array($cmd, $cmds) || (in_array($cmd, $cmds) && $this->app->erp->RechteVorhanden($cmd,'dateien')))) {
$datei = $this->app->DB->SelectRow( $datei = $this->app->DB->SelectRow(
@ -661,7 +658,7 @@ class Ajax {
"SELECT dv.id, ds.parameter, dv.dateiname "SELECT dv.id, ds.parameter, dv.dateiname
FROM datei_version AS dv FROM datei_version AS dv
INNER JOIN datei_stichwoerter ds ON ds.datei = dv.datei 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 ORDER BY dv.datei DESC, dv.version DESC
LIMIT 1", LIMIT 1",
$id, $cmd $id, $cmd
@ -694,7 +691,7 @@ class Ajax {
$projekt = $this->app->DB->Select( $projekt = $this->app->DB->Select(
sprintf( sprintf(
'SELECT `projekt` FROM `%s` WHERE `id` = %d LIMIT 1', 'SELECT `projekt` FROM `%s` WHERE `id` = %d LIMIT 1',
$cmd, $datei[0]['parameter'] $module, $datei[0]['parameter']
) )
); );
if(!$this->app->erp->UserProjektRecht($projekt)) { if(!$this->app->erp->UserProjektRecht($projekt)) {

View File

@ -25,6 +25,7 @@
<tr><td>{|Adresse|}:</td><td><input type="text" name="adresse" id="adresse" value="[ADRESSE]" size="20"><a href="index.php?module=adresse&action=edit&id=[ADRESSE_ID]"><img src="./themes/new/images/forward.svg" border="0" style="top:6px; position:relative"></a></td></tr> <tr><td>{|Adresse|}:</td><td><input type="text" name="adresse" id="adresse" value="[ADRESSE]" size="20"><a href="index.php?module=adresse&action=edit&id=[ADRESSE_ID]"><img src="./themes/new/images/forward.svg" border="0" style="top:6px; position:relative"></a></td></tr>
<tr><td>{|Tags|}:</td><td><input type="text" name="tags" id="tags" value="[TAGS]" size="20"></td></tr> <tr><td>{|Tags|}:</td><td><input type="text" name="tags" id="tags" value="[TAGS]" size="20"></td></tr>
<tr><td>{|Letzte Aktion|}:</td><td>[ZEIT]</td></tr> <tr><td>{|Letzte Aktion|}:</td><td>[ZEIT]</td></tr>
[TICKET_ANHANG]
</table> </table>
</fieldset> </fieldset>
</div> </div>

View File

@ -23,6 +23,7 @@ class Ticket {
$this->app->ActionHandler("text_ausgang", "ticket_text_ausgang"); // Output text for iframe display $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("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("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->DefaultActionHandler("list");
$this->app->ActionHandlerListen($app); $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,"<tr><td>{|Anh&auml;nge|}:</td><td><div class=\"ticket_attachments\">");
foreach ($file_attachments as $file_attachment) {
$this->app->Tpl->Add($templatepos,
"<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>");
}
$this->app->Tpl->Add($templatepos,"</div></td></tr>");
}
}
function add_messages_tpl($messages, $showdrafts) { function add_messages_tpl($messages, $showdrafts) {
// Add Messages now // Add Messages now
@ -590,6 +612,19 @@ class Ticket {
$this->app->Tpl->Parse('PAGE', "ticket_create.tpl"); $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&uuml;ck zur &Uuml;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() { function ticket_edit() {
$id = $this->app->Secure->GetGET('id'); $id = $this->app->Secure->GetGET('id');
@ -597,10 +632,10 @@ class Ticket {
return; return;
} }
$this->ticket_menu($id);
$this->app->Tpl->Set('ID', $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&uuml;ck zur &Uuml;bersicht");
$id = $this->app->Secure->GetGET('id'); $id = $this->app->Secure->GetGET('id');
$cmd = $this->app->Secure->GetGET('cmd'); $cmd = $this->app->Secure->GetGET('cmd');
$input = $this->GetInput(); $input = $this->GetInput();
@ -901,11 +936,19 @@ class Ticket {
} }
$this->add_messages_tpl($messages, false); $this->add_messages_tpl($messages, false);
$this->add_attachments_header_html($id,'TICKET_ANHANG');
$this->app->Tpl->Set('MESSAGE', $msg); $this->app->Tpl->Set('MESSAGE', $msg);
$this->app->Tpl->Parse('PAGE', "ticket_edit.tpl"); $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 * Get all paramters from html form and save into $input
*/ */