mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-12-25 14:10:28 +01:00
185 lines
6.1 KiB
Plaintext
185 lines
6.1 KiB
Plaintext
<?php
|
|
|
|
/*
|
|
* Copyright (c) 2022 Xenomporio project
|
|
*/
|
|
|
|
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');
|
|
$heading = array(PLACEHOLDER_COLUMNS, 'Menü');
|
|
$width = array('10%'); // Fill out manually later
|
|
|
|
$findcols = array(PLACEHOLDER_SQL_COLUMNS);
|
|
$searchsql = array(PLACEHOLDER_SQL_COLUMNS);
|
|
|
|
$defaultorder = 1;
|
|
$defaultorderdesc = 0;
|
|
|
|
$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.png\" 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>";
|
|
|
|
$sql = "PLACEHOLDER_SQL_LIST";
|
|
|
|
$where = "1";
|
|
$count = "SELECT count(DISTINCT id) FROM PLACEHOLDER_MODULENAME WHERE $where";
|
|
// $groupby = "";
|
|
|
|
break;
|
|
}
|
|
|
|
$erg = false;
|
|
|
|
foreach ($erlaubtevars as $k => $v) {
|
|
if (isset($$v)) {
|
|
$erg[$v] = $$v;
|
|
}
|
|
}
|
|
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() {
|
|
$id = (int) $this->app->Secure->GetGET('id');
|
|
|
|
$this->app->DB->Delete("DELETE FROM `PLACEHOLDER_MODULENAME` WHERE `id` = '{$id}'");
|
|
$this->app->Tpl->Set('MESSAGE', "<div class=\"error\">Der Eintrag wurde gelöscht.</div>");
|
|
|
|
$this->PLACEHOLDER_LIST();
|
|
}
|
|
|
|
/*
|
|
* Edit PLACEHOLDER_MODULENAME item
|
|
* If id is empty, create a new one
|
|
*/
|
|
|
|
function PLACEHOLDER_EDIT() {
|
|
$id = $this->app->Secure->GetGET('id');
|
|
|
|
$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();
|
|
$submit = $this->app->Secure->GetPOST('submit');
|
|
|
|
if (empty($id)) {
|
|
// New item
|
|
$id = 'NULL';
|
|
}
|
|
|
|
if ($submit != '')
|
|
{
|
|
|
|
// Write to database
|
|
|
|
// Add checks here
|
|
|
|
$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;
|
|
|
|
// 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=PLACEHOLDER_MODULENAME&action=list&msg=$msg");
|
|
} else {
|
|
$this->app->Tpl->Set('MESSAGE', "<div class=\"success\">Die Einstellungen wurden erfolgreich übernommen.</div>");
|
|
}
|
|
}
|
|
|
|
|
|
// Load values again from database
|
|
$result = $this->app->DB->SelectArr("PLACEHOLDER_SQL_LIST"." WHERE id=$id");
|
|
|
|
foreach ($result[0] as $key => $value) {
|
|
$this->app->Tpl->Set(strtoupper($key), $value);
|
|
}
|
|
|
|
/*
|
|
* Add displayed items later
|
|
*
|
|
|
|
$this->app->Tpl->Add('KURZUEBERSCHRIFT2', $email);
|
|
$this->app->Tpl->Add('EMAIL', $email);
|
|
$this->app->Tpl->Add('ANGEZEIGTERNAME', $angezeigtername);
|
|
*/
|
|
|
|
// $this->SetInput($input);
|
|
$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;
|
|
}
|
|
|
|
/*
|
|
* Set all fields in the page corresponding to $input
|
|
*/
|
|
function SetInput($input) {
|
|
// $this->app->Tpl->Set('EMAIL', $input['email']);
|
|
|
|
PLACEHOLDER_SET_INPUT
|
|
}
|
|
|
|
}
|