From 2b50aa6f3a79f428dbf51f29dc7544ccb3c2cac8 Mon Sep 17 00:00:00 2001 From: OpenXE <> Date: Thu, 30 May 2024 18:13:49 +0200 Subject: [PATCH] AARLGEditable insert with position # --- phpwf/plugins/class.yui.php | 30 ++++++- www/pages/angebot.php | 151 ------------------------------------ 2 files changed, 27 insertions(+), 154 deletions(-) diff --git a/phpwf/plugins/class.yui.php b/phpwf/plugins/class.yui.php index d78eb336..9b17b1ec 100644 --- a/phpwf/plugins/class.yui.php +++ b/phpwf/plugins/class.yui.php @@ -1122,6 +1122,15 @@ class YUI { return $newid; } + /* + * Move all special fields by one position after a certain position + * Use after inserting a position + */ + function pushDrawItem($module, $id, $pos) { + $sql = "UPDATE `beleg_zwischenpositionen` set `pos` = `pos`+1 WHERE `pos` > $pos AND `doctype` = '$module' AND `doctypeid` = '$id'"; + $this->app->DB->Update($sql); + } + function ReSortDrawItem($module, $id) { $items = $this->app->DB->SelectArr("SELECT id, pos, sort FROM beleg_zwischenpositionen WHERE doctype = '".$module."' AND doctypeid = '$id' ORDER BY pos, sort"); @@ -1820,8 +1829,16 @@ class YUI { ) ); $projekt = $this->app->DB->Select("SELECT id FROM projekt WHERE abkuerzung='$projekt' LIMIT 1"); - $sort = $this->app->DB->Select("SELECT MAX(sort) FROM $table WHERE $module='$id' LIMIT 1"); - $sort = $sort + 1; + + $insertbefore = $this->app->Secure->GetPOST("insertbefore"); + if (is_numeric($insertbefore)) { + $sort = $insertbefore - 1; + $reload_afterwards = true; + } else { + $sort = $this->app->DB->Select("SELECT MAX(sort) FROM $table WHERE $module='$id' LIMIT 1"); + $sort = $sort + 1; + } + $adresse = $docArr['adresse'];// $this->app->DB->Select("SELECT adresse FROM $module WHERE id='$id' LIMIT 1"); $sprache = $docArr['sprache'];//$this->app->DB->Select("SELECT sprache FROM $module WHERE id='$id' LIMIT 1"); if($sprache=='') { @@ -3043,6 +3060,13 @@ class YUI { } $this->app->Tpl->Add('PAGE', ""); } + + if ($reload_afterwards) { + $this->pushDrawItem($module,$id,$sort); + header('Location: index.php?module='.$module.'&action=positionen&id='.$id); + exit; + } + } function FormatPreis($spalte) @@ -14792,7 +14816,7 @@ source: "index.php?module=ajax&action=filter&filtername=' . $filter . $extendurl if ($module == "angebot" || $module == "auftrag" || $module == "rechnung" || $module == "gutschrift" || $module == "proformarechnung") { if ($schreibschutz != 1) { - $addrow = array('