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