dolibarr 21.0.0-alpha
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 a 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 if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) {
126 $messagewarning = $langs->trans("SorryThisModuleIsNotCompatibleWithTheExperimentalFeatureOfSituationInvoices");
127 $messagewarning .= ' '.$langs->trans("WarningExperimentalFeatureInvoiceSituationNeedToUpgradeToProgressiveMode", 'https://partners.dolibarr.org');
128 print info_admin($messagewarning);
129 print "<br>";
130 }
131
132 if (!$helpisexpanded && empty($resultboxes['boxlista']) && empty($resultboxes['boxlistb'])) {
133 print '<div class="opacitymedium idfaq2"><br>'.$langs->trans("ClickOnUseTutorialForHelp", $langs->transnoentities("ShowTutorial"))."</div>\n";
134 }
135
136 print '<div class="'.($helpisexpanded ? '' : 'hideobject').' idfaq">'; // hideobject is to start hidden
137 print "<br>\n";
138 print '<span class="opacitymedium">'.$langs->trans("AccountancyAreaDescIntro")."</span><br>\n";
139 if ($user->hasRight('accounting', 'chartofaccount')) {
140 print '<br>';
141 print load_fiche_titre('<span class="fa fa-calendar"></span> '.$langs->trans("AccountancyAreaDescActionOnce"), '', '', 0, '', 'nomarginbottom')."\n";
142 print '<hr>';
143 print "<br>\n";
144
145 // STEPS
146 $step++;
147 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, '{s}');
148 $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);
149 print $s;
150 print "<br>\n";
151 $step++;
152 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, '{s}');
153 $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);
154 print $s;
155 print "<br>\n";
156 $step++;
157 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, '{s}');
158 $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);
159 print $s;
160 if ($pcgver > 0) {
161 $pcgversion = '';
162 $pcglabel = '';
163
164 $sql = "SELECT a.rowid, a.pcg_version, a.label, a.active";
165 $sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a";
166 $sql .= " WHERE a.rowid = ".((int) $pcgver);
167
168 $resqlchart = $db->query($sql);
169 if ($resqlchart) {
170 $obj = $db->fetch_object($resqlchart);
171 if ($obj) {
172 $pcgversion = $obj->pcg_version;
173 $pcglabel = $obj->label;
174 }
175 } else {
176 dol_print_error($db);
177 }
178 print ' <span class="opacitymedium">('.$langs->trans("CurrentChartOfAccount").': '.$pcgversion.')</span>';
179 }
180 print "<br>\n";
181
182 // Fiscal period
183 if (getDolGlobalString('ACCOUNTANCY_FISCAL_PERIOD_MODE') != 'blockedonclosed') {
184 $step++;
185 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescFiscalPeriod", $step, '{s}');
186 $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);
187 print $s;
188 print "<br>\n";
189 }
190
191
192 print "<br>\n";
193 print $langs->trans("AccountancyAreaDescActionOnceBis");
194 print "<br>\n";
195 print "<br>\n";
196
197 $step++;
198 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDefault", $step, '{s}');
199 $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);
200 print $s;
201 print "<br>\n";
202
203 $step++;
204 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, '{s}')."\n";
205 $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);
206 print $s;
207 print "<br>\n";
208
209 $step++;
210 $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>';
211 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, '{s}');
212 $s = str_replace('{s}', $textlink, $s);
213 print $s;
214 print "<br>\n";
215
216 if (isModEnabled('tax')) {
217 $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>';
218 $step++;
219 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, '{s}');
220 $s = str_replace('{s}', $textlink, $s);
221 print $s;
222 print "<br>\n";
223 }
224 if (isModEnabled('expensereport')) { // TODO Move this in the default account page because this is only one accounting account per purpose, not several.
225 $step++;
226 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, '{s}');
227 $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);
228 print $s;
229 print "<br>\n";
230 }
231
232 $step++;
233 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, '{s}');
234 $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);
235 print $s;
236 print "<br>\n";
237
238 print '<br>';
239 }
240
241 // Step A - E
242
243 print "<br>\n";
244 print load_fiche_titre('<span class="fa fa-calendar"></span> '.$langs->trans("AccountancyAreaDescActionFreq"), '', '', 0, '', 'nomarginbottom')."\n";
245 print '<hr>';
246 print "<br>\n";
247 $step = 0;
248
249 $langs->loadLangs(array('bills', 'trips'));
250
251 $step++;
252 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("BillsCustomers"), '{s}')."\n";
253 $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);
254 print $s;
255 print "<br>\n";
256
257 $step++;
258 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("BillsSuppliers"), '{s}')."\n";
259 $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);
260 print $s;
261 print "<br>\n";
262
263 if (isModEnabled('expensereport') || isModEnabled('deplacement')) {
264 $step++;
265 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("ExpenseReports"), '{s}')."\n";
266 $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);
267 print $s;
268 print "<br>\n";
269 }
270
271 $step++;
272 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescWriteRecords", chr(64 + $step), $langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("RegistrationInAccounting"), $langs->transnoentitiesnoconv("WriteBookKeeping"))."\n";
273 print $s;
274 print "<br>\n";
275
276 $step++;
277 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescAnalyze", chr(64 + $step))."<br>\n";
278 print $s;
279
280 $step++;
281 $s = img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescClosePeriod", chr(64 + $step))."<br>\n";
282 print $s;
283
284 if (!empty($resultboxes['boxlista']) || !empty($resultboxes['boxlistb'])) {
285 print "<br>\n";
286 print '<br>';
287 }
288
289 print '</div>';
290
291 print '<div class="clearboth"></div>';
292} elseif (isModEnabled('comptabilite')) {
293 print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy');
294
295 print '<span class="opacitymedium">'.$langs->trans("Module10Desc")."</span>\n";
296 print "<br>";
297} else {
298 // This case can happen when no accounting module is on but module "intracommreport" is on
299 print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy');
300}
301
302/*
303 * Show boxes
304 */
305print $boxlist;
306
307// End of page
308llxFooter();
309$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:70
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.
llxFooter()
Footer empty.
Definition document.php:107
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.
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.