2016-10-06 17:43:31 +02:00
< ? php
2020-12-05 13:40:03 +01:00
/* Copyright ( C ) 2016 - 2020 Laurent Destailleur < eldy @ users . sourceforge . net >
2019-10-02 08:43:35 +02:00
* Copyright ( C ) 2016 - 2019 Alexandre Spangaro < aspangaro @ open - dsi . fr >
2021-03-14 18:04:51 +01:00
* Copyright ( C ) 2019 - 2021 Frédéric France < frederic . france @ netlogic . fr >
2016-10-06 17:43:31 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2016-10-06 17:43:31 +02:00
*/
/**
* \file htdocs / accountancy / index . php
2019-05-13 22:25:15 +02:00
* \ingroup Accountancy ( Double entries )
2016-10-06 17:43:31 +02:00
* \brief Home accounting module
*/
require '../main.inc.php' ;
2019-11-13 19:35:39 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php' ;
2016-10-06 17:43:31 +02:00
2018-05-26 23:52:52 +02:00
// Load translation files required by the page
2019-11-13 19:35:39 +01:00
$langs -> loadLangs ( array ( " compta " , " bills " , " other " , " accountancy " , " loans " , " banks " , " admin " , " dict " ));
2016-10-06 17:43:31 +02:00
2021-03-18 14:34:44 +01:00
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks
$hookmanager -> initHooks ( array ( 'accountancyindex' ));
2016-10-06 17:43:31 +02:00
// Security check
2021-04-19 17:23:16 +02:00
if ( $user -> socid > 0 ) {
2021-03-18 14:34:44 +01:00
accessforbidden ();
}
2021-04-19 17:23:16 +02:00
/*
2022-08-24 10:26:47 +02:00
if ( ! isModEnabled ( 'accounting' )) {
2016-10-06 17:43:31 +02:00
accessforbidden ();
2021-02-22 21:36:42 +01:00
}
2021-03-18 14:34:44 +01:00
if ( empty ( $user -> rights -> accounting -> mouvements -> lire )) {
accessforbidden ();
}
2021-04-19 17:23:16 +02:00
*/
2022-08-24 10:26:47 +02:00
if ( ! isModEnabled ( 'comptabilite' ) && ! isModEnabled ( 'accounting' ) && ! isModEnabled ( 'asset' ) && ! isModEnabled ( 'intracommreport' )) {
2021-04-19 17:23:16 +02:00
accessforbidden ();
}
2021-08-08 12:23:14 +02:00
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 )) {
2021-04-19 17:23:16 +02:00
accessforbidden ();
}
2019-02-17 09:11:11 +01:00
2020-09-24 16:19:24 +02:00
2016-10-06 17:43:31 +02:00
/*
* Actions
*/
2021-02-22 21:36:42 +01:00
if ( GETPOST ( 'addbox' )) {
// Add box (when submit is done from a form when ajax disabled)
2020-10-31 14:32:18 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/infobox.class.php' ;
2021-06-11 15:21:24 +02:00
$zone = GETPOST ( 'areacode' , 'int' );
2020-10-31 14:32:18 +01:00
$userid = GETPOST ( 'userid' , 'int' );
$boxorder = GETPOST ( 'boxorder' , 'aZ09' );
$boxorder .= GETPOST ( 'boxcombo' , 'aZ09' );
$result = InfoBox :: saveboxorder ( $db , $zone , $boxorder , $userid );
2021-02-22 21:36:42 +01:00
if ( $result > 0 ) {
setEventMessages ( $langs -> trans ( " BoxAdded " ), null );
}
2019-09-23 20:42:50 +02:00
}
2016-10-06 17:43:31 +02:00
2020-09-24 16:19:24 +02:00
2016-10-06 17:43:31 +02:00
/*
* View
*/
2021-02-27 17:15:40 +01:00
$help_url = '' ;
llxHeader ( '' , $langs -> trans ( " AccountancyArea " ), $help_url );
2016-10-06 17:43:31 +02:00
2021-10-07 10:38:10 +02:00
if ( ! empty ( $conf -> global -> INVOICE_USE_SITUATION ) && $conf -> global -> INVOICE_USE_SITUATION == 1 ) {
print load_fiche_titre ( $langs -> trans ( " AccountancyArea " ), '' , 'accountancy' );
print '<span class="opacitymedium">' . $langs -> trans ( " SorryThisModuleIsNotCompatibleWithTheExperimentalFeatureOfSituationInvoices " ) . " </span> \n " ;
print " <br> " ;
2022-08-24 10:26:47 +02:00
} elseif ( isModEnabled ( 'accounting' )) {
2020-10-31 14:32:18 +01:00
$step = 0 ;
2019-10-02 08:43:35 +02:00
2020-10-31 14:32:18 +01:00
$resultboxes = FormOther :: getBoxesArea ( $user , " 27 " ); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb)
2019-10-07 14:39:29 +02:00
2020-10-31 14:32:18 +01:00
$helpisexpanded = empty ( $resultboxes [ 'boxactivated' ]) || ( empty ( $resultboxes [ 'boxlista' ]) && empty ( $resultboxes [ 'boxlistb' ])); // If there is no widget, the tooltip help is expanded by default.
2019-10-07 14:39:29 +02:00
$showtutorial = '' ;
2021-02-22 21:36:42 +01:00
if ( ! $helpisexpanded ) {
2019-10-07 14:39:29 +02:00
$showtutorial = '<div align="right"><a href="#" id="show_hide">' ;
$showtutorial .= img_picto ( '' , 'chevron-down' );
2019-11-13 19:35:39 +01:00
$showtutorial .= ' ' . $langs -> trans ( " ShowTutorial " );
2019-10-07 14:39:29 +02:00
$showtutorial .= '</a></div>' ;
2021-11-29 15:09:18 +01:00
$showtutorial .= ' < script type = " text/javascript " >
2019-10-07 14:39:29 +02:00
jQuery ( document ) . ready ( function () {
jQuery ( " #show_hide " ) . click ( function () {
jQuery ( " #idfaq " ) . toggle ({
duration : 400 ,
});
});
});
</ script > ' ;
}
2021-02-27 17:15:40 +01:00
print load_fiche_titre ( $langs -> trans ( " AccountancyArea " ), $resultboxes [ 'selectboxlist' ], 'accountancy' , 0 , '' , '' , $showtutorial );
2019-10-07 14:39:29 +02:00
2022-11-05 08:02:56 +01:00
if ( ! empty ( $conf -> global -> INVOICE_USE_SITUATION ) && $conf -> global -> INVOICE_USE_SITUATION == 1 ) {
print info_admin ( $langs -> trans ( " SorryThisModuleIsNotCompatibleWithTheExperimentalFeatureOfSituationInvoices " ));
print " <br> " ;
}
2020-10-31 14:32:18 +01:00
print '<div class="' . ( $helpisexpanded ? '' : 'hideobject' ) . '" id="idfaq">' ; // hideobject is to start hidden
print " <br> \n " ;
print '<span class="opacitymedium">' . $langs -> trans ( " AccountancyAreaDescIntro " ) . " </span><br> \n " ;
2022-03-29 15:10:11 +02:00
if ( ! empty ( $user -> rights -> accounting -> chartofaccount )) {
2022-03-14 09:24:26 +01:00
print load_fiche_titre ( '<span class="fa fa-calendar-check-o"></span> ' . $langs -> trans ( " AccountancyAreaDescActionOnce " ), '' , '' ) . " \n " ;
print '<hr>' ;
print " <br> \n " ;
2019-10-02 08:43:35 +02:00
2022-03-14 09:24:26 +01:00
// STEPS
$step ++ ;
2022-03-29 14:39:47 +02:00
$s = img_picto ( '' , 'puce' ) . ' ' . $langs -> trans ( " AccountancyAreaDescJournalSetup " , $step , '{s}' );
$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 );
print $s ;
2022-03-14 09:24:26 +01:00
print " <br> \n " ;
$step ++ ;
2022-03-29 14:39:47 +02:00
$s = img_picto ( '' , 'puce' ) . ' ' . $langs -> trans ( " AccountancyAreaDescChartModel " , $step , '{s}' );
$s = str_replace ( '{s}' , '<a href="' . DOL_URL_ROOT . '/accountancy/admin/accountmodel.php"><strong>' . $langs -> transnoentitiesnoconv ( " Setup " ) . ' - ' . $langs -> transnoentitiesnoconv ( " Pcg_version " ) . '</strong></a>' , $s );
print $s ;
2022-03-14 09:24:26 +01:00
print " <br> \n " ;
$step ++ ;
2022-03-29 14:39:47 +02:00
$s = img_picto ( '' , 'puce' ) . ' ' . $langs -> trans ( " AccountancyAreaDescChart " , $step , '{s}' );
$s = str_replace ( '{s}' , '<a href="' . DOL_URL_ROOT . '/accountancy/admin/account.php"><strong>' . $langs -> transnoentitiesnoconv ( " Setup " ) . ' - ' . $langs -> transnoentitiesnoconv ( " Chartofaccounts " ) . '</strong></a>' , $s );
print $s ;
2022-03-14 09:24:26 +01:00
print " <br> \n " ;
2019-10-02 08:43:35 +02:00
2022-03-14 09:24:26 +01:00
print " <br> \n " ;
print $langs -> trans ( " AccountancyAreaDescActionOnceBis " );
print " <br> \n " ;
print " <br> \n " ;
2019-10-02 08:43:35 +02:00
2022-03-14 09:24:26 +01:00
$step ++ ;
2022-03-29 14:39:47 +02:00
$s = img_picto ( '' , 'puce' ) . ' ' . $langs -> trans ( " AccountancyAreaDescDefault " , $step , '{s}' );
$s = str_replace ( '{s}' , '<a href="' . DOL_URL_ROOT . '/accountancy/admin/defaultaccounts.php"><strong>' . $langs -> transnoentitiesnoconv ( " Setup " ) . ' - ' . $langs -> transnoentitiesnoconv ( " MenuDefaultAccounts " ) . '</strong></a>' , $s );
print $s ;
2022-03-14 09:24:26 +01:00
print " <br> \n " ;
2019-10-02 08:43:35 +02:00
2022-03-14 09:24:26 +01:00
$step ++ ;
2022-03-29 14:39:47 +02:00
$s = img_picto ( '' , 'puce' ) . ' ' . $langs -> trans ( " AccountancyAreaDescBank " , $step , '{s}' ) . " \n " ;
$s = str_replace ( '{s}' , '<a href="' . DOL_URL_ROOT . '/compta/bank/list.php"><strong>' . $langs -> transnoentitiesnoconv ( " Setup " ) . ' - ' . $langs -> transnoentitiesnoconv ( " MenuBankAccounts " ) . '</strong></a>' , $s );
print $s ;
2022-03-14 09:24:26 +01:00
print " <br> \n " ;
2019-10-02 08:43:35 +02:00
2020-10-31 14:32:18 +01:00
$step ++ ;
2022-03-14 09:24:26 +01:00
$textlink = '<a href="' . DOL_URL_ROOT . '/admin/dict.php?id=10&from=accountancy"><strong>' . $langs -> transnoentitiesnoconv ( " Setup " ) . ' - ' . $langs -> transnoentitiesnoconv ( " MenuVatAccounts " ) . '</strong></a>' ;
2022-03-29 14:39:47 +02:00
$s = img_picto ( '' , 'puce' ) . ' ' . $langs -> trans ( " AccountancyAreaDescVat " , $step , '{s}' );
2020-12-05 13:40:03 +01:00
$s = str_replace ( '{s}' , $textlink , $s );
print $s ;
2020-10-31 14:32:18 +01:00
print " <br> \n " ;
2022-03-29 15:10:11 +02:00
2022-08-24 10:26:47 +02:00
if ( isModEnabled ( 'tax' )) {
2022-03-14 09:24:26 +01:00
$textlink = '<a href="' . DOL_URL_ROOT . '/admin/dict.php?id=7&from=accountancy"><strong>' . $langs -> transnoentitiesnoconv ( " Setup " ) . ' - ' . $langs -> transnoentitiesnoconv ( " MenuTaxAccounts " ) . '</strong></a>' ;
$step ++ ;
2022-03-29 14:39:47 +02:00
$s = img_picto ( '' , 'puce' ) . ' ' . $langs -> trans ( " AccountancyAreaDescContrib " , $step , '{s}' );
$s = str_replace ( '{s}' , $textlink , $s );
print $s ;
2022-03-14 09:24:26 +01:00
print " <br> \n " ;
}
2022-08-24 10:26:47 +02:00
if ( isModEnabled ( 'expensereport' )) { // TODO Move this in the default account page because this is only one accounting account per purpose, not several.
2022-03-14 09:24:26 +01:00
$step ++ ;
2022-03-29 14:39:47 +02:00
$s = img_picto ( '' , 'puce' ) . ' ' . $langs -> trans ( " AccountancyAreaDescExpenseReport " , $step , '{s}' );
$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 );
print $s ;
2022-03-14 09:24:26 +01:00
print " <br> \n " ;
}
2020-10-31 14:32:18 +01:00
$step ++ ;
2022-03-29 14:39:47 +02:00
$s = img_picto ( '' , 'puce' ) . ' ' . $langs -> trans ( " AccountancyAreaDescProd " , $step , '{s}' );
$s = str_replace ( '{s}' , '<a href="' . DOL_URL_ROOT . '/accountancy/admin/productaccount.php"><strong>' . $langs -> transnoentitiesnoconv ( " Setup " ) . ' - ' . $langs -> transnoentitiesnoconv ( " ProductsBinding " ) . '</strong></a>' , $s );
2020-12-05 13:40:03 +01:00
print $s ;
2020-10-31 14:32:18 +01:00
print " <br> \n " ;
2018-04-16 14:25:39 +02:00
2022-03-14 09:24:26 +01:00
print '<br>' ;
2019-10-02 08:43:35 +02:00
}
2018-04-16 14:25:39 +02:00
2020-10-31 14:32:18 +01:00
// Step A - E
2019-09-23 20:42:50 +02:00
2019-10-02 08:43:35 +02:00
print " <br> \n " ;
print load_fiche_titre ( '<span class="fa fa-calendar"></span> ' . $langs -> trans ( " AccountancyAreaDescActionFreq " ), '' , '' );
print '<hr>' ;
print " <br> \n " ;
$step = 0 ;
2019-09-23 20:42:50 +02:00
2019-10-02 08:43:35 +02:00
$langs -> loadLangs ( array ( 'bills' , 'trips' ));
2019-09-23 20:42:50 +02:00
2019-10-02 08:43:35 +02:00
$step ++ ;
2020-12-05 13:40:03 +01:00
$s = img_picto ( '' , 'puce' ) . ' ' . $langs -> trans ( " AccountancyAreaDescBind " , chr ( 64 + $step ), $langs -> transnoentitiesnoconv ( " BillsCustomers " ), '{s}' ) . " \n " ;
$s = str_replace ( '{s}' , '<a href="' . DOL_URL_ROOT . '/accountancy/customer/index.php"><strong>' . $langs -> transnoentitiesnoconv ( " TransferInAccounting " ) . ' - ' . $langs -> transnoentitiesnoconv ( " CustomersVentilation " ) . '</strong></a>' , $s );
print $s ;
2019-10-02 08:43:35 +02:00
print " <br> \n " ;
2019-09-23 20:42:50 +02:00
2019-10-02 08:43:35 +02:00
$step ++ ;
2020-12-05 13:40:03 +01:00
$s = img_picto ( '' , 'puce' ) . ' ' . $langs -> trans ( " AccountancyAreaDescBind " , chr ( 64 + $step ), $langs -> transnoentitiesnoconv ( " BillsSuppliers " ), '{s}' ) . " \n " ;
$s = str_replace ( '{s}' , '<a href="' . DOL_URL_ROOT . '/accountancy/supplier/index.php"><strong>' . $langs -> transnoentitiesnoconv ( " TransferInAccounting " ) . ' - ' . $langs -> transnoentitiesnoconv ( " SuppliersVentilation " ) . '</strong></a>' , $s );
print $s ;
2019-10-02 08:43:35 +02:00
print " <br> \n " ;
2019-09-23 20:42:50 +02:00
2022-08-24 10:26:47 +02:00
if ( isModEnabled ( 'expensereport' ) || isModEnabled ( 'deplacement' )) {
2019-09-23 20:42:50 +02:00
$step ++ ;
2020-12-05 13:40:03 +01:00
$s = img_picto ( '' , 'puce' ) . ' ' . $langs -> trans ( " AccountancyAreaDescBind " , chr ( 64 + $step ), $langs -> transnoentitiesnoconv ( " ExpenseReports " ), '{s}' ) . " \n " ;
$s = str_replace ( '{s}' , '<a href="' . DOL_URL_ROOT . '/accountancy/expensereport/index.php"><strong>' . $langs -> transnoentitiesnoconv ( " TransferInAccounting " ) . ' - ' . $langs -> transnoentitiesnoconv ( " ExpenseReportsVentilation " ) . '</strong></a>' , $s );
print $s ;
2020-10-31 14:32:18 +01:00
print " <br> \n " ;
2019-10-02 08:43:35 +02:00
}
2019-09-23 20:42:50 +02:00
2019-10-02 08:43:35 +02:00
$step ++ ;
2020-12-05 13:40:03 +01:00
$s = img_picto ( '' , 'puce' ) . ' ' . $langs -> trans ( " AccountancyAreaDescWriteRecords " , chr ( 64 + $step ), $langs -> transnoentitiesnoconv ( " TransferInAccounting " ) . ' - ' . $langs -> transnoentitiesnoconv ( " RegistrationInAccounting " ), $langs -> transnoentitiesnoconv ( " WriteBookKeeping " )) . " \n " ;
print $s ;
2019-10-02 08:43:35 +02:00
print " <br> \n " ;
2019-09-23 20:42:50 +02:00
2019-10-02 08:43:35 +02:00
$step ++ ;
2020-12-05 13:40:03 +01:00
$s = img_picto ( '' , 'puce' ) . ' ' . $langs -> trans ( " AccountancyAreaDescAnalyze " , chr ( 64 + $step )) . " <br> \n " ;
print $s ;
2019-10-02 08:43:35 +02:00
print " <br> \n " ;
2019-09-23 20:42:50 +02:00
2019-10-07 14:39:29 +02:00
print '<br>' ;
2019-10-02 08:43:35 +02:00
print '</div>' ;
2019-09-23 20:42:50 +02:00
2020-10-31 14:32:18 +01:00
print '<div class="clearboth"></div>' ;
2019-09-23 20:42:50 +02:00
2020-10-31 14:32:18 +01:00
print '<div class="fichecenter fichecenterbis">' ;
2019-09-23 20:42:50 +02:00
2020-10-31 14:32:18 +01:00
/*
2021-02-22 21:36:42 +01:00
* Show boxes
*/
2021-03-14 18:04:51 +01:00
$boxlist = '<div class="twocolumns">' ;
2019-09-23 20:42:50 +02:00
2020-10-31 14:32:18 +01:00
$boxlist .= '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">' ;
2018-04-16 14:25:39 +02:00
2020-10-31 14:32:18 +01:00
$boxlist .= $resultboxes [ 'boxlista' ];
2019-09-23 20:42:50 +02:00
2020-10-31 14:32:18 +01:00
$boxlist .= '</div>' ;
2019-09-23 20:42:50 +02:00
2020-10-31 14:32:18 +01:00
$boxlist .= '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">' ;
2019-09-23 20:42:50 +02:00
2020-10-31 14:32:18 +01:00
$boxlist .= $resultboxes [ 'boxlistb' ];
2019-09-23 20:42:50 +02:00
2020-10-31 14:32:18 +01:00
$boxlist .= '</div>' ;
$boxlist .= " \n " ;
2019-09-23 20:42:50 +02:00
2020-10-31 14:32:18 +01:00
$boxlist .= '</div>' ;
2019-09-23 20:42:50 +02:00
2020-10-31 14:32:18 +01:00
print $boxlist ;
2018-04-16 14:25:39 +02:00
2020-10-31 14:32:18 +01:00
print '</div>' ;
2020-05-21 15:05:19 +02:00
} else {
2020-10-31 14:32:18 +01:00
print load_fiche_titre ( $langs -> trans ( " AccountancyArea " ), '' , 'accountancy' );
2019-10-02 08:43:35 +02:00
2021-10-07 10:38:10 +02:00
print '<span class="opacitymedium">' . $langs -> trans ( " Module10Desc " ) . " </span> \n " ;
print " <br> " ;
2016-10-26 11:15:25 +02:00
}
2016-10-06 17:43:31 +02:00
2018-07-28 14:29:28 +02:00
// End of page
2016-10-06 17:43:31 +02:00
llxFooter ();
$db -> close ();