index.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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 (!isModEnabled('accounting')) {
  38. accessforbidden();
  39. }
  40. if (empty($user->rights->accounting->mouvements->lire)) {
  41. accessforbidden();
  42. }
  43. */
  44. if (!isModEnabled('comptabilite') && !isModEnabled('accounting') && !isModEnabled('asset') && !isModEnabled('intracommreport')) {
  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 (!empty($conf->global->INVOICE_USE_SITUATION) && $conf->global->INVOICE_USE_SITUATION == 1) {
  71. print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy');
  72. print '<span class="opacitymedium">'.$langs->trans("SorryThisModuleIsNotCompatibleWithTheExperimentalFeatureOfSituationInvoices")."</span>\n";
  73. print "<br>";
  74. } elseif (isModEnabled('accounting')) {
  75. $step = 0;
  76. $resultboxes = FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb)
  77. $helpisexpanded = empty($resultboxes['boxactivated']) || (empty($resultboxes['boxlista']) && empty($resultboxes['boxlistb'])); // If there is no widget, the tooltip help is expanded by default.
  78. $showtutorial = '';
  79. if (!$helpisexpanded) {
  80. $showtutorial = '<div align="right"><a href="#" id="show_hide">';
  81. $showtutorial .= img_picto('', 'chevron-down');
  82. $showtutorial .= ' '.$langs->trans("ShowTutorial");
  83. $showtutorial .= '</a></div>';
  84. $showtutorial .= '<script type="text/javascript">
  85. jQuery(document).ready(function() {
  86. jQuery("#show_hide").click(function () {
  87. jQuery( "#idfaq" ).toggle({
  88. duration: 400,
  89. });
  90. });
  91. });
  92. </script>';
  93. }
  94. print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'accountancy', 0, '', '', $showtutorial);
  95. if (!empty($conf->global->INVOICE_USE_SITUATION) && $conf->global->INVOICE_USE_SITUATION == 1) {
  96. print info_admin($langs->trans("SorryThisModuleIsNotCompatibleWithTheExperimentalFeatureOfSituationInvoices"));
  97. print "<br>";
  98. }
  99. print '<div class="'.($helpisexpanded ? '' : 'hideobject').'" id="idfaq">'; // hideobject is to start hidden
  100. print "<br>\n";
  101. print '<span class="opacitymedium">'.$langs->trans("AccountancyAreaDescIntro")."</span><br>\n";
  102. if (!empty($user->rights->accounting->chartofaccount)) {
  103. print load_fiche_titre('<span class="fa fa-calendar-check-o"></span> '.$langs->trans("AccountancyAreaDescActionOnce"), '', '')."\n";
  104. print '<hr>';
  105. print "<br>\n";
  106. // STEPS
  107. $step++;
  108. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, '{s}');
  109. $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);
  110. print $s;
  111. print "<br>\n";
  112. $step++;
  113. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, '{s}');
  114. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/accountmodel.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Pcg_version").'</strong></a>', $s);
  115. print $s;
  116. print "<br>\n";
  117. $step++;
  118. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, '{s}');
  119. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/account.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Chartofaccounts").'</strong></a>', $s);
  120. print $s;
  121. print "<br>\n";
  122. print "<br>\n";
  123. print $langs->trans("AccountancyAreaDescActionOnceBis");
  124. print "<br>\n";
  125. print "<br>\n";
  126. $step++;
  127. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDefault", $step, '{s}');
  128. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/defaultaccounts.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong></a>', $s);
  129. print $s;
  130. print "<br>\n";
  131. $step++;
  132. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, '{s}')."\n";
  133. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuBankAccounts").'</strong></a>', $s);
  134. print $s;
  135. print "<br>\n";
  136. $step++;
  137. $textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=10&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuVatAccounts").'</strong></a>';
  138. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, '{s}');
  139. $s = str_replace('{s}', $textlink, $s);
  140. print $s;
  141. print "<br>\n";
  142. if (isModEnabled('tax')) {
  143. $textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=7&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").'</strong></a>';
  144. $step++;
  145. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, '{s}');
  146. $s = str_replace('{s}', $textlink, $s);
  147. print $s;
  148. print "<br>\n";
  149. }
  150. if (isModEnabled('expensereport')) { // TODO Move this in the default account page because this is only one accounting account per purpose, not several.
  151. $step++;
  152. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, '{s}');
  153. $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);
  154. print $s;
  155. print "<br>\n";
  156. }
  157. $step++;
  158. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, '{s}');
  159. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/productaccount.php"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("ProductsBinding").'</strong></a>', $s);
  160. print $s;
  161. print "<br>\n";
  162. print '<br>';
  163. }
  164. // Step A - E
  165. print "<br>\n";
  166. print load_fiche_titre('<span class="fa fa-calendar"></span> '.$langs->trans("AccountancyAreaDescActionFreq"), '', '');
  167. print '<hr>';
  168. print "<br>\n";
  169. $step = 0;
  170. $langs->loadLangs(array('bills', 'trips'));
  171. $step++;
  172. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("BillsCustomers"), '{s}')."\n";
  173. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/customer/index.php"><strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("CustomersVentilation").'</strong></a>', $s);
  174. print $s;
  175. print "<br>\n";
  176. $step++;
  177. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("BillsSuppliers"), '{s}')."\n";
  178. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/supplier/index.php"><strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("SuppliersVentilation").'</strong></a>', $s);
  179. print $s;
  180. print "<br>\n";
  181. if (isModEnabled('expensereport') || isModEnabled('deplacement')) {
  182. $step++;
  183. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("ExpenseReports"), '{s}')."\n";
  184. $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/expensereport/index.php"><strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("ExpenseReportsVentilation").'</strong></a>', $s);
  185. print $s;
  186. print "<br>\n";
  187. }
  188. $step++;
  189. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescWriteRecords", chr(64 + $step), $langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("RegistrationInAccounting"), $langs->transnoentitiesnoconv("WriteBookKeeping"))."\n";
  190. print $s;
  191. print "<br>\n";
  192. $step++;
  193. $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescAnalyze", chr(64 + $step))."<br>\n";
  194. print $s;
  195. print "<br>\n";
  196. print '<br>';
  197. print '</div>';
  198. print '<div class="clearboth"></div>';
  199. print '<div class="fichecenter fichecenterbis">';
  200. /*
  201. * Show boxes
  202. */
  203. $boxlist = '<div class="twocolumns">';
  204. $boxlist .= '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
  205. $boxlist .= $resultboxes['boxlista'];
  206. $boxlist .= '</div>';
  207. $boxlist .= '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
  208. $boxlist .= $resultboxes['boxlistb'];
  209. $boxlist .= '</div>';
  210. $boxlist .= "\n";
  211. $boxlist .= '</div>';
  212. print $boxlist;
  213. print '</div>';
  214. } else {
  215. print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy');
  216. print '<span class="opacitymedium">'.$langs->trans("Module10Desc")."</span>\n";
  217. print "<br>";
  218. }
  219. // End of page
  220. llxFooter();
  221. $db->close();