ticket system migration helper for ticket status from xentral 20

This commit is contained in:
Xenomporio 2022-08-18 20:45:09 +02:00
parent b16b19f2d6
commit 3f75bfad7d

View File

@ -21,6 +21,7 @@ class Ticket {
$this->app->ActionHandler("minidetail", "ticket_minidetail");
$this->app->ActionHandler("text", "ticket_text"); // 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->DefaultActionHandler("list");
$this->app->ActionHandlerListen($app);
}
@ -848,6 +849,55 @@ class Ticket {
$this->app->Tpl->Parse($parsetarget,'ticket_minidetail.tpl');
}
}
/*
* After import of Xentral 20 ticket system
* Set all ticket status to the status of the latest ticket_nachricht
*/
function ticket_statusfix() {
$confirmed = $this->app->Secure->GetGET('confirmed');
if ($confirmed == "yes") {
$sql = "UPDATE
ticket
SET
STATUS
=ifnull((
SELECT
tn.status
FROM
ticket_nachricht tn
INNER JOIN(
SELECT
ticket,
MAX(zeit) AS lastzeit
FROM
ticket_nachricht
GROUP BY
ticket
) l
ON
tn.ticket = l.ticket AND tn.zeit = l.lastzeit
WHERE
ticket.schluessel = tn.ticket
LIMIT 1
),'abgeschlossen')
WHERE ticket.status = 'neu'";
$this->app->DB->Update($sql);
$this->app->Tpl->Set('TEXT', "Done.");
$this->app->Tpl->Parse('PAGE','ticket_text.tpl');
}
else {
$this->app->Tpl->Set('TEXT', "This will replace all ticket status with the status of the latest ticket_nachricht. To confirm, press here: ");
$this->app->Tpl->Add('TEXT', '<a href="index.php?module=ticket&action=statusfix&confirmed=yes">Confirm</a>');
$this->app->Tpl->Parse('PAGE','ticket_text.tpl');
}
}
}