index.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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 (!empty($conf->global->INVOICE_USE_SITUATION) && $conf->global->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 load_fiche_titre('<span class="fa fa-calendar-check-o"></span> '.$langs->trans("AccountancyAreaDescActionOnce"), '', '')."\n";
  101. print '<hr>';
  102. print "<br>\n";
  103. // STEPS
  104. $step++;
  105. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, '{s}');
  106. $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);
  107. print $s;
  108. print "<br>\n";
  109. $step++;
  110. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, '{s}');
  111. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/accountmodel.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Pcg_version").'</strong></a>', $s);
  112. print $s;
  113. print "<br>\n";
  114. $step++;
  115. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, '{s}');
  116. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/account.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Chartofaccounts").'</strong></a>', $s);
  117. print $s;
  118. print "<br>\n";
  119. print "<br>\n";
  120. print $langs->trans("AccountancyAreaDescActionOnceBis");
  121. print "<br>\n";
  122. print "<br>\n";
  123. $step++;
  124. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDefault", $step, '{s}');
  125. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/defaultaccounts.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong></a>', $s);
  126. print $s;
  127. print "<br>\n";
  128. $step++;
  129. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, '{s}')."\n";
  130. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuBankAccounts").'</strong></a>', $s);
  131. print $s;
  132. print "<br>\n";
  133. $step++;
  134. $textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=10&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuVatAccounts").'</strong></a>';
  135. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, '{s}');
  136. $s = str_replace('{s}', $textlink, $s);
  137. print $s;
  138. print "<br>\n";
  139. if (isModEnabled('tax')) {
  140. $textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=7&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").'</strong></a>';
  141. $step++;
  142. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, '{s}');
  143. $s = str_replace('{s}', $textlink, $s);
  144. print $s;
  145. print "<br>\n";
  146. }
  147. if (isModEnabled('expensereport')) { // TODO Move this in the default account page because this is only one accounting account per purpose, not several.
  148. $step++;
  149. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, '{s}');
  150. $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);
  151. print $s;
  152. print "<br>\n";
  153. }
  154. $step++;
  155. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, '{s}');
  156. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/productaccount.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("ProductsBinding").'</strong></a>', $s);
  157. print $s;
  158. print "<br>\n";
  159. print '<br>';
  160. }
  161. // Step A - E
  162. print "<br>\n";
  163. print load_fiche_titre('<span class="fa fa-calendar"></span> '.$langs->trans("AccountancyAreaDescActionFreq"), '', '');
  164. print '<hr>';
  165. print "<br>\n";
  166. $step = 0;
  167. $langs->loadLangs(array('bills', 'trips'));
  168. $step++;
  169. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("BillsCustomers"), '{s}')."\n";
  170. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/customer/index.php"><strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("CustomersVentilation").'</strong></a>', $s);
  171. print $s;
  172. print "<br>\n";
  173. $step++;
  174. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("BillsSuppliers"), '{s}')."\n";
  175. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/supplier/index.php"><strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("SuppliersVentilation").'</strong></a>', $s);
  176. print $s;
  177. print "<br>\n";
  178. if (isModEnabled('expensereport') || isModEnabled('deplacement')) {
  179. $step++;
  180. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("ExpenseReports"), '{s}')."\n";
  181. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/expensereport/index.php"><strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("ExpenseReportsVentilation").'</strong></a>', $s);
  182. print $s;
  183. print "<br>\n";
  184. }
  185. $step++;
  186. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescWriteRecords", chr(64 + $step), $langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("RegistrationInAccounting"), $langs->transnoentitiesnoconv("WriteBookKeeping"))."\n";
  187. print $s;
  188. print "<br>\n";
  189. $step++;
  190. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescAnalyze", chr(64 + $step))."<br>\n";
  191. print $s;
  192. print "<br>\n";
  193. print '<br>';
  194. print '</div>';
  195. print '<div class="clearboth"></div>';
  196. print '<div class="fichecenter fichecenterbis">';
  197. /*
  198. * Show boxes
  199. */
  200. $boxlist = '<div class="twocolumns">';
  201. $boxlist .= '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
  202. $boxlist .= $resultboxes['boxlista'];
  203. $boxlist .= '</div>';
  204. $boxlist .= '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
  205. $boxlist .= $resultboxes['boxlistb'];
  206. $boxlist .= '</div>';
  207. $boxlist .= "\n";
  208. $boxlist .= '</div>';
  209. print $boxlist;
  210. print '</div>';
  211. } else {
  212. print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy');
  213. print '<span class="opacitymedium">'.$langs->trans("Module10Desc")."</span>\n";
  214. print "<br>";
  215. }
  216. // End of page
  217. llxFooter();
  218. $db->close();