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