settlementdailyclosingindex.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <?php
  2. /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file settlements/settlementsindex.php
  22. * \ingroup settlements
  23. * \brief Home page of settlements top menu
  24. */
  25. // Load Dolibarr environment
  26. $res = 0;
  27. // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
  28. if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
  29. $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"] . "/main.inc.php";
  30. }
  31. // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
  32. $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME'];
  33. $tmp2 = realpath(__FILE__);
  34. $i = strlen($tmp) - 1;
  35. $j = strlen($tmp2) - 1;
  36. while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
  37. $i--;
  38. $j--;
  39. }
  40. if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)) . "/main.inc.php")) {
  41. $res = @include substr($tmp, 0, ($i + 1)) . "/main.inc.php";
  42. }
  43. if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php")) {
  44. $res = @include dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php";
  45. }
  46. // Try main.inc.php using relative path
  47. if (!$res && file_exists("../main.inc.php")) {
  48. $res = @include "../main.inc.php";
  49. }
  50. if (!$res && file_exists("../../main.inc.php")) {
  51. $res = @include "../../main.inc.php";
  52. }
  53. if (!$res && file_exists("../../../main.inc.php")) {
  54. $res = @include "../../../main.inc.php";
  55. }
  56. if (!$res) {
  57. die("Include of main fails");
  58. }
  59. use Luracast\Restler\RestException;
  60. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
  61. require_once DOL_DOCUMENT_ROOT . '/user/class/usergroup.class.php';
  62. require_once DOL_DOCUMENT_ROOT . '/custom/settlements/class/groupusers.class.php';
  63. require_once DOL_DOCUMENT_ROOT . '/custom/settlements/class/usernaplo.class.php';
  64. require_once DOL_DOCUMENT_ROOT . '/custom/financialreport/class/helper.class.php';
  65. require_once DOL_DOCUMENT_ROOT . '/custom/settlements/class/grouptoolstools.class.php';
  66. require_once DOL_DOCUMENT_ROOT . '/custom/settlements/class/toolnaplo.class.php';
  67. require_once DOL_DOCUMENT_ROOT . '/custom/settlements/class/packagetool.class.php';
  68. // Include the main TCPDF library (search for installation path).
  69. require_once DOL_DOCUMENT_ROOT . '/includes/tecnickcom/tcpdf/examples/tcpdf_include.php';
  70. require_once DOL_DOCUMENT_ROOT . '/includes/tecnickcom/tcpdf/tcpdf.php';
  71. // create new PDF document
  72. // Load translation files required by the page
  73. $langs->loadLangs(array("settlements@settlements"));
  74. $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
  75. $massactionadd = GETPOST('massactionadd', 'alpha'); // The bulk action (combo box choice into lists)
  76. $action = GETPOST('action', 'aZ09');
  77. $cancel = GETPOST('cancel', 'int');
  78. $id = GETPOST('id', 'int');
  79. $idmenu = GETPOST('idmenu', 'int');
  80. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  81. $sortfield = GETPOST('sortfield', 'aZ09comma');
  82. $sortorder = GETPOST('sortorder', 'aZ09comma');
  83. $search_nickname = GETPOST('search_nickname', 'alpha');
  84. $search_name = GETPOST('search_name', 'alpha');
  85. $search_login = GETPOST('search_login', 'alpha');
  86. $searchArray = ['search_name' => $search_name, 'search_nickname' => $search_nickname, 'search_login' => $search_login];
  87. $socid = GETPOST('socid', 'int');
  88. if (isset($user->socid) && $user->socid > 0) {
  89. $action = '';
  90. $socid = $user->socid;
  91. }
  92. $form = new Form($db);
  93. $formfile = new FormFile($db);
  94. $helper = new HelperUserInvoice($db);
  95. $sql = "SELECT u.rowid, u.lastname, u.firstname, u.login, ue.nickname
  96. FROM llx_user AS u
  97. LEFT JOIN llx_user_extrafields AS ue ON u.rowid = ue.fk_object
  98. WHERE ue.user_category = '1'";
  99. if ($search_nickname) {
  100. $sql .= " AND ue.nickname LIKE '%{$search_nickname}%'";
  101. }
  102. if ($search_name) {
  103. $sql .= " AND (u.firstname LIKE '%{$search_name}%' OR u.lastname LIKE '%{$search_name}%')";
  104. }
  105. if ($search_login) {
  106. $sql .= " AND u.login LIKE '%{$search_login}%'";
  107. }
  108. $sql .= " ORDER BY u.lastname";
  109. $sql .= " {$sortorder}";
  110. $allSalesUsers = $helper->getAllSalesWithSQL($sql);
  111. $title = '';
  112. $help_url = '';
  113. $morejs = '';
  114. $morecss = '';
  115. llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'classforhorizontalscrolloftabs');
  116. include DOL_DOCUMENT_ROOT . '/custom/settlements/core/actions_addupdatedelete.inc.php';
  117. $url = $_SERVER["PHP_SELF"] . '?idmenu=' . $idmenu . '&mainmenu=settlements&leftmenu=&id=' . $id;
  118. print '<form method="POST" id="searchFormList" action="' . $url . '">' . "\n";
  119. print '<input type="hidden" name="token" value="' . newToken() . '">';
  120. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  121. print '<input type="hidden" name="action" value="list">';
  122. print '<input type="hidden" name="sortfield" value="' . $sortfield . '">';
  123. print '<input type="hidden" name="sortorder" value="' . $sortorder . '">';
  124. /*print '<input type="hidden" name="page" value="' . $page . '">';
  125. print '<input type="hidden" name="contextpage" value="' . $contextpage . '">';*/
  126. print '<input type="hidden" id ="groupid" name="groupid" value="' . $id . '">';
  127. print load_fiche_titre($langs->trans("DailyClosing"), '', 'settlements.png@settlements');
  128. print '
  129. <table style="width:100%;">
  130. <tr>
  131. <th>' . $langs->trans("username") . '</th>
  132. <th>' . $langs->trans("nickname") . '</th>
  133. <th>' . $langs->trans("login") . '</th>
  134. <th>' . $langs->trans("CurrentBalance") . ' HUF</th>
  135. <th>' . $langs->trans("Commissionpaidamount") . ' HUF</th>
  136. <th>' . $langs->trans("Deposit") . ' HUF</th>
  137. </tr>';
  138. $commission_history_page = true;
  139. include DOL_DOCUMENT_ROOT . '/custom/financialreport/core/tpl/search_fields_for_userslist.tpl.php';
  140. $helper->tableDrawerForDailyClosing($allSalesUsers, $idmenu);
  141. print '</table>';
  142. print '</form>' . "\n";
  143. // End of page
  144. llxFooter();
  145. $db->close();