dolibarr 20.0.5
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2016-2020 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2016-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
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
27// Load Dolibarr environment
28require '../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
32
33// Load translation files required by the page
34$langs->loadLangs(array("compta", "bills", "other", "accountancy", "loans", "banks", "admin", "dict"));
35
36// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
37$hookmanager->initHooks(array('accountancyindex'));
38
39// Security check
40if ($user->socid > 0) {
42}
43if (!isModEnabled('comptabilite') && !isModEnabled('accounting') && !isModEnabled('asset') && !isModEnabled('intracommreport')) {
45}
46if (!$user->hasRight('compta', 'resultat', 'lire') && !$user->hasRight('accounting', 'comptarapport', 'lire') && !$user->hasRight('accounting', 'mouvements', 'lire') && !$user->hasRight('asset', 'read') && !$user->hasRight('intracommreport', 'read')) {
48}
49
50$pcgver = getDolGlobalInt('CHARTOFACCOUNTS');
51
52
53/*
54 * Actions
55 */
56
57if (GETPOST('addbox')) {
58 // Add box (when submit is done from a form when ajax disabled)
59 require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
60 $zone = GETPOSTINT('areacode');
61 $userid = GETPOSTINT('userid');
62 $boxorder = GETPOST('boxorder', 'aZ09');
63 $boxorder .= GETPOST('boxcombo', 'aZ09');
64
65 $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid);
66 if ($result > 0) {
67 setEventMessages($langs->trans("BoxAdded"), null);
68 }
69}
70
71
72/*
73 * View
74 */
75
76$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
77
78llxHeader('', $langs->trans("AccountancyArea"), $help_url, '', 0, 0, '', '', '', 'mod-accountancy page-index');
79
80$resultboxes = FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb)
81
82$boxlist = '';
83$boxlist .= '<div class="twocolumns">';
84$boxlist .= '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
85$boxlist .= $resultboxes['boxlista'];
86$boxlist .= '</div>';
87$boxlist .= '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
88$boxlist .= $resultboxes['boxlistb'];
89$boxlist .= '</div>';
90$boxlist .= "\n";
91$boxlist .= '</div>';
92
93if (isModEnabled('accounting')) {
94 $step = 0;
95
96 $helpisexpanded = false;
97 //$helpisexpanded = empty($resultboxes['boxactivated']) || (empty($resultboxes['boxlista']) && empty($resultboxes['boxlistb'])); // If there is no widget, the tooltip help is expanded by default.
98 $showtutorial = '';
99
100 if (!$helpisexpanded) {
101 $showtutorial = '<div class="right"><a href="#" id="show_hide">';
102 $showtutorial .= img_picto('', 'chevron-down');
103 $showtutorial .= ' '.$langs->trans("ShowTutorial");
104 $showtutorial .= '</a></div>';
105
106 $showtutorial .= '<script type="text/javascript">
107 jQuery(document).ready(function() {
108 jQuery("#show_hide").click(function () {
109 console.log("We click on show-hide");
110 if ($(".idfaq2").is(":hidden")) {
111 jQuery( ".idfaq2" ).show();
112 } else {
113 jQuery( ".idfaq2" ).hide();
114 }
115 jQuery( ".idfaq" ).toggle({
116 duration: 400,
117 });
118 });
119 });
120 </script>';
121 }
122
123 print load_fiche_titre($langs->trans("AccountancyArea"), empty($resultboxes['selectboxlist']) ? '' : $resultboxes['selectboxlist'], 'accountancy', 0, '', '', $showtutorial);
124
125 /*
126 if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
127 $messagewarning = $langs->trans("SorryThisModuleIsNotCompatibleWithTheExperimentalFeatureOfSituationInvoices");
128 $messagewarning .= ' '.$langs->trans("WarningExperimentalFeatureInvoiceSituationNeedToUpgradeToProgressiveMode", 'https://partners.dolibarr.org');
129 print info_admin($messagewarning);
130 print "<br>";
131 }
132 */
133
134 if (!$helpisexpanded && empty($resultboxes['boxlista']) && empty($resultboxes['boxlistb'])) {
135 print '<div class="opacitymedium idfaq2"><br>'.$langs->trans("ClickOnUseTutorialForHelp", $langs->transnoentities("ShowTutorial"))."</div>\n";
136 }
137
138 print '<div class="'.($helpisexpanded ? '' : 'hideobject').' idfaq">'; // hideobject is to start hidden
139 print "<br>\n";
140 print '<span class="opacitymedium">'.$langs->trans("AccountancyAreaDescIntro")."</span><br>\n";
141 if ($user->hasRight('accounting', 'chartofaccount')) {
142 print '<br>';
143 print load_fiche_titre('<span class="fa fa-calendar"></span> '.$langs->trans("AccountancyAreaDescActionOnce"), '', '', 0, '', 'nomarginbottom')."\n";
144 print '<hr>';
145 print "<br>\n";
146
147 // STEPS
148 $step++;
149 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, '{s}');
150 $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/journals_list.php?id=35&&leftmenu=accountancy_admin" target="setupaccountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("AccountingJournals").'</strong></a>', $s);
151 print $s;
152 print "<br>\n";
153 $step++;
154 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, '{s}');
155 $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/accountmodel.php?search_country_id='.$mysoc->country_id.'&leftmenu=accountancy_admin" target="setupaccountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Pcg_version").'</strong></a>', $s);
156 print $s;
157 print "<br>\n";
158 $step++;
159 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, '{s}');
160 $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/account.php?leftmenu=accountancy_admin" target="setupaccountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("Chartofaccounts").'</strong></a>', $s);
161 print $s;
162 if ($pcgver > 0) {
163 $pcgversion = '';
164 $pcglabel = '';
165
166 $sql = "SELECT a.rowid, a.pcg_version, a.label, a.active";
167 $sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a";
168 $sql .= " WHERE a.rowid = ".((int) $pcgver);
169
170 $resqlchart = $db->query($sql);
171 if ($resqlchart) {
172 $obj = $db->fetch_object($resqlchart);
173 if ($obj) {
174 $pcgversion = $obj->pcg_version;
175 $pcglabel = $obj->label;
176 }
177 } else {
178 dol_print_error($db);
179 }
180 print ' <span class="opacitymedium">('.$langs->trans("CurrentChartOfAccount").': '.$pcgversion.')</span>';
181 }
182 print "<br>\n";
183
184 // Fiscal period
185 if (getDolGlobalString('ACCOUNTANCY_FISCAL_PERIOD_MODE') != 'blockedonclosed') {
186 $step++;
187 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescFiscalPeriod", $step, '{s}');
188 $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/fiscalyear.php?leftmenu=accountancy_admin" target="setupaccountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("FiscalPeriod").'</strong></a>', $s);
189 print $s;
190 print "<br>\n";
191 }
192
193
194 print "<br>\n";
195 print $langs->trans("AccountancyAreaDescActionOnceBis");
196 print "<br>\n";
197 print "<br>\n";
198
199 $step++;
200 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDefault", $step, '{s}');
201 $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/defaultaccounts.php?leftmenu=accountancy_admin" target="setupaccountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong></a>', $s);
202 print $s;
203 print "<br>\n";
204
205 $step++;
206 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, '{s}')."\n";
207 $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?leftmenu=accountancy_admin" target="setupaccountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuBankAccounts").'</strong></a>', $s);
208 print $s;
209 print "<br>\n";
210
211 $step++;
212 $textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=10&from=accountancy&leftmenu=accountancy_admin" target="setupaccountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuVatAccounts").'</strong></a>';
213 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, '{s}');
214 $s = str_replace('{s}', $textlink, $s);
215 print $s;
216 print "<br>\n";
217
218 if (isModEnabled('tax')) {
219 $textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=7&from=accountancy&leftmenu=accountancy_admin" target="setupaccountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").'</strong></a>';
220 $step++;
221 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, '{s}');
222 $s = str_replace('{s}', $textlink, $s);
223 print $s;
224 print "<br>\n";
225 }
226 if (isModEnabled('expensereport')) { // TODO Move this in the default account page because this is only one accounting account per purpose, not several.
227 $step++;
228 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, '{s}');
229 $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=17&from=accountancy&leftmenu=accountancy_admin"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").'</strong></a>', $s);
230 print $s;
231 print "<br>\n";
232 }
233
234 $step++;
235 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, '{s}');
236 $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/admin/productaccount.php?leftmenu=accountancy_admin" target="setupaccountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("ProductsBinding").'</strong></a>', $s);
237 print $s;
238 print "<br>\n";
239
240 print '<br>';
241 }
242
243 // Step A - E
244
245 print "<br>\n";
246 print load_fiche_titre('<span class="fa fa-calendar"></span> '.$langs->trans("AccountancyAreaDescActionFreq"), '', '', 0, '', 'nomarginbottom')."\n";
247 print '<hr>';
248 print "<br>\n";
249 $step = 0;
250
251 $langs->loadLangs(array('bills', 'trips'));
252
253 $step++;
254 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("BillsCustomers"), '{s}')."\n";
255 $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/customer/index.php" target="setupaccountancy"><strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("CustomersVentilation").'</strong></a>', $s);
256 print $s;
257 print "<br>\n";
258
259 $step++;
260 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("BillsSuppliers"), '{s}')."\n";
261 $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/supplier/index.php" target="setupaccountancy"><strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("SuppliersVentilation").'</strong></a>', $s);
262 print $s;
263 print "<br>\n";
264
265 if (isModEnabled('expensereport') || isModEnabled('deplacement')) {
266 $step++;
267 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("ExpenseReports"), '{s}')."\n";
268 $s = str_replace('{s}', '<a href="'.DOL_URL_ROOT.'/accountancy/expensereport/index.php" target="setupaccountancy"><strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("ExpenseReportsVentilation").'</strong></a>', $s);
269 print $s;
270 print "<br>\n";
271 }
272
273 $step++;
274 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescWriteRecords", chr(64 + $step), $langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("RegistrationInAccounting"), $langs->transnoentitiesnoconv("WriteBookKeeping"))."\n";
275 print $s;
276 print "<br>\n";
277
278 $step++;
279 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescAnalyze", chr(64 + $step))."<br>\n";
280 print $s;
281
282 $step++;
283 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescClosePeriod", chr(64 + $step))."<br>\n";
284 print $s;
285
286 if (!empty($resultboxes['boxlista']) || !empty($resultboxes['boxlistb'])) {
287 print "<br>\n";
288 print '<br>';
289 }
290
291 print '</div>';
292
293 print '<div class="clearboth"></div>';
294} elseif (isModEnabled('comptabilite')) {
295 print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy');
296
297 print '<span class="opacitymedium">'.$langs->trans("Module10Desc")."</span>\n";
298 print "<br>";
299} else {
300 // This case can happen when no accounting module is on but module "intracommreport" is on
301 print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy');
302}
303
304/*
305 * Show boxes
306 */
307print $boxlist;
308
309// End of page
310llxFooter();
311$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
static getBoxesArea($user, $areacode)
Get array with HTML tabs with boxes of a particular area including personalized choices of user.
static saveboxorder($dbs, $zone, $boxorder, $userid=0)
Save order of boxes for area and user.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.