| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- <?php
- $res = 0;
- // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
- if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
- $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"] . "/main.inc.php";
- }
- // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
- $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME'];
- $tmp2 = realpath(__FILE__);
- $i = strlen($tmp) - 1;
- $j = strlen($tmp2) - 1;
- while ($i > 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);
- $search_group_title = GETPOST('search_group_title', 'alpha');
- $selectedEntities = GETPOST('selectedEntities', 'alpha');
- $groups = $search_group_title !== '' ? $helper->getFilteredpackageGroups($search_group_title, $selectedEntities) : $helper->getGroupsFromGroupToolsClass($db, $selectedEntities);
- $form = new Form($db);
- if (!empty($groups)) {
- print '<form method="POST" id="AssociationFormList" action="' . $url . '" onkeyup="submitFormAjaxTools()">' . "\n";
- $searchedGroupString = '<table style="width:100%;">';
- $userCounter = $helper->getNumberOfUsers();
- foreach ($groups as $group) {
- $confirmedGroup = $helper->checkConfirmation($group['rowid']);
- $numberOfUsers = '';
- $usersArray = [];
- if (isset($userCounter[$group['rowid']][0])) {
- $peopleOrPerson = intval($userCounter[$group['rowid']][0]) > 1 ? $langs->trans('people') : $langs->trans('person');
- $numberOfUsers = '(' . $userCounter[$group['rowid']][0] . ' ' . $langs->trans('person') . ')';
- $usersArray = $helper->getUsersById($db, $userCounter[$group['rowid']][1]);
- }
- $popoupBox = $helper->createPopoupBox($numberOfUsers, $usersArray, $group['rowid']);
- $coloredLine = $id == $group['rowid'] ? ' background-color: #b0c4de' : '';
- $checker = $confirmedGroup ? '<span class="fa fa-check" style="color: green;"></span>' : '<span class="fa fa-exclamation" style="color: red;"></span>';
- //$searchedGroupString .= '<tr style="height:30px; cursor:pointer;' . $coloredLine . '" class="submitFormLink" data-value="' . $group['rowid'] . '"><td><span class="fa fa-group pictofixedwidth"></span> ' . $group['ref'] . $popoupBox . '</td><td>' . $checker . '</td></tr>';
- $searchedGroupString .= '<tr style="height:30px; cursor:pointer;' . $coloredLine . '"><td><div class="submitFormLink" data-value="' . $group['rowid'] . '"><span class="fa fa-group pictofixedwidth"></span> ' . $group['ref'] . '</div><div class="groupColumn2ndLine submitFormLink" data-value="' . $group['rowid'] . '" style="float:left;">' . $group['label'] . '</div>' . $popupBox . '</td></tr>';
- $searchedGroupString .= '<tr id="users_' . $group['rowid'] . '" style="display:none; width:100%; background-color:lightgrey;"><td>';
- foreach ($usersArray as $users) {
- $searchedGroupString .= ' <a href="/user/card.php?id=' . $users['fk_user'] . '&save_lastsearch_values=1"><span class="fas fa-user" style="color: #a69944; cursor: pointer;"></span> ' . $users['lastname'] . ' ' . $users['firstname'] . ' (' . $users['login'] . ')</a><br>';
- }
- $searchedGroupString .= '</td></tr>';
- }
- } else {
- $searchedGroupString .= '<tr style="height: 60px; text-align: center; color:red;"><td>' . $langs->trans('nogroup') . '</td></tr>';
- }
- print $searchedGroupString;
- ?>
- <style>
- .groupColumn2ndLine {
- color: grey !important;
- }
- .createPackageHistoryRecord {
- display: block;
- height: 25px;
- width: 40px;
- background-color: green;
- border-radius: 5px;
- text-decoration: none;
- color: white !important;
- text-align: center;
- padding-top: 10px;
- }
- .confirmUsersButton {
- display: block;
- height: 40px;
- width: 100%;
- border-radius: 5px;
- text-decoration: none;
- text-align: center;
- background-color: #98FB98;
- }
- .createPackageHistoryRecord:hover {
- text-decoration: none;
- }
- .cursorNotAllowed {
- cursor: not-allowed;
- }
- .clearAllButton {
- height: 20px;
- width: 70px;
- background-color: red;
- border: 1px red solid;
- border-radius: 5px;
- text-align: center;
- color: white !important;
- text-decoration: none;
- }
- .clearAllButton:hover {
- text-decoration: none;
- }
- </style>
- <script>
- $(document).ready(function () {
- var elements = document.getElementsByClassName('submitFormLink');
- var inputGroup = document.getElementById("group_search");
- for (var i = 0; i < elements.length; i++) {
- elements[i].addEventListener('click', function (event) {
- event.preventDefault();
- var form = document.getElementById('AssociationFormList');
- var actionValue = form.getAttribute('action');
- var clickedElementValue = this.getAttribute('data-value');
- lastIndex = actionValue.lastIndexOf('&');
- var trimmedQueryString = actionValue.substring(0, lastIndex);
- form.action = trimmedQueryString + '&id=' + clickedElementValue + '&search_group_title=' + inputGroup.value;
- document.getElementById('AssociationFormList').submit();
- });
- }
- });
- function submitFormAjaxPackages() {
- var input = document.getElementById("package_search");
- var inputGroup = document.getElementById("group_search");
- var checkboxes = document.querySelectorAll('.checkforselectadd:checked');
- var values = Array.from(checkboxes).map(function (checkbox) {
- return checkbox.value;
- });
- //if (input.value != '') {
- var xhr = new XMLHttpRequest();
- xhr.open("GET", "ajaxPackage.php?search_package_name=" + input.value + "&toselectnewpackage=" + values + "&groupid=" + groupid.value, true);
- xhr.onreadystatechange = function () {
- if (xhr.readyState === 4 && xhr.status === 200) {
- $("#searchedPackageDiv").html(xhr.responseText);
- }
- };
- xhr.send();
- //}
- //if (inputGroup.value != '') {
- var xhrGroup = new XMLHttpRequest();
- var selectedCheckboxes = $('input[type="checkbox"][id*="entity_"]:checked');
- var checkboxValues = selectedCheckboxes.toArray().map(function (checkbox) {
- return $(checkbox).val();
- });
- xhrGroup.open("GET", "ajaxPackageName.php?search_group_title=" + inputGroup.value + '&selectedEntities=' + checkboxValues, true);
- xhrGroup.onreadystatechange = function () {
- if (xhrGroup.readyState === 4 && xhrGroup.status === 200) {
- $("#searchedPackagesDiv").html(xhrGroup.responseText);
- }
- };
- xhrGroup.send();
- //}
- }
- </script>
|