From 29d91042866e9dbd9bbdd934c1dc28125c65a8ef Mon Sep 17 00:00:00 2001 From: Geno Date: Thu, 19 Nov 2020 23:10:23 +0100 Subject: [PATCH] OrderSprinter 1.4.7 --- gastsystem/index.php | 6 +- gastsystem/install.php | 4 +- printserver/OrderSprinterPrintserver.exe | Bin 265728 -> 265728 bytes spider/install/installer.php | 2 +- webapp/OrderSprinterPrintserver.exe | Bin 265728 -> 265728 bytes webapp/bar.html | 2 +- webapp/bill.html | 2 +- webapp/feedback.html | 2 +- webapp/index.html | 6 +- webapp/install.html | 2 +- webapp/install/installer.php | 32 ++++++++-- webapp/kitchen.html | 2 +- webapp/manager.html | 8 +-- webapp/paydesk.html | 2 +- webapp/php/admin.php | 50 ++++++++------- webapp/php/debug.php | 2 +- webapp/php/products.php | 76 +++++++++++++++++------ webapp/php/utilities/basedb.php | 30 +++++++++ webapp/preferences.html | 2 +- webapp/products.html | 2 +- webapp/rating.html | 2 +- webapp/reports.html | 2 +- webapp/reservation.html | 2 +- webapp/supplydesk.html | 2 +- webapp/waiter.html | 4 +- 25 files changed, 171 insertions(+), 73 deletions(-) diff --git a/gastsystem/index.php b/gastsystem/index.php index fac1e41..2e6e697 100644 --- a/gastsystem/index.php +++ b/gastsystem/index.php @@ -9,8 +9,8 @@ - - + + @@ -105,7 +105,7 @@
  OrderSprinter
-
1.4.6  
+
1.4.7  
diff --git a/gastsystem/install.php b/gastsystem/install.php index b3bb889..f402968 100644 --- a/gastsystem/install.php +++ b/gastsystem/install.php @@ -90,10 +90,10 @@ if (isset($_POST['code'])) { } else { echo ""; echo "Installation Gastsystem"; - echo ''; + echo ''; echo ""; echo "
"; - echo "Installation OrderSprinter-Gastsystem 1.4.6

"; + echo "Installation OrderSprinter-Gastsystem 1.4.7

"; echo "
"; echo "
"; echo "
"; diff --git a/printserver/OrderSprinterPrintserver.exe b/printserver/OrderSprinterPrintserver.exe index 92fb76f7bfb6121d95801fd7181e88143bb34cbe..17f41aba709c904f81ecd833510c9db09ed07f1b 100644 GIT binary patch delta 154 zcmZpeBhWBMU_uA;myNd@yIZ>%Tf3RIb~A78W@O)P-^094N5#n0$il$fz);uC(9J;C z#KP2A*TTiwQPt=&vpyO}q4GqP>B?_pl2qhf68YGz?z?5Jz#X5^}C zV(#ds>u71>q-*A4Y;0-f>|}0WY`9%;Cv&thquKV{H_Y5z0#*&rO!ef~yRY=lHJ*05 zz;JuVH|BNxKxuO}mT)FcHU<_3Mg|53w(Zk7SYjE0;$JygmILYObGcbSrd;G^(Pshx D "OK","msg" => "Installation successful"); diff --git a/webapp/OrderSprinterPrintserver.exe b/webapp/OrderSprinterPrintserver.exe index 92fb76f7bfb6121d95801fd7181e88143bb34cbe..17f41aba709c904f81ecd833510c9db09ed07f1b 100644 GIT binary patch delta 154 zcmZpeBhWBMU_uA;myNd@yIZ>%Tf3RIb~A78W@O)P-^094N5#n0$il$fz);uC(9J;C z#KP2A*TTiwQPt=&vpyO}q4GqP>B?_pl2qhf68YGz?z?5Jz#X5^}C zV(#ds>u71>q-*A4Y;0-f>|}0WY`9%;Cv&thquKV{H_Y5z0#*&rO!ef~yRY=lHJ*05 zz;JuVH|BNxKxuO}mT)FcHU<_3Mg|53w(Zk7SYjE0;$JygmILYObGcbSrd;G^(Pshx D - + diff --git a/webapp/bill.html b/webapp/bill.html index d3e3499..b74948e 100644 --- a/webapp/bill.html +++ b/webapp/bill.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/feedback.html b/webapp/feedback.html index 5b4cce4..1f9f3a3 100644 --- a/webapp/feedback.html +++ b/webapp/feedback.html @@ -4,7 +4,7 @@ - + diff --git a/webapp/index.html b/webapp/index.html index 6121cd8..711db78 100644 --- a/webapp/index.html +++ b/webapp/index.html @@ -9,8 +9,8 @@ - - + + @@ -215,7 +215,7 @@ function handleResultOfInstallCheck(is_installed) { if (is_installed == "Yes") { useInstallation(); } else { - setTimeout(function(){document.location.href = "install.html?v=1.4.6"},500); + setTimeout(function(){document.location.href = "install.html?v=1.4.7"},500); } } diff --git a/webapp/install.html b/webapp/install.html index 5679956..9480258 100644 --- a/webapp/install.html +++ b/webapp/install.html @@ -727,7 +727,7 @@ $(document).ready(function() {   - +   diff --git a/webapp/install/installer.php b/webapp/install/installer.php index d360d46..6af287a 100644 --- a/webapp/install/installer.php +++ b/webapp/install/installer.php @@ -2931,6 +2931,30 @@ return false; } } +function updateUserTable1406_1407($prefix, $version, $dbname) { +$pdo = $this->pdo; +try { +if ($version != "1.4.6") { +$ret = $this->updateUserTable1405_1406($prefix, $version, $dbname); +if (!$ret) { +echo "Version update v1.4.5 to 1.4.6 not successful."; +return false; +} +} + +DbUtils::overrulePrefix($prefix); + +$this->basedb->sortProdTypes($pdo); + +$this->updateVersion($pdo, '1.4.7'); + +return true; +} catch (PDOException $e) { +echo "Error in v1.4.6 to 1.4.7: $e"; +return false; +} +} + function insertIntRow($pdo,$table,$rowToInsert,$afterRow) { $this->insertTypeRow($pdo, $table, $rowToInsert, $afterRow, 'INT(1) NULL'); } @@ -3106,7 +3130,7 @@ $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VAL $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'billlanguage', $billlanguage)"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'currency', '$currency')"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'receiptfontsize', '12')"); -$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'version', '1.4.6')"); +$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'version', '1.4.7')"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'paymentconfig', '0')"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'remoteaccesscode', null)"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'decpoint', '$decpoint')"); @@ -3558,7 +3582,7 @@ $zones[] = $timezone_identifiers[$i]; echo json_encode($zones); } else if ($command == 'update') { set_time_limit(60*30); -$installerVersion = "1.4.6"; +$installerVersion = "1.4.7"; $admin = new InstallAdmin(); $pdo = $admin->openDbAndReturnPdo($_POST['host'],$_POST['db'],$_POST['user'],$_POST['password']); @@ -3590,7 +3614,7 @@ $supportedVersions = array("1.0.22","1.0.23","1.0.24","1.0.25","1.0.26","1.0.27" "1.2.0","1.2.1","1.2.2", "1.2.3", "1.2.4","1.2.5","1.2.6","1.2.7","1.2.8","1.2.9","1.2.10","1.2.11","1.2.12","1.2.13","1.2.14","1.2.15","1.2.16","1.2.17", "1.2.18","1.2.19","1.2.20","1.2.21","1.2.22","1.3.0","1.3.1","1.3.2","1.3.3","1.3.4","1.3.5","1.3.6","1.3.7","1.3.8","1.3.9","1.3.10","1.3.11","1.3.12", "1.3.13","1.3.14","1.3.15","1.3.16","1.3.17","1.3.18","1.3.19","1.3.20","1.3.21","1.3.22","1.3.23","1.3.24","1.3.25","1.3.26","1.4.0","1.4.1","1.4.2","1.4.3", -"1.4.4","1.4.5" +"1.4.4","1.4.5","1.4.6" ); if (!in_array($version, $supportedVersions)) { @@ -3598,7 +3622,7 @@ echo json_encode("Quellversion nicht unterstützt"); return; } -$ret = $admin->updateUserTable1405_1406($_POST['prefix'], $version, $_POST['db']); +$ret = $admin->updateUserTable1406_1407($_POST['prefix'], $version, $_POST['db']); if(session_id() == '') { session_start(); diff --git a/webapp/kitchen.html b/webapp/kitchen.html index 6ae6c64..635ed8e 100644 --- a/webapp/kitchen.html +++ b/webapp/kitchen.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/manager.html b/webapp/manager.html index 495e000..f9f2f1f 100644 --- a/webapp/manager.html +++ b/webapp/manager.html @@ -5,7 +5,7 @@ - + @@ -1246,7 +1246,7 @@ function initRestoreFileUpload() { } else { alert("Import war erfolgreich."); setTimeout(function(){ - document.location.href = "index.html?v=1.4.6"; + document.location.href = "index.html?v=1.4.7"; },250); } }, @@ -1783,9 +1783,9 @@ function handleUpdateCheckResult(answer) { var millis=getMillis(); setTimeout(function(){ - document.location.href = "install.html?v=1.4.6&mode=onlyupdate&n=" + millis; + document.location.href = "install.html?v=1.4.7&mode=onlyupdate&n=" + millis; },250); - document.location.href = "install.html?v=1.4.6&mode=onlyupdate&n=" + millis; + document.location.href = "install.html?v=1.4.7&mode=onlyupdate&n=" + millis; } function handleUpdateReplace(answer) { diff --git a/webapp/paydesk.html b/webapp/paydesk.html index 5c2682b..86038a8 100644 --- a/webapp/paydesk.html +++ b/webapp/paydesk.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/php/admin.php b/webapp/php/admin.php index 0a7ee94..23e67f1 100644 --- a/webapp/php/admin.php +++ b/webapp/php/admin.php @@ -970,7 +970,7 @@ class Admin { $buttonSizes = self::getButtonSizesCore($pdo); - $jsonMenuItems = $this->getJsonMenuItemsAndVersionCore(); + $jsonMenuItems = $this->getJsonMenuItemsAndVersionCore($pdo); $retVal = array("config" => $configresult, "rightchangeprice" => $row->right_changeprice, @@ -1253,7 +1253,7 @@ class Admin { $view = "preferences.html"; } - echo json_encode($view . "?v=1.4.6"); + echo json_encode($view . "?v=1.4.7"); } } @@ -1388,6 +1388,9 @@ class Admin { Products::cleanProdImagesTable($pdo); } + $basedb = new Basedb(); + $basedb->sortProdTypes($pdo); + return $ret; } @@ -1416,13 +1419,14 @@ class Admin { } function getJsonMenuItemsAndVersion() { - echo json_encode($this->getJsonMenuItemsAndVersionCore()); + $pdo = DbUtils::openDbAndReturnPdoStatic(); + echo json_encode($this->getJsonMenuItemsAndVersionCore($pdo)); } /* * Return all the entries for the main menu (the modules) */ - private function getJsonMenuItemsAndVersionCore() { + private function getJsonMenuItemsAndVersionCore($pdo) { if(session_id() == '') { session_start(); } @@ -1460,27 +1464,27 @@ class Admin { if (!self::isOnlyRatingUser($rights, $right_rating, true)) { if ($_SESSION['modus'] == 0) { - if ($_SESSION['right_waiter']) { $mainMenu[] = array("name" => $waitertxt[$lang], "link" => "waiter.html?v=1.4.6"); }; + if ($_SESSION['right_waiter']) { $mainMenu[] = array("name" => $waitertxt[$lang], "link" => "waiter.html?v=1.4.7"); }; } else { - if ($_SESSION['right_waiter']) { $mainMenu[] = array("name" => $waiterdesktxt[$lang], "link" => "waiterdesktop.php?v=1.4.6"); }; + if ($_SESSION['right_waiter']) { $mainMenu[] = array("name" => $waiterdesktxt[$lang], "link" => "waiterdesktop.php?v=1.4.7"); }; } - if ($_SESSION['right_kitchen']) { $mainMenu[] = array("name" => $kitchentxt[$lang], "link" => "kitchen.html?v=1.4.6"); }; - if ($_SESSION['right_bar']) { $mainMenu[] = array("name" => "Bar", "link" => "bar.html?v=1.4.6"); }; - if ($_SESSION['right_supply']) { $mainMenu[] = array("name" => $supplytxt[$lang], "link" => "supplydesk.html?v=1.4.6"); }; + if ($_SESSION['right_kitchen']) { $mainMenu[] = array("name" => $kitchentxt[$lang], "link" => "kitchen.html?v=1.4.7"); }; + if ($_SESSION['right_bar']) { $mainMenu[] = array("name" => "Bar", "link" => "bar.html?v=1.4.7"); }; + if ($_SESSION['right_supply']) { $mainMenu[] = array("name" => $supplytxt[$lang], "link" => "supplydesk.html?v=1.4.7"); }; if ($_SESSION['modus'] == 0) { - if ($_SESSION['right_paydesk']) { $mainMenu[] = array("name" => $paydesktxt[$lang], "link" => "paydesk.html?v=1.4.6"); }; + if ($_SESSION['right_paydesk']) { $mainMenu[] = array("name" => $paydesktxt[$lang], "link" => "paydesk.html?v=1.4.7"); }; } - if ($_SESSION['right_statistics']) { $mainMenu[] = array("name" => $stattxt[$lang], "link" => "reports.html?v=1.4.6"); }; - if ($_SESSION['right_bill']) { $mainMenu[] = array("name" => $bontxt[$lang], "link" => "bill.html?v=1.4.6"); }; - if ($_SESSION['right_products']) { $mainMenu[] = array("name" => $prodtxt[$lang], "link" => "products.html?v=1.4.6"); }; - if ($_SESSION['right_reservation']) { $mainMenu[] = array("name" => $restxt[$lang], "link" => "reservation.html?v=1.4.6"); }; - if ($_SESSION['right_rating']) { $mainMenu[] = array("name" => $ratingtxt[$lang], "link" => "rating.html?v=1.4.6"); }; - if ($_SESSION['right_customers']) { $mainMenu[] = array("name" => $customerstxt[$lang], "link" => "customers.html?v=1.4.6"); }; - if ($_SESSION['right_dash']) { $mainMenu[] = array("name" => $dashtxt[$lang], "link" => "dash.php?v=1.4.6"); }; - if ($_SESSION['right_manager'] || $_SESSION['is_admin'] || $_SESSION['right_closing']) { $mainMenu[] = array("name" => $admintxt[$lang], "link" => "manager.html?v=1.4.6"); }; - $mainMenu[] = array("name" => $settingtxt[$lang], "link" => "preferences.html?v=1.4.6"); - $mainMenu[] = array("name" => "Hilfe", "link" => "help.php?v=1.4.6"); - $mainMenu[] = array("name" => "Feedback", "link" => "feedback.html?v=1.4.6"); + if ($_SESSION['right_statistics']) { $mainMenu[] = array("name" => $stattxt[$lang], "link" => "reports.html?v=1.4.7"); }; + if ($_SESSION['right_bill']) { $mainMenu[] = array("name" => $bontxt[$lang], "link" => "bill.html?v=1.4.7"); }; + if ($_SESSION['right_products']) { $mainMenu[] = array("name" => $prodtxt[$lang], "link" => "products.html?v=1.4.7"); }; + if ($_SESSION['right_reservation']) { $mainMenu[] = array("name" => $restxt[$lang], "link" => "reservation.html?v=1.4.7"); }; + if ($_SESSION['right_rating']) { $mainMenu[] = array("name" => $ratingtxt[$lang], "link" => "rating.html?v=1.4.7"); }; + if ($_SESSION['right_customers']) { $mainMenu[] = array("name" => $customerstxt[$lang], "link" => "customers.html?v=1.4.7"); }; + if ($_SESSION['right_dash']) { $mainMenu[] = array("name" => $dashtxt[$lang], "link" => "dash.php?v=1.4.7"); }; + if ($_SESSION['right_manager'] || $_SESSION['is_admin'] || $_SESSION['right_closing']) { $mainMenu[] = array("name" => $admintxt[$lang], "link" => "manager.html?v=1.4.7"); }; + $mainMenu[] = array("name" => $settingtxt[$lang], "link" => "preferences.html?v=1.4.7"); + $mainMenu[] = array("name" => "Hilfe", "link" => "help.php?v=1.4.7"); + $mainMenu[] = array("name" => "Feedback", "link" => "feedback.html?v=1.4.7"); } $mainMenu[] = array("name" => $logout[$lang], "link" => "logout.php"); @@ -1488,7 +1492,9 @@ class Admin { $waiterMessage = $this->getMessage(null, "waitermessage"); } - $mainMenuAndVersion = array ("version" => "OrderSprinter 1.4.6", + $installedVersion = CommonUtils::getConfigValue($pdo, 'version', '?'); + + $mainMenuAndVersion = array ("version" => "OrderSprinter $installedVersion", "user" => $currentUser, "menu" => $mainMenu, "waitermessage" => $waiterMessage, diff --git a/webapp/php/debug.php b/webapp/php/debug.php index 5b46b23..43d0887 100644 --- a/webapp/php/debug.php +++ b/webapp/php/debug.php @@ -27,7 +27,7 @@ if (isset($_POST["cmd"])) { if (strlen($status) > 150) { $status = substr($status, 0,149); } - $version = "1.4.6"; + $version = "1.4.7"; $arr = array("cmd" => $cmd,"fct" => $fct, "xhr" => $xhr,"errormsg" => $errormsg,"status" => $status,"version" => $version,"phpversion" => $phpversion); } else { diff --git a/webapp/php/products.php b/webapp/php/products.php index 3e57c42..11ec652 100644 --- a/webapp/php/products.php +++ b/webapp/php/products.php @@ -218,7 +218,7 @@ class Products { $priceTxt = "priceC"; } - $sql = "select id,name,reference from %prodtype% where removed is null"; + $sql = "select id,name,reference,sorting from %prodtype% where removed is null"; $result = CommonUtils::fetchSqlAll($pdo, $sql, null); $typeArray = array(); @@ -227,7 +227,7 @@ class Products { if ($ref == null) { $ref = 0; } - $typeArray[] = array("id" => $row['id'], "name" => $row['name'], "ref" => $ref); + $typeArray[] = array("id" => $row['id'], "name" => $row['name'], "ref" => $ref,"sorting" => $row["sorting"]); } $sql = "select id,shortname,longname,audio,category as ref,favorite,$priceTxt as price,IF(unit is not null, unit, '0') as unit,IF(days is not null, days, '0123456') as days,IF(tax is not null, tax, 'null') as tax,IF(taxaustria is not null, taxaustria, 'null') as taxaustria,IF(amount is not null, amount, 'null') as amount "; @@ -261,10 +261,17 @@ class Products { $pdo->commit(); $filteredTypes = self::filterUsedTypes($typeArray, $prodArray); + usort($filteredTypes,"Products::cmptypes"); + $retArray = array("types" => $filteredTypes, "prods" => $prodArray); echo json_encode($retArray); } + public static function cmptypes($a, $b) + { + return $a['sorting'] - $b['sorting']; + } + private static function filterUsedTypes($types,$products) { $typesWithContent = array(); @@ -279,7 +286,7 @@ class Products { $keys = array_keys($typesWithContent); foreach($keys as $aKey) { $t = $typesWithContent[$aKey]; - $out[] = array("id" => $t["id"],"name" => $t["name"],"ref" => $t["ref"]); + $out[] = array("id" => $t["id"],"name" => $t["name"],"ref" => $t["ref"],"sorting" => $t["sorting"]); } return $out; } @@ -296,8 +303,9 @@ class Products { private static function declareProdTypeAndParentsInUse($alltypes,$aType,$typesWithContent) { $typeid = $aType["id"]; $reference = $aType["ref"]; + $sorting = $aType["sorting"]; if (!array_key_exists($typeid, $typesWithContent)) { - $typesWithContent[$typeid] = array("id" => $typeid,"name" => $aType["name"],"ref" => $reference); + $typesWithContent[$typeid] = array("id" => $typeid,"name" => $aType["name"],"ref" => $reference,"sorting" => $sorting); $parent = null; foreach($alltypes as $a) { @@ -422,10 +430,9 @@ class Products { * ["id" => 2, "name" => "Drinks"], ... */ private function getProdTypesWithReferenz($pdo,$ref) { - - $sql = "SELECT id,name,kind,usekitchen,usesupplydesk,printer,'t' as type from %prodtype% where removed is null AND reference is null"; + $sql = "SELECT id,name,kind,usekitchen,usesupplydesk,printer,'t' as type,sorting from %prodtype% where removed is null AND reference is null ORDER BY sorting"; if ($ref > 0) { - $sql = "SELECT id,name,kind,usekitchen,usesupplydesk,printer,'t' as type from %prodtype% where removed is null AND reference=$ref"; + $sql = "SELECT id,name,kind,usekitchen,usesupplydesk,printer,'t' as type,sorting from %prodtype% where removed is null AND reference=$ref ORDER BY sorting"; } $stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($sql)); @@ -443,7 +450,7 @@ class Products { private function getMenuLevelUp($ref) { $pdo = $this->dbutils->openDbAndReturnPdo(); - $sql = "SELECT reference from %prodtype% where removed is null AND id=?"; + $sql = "SELECT reference from %prodtype% where removed is null AND id=? ORDER BY sorting"; $stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($sql)); $stmt->execute(array($ref)); $currentRef =$stmt->fetchObject(); @@ -1358,17 +1365,35 @@ class Products { echo json_encode(array("status" => "OK")); } + function getMaxSortOfTypeInKat($pdo,$idOfKat) { + if (!is_null($idOfKat)) { + $sql = "SELECT MAX(sorting) as maxsort,reference FROM %prodtype% WHERE reference=? GROUP BY reference"; + $maxSorting = CommonUtils::fetchSqlAll($pdo, $sql, array($idOfKat)); + } else { + $sql = "SELECT MAX(sorting) as maxsort,reference FROM %prodtype% WHERE reference is null AND removed is null GROUP BY reference"; + $maxSorting = CommonUtils::fetchSqlAll($pdo, $sql, null); + } + + if (count($maxSorting) != 1) { + return null; + } else { + return intval($maxSorting[0]["maxsort"]) + 1; + } + } + function createProdType($id,$prodTypeName) { $pdo = DbUtils::openDbAndReturnPdoStatic(); $pdo->beginTransaction(); if ($id == "top") { + $nextSort = $this->getMaxSortOfTypeInKat($pdo, null); + $kind = 0; if (isset($_POST["kind"])) { $kind = $_POST["kind"]; } - $sql = "INSERT INTO `%prodtype%` (`name`,`usekitchen`,`usesupplydesk`,`kind`,`printer`,`sorting`,`reference`) VALUES(?,1,1,?,1,NULL,?)"; - CommonUtils::execSql($pdo, $sql, array($prodTypeName,$kind,null)); + $sql = "INSERT INTO `%prodtype%` (`name`,`usekitchen`,`usesupplydesk`,`kind`,`printer`,`sorting`,`reference`) VALUES(?,1,1,?,1,?,?)"; + CommonUtils::execSql($pdo, $sql, array($prodTypeName,$kind,$nextSort,null)); $pdo->commit(); echo json_encode(array("status" => "OK")); return; @@ -1378,7 +1403,7 @@ class Products { return; } - + $nextSort = $this->getMaxSortOfTypeInKat($pdo, $id); $sql = "SELECT kind FROM %prodtype% WHERE id=?"; $stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($sql)); @@ -1391,11 +1416,8 @@ class Products { } $kind = $row->kind; - $sql = "INSERT INTO `%prodtype%` (`id`,`name`,`usekitchen`,`usesupplydesk`,`kind`,`printer`,`sorting`,`reference`) "; - $sql .= " VALUES(NULL,?,1,1,?,1,NULL,?)"; - - $stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($sql)); - $stmt->execute(array($prodTypeName,$kind,$id)); + $sql = "INSERT INTO `%prodtype%` (`name`,`usekitchen`,`usesupplydesk`,`kind`,`printer`,`sorting`,`reference`) VALUES(?,?,?,?,?,?,?)"; + CommonUtils::execSql($pdo, $sql, array($prodTypeName,1,1,$kind,1,$nextSort,$id)); $pdo->commit(); echo json_encode(array("status" => "OK")); @@ -1470,6 +1492,24 @@ class Products { $sql = "UPDATE %prodtype% SET removed=? WHERE id=?"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(array(1,$id)); + + + $sql = "SELECT IFNULL(reference,0) as reference FROM %prodtype% WHERE id=?"; + $parentRef = CommonUtils::fetchSqlAll($pdo, $sql, array($id)); + if (count($parentRef) != 1) { + return; + } + $parentId = $parentRef[0]['reference']; + + $sql = "SELECT id,reference,sorting FROM %prodtype% WHERE reference=? AND removed is null ORDER BY sorting"; + $allChildren = CommonUtils::fetchSqlAll($pdo, $sql, array($parentId)); + + $sort = 1; + $sql = "UPDATE %prodtype% SET sorting=? WHERE id=?"; + foreach($allChildren as $c) { + CommonUtils::execSql($pdo, $sql, array($sort,$c["id"])); + $sort++; + } } static private function declareProductAsDeletedWithoutResort($pdo,$id) { @@ -1628,6 +1668,4 @@ class Products { echo json_encode($audioFiles); } -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/webapp/php/utilities/basedb.php b/webapp/php/utilities/basedb.php index 5e05b60..070595b 100644 --- a/webapp/php/utilities/basedb.php +++ b/webapp/php/utilities/basedb.php @@ -971,4 +971,34 @@ class Basedb { fclose ($handle); } + + public function sortProdTypes($pdo) { + $orderedTypeIds = array(); + $sql = "SELECT id,IFNULL(reference,0) as reference,removed FROM %prodtype% WHERE removed is null ORDER by id"; + $alltypes = CommonUtils::fetchSqlAll($pdo, $sql, null); + foreach($alltypes as $aType) { + $id = $aType["id"]; + $sql = "UPDATE %prodtype% SET sorting=? WHERE id=?"; + if (!array_key_exists($id, $orderedTypeIds)) { + $brothersAndMe = self::getAllTypesOfSameParent($alltypes, $aType); + // REMÜ* start from 1 + $sort = 1; + foreach($brothersAndMe as $brotherid) { + CommonUtils::execSql($pdo, $sql, array($sort,$brotherid)); + $orderedTypeIds[] = $brotherid; + $sort++; + } + } + } + } + + private static function getAllTypesOfSameParent($alltypes,$keyType) { + $brothers = array(); + foreach($alltypes as $t) { + if ($t['reference'] == $keyType['reference']) { + $brothers[] = $t['id']; + } + } + return $brothers; + } } diff --git a/webapp/preferences.html b/webapp/preferences.html index 37feb9c..a1cb3b0 100644 --- a/webapp/preferences.html +++ b/webapp/preferences.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/products.html b/webapp/products.html index 69fa251..4a2de1c 100644 --- a/webapp/products.html +++ b/webapp/products.html @@ -7,7 +7,7 @@ - + diff --git a/webapp/rating.html b/webapp/rating.html index ba4ca37..b2d3bb4 100644 --- a/webapp/rating.html +++ b/webapp/rating.html @@ -7,7 +7,7 @@ - + diff --git a/webapp/reports.html b/webapp/reports.html index 60b3284..469f61a 100644 --- a/webapp/reports.html +++ b/webapp/reports.html @@ -7,7 +7,7 @@ - + diff --git a/webapp/reservation.html b/webapp/reservation.html index 4e3901f..d9b714c 100644 --- a/webapp/reservation.html +++ b/webapp/reservation.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/supplydesk.html b/webapp/supplydesk.html index db93bf3..e5d5935 100644 --- a/webapp/supplydesk.html +++ b/webapp/supplydesk.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/waiter.html b/webapp/waiter.html index 7e19f1e..6ffe034 100644 --- a/webapp/waiter.html +++ b/webapp/waiter.html @@ -4,8 +4,8 @@ - - + +