0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)) . "/main.inc.php")) { $res = @include substr($tmp, 0, ($i + 1)) . "/main.inc.php"; } if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php")) { $res = @include dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php"; } // Try main.inc.php using relative path if (!$res && file_exists("../main.inc.php")) { $res = @include "../main.inc.php"; } if (!$res && file_exists("../../main.inc.php")) { $res = @include "../../main.inc.php"; } if (!$res && file_exists("../../../main.inc.php")) { $res = @include "../../../main.inc.php"; } if (!$res) { die("Include of main fails"); } require_once DOL_DOCUMENT_ROOT . '/custom/settlements/class/helper.class.php'; $helper = new Helper($db); $oneselect = GETPOST('oneselect', 'int'); $search_package_name = GETPOST('search_package_name', 'alpha'); $toselectnewpackage = GETPOST('toselectnewpackage', 'alpha'); $reduction = GETPOST('reduction', 'alpha'); $groupid = GETPOST('groupid', 'int'); $selectedArray = explode(',', $toselectnewpackage); if (isset($_SESSION['package_array'])) { $package_array = $_SESSION['package_array']; if ($toselectnewpackage !== '') { $_SESSION['package_array'] = array_unique(array_merge($package_array, $selectedArray)); } if ($reduction !== '') { $_SESSION['package_array'] = explode(',', $reduction); } $selectedArray = $_SESSION['package_array']; if ($toselectnewpackage === '' && $reduction === '' && $search_package_name === '') { unset($_SESSION['package_array']); $selectedArray = []; } } else { $_SESSION['package_array'] = $selectedArray; } $allPackages = $search_package_name !== '' ? $helper->getFilteredPackages($search_package_name, $groupid) : $helper->getAllPackagesFromSelectedEntity($groupid); $form = new Form($db); if (is_array($allPackages)) { print '
' . "\n"; $searchedString = ''; $DeviceCounter = $helper->getNumberOfDevices(); if (!empty($allPackages['freePackages'])) { foreach ($allPackages['freePackages'] as $freePackage) { $numberOfDevices3 = ''; $devicesArray3 = []; if (isset($DeviceCounter[$freePackage['rowid']])) { $numberOfDevices3 = '(' . $DeviceCounter[$freePackage['rowid']] . ' ' . $langs->trans('device') . ')'; $devicesArray3 = $helper->getDevicesById($db, $freePackage['rowid']); } $popupBox3Text = $helper->createPopoupBoxForDeviceList($numberOfDevices3, $devicesArray3); $popupBox3 = $popupBox3Text != '' ? $popupBox3Text : '' . $langs->trans('emptyPackage') . ''; $selected = in_array($freePackage['rowid'], $selectedArray) ? 'checked' : ''; $searchedString .= ''; } } $searchedString .= '
' . $freePackage['ref'] . ' ' . $popupBox3 . '
'; if (is_array($allPackages['addedPackages'])) { foreach ($allPackages['addedPackages'] as $addedPackage) { $numberOfDevices4 = ''; $devicesArray4 = []; if (isset($DeviceCounter[$addedPackage['gprowid']])) { $numberOfDevices4 = '(' . $DeviceCounter[$addedPackage['gprowid']] . ' ' . $langs->trans('device') . ')'; $devicesArray4 = $helper->getDevicesById($db, $addedPackage['rowid']); } $popupBox4Text = $helper->createPopoupBoxForDeviceList($numberOfDevices4, $devicesArray4); $popupBox4 = $popupBox4Text != '' ? $popupBox4Text : '' . $langs->trans('emptyPackage') . ''; $searchedString .= '
' . $addedPackage['gplabel'] . '
' . $addedPackage['ref'] . ' ' . $popupBox4 . '
' ; } } $searchedString .= '
'; } print $searchedString; ?>