dailyclosinghistory_card.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
  60. require_once DOL_DOCUMENT_ROOT . '/user/class/usergroup.class.php';
  61. require_once DOL_DOCUMENT_ROOT . '/custom/settlements/class/groupusers.class.php';
  62. require_once DOL_DOCUMENT_ROOT . '/custom/settlements/class/helper.class.php';
  63. require_once DOL_DOCUMENT_ROOT . '/custom/settlements/class/daily_closing.class.php';
  64. require_once DOL_DOCUMENT_ROOT . '/custom/bbus/class/commissionhandler.class.php';
  65. require_once DOL_DOCUMENT_ROOT . '/custom/financialreport/class/helper.class.php';
  66. require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php';
  67. require_once DOL_DOCUMENT_ROOT . '/custom/settlements/core/tpl/printPDF_szisz.php';
  68. dol_include_once('/settlements/lib/settlements_group.lib.php');
  69. $helper = new Helper($db);
  70. $commmissionhandler = new CommissionHandler();
  71. $userObj = new User($db);
  72. $dailyClosing = new DailyClosing();
  73. // Load translation files required by the page
  74. $langs->loadLangs(array("financialreport@financialreport"));
  75. $action = GETPOST('action', 'aZ09');
  76. $id = GETPOST('id', 'int');
  77. $user_id = GETPOST('user_id', 'int');
  78. $idmenu = GETPOST('idmenu', 'int');
  79. $confirmdailyclosing = GETPOST('confirmdailyclosing', 'int');
  80. $confirmUnclosedDailyHistory = GETPOST('confirmUnclosedDailyHistory', 'int');
  81. if ($confirmUnclosedDailyHistory) {
  82. $result = $dailyClosing->closeRecord($confirmUnclosedDailyHistory);
  83. if ($result > 0) {
  84. setEventMessage($langs->trans('SuccessfullyClosed'));
  85. }else{
  86. setEventMessage($langs->trans('NoClosed', 'error'));
  87. }
  88. }
  89. //print_r($_REQUEST);
  90. $form = new Form($db);
  91. $formfile = new FormFile($db);
  92. $userObj = new User($db);
  93. $result = $userObj->fetch($user_id);
  94. $name = $userObj->firstname . ' ' . $userObj->lastname;
  95. if (isset($userObj->array_options['options_nickname'])) {
  96. $name .= ' (' . $userObj->array_options['options_nickname'] . ')';
  97. }
  98. $isStatusClosed = $dailyClosing->getStatus($id);
  99. if ($isStatusClosed) {
  100. $Block1stDataClosed = $dailyClosing->get1stBlocHistorykDataCLosed($id);
  101. $JSON = json_decode($Block1stDataClosed->dailyclosing_json);
  102. }else{
  103. $packageHistoryRecordObj = $dailyClosing->get1stBlocHistorykDataOpen($id);
  104. if (!empty($packageHistoryRecordObj)) {
  105. $BLock2ndData = $helper->get2ndBlockData($packageHistoryRecordObj->package_id);
  106. $BLock3rdData = $helper->get3rdBlockDataHistory($packageHistoryRecordObj->package_entity, $user_id, $id);
  107. $factures = $helper->getAllFactures($packageHistoryRecordObj, $user_id);
  108. $addititonalDevices = $helper->getAddititonalDevices($packageHistoryRecordObj->id);
  109. $addititonalChangesDevices = $helper->getAddititonalChangesDevices($packageHistoryRecordObj->id);
  110. }
  111. $changeMoneyHUF = 0;
  112. $changeMoneyEUR = 0;
  113. $disabled = '';
  114. }
  115. if (isset($_REQUEST['withholding'])) {
  116. $deviceArray = $_REQUEST['withholding']['withholdingchk'];
  117. $amountArray = $_REQUEST['withholding']['withholdingAmount'];
  118. $problemWithForm = $helper->checkForm($deviceArray, $amountArray);
  119. if ($problemWithForm == false) {
  120. $resultDailyClosing = $helper->updatePackageHistoryFromHistory($id, $BLock3rdData);
  121. if ($resultDailyClosing < 0) {
  122. setEventMessage($langs->trans('dailyClosingFail'), 'errors');
  123. } else {
  124. $helper->returnDailyClosingHistoryWindowLocation($_SERVER["PHP_SELF"], $id, $user_id, $idmenu);
  125. }
  126. } else {
  127. setEventMessage($langs->trans('checklistFail'), 'errors');
  128. }
  129. }
  130. $title = '';
  131. $help_url = '';
  132. $morejs = '';
  133. $morecss = '';
  134. llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'classforhorizontalscrolloftabs');
  135. print '<br>';
  136. $linkback = '<a href="' . dol_buildpath("/custom/settlements/dailyclosing_list.php?user_id={$user_id}&idmenu={$idmenu}&mainmenu=settlements&leftmenu=", 1) . '">' . '<b><span class="fa fa-arrow-left"></span> ' . $langs->trans("BackToList") . '</b></a>';
  137. print $linkback;
  138. if ($isStatusClosed) {
  139. print '<div id="DCuserData" style="width: 100%, height:100%">';
  140. print '<table style="width:50%;">';
  141. include DOL_DOCUMENT_ROOT . '/custom/settlements/core/tpl/dailyclosing_json.tpl.php';
  142. } else {
  143. include DOL_DOCUMENT_ROOT . '/custom/settlements/core/tpl/dailyclosing_open.tpl.php';
  144. }
  145. llxFooter();
  146. $db->close();
  147. ?>
  148. <style>
  149. .dailyClosingHeader {
  150. height: 80px;
  151. text-align: center;
  152. background-color: rgb(163, 0, 51);
  153. color: white;
  154. padding-top: 0px;
  155. border-radius: 10px;
  156. }
  157. .confirmButton {
  158. display: block;
  159. height: 40px;
  160. width: 100%;
  161. background-color: green;
  162. border: 1px solid darkgreen;
  163. border-radius: 5px;
  164. text-decoration: none;
  165. color: white;
  166. text-align: center;
  167. margin: auto;
  168. cursor: pointer;
  169. }
  170. .printbutton {
  171. display: block;
  172. padding-top: 10px;
  173. background-color: rgb(163, 0, 51);
  174. color: white !important;
  175. height: 30px;
  176. width: 250px;
  177. text-align: center;
  178. border: 1px solid grey;
  179. border-radius: 5px;
  180. text-decoration: none;
  181. white-space: nowrap;
  182. }
  183. .unprintedfactures {
  184. height: 40px;
  185. text-align: center;
  186. background-color: rgb(163, 0, 51);
  187. color: white;
  188. padding-top: 0px;
  189. border-radius: 10px;
  190. cursor: pointer;
  191. }
  192. .unprintedfacturetr {
  193. font-weight: bold;
  194. }
  195. .dailyclosingTableLeftSide {
  196. width: 100%;
  197. }
  198. .withholding{
  199. background-color: lightgrey;
  200. }
  201. </style>
  202. <script>
  203. $(document).ready(function () {
  204. });
  205. function showFactures(event) {
  206. const checkbox = event.target;
  207. const isChecked = checkbox.checked;
  208. if ($('#unprintedfactureslist').css('display') === 'none') {
  209. $('#unprintedfactureslist').css('display', 'inline-block');
  210. $('#unprintedFactureSpan').removeClass('fa-chevron-down');
  211. $('#unprintedFactureSpan').addClass('fa-chevron-up');
  212. } else {
  213. $('#unprintedFactureSpan').addClass('fa-chevron-down');
  214. $('#unprintedFactureSpan').removeClass('fa-chevron-up');
  215. $('#unprintedfactureslist').css('display', 'none');
  216. }
  217. }
  218. function checkall(event) {
  219. $('.inputfield').val('');
  220. var checkbox = event.target;
  221. if (checkbox.checked) {
  222. $('.DCcheckbox').prop('checked', true);
  223. $('.fields').css('display', 'none');
  224. } else {
  225. $('.DCcheckbox').prop('checked', false);
  226. $('.fields').css('display', 'inline-block');
  227. }
  228. }
  229. function checkboxClick(event) {
  230. const checkbox = event.target;
  231. const dataChkValue = checkbox.getAttribute("data-chk");
  232. const dataInputValue = checkbox.getAttribute("data-input");
  233. if (checkbox.checked) {
  234. $("#" + dataInputValue).val('');
  235. $("#" + dataChkValue).css('display', 'none');
  236. } else {
  237. $("#" + dataChkValue).css('display', 'inline-block');
  238. }
  239. }
  240. </script>