2022-06-24 18:19:26 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2022-10-14 14:18:26 +02:00
|
|
|
* Copyright (c) 2022 OpenXE project
|
2022-06-24 18:19:26 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
use Xentral\Components\Database\Exception\QueryFailureException;
|
|
|
|
|
|
|
|
class PLACEHOLDER_MODULECLASSNAME {
|
|
|
|
|
|
|
|
function __construct($app, $intern = false) {
|
|
|
|
$this->app = $app;
|
|
|
|
if ($intern)
|
|
|
|
return;
|
|
|
|
|
|
|
|
$this->app->ActionHandlerInit($this);
|
|
|
|
$this->app->ActionHandler("list", "PLACEHOLDER_LIST");
|
|
|
|
$this->app->ActionHandler("create", "PLACEHOLDER_EDIT"); // This automatically adds a "New" button
|
|
|
|
$this->app->ActionHandler("edit", "PLACEHOLDER_EDIT");
|
|
|
|
$this->app->ActionHandler("delete", "PLACEHOLDER_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 "PLACEHOLDER_LIST":
|
|
|
|
$allowed['PLACEHOLDER_LIST'] = array('list');
|
2023-03-02 09:52:36 +01:00
|
|
|
$heading = array('','',PLACEHOLDER_HEADERS, 'Menü');
|
2022-10-21 18:11:56 +02:00
|
|
|
$width = array('1%','1%','10%'); // Fill out manually later
|
2022-06-24 18:19:26 +02:00
|
|
|
|
2022-11-07 16:54:57 +01:00
|
|
|
// columns that are aligned right (numbers etc)
|
|
|
|
// $alignright = array(4,5,6,7,8);
|
|
|
|
|
2023-03-02 09:52:36 +01:00
|
|
|
$findcols = array('PLACEHOLDER_ID_COLUMN','PLACEHOLDER_ID_COLUMN',PLACEHOLDER_SQL_COLUMNS);
|
2022-07-22 11:55:58 +02:00
|
|
|
$searchsql = array(PLACEHOLDER_SQL_COLUMNS);
|
2022-06-24 18:19:26 +02:00
|
|
|
|
|
|
|
$defaultorder = 1;
|
|
|
|
$defaultorderdesc = 0;
|
2023-11-30 19:39:11 +01:00
|
|
|
$aligncenter = array();
|
|
|
|
$alignright = array();
|
|
|
|
$numbercols = array();
|
|
|
|
$sumcol = array();
|
2022-06-24 18:19:26 +02:00
|
|
|
|
2023-10-16 21:22:21 +02:00
|
|
|
$dropnbox = "PLACEHOLDER_DROPNBOX";
|
|
|
|
|
|
|
|
// $moreinfo = true; // Allow drop down details
|
2023-10-20 15:48:53 +02:00
|
|
|
// $moreinfoaction = "lieferschein"; // specify suffix for minidetail-URL to allow different minidetails
|
2023-10-16 21:22:21 +02:00
|
|
|
// $menucol = 11; // Set id col for moredata/menu
|
2022-10-21 18:11:56 +02:00
|
|
|
|
2022-08-07 11:50:57 +02:00
|
|
|
$menu = "<table cellpadding=0 cellspacing=0><tr><td nowrap>" . "<a href=\"index.php?module=PLACEHOLDER_MODULENAME&action=edit&id=%value%\"><img src=\"./themes/{$app->Conf->WFconf['defaulttheme']}/images/edit.svg\" border=\"0\"></a> <a href=\"#\" onclick=DeleteDialog(\"index.php?module=PLACEHOLDER_MODULENAME&action=delete&id=%value%\");>" . "<img src=\"themes/{$app->Conf->WFconf['defaulttheme']}/images/delete.svg\" border=\"0\"></a>" . "</td></tr></table>";
|
2022-06-24 18:19:26 +02:00
|
|
|
|
|
|
|
$sql = "PLACEHOLDER_SQL_LIST";
|
|
|
|
|
2022-06-25 11:33:55 +02:00
|
|
|
$where = "1";
|
2022-06-24 18:19:26 +02:00
|
|
|
$count = "SELECT count(DISTINCT id) FROM PLACEHOLDER_MODULENAME WHERE $where";
|
2022-06-25 11:33:55 +02:00
|
|
|
// $groupby = "";
|
2022-06-24 18:19:26 +02:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$erg = false;
|
|
|
|
|
|
|
|
foreach ($erlaubtevars as $k => $v) {
|
2022-06-25 11:33:55 +02:00
|
|
|
if (isset($$v)) {
|
2022-06-24 18:19:26 +02:00
|
|
|
$erg[$v] = $$v;
|
2022-06-25 11:33:55 +02:00
|
|
|
}
|
2022-06-24 18:19:26 +02:00
|
|
|
}
|
|
|
|
return $erg;
|
|
|
|
}
|
|
|
|
|
|
|
|
function PLACEHOLDER_LIST() {
|
|
|
|
$this->app->erp->MenuEintrag("index.php?module=PLACEHOLDER_MODULENAME&action=list", "Übersicht");
|
|
|
|
$this->app->erp->MenuEintrag("index.php?module=PLACEHOLDER_MODULENAME&action=create", "Neu anlegen");
|
|
|
|
|
|
|
|
$this->app->erp->MenuEintrag("index.php", "Zurück");
|
|
|
|
|
|
|
|
$this->app->YUI->TableSearch('TAB1', 'PLACEHOLDER_LIST', "show", "", "", basename(__FILE__), __CLASS__);
|
|
|
|
$this->app->Tpl->Parse('PAGE', "PLACEHOLDER_MODULENAME_list.tpl");
|
|
|
|
}
|
|
|
|
|
|
|
|
public function PLACEHOLDER_DELETE() {
|
2024-06-05 09:50:51 +02:00
|
|
|
$id = (int) $this->app->Secure->GetGET('id');
|
2022-06-24 18:19:26 +02:00
|
|
|
$this->app->DB->Delete("DELETE FROM `PLACEHOLDER_MODULENAME` WHERE `id` = '{$id}'");
|
2024-06-05 09:50:51 +02:00
|
|
|
$this->app->Tpl->addMessage('error', 'Der Eintrag wurde gelöscht');
|
2022-06-24 18:19:26 +02:00
|
|
|
$this->PLACEHOLDER_LIST();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Edit PLACEHOLDER_MODULENAME item
|
|
|
|
* If id is empty, create a new one
|
|
|
|
*/
|
|
|
|
|
|
|
|
function PLACEHOLDER_EDIT() {
|
|
|
|
$id = $this->app->Secure->GetGET('id');
|
2022-11-10 17:00:25 +01:00
|
|
|
|
|
|
|
// Check if other users are editing this id
|
2024-01-05 11:44:45 +01:00
|
|
|
if($this->app->erp->DisableModul('PLACEHOLDER_MODULENAME',$id))
|
2022-11-10 17:00:25 +01:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2022-06-24 18:19:26 +02:00
|
|
|
|
|
|
|
$this->app->Tpl->Set('ID', $id);
|
|
|
|
|
|
|
|
$this->app->erp->MenuEintrag("index.php?module=PLACEHOLDER_MODULENAME&action=edit&id=$id", "Details");
|
|
|
|
$this->app->erp->MenuEintrag("index.php?module=PLACEHOLDER_MODULENAME&action=list", "Zurück zur Übersicht");
|
|
|
|
$id = $this->app->Secure->GetGET('id');
|
|
|
|
$input = $this->GetInput();
|
2024-06-10 17:44:23 +02:00
|
|
|
|
|
|
|
// Convert here
|
|
|
|
// $input['prio'] = !empty($this->app->Secure->GetPOST('prio'))?"1":"0";
|
|
|
|
|
2022-06-24 18:19:26 +02:00
|
|
|
$submit = $this->app->Secure->GetPOST('submit');
|
|
|
|
|
|
|
|
if (empty($id)) {
|
|
|
|
// New item
|
|
|
|
$id = 'NULL';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($submit != '')
|
|
|
|
{
|
|
|
|
|
|
|
|
// Write to database
|
|
|
|
|
|
|
|
// Add checks here
|
|
|
|
|
2023-10-16 21:22:21 +02:00
|
|
|
// $input['projekt'] = $this->app->erp->ReplaceProjekt(true,$input['projekt'],true); // Parameters: Target db?, value, from form?
|
|
|
|
|
2022-06-24 18:19:26 +02:00
|
|
|
$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 PLACEHOLDER_MODULENAME (".$columns.") VALUES (".$values.") ON DUPLICATE KEY UPDATE ".$update;
|
|
|
|
|
2022-06-25 11:33:55 +02:00
|
|
|
// echo($sql);
|
2022-06-24 18:19:26 +02:00
|
|
|
|
|
|
|
$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=PLACEHOLDER_MODULENAME&action=list&msg=$msg");
|
|
|
|
} else {
|
2024-06-05 09:50:51 +02:00
|
|
|
$this->app->Tpl->addMessage('success', 'Die Einstellungen wurden erfolgreich übernommen.');
|
2022-06-24 18:19:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Load values again from database
|
2024-06-05 09:50:51 +02:00
|
|
|
if ($id != 'NULL') {
|
2022-06-24 18:19:26 +02:00
|
|
|
|
2024-06-05 09:50:51 +02:00
|
|
|
$dropnbox = "PLACEHOLDER_DROPNBOX";
|
|
|
|
$result = $this->app->DB->SelectArr("PLACEHOLDER_SQL_LIST"." WHERE id=$id");
|
2023-11-30 19:39:11 +01:00
|
|
|
|
2024-06-05 09:50:51 +02:00
|
|
|
foreach ($result[0] as $key => $value) {
|
|
|
|
$this->app->Tpl->Set(strtoupper($key), $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($result)) {
|
|
|
|
$PLACEHOLDER_MODULENAME_from_db = $result[0];
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
2023-11-30 19:39:11 +01:00
|
|
|
}
|
2022-06-25 11:33:55 +02:00
|
|
|
|
2022-06-24 18:19:26 +02:00
|
|
|
/*
|
|
|
|
* Add displayed items later
|
|
|
|
*
|
|
|
|
|
|
|
|
$this->app->Tpl->Add('KURZUEBERSCHRIFT2', $email);
|
|
|
|
$this->app->Tpl->Add('EMAIL', $email);
|
|
|
|
$this->app->Tpl->Add('ANGEZEIGTERNAME', $angezeigtername);
|
2023-10-16 21:22:21 +02:00
|
|
|
|
|
|
|
$this->app->YUI->AutoComplete("artikel", "artikelnummer");
|
2024-06-10 17:44:23 +02:00
|
|
|
$this->app->Tpl->Set('PROJEKT',$this->app->erp->ReplaceProjekt(false,$PLACEHOLDER_MODULENAME_from_db['projekt'],false));
|
|
|
|
$this->app->Tpl->Set('PRIO', $PLACEHOLDER_MODULENAME_from_db['prio']==1?"checked":"");
|
2023-10-16 21:22:21 +02:00
|
|
|
|
2022-06-24 18:19:26 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
$this->app->Tpl->Parse('PAGE', "PLACEHOLDER_MODULENAME_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');
|
|
|
|
|
|
|
|
PLACEHOLDER_GET_INPUT
|
|
|
|
|
|
|
|
return $input;
|
|
|
|
}
|
2023-10-20 15:48:53 +02:00
|
|
|
}
|