checkoutclosureindex.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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 . '/custom/bbus/class/facturestat.class.php';
  61. require_once DOL_DOCUMENT_ROOT . '/custom/bbus/class/facturestorno.class.php';
  62. require_once DOL_DOCUMENT_ROOT . '/custom/financialreport/class/checkoutclosure_helper.class.php';
  63. require_once DOL_DOCUMENT_ROOT . '/custom/financialreport/class/checkoutclosure.class.php';
  64. require_once DOL_DOCUMENT_ROOT . '/custom/settlements/core/tpl/printPDF_szisz.php';
  65. // Load translation files required by the page
  66. $langs->loadLangs(array("financialreport@financialreport"));
  67. $action = GETPOST('action', 'aZ09');
  68. $id = GETPOST('id', 'int');
  69. $idmenu = GETPOST('idmenu', 'int');
  70. $entityClosing = GETPOST('entityClosing', 'alpha');
  71. $datastring = GETPOST('datastring', 'alpha');
  72. $form = new Form($db);
  73. $formfile = new FormFile($db);
  74. $factureStat = new FactureStat();
  75. $factureStorno = new FactureStorno();
  76. $helper = new CheckoutclosureHelper();
  77. include DOL_DOCUMENT_ROOT . '/custom/financialreport/core/actions_addupdatedelete.inc.php';
  78. if ($entityClosing) {
  79. $string = $idmenu . '_' . $entityClosing;
  80. $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?datastring=' . $string, $langs->trans('CheckoutClosureConfirm'), $langs->trans('CheckoutCloseurConfirmObject', $userString), 'confirm_checkoutclosure_settlement', '', 0, 1);
  81. }
  82. $allEntities = $helper->getAllEntities();
  83. $title = '';
  84. $help_url = '';
  85. $morejs = '';
  86. $morecss = '';
  87. llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'classforhorizontalscrolloftabs');
  88. $url = $_SERVER["PHP_SELF"] . '?idmenu=' . $idmenu . '&mainmenu=financialreport&leftmenu=';
  89. if ($entityClosing) {
  90. print $formconfirm;
  91. }
  92. print '<form method="POST" id="checkoutclosurehufForm" action="' . $url . '">' . "\n";
  93. print '<input type="hidden" name="token" value="' . newToken() . '">';
  94. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  95. print '<input type="hidden" name="action" value="list">';
  96. print '<input type="hidden" name="sortfield" value="' . $sortfield . '">';
  97. print '<input type="hidden" name="sortorder" value="' . $sortorder . '">';
  98. print load_fiche_titre($langs->trans("checkoutclosurehuf"), '', 'financialreport.png@financialreport');
  99. print '<div class="container">';
  100. foreach ($allEntities as $key => $value) {
  101. $from = $helper->getLastAccountDailyClosing($key);
  102. $amounts = $helper->getEntitiesIncome($key, $from, date("Y-m-d H:i:s", dol_now()));
  103. print '<div id="column_' . $key . '" class="column">
  104. <div class="titleDivForEntity">' . $value . '</div>
  105. <div class="dateDiv">
  106. <div class="row">' . $langs->trans('PreviousDate') . ':</div>
  107. <div class="row"><b>' . $from . '</b></div>
  108. </div>
  109. <div class="divstring row">' . $langs->trans('CashHUFGross') . '</div>
  110. <div class="divAmount row">' . $helper->correctNumber(intval($amounts['HUFCash'])) . ' HUF</div>
  111. <div class="divstring row">' . $langs->trans('CashEURGross') . '</div>
  112. <div class="divAmount row">' . $helper->correctNumber(intval($amounts['EURCash'])) . ' EUR</div>
  113. <div>&nbsp;</div>
  114. <div class="buttonMore" onclick="openMore(' . $key . ')"><span id="moreSpan1_' . $key . '" class="fa fa-chevron-down"></span>&nbsp; ' . $langs->trans('ReadMore') . ' &nbsp;<span id="moreSpan2_' . $key . '" class="fa fa-chevron-down"></span> </div>
  115. <div>&nbsp;</div>
  116. <div><button class="entitybutton" type="submit" name="entityClosing" value="' . $key . '_' . $from . '">' . $langs->trans('Close') .'</button></div>
  117. </div>';
  118. }
  119. foreach ($allEntities as $key => $value) {
  120. $from = $helper->getLastAccountDailyClosing($key);
  121. $arraySumSale = $helper->getSumSaleArray($from, $key);
  122. $arraySumCash = $helper->getsumCashArray($from, $key);
  123. $arraySumCard = $helper->getsumCardArray($from, $key);
  124. $arraystornoSumCash = $helper->getfacturesToBeStornoCashArray($from, $key);
  125. $arraystornoSumCard = $helper->getfacturesToBeStornoCardArray($from, $key);
  126. $title = [$langs->trans('TotalSalesByVAT'), $langs->trans('TotalSalesCash'), $langs->trans('TotalSalesCard'), $langs->trans('MarkedAccountsCash'), $langs->trans('MarkedAccountsCard')];
  127. print '<div id="hidden_' . $key . '" class="hiddenDiv" style="display:none; width:100%;">
  128. <table style="width:100%">
  129. <tr class="dropdownTitle"><td colspan="7">' . $value . '</td></tr>';
  130. $helper->fullHeaderTable();
  131. if(!empty($arraySumSale)){
  132. $helper->sumSaleBlock($arraySumSale, $title);
  133. }else{
  134. print $helper->noDataTR($title[0]);
  135. }
  136. print '<tr><td colspan="7">&nbsp;</td></tr>';
  137. print $helper->bruttoTable();
  138. $helper->generateRow($arraySumCash, $title[1]);
  139. $helper->generateRow($arraySumCard, $title[2]);
  140. print '<tr><td colspan="7">&nbsp;</td></tr>';
  141. $helper->bruttoTable();
  142. $helper->generateRow($arraystornoSumCash, $title[3]);
  143. $helper->generateRow($arraystornoSumCard, $title[4]);
  144. print '
  145. </table>
  146. </div>';
  147. }
  148. print '</div>';
  149. print '</form>' . "\n";
  150. llxFooter();
  151. $db->close();
  152. ?>
  153. <style>
  154. .tdTitle{
  155. width:20%;
  156. text-align:right;
  157. }
  158. .b{
  159. font-weight: bold;
  160. background-color: lightgray;
  161. }
  162. .buttonMore {
  163. cursor: pointer;
  164. }
  165. .dateDiv {
  166. margin-top: -10px;
  167. padding-top: 5px;
  168. padding-bottom: 10px;
  169. background-color: lightgray;
  170. }
  171. .container {
  172. width: 100%;
  173. display: block;
  174. text-align: center;
  175. }
  176. .column {
  177. text-align: center;
  178. margin-left: 5px;
  179. margin-right: 5px;
  180. width: 19%;
  181. float: left;
  182. }
  183. .columnSelected {
  184. background-color: lightgray;
  185. }
  186. .row {
  187. margin-top: 10px;
  188. height: 20px;
  189. }
  190. .titleDivForEntity {
  191. font-weight: bold;
  192. height: 40px;
  193. background-color: rgb(163, 0, 51);
  194. display: block;
  195. text-align: center;
  196. color: white;
  197. padding-top: 15px;
  198. border-top-right-radius: 10px;
  199. border-top-left-radius: 10px;
  200. }
  201. .dropdownTitle {
  202. height:30px;
  203. background-color:rgb(163, 0, 51);
  204. color: white;
  205. }
  206. .divstring {
  207. text-align: center;
  208. }
  209. .divAmount {
  210. text-align: center;
  211. color: green;
  212. font-weight: bold;
  213. }
  214. .entitybutton {
  215. width: 100%;
  216. height: 30px;
  217. background-color: rgb(163, 0, 51);
  218. color: white;
  219. border-radius: 20px;
  220. border: none;
  221. cursor: pointer;
  222. margin-bottom : 40px;
  223. }
  224. </style>
  225. <script>
  226. function openMore(entity) {
  227. var x = document.getElementById("hidden_" + entity);
  228. var column = document.getElementById("column_" + entity);
  229. var arrow1 = document.getElementById("moreSpan1_" + entity);
  230. var arrow2 = document.getElementById("moreSpan2_" + entity);
  231. var display = x.style.display;
  232. if (display == 'none') {
  233. $('.hiddenDiv').css('display', 'none');
  234. $('.column').removeClass('columnSelected');
  235. $('.fa').removeClass('fa-chevron-up');
  236. $('.fa').addClass('fa-chevron-down');
  237. x.style.display = "block";
  238. arrow1.classList.remove("fa-chevron-down");
  239. arrow1.classList.add("fa-chevron-up");
  240. arrow2.classList.remove("fa-chevron-down");
  241. arrow2.classList.add("fa-chevron-up");
  242. column.classList.add("columnSelected");
  243. } else {
  244. x.style.display = "none";
  245. arrow1.classList.remove("fa-chevron-up");
  246. arrow1.classList.add("fa-chevron-down");
  247. arrow2.classList.remove("fa-chevron-up");
  248. arrow2.classList.add("fa-chevron-down");
  249. column.classList.remove("columnSelected");
  250. }
  251. }
  252. </script>