index.php 10 KB

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