From 2b95a3891a726b03a9e885263256ee8bdf61937b Mon Sep 17 00:00:00 2001
From: OpenXE <>
Date: Fri, 29 Dec 2023 13:44:31 +0100
Subject: [PATCH] restored module kostenstellen
---
www/pages/content/kostenstellen_edit.tpl | 119 +++++++++++++
www/pages/content/kostenstellen_list.tpl | 10 ++
www/pages/kostenstellen.php | 207 +++++++++++++++++++++++
3 files changed, 336 insertions(+)
create mode 100644 www/pages/content/kostenstellen_edit.tpl
create mode 100644 www/pages/content/kostenstellen_list.tpl
create mode 100644 www/pages/kostenstellen.php
diff --git a/www/pages/content/kostenstellen_edit.tpl b/www/pages/content/kostenstellen_edit.tpl
new file mode 100644
index 00000000..56f30def
--- /dev/null
+++ b/www/pages/content/kostenstellen_edit.tpl
@@ -0,0 +1,119 @@
+
+
diff --git a/www/pages/content/kostenstellen_list.tpl b/www/pages/content/kostenstellen_list.tpl
new file mode 100644
index 00000000..394c103a
--- /dev/null
+++ b/www/pages/content/kostenstellen_list.tpl
@@ -0,0 +1,10 @@
+
+
+
+ [MESSAGE]
+ [TAB1]
+ [TAB1NEXT]
+
+
diff --git a/www/pages/kostenstellen.php b/www/pages/kostenstellen.php
new file mode 100644
index 00000000..e1a8f082
--- /dev/null
+++ b/www/pages/kostenstellen.php
@@ -0,0 +1,207 @@
+app = $app;
+ if ($intern)
+ return;
+
+ $this->app->ActionHandlerInit($this);
+ $this->app->ActionHandler("list", "kostenstellen_list");
+ $this->app->ActionHandler("create", "kostenstellen_edit"); // This automatically adds a "New" button
+ $this->app->ActionHandler("edit", "kostenstellen_edit");
+ $this->app->ActionHandler("delete", "kostenstellen_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 "kostenstellen_list":
+ $allowed['kostenstellen_list'] = array('list');
+ $heading = array('','','Nummer', 'Beschreibung', 'Internebemerkung', 'Menü');
+ $width = array('1%','1%','10%'); // Fill out manually later
+
+ // columns that are aligned right (numbers etc)
+ // $alignright = array(4,5,6,7,8);
+
+ $findcols = array('k.id','k.id','k.nummer', 'k.beschreibung', 'k.internebemerkung');
+ $searchsql = array('k.nummer', 'k.beschreibung', 'k.internebemerkung');
+
+ $defaultorder = 1;
+ $defaultorderdesc = 0;
+ $aligncenter = array();
+ $alignright = array();
+ $numbercols = array();
+ $sumcol = array();
+
+ $dropnbox = "'
' AS `open`, CONCAT('') AS `auswahl`";
+
+// $moreinfo = true; // Allow drop down details
+// $moreinfoaction = "lieferschein"; // specify suffix for minidetail-URL to allow different minidetails
+// $menucol = 11; // Set id col for moredata/menu
+
+ $menu = "";
+
+ $sql = "SELECT SQL_CALC_FOUND_ROWS k.id, $dropnbox, k.nummer, k.beschreibung, k.internebemerkung, k.id FROM kostenstellen k";
+
+ $where = "1";
+ $count = "SELECT count(DISTINCT id) FROM kostenstellen WHERE $where";
+// $groupby = "";
+
+ break;
+ }
+
+ $erg = false;
+
+ foreach ($erlaubtevars as $k => $v) {
+ if (isset($$v)) {
+ $erg[$v] = $$v;
+ }
+ }
+ return $erg;
+ }
+
+ function kostenstellen_list() {
+ $this->app->erp->MenuEintrag("index.php?module=kostenstellen&action=list", "Übersicht");
+ $this->app->erp->MenuEintrag("index.php?module=kostenstellen&action=create", "Neu anlegen");
+
+ $this->app->erp->MenuEintrag("index.php", "Zurück");
+
+ $this->app->YUI->TableSearch('TAB1', 'kostenstellen_list', "show", "", "", basename(__FILE__), __CLASS__);
+ $this->app->Tpl->Parse('PAGE', "kostenstellen_list.tpl");
+ }
+
+ public function kostenstellen_delete() {
+ $id = (int) $this->app->Secure->GetGET('id');
+
+ $this->app->DB->Delete("DELETE FROM `kostenstellen` WHERE `id` = '{$id}'");
+ $this->app->Tpl->Set('MESSAGE', "Der Eintrag wurde gelöscht.
");
+
+ $this->kostenstellen_list();
+ }
+
+ /*
+ * Edit kostenstellen item
+ * If id is empty, create a new one
+ */
+
+ function kostenstellen_edit() {
+ $id = $this->app->Secure->GetGET('id');
+
+ // Check if other users are editing this id
+ if($this->app->erp->DisableModul('artikel',$id))
+ {
+ return;
+ }
+
+ $this->app->Tpl->Set('ID', $id);
+
+ $this->app->erp->MenuEintrag("index.php?module=kostenstellen&action=edit&id=$id", "Details");
+ $this->app->erp->MenuEintrag("index.php?module=kostenstellen&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
+
+ // $input['projekt'] = $this->app->erp->ReplaceProjekt(true,$input['projekt'],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."
");
+// echo($values."
");
+// echo($update."
");
+
+ $sql = "INSERT INTO kostenstellen (".$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("Das Element wurde erfolgreich angelegt.
");
+ header("Location: index.php?module=kostenstellen&action=list&msg=$msg");
+ } else {
+ $this->app->Tpl->Set('MESSAGE', "Die Einstellungen wurden erfolgreich übernommen.
");
+ }
+ }
+
+
+ // Load values again from database
+ $dropnbox = "'
' AS `open`, CONCAT('') AS `auswahl`";
+ $result = $this->app->DB->SelectArr("SELECT SQL_CALC_FOUND_ROWS k.id, $dropnbox, k.nummer, k.beschreibung, k.internebemerkung, k.id FROM kostenstellen k"." WHERE id=$id");
+
+ foreach ($result[0] as $key => $value) {
+ $this->app->Tpl->Set(strtoupper($key), $value);
+ }
+
+ if (!empty($result)) {
+ $kostenstellen_from_db = $result[0];
+ } else {
+ return;
+ }
+
+ /*
+ * Add displayed items later
+ *
+
+ $this->app->Tpl->Add('KURZUEBERSCHRIFT2', $email);
+ $this->app->Tpl->Add('EMAIL', $email);
+ $this->app->Tpl->Add('ANGEZEIGTERNAME', $angezeigtername);
+
+ $this->app->YUI->AutoComplete("artikel", "artikelnummer");
+
+ */
+
+ $this->app->Tpl->Parse('PAGE', "kostenstellen_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['nummer'] = $this->app->Secure->GetPOST('nummer');
+ $input['beschreibung'] = $this->app->Secure->GetPOST('beschreibung');
+ $input['internebemerkung'] = $this->app->Secure->GetPOST('internebemerkung');
+
+
+ return $input;
+ }
+ }