index.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <?php
  2. /* Copyright (C) 2016-2020 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2016-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
  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. /*
  38. if (!isModEnabled('accounting')) {
  39. accessforbidden();
  40. }
  41. if (!$user->hasRight('accounting', 'mouvements', 'lire')) {
  42. accessforbidden();
  43. }
  44. */
  45. if (!isModEnabled('comptabilite') && !isModEnabled('accounting') && !isModEnabled('asset') && !isModEnabled('intracommreport')) {
  46. accessforbidden();
  47. }
  48. if (!$user->hasRight('compta', 'resultat', 'lire') && !$user->hasRight('accounting', 'comptarapport', 'lire') && !$user->hasRight('accounting', 'mouvements', 'lire') && !$user->hasRight('asset', 'read') && !$user->hasRight('intracommreport', 'read')) {
  49. accessforbidden();
  50. }
  51. /*
  52. * Actions
  53. */
  54. if (GETPOST('addbox')) {
  55. // Add box (when submit is done from a form when ajax disabled)
  56. require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
  57. $zone = GETPOST('areacode', 'int');
  58. $userid = GETPOST('userid', 'int');
  59. $boxorder = GETPOST('boxorder', 'aZ09');
  60. $boxorder .= GETPOST('boxcombo', 'aZ09');
  61. $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid);
  62. if ($result > 0) {
  63. setEventMessages($langs->trans("BoxAdded"), null);
  64. }
  65. }
  66. /*
  67. * View
  68. */
  69. $help_url = 'EN:Module_Double_Entry_Accounting#Setup';
  70. llxHeader('', $langs->trans("AccountancyArea"), $help_url);
  71. if (isModEnabled('accounting')) {
  72. $step = 0;
  73. $resultboxes = FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb)
  74. $helpisexpanded = empty($resultboxes['boxactivated']) || (empty($resultboxes['boxlista']) && empty($resultboxes['boxlistb'])); // If there is no widget, the tooltip help is expanded by default.
  75. $showtutorial = '';
  76. if (!$helpisexpanded) {
  77. $showtutorial = '<div align="right"><a href="#" id="show_hide">';
  78. $showtutorial .= img_picto('', 'chevron-down');
  79. $showtutorial .= ' '.$langs->trans("ShowTutorial");
  80. $showtutorial .= '</a></div>';
  81. $showtutorial .= '<script type="text/javascript">
  82. jQuery(document).ready(function() {
  83. jQuery("#show_hide").click(function () {
  84. jQuery( "#idfaq" ).toggle({
  85. duration: 400,
  86. });
  87. });
  88. });
  89. </script>';
  90. }
  91. print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'accountancy', 0, '', '', $showtutorial);
  92. if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
  93. print info_admin($langs->trans("SorryThisModuleIsNotCompatibleWithTheExperimentalFeatureOfSituationInvoices"));
  94. print "<br>";
  95. }
  96. print '<div class="'.($helpisexpanded ? '' : 'hideobject').'" id="idfaq">'; // hideobject is to start hidden
  97. print "<br>\n";
  98. print '<span class="opacitymedium">'.$langs->trans("AccountancyAreaDescIntro")."</span><br>\n";
  99. if ($user->hasRight('accounting', 'chartofaccount')) {
  100. print '<br>';
  101. print load_fiche_titre('<span class="fa fa-calendar-check-o"></span> '.$langs->trans("AccountancyAreaDescActionOnce"), '', '')."\n";
  102. print '<hr>';
  103. print "<br>\n";
  104. // STEPS
  105. $step++;
  106. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, '{s}');
  107. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/journals_list.php?id=35"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("AccountingJournals").'</strong></a>', $s);
  108. print $s;
  109. print "<br>\n";
  110. $step++;
  111. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, '{s}');
  112. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/accountmodel.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Pcg_version").'</strong></a>', $s);
  113. print $s;
  114. print "<br>\n";
  115. $step++;
  116. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, '{s}');
  117. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/account.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Chartofaccounts").'</strong></a>', $s);
  118. print $s;
  119. print "<br>\n";
  120. print "<br>\n";
  121. print $langs->trans("AccountancyAreaDescActionOnceBis");
  122. print "<br>\n";
  123. print "<br>\n";
  124. $step++;
  125. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDefault", $step, '{s}');
  126. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/defaultaccounts.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong></a>', $s);
  127. print $s;
  128. print "<br>\n";
  129. $step++;
  130. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, '{s}')."\n";
  131. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuBankAccounts").'</strong></a>', $s);
  132. print $s;
  133. print "<br>\n";
  134. $step++;
  135. $textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=10&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuVatAccounts").'</strong></a>';
  136. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, '{s}');
  137. $s = str_replace('{s}', $textlink, $s);
  138. print $s;
  139. print "<br>\n";
  140. if (isModEnabled('tax')) {
  141. $textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=7&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").'</strong></a>';
  142. $step++;
  143. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, '{s}');
  144. $s = str_replace('{s}', $textlink, $s);
  145. print $s;
  146. print "<br>\n";
  147. }
  148. if (isModEnabled('expensereport')) { // TODO Move this in the default account page because this is only one accounting account per purpose, not several.
  149. $step++;
  150. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, '{s}');
  151. $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);
  152. print $s;
  153. print "<br>\n";
  154. }
  155. $step++;
  156. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, '{s}');
  157. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/productaccount.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("ProductsBinding").'</strong></a>', $s);
  158. print $s;
  159. print "<br>\n";
  160. print '<br>';
  161. }
  162. // Step A - E
  163. print "<br>\n";
  164. print load_fiche_titre('<span class="fa fa-calendar"></span> '.$langs->trans("AccountancyAreaDescActionFreq"), '', '');
  165. print '<hr>';
  166. print "<br>\n";
  167. $step = 0;
  168. $langs->loadLangs(array('bills', 'trips'));
  169. $step++;
  170. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("BillsCustomers"), '{s}')."\n";
  171. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/customer/index.php"><strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("CustomersVentilation").'</strong></a>', $s);
  172. print $s;
  173. print "<br>\n";
  174. $step++;
  175. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("BillsSuppliers"), '{s}')."\n";
  176. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/supplier/index.php"><strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("SuppliersVentilation").'</strong></a>', $s);
  177. print $s;
  178. print "<br>\n";
  179. if (isModEnabled('expensereport') || isModEnabled('deplacement')) {
  180. $step++;
  181. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("ExpenseReports"), '{s}')."\n";
  182. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/expensereport/index.php"><strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("ExpenseReportsVentilation").'</strong></a>', $s);
  183. print $s;
  184. print "<br>\n";
  185. }
  186. $step++;
  187. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescWriteRecords", chr(64 + $step), $langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("RegistrationInAccounting"), $langs->transnoentitiesnoconv("WriteBookKeeping"))."\n";
  188. print $s;
  189. print "<br>\n";
  190. $step++;
  191. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescAnalyze", chr(64 + $step))."<br>\n";
  192. print $s;
  193. print "<br>\n";
  194. print '<br>';
  195. print '</div>';
  196. print '<div class="clearboth"></div>';
  197. print '<div class="fichecenter fichecenterbis">';
  198. /*
  199. * Show boxes
  200. */
  201. $boxlist = '<div class="twocolumns">';
  202. $boxlist .= '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
  203. $boxlist .= $resultboxes['boxlista'];
  204. $boxlist .= '</div>';
  205. $boxlist .= '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
  206. $boxlist .= $resultboxes['boxlistb'];
  207. $boxlist .= '</div>';
  208. $boxlist .= "\n";
  209. $boxlist .= '</div>';
  210. print $boxlist;
  211. print '</div>';
  212. } elseif (isModEnabled('compta')) {
  213. print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy');
  214. print '<span class="opacitymedium">'.$langs->trans("Module10Desc")."</span>\n";
  215. print "<br>";
  216. } else {
  217. // This case can happen mode no accounting module is on but module "intracommreport" is on
  218. print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy');
  219. }
  220. // End of page
  221. llxFooter();
  222. $db->close();