index.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <?php
  2. /* Copyright (C) 2016-2020 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2016-2023 Alexandre Spangaro <aspangaro@easya.solutions>
  4. * Copyright (C) 2019-2021 Frédéric France <frederic.france@netlogic.fr>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/accountancy/index.php
  21. * \ingroup Accountancy (Double entries)
  22. * \brief Home accounting module
  23. */
  24. // Load Dolibarr environment
  25. require '../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  29. // Load translation files required by the page
  30. $langs->loadLangs(array("compta", "bills", "other", "accountancy", "loans", "banks", "admin", "dict"));
  31. // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
  32. $hookmanager->initHooks(array('accountancyindex'));
  33. // Security check
  34. if ($user->socid > 0) {
  35. accessforbidden();
  36. }
  37. if (!isModEnabled('comptabilite') && !isModEnabled('accounting') && !isModEnabled('asset') && !isModEnabled('intracommreport')) {
  38. accessforbidden();
  39. }
  40. if (!$user->hasRight('compta', 'resultat', 'lire') && !$user->hasRight('accounting', 'comptarapport', 'lire') && !$user->hasRight('accounting', 'mouvements', 'lire') && !$user->hasRight('asset', 'read') && !$user->hasRight('intracommreport', 'read')) {
  41. accessforbidden();
  42. }
  43. $pcgver = getDolGlobalInt('CHARTOFACCOUNTS');
  44. /*
  45. * Actions
  46. */
  47. if (GETPOST('addbox')) {
  48. // Add box (when submit is done from a form when ajax disabled)
  49. require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
  50. $zone = GETPOST('areacode', 'int');
  51. $userid = GETPOST('userid', 'int');
  52. $boxorder = GETPOST('boxorder', 'aZ09');
  53. $boxorder .= GETPOST('boxcombo', 'aZ09');
  54. $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid);
  55. if ($result > 0) {
  56. setEventMessages($langs->trans("BoxAdded"), null);
  57. }
  58. }
  59. /*
  60. * View
  61. */
  62. $help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
  63. llxHeader('', $langs->trans("AccountancyArea"), $help_url);
  64. if (isModEnabled('accounting')) {
  65. $step = 0;
  66. $resultboxes = FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb)
  67. $helpisexpanded = empty($resultboxes['boxactivated']) || (empty($resultboxes['boxlista']) && empty($resultboxes['boxlistb'])); // If there is no widget, the tooltip help is expanded by default.
  68. $showtutorial = '';
  69. if (!$helpisexpanded) {
  70. $showtutorial = '<div class="right"><a href="#" id="show_hide">';
  71. $showtutorial .= img_picto('', 'chevron-down');
  72. $showtutorial .= ' '.$langs->trans("ShowTutorial");
  73. $showtutorial .= '</a></div>';
  74. $showtutorial .= '<script type="text/javascript">
  75. jQuery(document).ready(function() {
  76. jQuery("#show_hide").click(function () {
  77. jQuery( "#idfaq" ).toggle({
  78. duration: 400,
  79. });
  80. });
  81. });
  82. </script>';
  83. }
  84. print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'accountancy', 0, '', '', $showtutorial);
  85. if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
  86. print info_admin($langs->trans("SorryThisModuleIsNotCompatibleWithTheExperimentalFeatureOfSituationInvoices"));
  87. print "<br>";
  88. }
  89. print '<div class="'.($helpisexpanded ? '' : 'hideobject').'" id="idfaq">'; // hideobject is to start hidden
  90. print "<br>\n";
  91. print '<span class="opacitymedium">'.$langs->trans("AccountancyAreaDescIntro")."</span><br>\n";
  92. if ($user->hasRight('accounting', 'chartofaccount')) {
  93. print '<br>';
  94. print load_fiche_titre('<span class="fa fa-calendar"></span> '.$langs->trans("AccountancyAreaDescActionOnce"), '', '')."\n";
  95. print '<hr>';
  96. print "<br>\n";
  97. // STEPS
  98. $step++;
  99. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, '{s}');
  100. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/journals_list.php?id=35" target="setupaccountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("AccountingJournals").'</strong></a>', $s);
  101. print $s;
  102. print "<br>\n";
  103. $step++;
  104. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, '{s}');
  105. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/accountmodel.php?search_country_id='.$mysoc->country_id.'" target="setupaccountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Pcg_version").'</strong></a>', $s);
  106. print $s;
  107. print "<br>\n";
  108. $step++;
  109. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, '{s}');
  110. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/account.php" target="setupaccountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Chartofaccounts").'</strong></a>', $s);
  111. print $s;
  112. if ($pcgver > 0) {
  113. $pcgversion = '';
  114. $pcglabel = '';
  115. $sql = "SELECT a.rowid, a.pcg_version, a.label, a.active";
  116. $sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a";
  117. $sql .= " WHERE a.rowid = ".((int) $pcgver);
  118. $resqlchart = $db->query($sql);
  119. if ($resqlchart) {
  120. $obj = $db->fetch_object($resqlchart);
  121. if ($obj) {
  122. $pcgversion = $obj->pcg_version;
  123. $pcglabel = $obj->label;
  124. }
  125. } else {
  126. dol_print_error($db);
  127. }
  128. print ' <span class="opacitymedium">('.$langs->trans("CurrentChartOfAccount").': '.$pcgversion.')</span>';
  129. }
  130. print "<br>\n";
  131. print "<br>\n";
  132. print $langs->trans("AccountancyAreaDescActionOnceBis");
  133. print "<br>\n";
  134. print "<br>\n";
  135. if (getDolGlobalString('ACCOUNTANCY_FISCAL_PERIOD_MODE') != 'blockedonclosed') {
  136. $step++;
  137. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescFiscalPeriod", $step, '{s}');
  138. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/fiscalyear.php" target="setupaccountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("FiscalPeriod").'</strong></a>', $s);
  139. print $s;
  140. print "<br>\n";
  141. }
  142. $step++;
  143. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDefault", $step, '{s}');
  144. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/defaultaccounts.php" target="setupaccountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong></a>', $s);
  145. print $s;
  146. print "<br>\n";
  147. $step++;
  148. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, '{s}')."\n";
  149. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php" target="setupaccountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuBankAccounts").'</strong></a>', $s);
  150. print $s;
  151. print "<br>\n";
  152. $step++;
  153. $textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=10&from=accountancy" target="setupaccountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuVatAccounts").'</strong></a>';
  154. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, '{s}');
  155. $s = str_replace('{s}', $textlink, $s);
  156. print $s;
  157. print "<br>\n";
  158. if (isModEnabled('tax')) {
  159. $textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=7&from=accountancy" target="setupaccountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").'</strong></a>';
  160. $step++;
  161. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, '{s}');
  162. $s = str_replace('{s}', $textlink, $s);
  163. print $s;
  164. print "<br>\n";
  165. }
  166. if (isModEnabled('expensereport')) { // TODO Move this in the default account page because this is only one accounting account per purpose, not several.
  167. $step++;
  168. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, '{s}');
  169. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=17&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").'</strong></a>', $s);
  170. print $s;
  171. print "<br>\n";
  172. }
  173. $step++;
  174. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, '{s}');
  175. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/productaccount.php" target="setupaccountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("ProductsBinding").'</strong></a>', $s);
  176. print $s;
  177. print "<br>\n";
  178. print '<br>';
  179. }
  180. // Step A - E
  181. print "<br>\n";
  182. print load_fiche_titre('<span class="fa fa-calendar"></span> '.$langs->trans("AccountancyAreaDescActionFreq"), '', '');
  183. print '<hr>';
  184. print "<br>\n";
  185. $step = 0;
  186. $langs->loadLangs(array('bills', 'trips'));
  187. $step++;
  188. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("BillsCustomers"), '{s}')."\n";
  189. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/customer/index.php" target="setupaccountancy"><strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("CustomersVentilation").'</strong></a>', $s);
  190. print $s;
  191. print "<br>\n";
  192. $step++;
  193. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("BillsSuppliers"), '{s}')."\n";
  194. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/supplier/index.php" target="setupaccountancy"><strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("SuppliersVentilation").'</strong></a>', $s);
  195. print $s;
  196. print "<br>\n";
  197. if (isModEnabled('expensereport') || isModEnabled('deplacement')) {
  198. $step++;
  199. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("ExpenseReports"), '{s}')."\n";
  200. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/expensereport/index.php" target="setupaccountancy"><strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("ExpenseReportsVentilation").'</strong></a>', $s);
  201. print $s;
  202. print "<br>\n";
  203. }
  204. $step++;
  205. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescWriteRecords", chr(64 + $step), $langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("RegistrationInAccounting"), $langs->transnoentitiesnoconv("WriteBookKeeping"))."\n";
  206. print $s;
  207. print "<br>\n";
  208. $step++;
  209. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescAnalyze", chr(64 + $step))."<br>\n";
  210. print $s;
  211. $step++;
  212. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescClosePeriod", chr(64 + $step))."<br>\n";
  213. print $s;
  214. print "<br>\n";
  215. print '<br>';
  216. print '</div>';
  217. print '<div class="clearboth"></div>';
  218. print '<div class="fichecenter fichecenterbis">';
  219. /*
  220. * Show boxes
  221. */
  222. $boxlist = '<div class="twocolumns">';
  223. $boxlist .= '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
  224. $boxlist .= $resultboxes['boxlista'];
  225. $boxlist .= '</div>';
  226. $boxlist .= '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
  227. $boxlist .= $resultboxes['boxlistb'];
  228. $boxlist .= '</div>';
  229. $boxlist .= "\n";
  230. $boxlist .= '</div>';
  231. print $boxlist;
  232. print '</div>';
  233. } elseif (isModEnabled('comptabilite')) {
  234. print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy');
  235. print '<span class="opacitymedium">'.$langs->trans("Module10Desc")."</span>\n";
  236. print "<br>";
  237. } else {
  238. // This case can happen mode no accounting module is on but module "intracommreport" is on
  239. print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy');
  240. }
  241. // End of page
  242. llxFooter();
  243. $db->close();