Reimplemented module ticket wartschlangen

This commit is contained in:
Xenomporio 2022-07-22 11:15:27 +02:00
parent 910a8544a4
commit dbf5201c20
3 changed files with 266 additions and 0 deletions

View File

@ -0,0 +1,78 @@
<div id="tabs">
<ul>
<li><a href="#tabs-1"></a></li>
</ul>
<!-- Example for multiple tabs
<ul hidden">
<li><a href="#tabs-1">First Tab</a></li>
<li><a href="#tabs-2">Second Tab</a></li>
</ul>
-->
<div id="tabs-1">
[MESSAGE]
<form action="" method="post">
[FORMHANDLEREVENT]
<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>{|<!--Legend for this form area goes here>-->warteschlangen|}</legend>
<table width="100%" border="0" class="mkTableFormular">
<tr><td>{|Warteschlange|}:</td><td><input type="text" name="warteschlange" value="[WARTESCHLANGE]" size="40"></td></tr>
<tr><td>{|Kennung|}:</td><td><input type="text" name="label" value="[LABEL]" size="40"><i>Nur Buchstaben, keine Leerzeichen, keine Sonderzeichen und jede Kennung darf es nur einmal geben.</i></td></tr>
<tr valign="top"><td width="200">{|Verantwortlicher|}:</td><td width="">[ADRESSEAUTOSTART]<input type="text" name="adresse" id="adresse" value="[ADRESSE]" size="40">[ADRESSEAUTOEND]</td></tr>
</table>
</fieldset>
</div>
</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>{|Warteschlange|}:</td><td><input type="text" name="warteschlange" value="[WARTESCHLANGE]" size="40"></td></tr>
<tr><td>{|Label|}:</td><td><input type="text" name="label" value="[LABEL]" size="40"></td></tr>
<tr><td>{|Wiedervorlage|}:</td><td><input type="text" name="wiedervorlage" value="[WIEDERVORLAGE]" size="40"></td></tr>
<tr><td>{|Adresse|}:</td><td><input type="text" name="adresse" value="[ADRESSE]" size="40"></td></tr>
</table>
</fieldset>
</div>
</div>
</div>
</div> -->
<input type="submit" name="submit" value="Speichern" style="float:right"/>
</form>
</div>
<!-- Example for 2nd tab
<div id="tabs-2">
[MESSAGE]
<form action="" method="post">
[FORMHANDLEREVENT]
<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>{|...|}</legend>
<table width="100%" border="0" class="mkTableFormular">
...
</table>
</fieldset>
</div>
</div>
</div>
</div>
<input type="submit" name="submit" value="Speichern" style="float:right"/>
</form>
</div>
-->
</div>

View File

@ -0,0 +1,5 @@
<div id="tabs-1">
[MESSAGE]
[TAB1]
[TAB1NEXT]
</div>

View File

@ -0,0 +1,183 @@
<?php
/*
* Copyright (c) 2022 Xenomporio project
*/
use Xentral\Components\Database\Exception\QueryFailureException;
class Warteschlangen {
function __construct($app, $intern = false) {
$this->app = $app;
if ($intern)
return;
$this->app->ActionHandlerInit($this);
$this->app->ActionHandler("list", "warteschlangen_list");
$this->app->ActionHandler("create", "warteschlangen_edit"); // This automatically adds a "New" button
$this->app->ActionHandler("edit", "warteschlangen_edit");
$this->app->ActionHandler("delete", "warteschlangen_delete");
$this->app->DefaultActionHandler("list");
$this->app->ActionHandlerListen($app);
}
public function Install() {
/* Fill out manually later */
}
static function TableSearch(&$app, $name, $erlaubtevars) {
switch ($name) {
case "warteschlangen_list":
$allowed['warteschlangen_list'] = array('list');
$heading = array('Name', 'Kennung', 'Verantwortlicher', 'Men&uuml;');
$width = array('10%'); // Fill out manually later
$findcols = array('warteschlange', 'label', 'adresse');
$searchsql = array('warteschlange', 'label', 'adresse');
$defaultorder = 1;
$defaultorderdesc = 0;
$menu = "<table cellpadding=0 cellspacing=0><tr><td nowrap>" . "<a href=\"index.php?module=warteschlangen&action=edit&id=%value%\"><img src=\"./themes/{$app->Conf->WFconf['defaulttheme']}/images/edit.png\" border=\"0\"></a>&nbsp;<a href=\"#\" onclick=DeleteDialog(\"index.php?module=warteschlangen&action=delete&id=%value%\");>" . "<img src=\"themes/{$app->Conf->WFconf['defaulttheme']}/images/delete.svg\" border=\"0\"></a>" . "</td></tr></table>";
$sql = "SELECT w.id, w.warteschlange, w.label, (SELECT a.name from adresse a WHERE a.id = w.adresse), id FROM warteschlangen w";
$where = "1";
$count = "SELECT count(DISTINCT id) FROM warteschlangen WHERE $where";
// $groupby = "";
break;
}
$erg = false;
foreach ($erlaubtevars as $k => $v) {
if (isset($$v)) {
$erg[$v] = $$v;
}
}
return $erg;
}
function warteschlangen_list() {
$this->app->erp->MenuEintrag("index.php?module=warteschlangen&action=list", "&Uuml;bersicht");
$this->app->erp->MenuEintrag("index.php?module=warteschlangen&action=create", "Neu anlegen");
$this->app->erp->MenuEintrag("index.php", "Zur&uuml;ck");
$this->app->YUI->TableSearch('TAB1', 'warteschlangen_list', "show", "", "", basename(__FILE__), __CLASS__);
$this->app->Tpl->Parse('PAGE', "warteschlangen_list.tpl");
}
public function warteschlangen_delete() {
$id = (int) $this->app->Secure->GetGET('id');
$this->app->DB->Delete("DELETE FROM `warteschlangen` WHERE `id` = '{$id}'");
$this->app->Tpl->Set('MESSAGE', "<div class=\"error\">Der Eintrag wurde gel&ouml;scht.</div>");
$this->warteschlangen_list();
}
/*
* Edit warteschlangen item
* If id is empty, create a new one
*/
function warteschlangen_edit() {
$id = $this->app->Secure->GetGET('id');
$this->app->Tpl->Set('ID', $id);
$this->app->erp->MenuEintrag("index.php?module=warteschlangen&action=edit&id=$id", "Details");
$this->app->erp->MenuEintrag("index.php?module=warteschlangen&action=list", "Zur&uuml;ck zur &Uuml;bersicht");
$id = $this->app->Secure->GetGET('id');
$input = $this->GetInput();
$submit = $this->app->Secure->GetPOST('submit');
if (empty($id)) {
// New item
$id = 'NULL';
}
if ($submit != '')
{
// Write to database
// Add checks here
$input['adresse'] = $this->app->erp->ReplaceAdresse(true,$input['adresse'],true); // Parameters: Target db?, value, from form?
$columns = "id, ";
$values = "$id, ";
$update = "";
$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 warteschlangen (".$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=warteschlangen&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 id, warteschlange, label, wiedervorlage, adresse, id FROM warteschlangen"." WHERE id=$id");
foreach ($result[0] as $key => $value) {
$this->app->Tpl->Set(strtoupper($key), $value);
}
$this->app->YUI->AutoComplete("adresse","mitarbeiterid");
$this->app->Tpl->Set('ADRESSE', $this->app->erp->ReplaceAdresse(false,$result[0]['adresse'],false)); // Convert ID to form display
/*
* Add displayed items later
*
$this->app->Tpl->Add('KURZUEBERSCHRIFT2', $email);
$this->app->Tpl->Add('EMAIL', $email);
$this->app->Tpl->Add('ANGEZEIGTERNAME', $angezeigtername);
*/
$this->app->Tpl->Parse('PAGE', "warteschlangen_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');
$input['warteschlange'] = $this->app->Secure->GetPOST('warteschlange');
$input['label'] = $this->app->Secure->GetPOST('label');
$input['wiedervorlage'] = $this->app->Secure->GetPOST('wiedervorlage');
$input['adresse'] = $this->app->Secure->GetPOST('adresse');
return $input;
}
}