From fddff4d1ca98bae787725681580e7db00ffff0f8 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Wed, 27 Oct 2021 15:59:27 +0200 Subject: [PATCH] TakePOS hooks improvements --- htdocs/takepos/index.php | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 2c4da0515f1..dede65df2d6 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -1121,15 +1121,26 @@ if ($resql) { } $hookmanager->initHooks(array('takeposfrontend')); -$reshook = $hookmanager->executeHooks('ActionButtons'); -if (!empty($reshook)) { - if (is_array($reshook) && !isset($reshook['title'])) { - foreach ($reshook as $reshook) { - $menus[$r++] = $reshook; - } - } else { - $menus[$r++] = $reshook; - } +$parameters = array('menus'=>$menus); +$reshook = $hookmanager->executeHooks('ActionButtons',$parameters); +if ($reshook == 0) { //add buttons + if (is_array($hookmanager->resArray) ) { + foreach ($hookmanager->resArray as $resArray) { + foreach ($resArray as $butmenu) { + $menus[$r++] = $butmenu; + } + } + } + elseif ($reshook == 1){ + $r = 0; //replace buttons + if (is_array($hookmanager->resArray) ) { + foreach ($hookmanager->resArray as $resArray) { + foreach ($resArray as $butmenu) { + $menus[$r++] = $butmenu; + } + } + } + } } if ($r % 3 == 2) {