2014-05-28 05:34:10 +02:00
|
|
|
<?php
|
2019-01-28 21:39:22 +01:00
|
|
|
/* Copyright (C) 2013-2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
2014-05-28 05:34:10 +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/>.
|
2014-05-28 05:34:10 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2018-12-02 11:01:11 +01:00
|
|
|
* \file htdocs/accountancy/admin/fiscalyear.php
|
2019-05-13 22:25:15 +02:00
|
|
|
* \ingroup Accountancy (Double entries)
|
2018-12-02 11:01:11 +01:00
|
|
|
* \brief Setup page to configure fiscal year
|
2014-05-28 05:34:10 +02:00
|
|
|
*/
|
|
|
|
|
|
2016-09-30 17:03:09 +02:00
|
|
|
require '../../main.inc.php';
|
2019-11-13 19:35:02 +01:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php';
|
2014-05-28 05:34:10 +02:00
|
|
|
|
2019-01-27 11:55:16 +01:00
|
|
|
$action = GETPOST('action', 'aZ09');
|
2014-05-28 05:34:10 +02:00
|
|
|
|
2016-05-12 21:32:24 +02:00
|
|
|
// Load variable for pagination
|
2019-11-13 19:35:02 +01:00
|
|
|
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
2020-09-18 17:13:01 +02:00
|
|
|
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
2020-09-17 14:31:25 +02:00
|
|
|
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
2020-03-13 13:07:11 +01:00
|
|
|
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
2021-02-22 21:36:42 +01:00
|
|
|
if (empty($page) || $page == -1) {
|
|
|
|
|
$page = 0;
|
|
|
|
|
} // If $page is not defined, or '' or -1
|
2016-05-12 21:32:24 +02:00
|
|
|
$offset = $limit * $page;
|
|
|
|
|
$pageprev = $page - 1;
|
|
|
|
|
$pagenext = $page + 1;
|
2021-02-22 21:36:42 +01:00
|
|
|
if (!$sortfield) {
|
|
|
|
|
$sortfield = "f.rowid"; // Set here default search field
|
|
|
|
|
}
|
|
|
|
|
if (!$sortorder) {
|
|
|
|
|
$sortorder = "ASC";
|
|
|
|
|
}
|
2016-05-12 21:32:24 +02:00
|
|
|
|
2018-05-26 23:52:52 +02:00
|
|
|
// Load translation files required by the page
|
2019-11-13 19:35:02 +01:00
|
|
|
$langs->loadLangs(array("admin", "compta"));
|
2014-05-28 05:34:10 +02:00
|
|
|
|
2016-06-05 14:14:20 +02:00
|
|
|
// Security check
|
2021-02-22 21:36:42 +01:00
|
|
|
if ($user->socid > 0) {
|
2016-06-05 14:14:20 +02:00
|
|
|
accessforbidden();
|
2021-02-22 21:36:42 +01:00
|
|
|
}
|
2021-10-23 07:13:08 +02:00
|
|
|
if (empty($user->rights->accounting->fiscalyear->write)) { // If we can read accounting records, we should be able to see fiscal year.
|
2018-12-02 11:01:11 +01:00
|
|
|
accessforbidden();
|
2021-02-22 21:36:42 +01:00
|
|
|
}
|
2017-11-28 11:01:02 +01:00
|
|
|
|
2016-02-01 15:07:12 +01:00
|
|
|
$error = 0;
|
2014-05-28 05:34:10 +02:00
|
|
|
|
2016-06-05 14:22:13 +02:00
|
|
|
// List of status
|
2019-11-13 19:35:02 +01:00
|
|
|
static $tmpstatut2label = array(
|
2016-02-01 15:07:12 +01:00
|
|
|
'0' => 'OpenFiscalYear',
|
2017-11-28 11:01:02 +01:00
|
|
|
'1' => 'CloseFiscalYear'
|
2016-02-01 15:07:12 +01:00
|
|
|
);
|
2019-11-13 19:35:02 +01:00
|
|
|
$statut2label = array(
|
2017-11-28 11:01:02 +01:00
|
|
|
''
|
2014-05-28 05:34:10 +02:00
|
|
|
);
|
2021-02-22 21:36:42 +01:00
|
|
|
foreach ($tmpstatut2label as $key => $val) {
|
2016-02-01 15:07:12 +01:00
|
|
|
$statut2label[$key] = $langs->trans($val);
|
2021-02-22 21:36:42 +01:00
|
|
|
}
|
2014-05-28 05:34:10 +02:00
|
|
|
|
2019-11-13 19:35:02 +01:00
|
|
|
$errors = array();
|
2014-05-28 05:34:10 +02:00
|
|
|
|
|
|
|
|
$object = new Fiscalyear($db);
|
|
|
|
|
|
2016-09-30 17:03:09 +02:00
|
|
|
|
2014-05-28 05:34:10 +02:00
|
|
|
/*
|
|
|
|
|
* Actions
|
|
|
|
|
*/
|
|
|
|
|
|
2016-05-12 21:32:24 +02:00
|
|
|
|
|
|
|
|
|
2014-05-28 05:34:10 +02:00
|
|
|
/*
|
|
|
|
|
* View
|
|
|
|
|
*/
|
|
|
|
|
|
2016-02-01 15:07:12 +01:00
|
|
|
$max = 100;
|
2014-09-09 09:46:57 +02:00
|
|
|
|
2014-05-28 05:34:10 +02:00
|
|
|
$form = new Form($db);
|
2020-08-16 23:33:50 +02:00
|
|
|
$fiscalyearstatic = new Fiscalyear($db);
|
2014-05-28 05:34:10 +02:00
|
|
|
|
2016-10-14 13:05:01 +02:00
|
|
|
$title = $langs->trans('AccountingPeriods');
|
2021-03-19 09:05:49 +01:00
|
|
|
|
|
|
|
|
$help_url = "EN:Module_Double_Entry_Accounting";
|
|
|
|
|
|
|
|
|
|
llxHeader('', $title, $help_url);
|
2014-11-15 16:20:03 +01:00
|
|
|
|
2023-04-25 20:51:40 +02:00
|
|
|
$sql = "SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut as status, f.entity";
|
2019-11-13 19:35:02 +01:00
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear as f";
|
|
|
|
|
$sql .= " WHERE f.entity = ".$conf->entity;
|
|
|
|
|
$sql .= $db->order($sortfield, $sortorder);
|
2016-05-12 21:32:24 +02:00
|
|
|
|
|
|
|
|
// Count total nb of records
|
2017-01-15 20:49:20 +01:00
|
|
|
$nbtotalofrecords = '';
|
2021-02-22 21:36:42 +01:00
|
|
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
2016-05-12 21:32:24 +02:00
|
|
|
$result = $db->query($sql);
|
|
|
|
|
$nbtotalofrecords = $db->num_rows($result);
|
2021-02-22 21:36:42 +01:00
|
|
|
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
2018-04-24 11:37:57 +02:00
|
|
|
$page = 0;
|
|
|
|
|
$offset = 0;
|
|
|
|
|
}
|
2016-09-06 22:42:15 +02:00
|
|
|
}
|
2016-05-12 21:32:24 +02:00
|
|
|
|
2019-11-13 19:35:02 +01:00
|
|
|
$sql .= $db->plimit($limit + 1, $offset);
|
2014-05-28 05:34:10 +02:00
|
|
|
|
|
|
|
|
$result = $db->query($sql);
|
2021-02-22 21:36:42 +01:00
|
|
|
if ($result) {
|
2016-02-01 15:07:12 +01:00
|
|
|
$num = $db->num_rows($result);
|
2016-09-06 22:42:15 +02:00
|
|
|
|
2016-02-01 15:07:12 +01:00
|
|
|
$i = 0;
|
2016-05-12 21:32:24 +02:00
|
|
|
|
2019-04-15 21:33:31 +02:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
$addbutton .= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->rights->accounting->fiscalyear->write);
|
2019-04-15 21:33:31 +02:00
|
|
|
|
2017-11-28 11:49:11 +01:00
|
|
|
|
2016-10-14 13:05:01 +02:00
|
|
|
$title = $langs->trans('AccountingPeriods');
|
2017-11-28 11:49:11 +01:00
|
|
|
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $addbutton, '', $limit, 1);
|
2016-09-06 22:42:15 +02:00
|
|
|
|
2018-12-02 11:01:11 +01:00
|
|
|
print '<div class="div-table-responsive">';
|
2019-11-05 21:24:41 +01:00
|
|
|
print '<table class="tagtable liste centpercent">';
|
2014-05-28 05:34:10 +02:00
|
|
|
print '<tr class="liste_titre">';
|
2019-11-13 19:35:02 +01:00
|
|
|
print '<td>'.$langs->trans("Ref").'</td>';
|
|
|
|
|
print '<td>'.$langs->trans("Label").'</td>';
|
|
|
|
|
print '<td>'.$langs->trans("DateStart").'</td>';
|
|
|
|
|
print '<td>'.$langs->trans("DateEnd").'</td>';
|
|
|
|
|
print '<td class="center">'.$langs->trans("NumberOfAccountancyEntries").'</td>';
|
|
|
|
|
print '<td class="center">'.$langs->trans("NumberOfAccountancyMovements").'</td>';
|
|
|
|
|
print '<td class="right">'.$langs->trans("Statut").'</td>';
|
2014-05-28 05:34:10 +02:00
|
|
|
print '</tr>';
|
2016-09-06 22:42:15 +02:00
|
|
|
|
2016-02-01 15:07:12 +01:00
|
|
|
if ($num) {
|
2019-11-13 19:35:02 +01:00
|
|
|
while ($i < $num && $i < $max) {
|
2016-02-01 15:07:12 +01:00
|
|
|
$obj = $db->fetch_object($result);
|
2020-08-16 23:33:50 +02:00
|
|
|
|
2023-04-18 11:24:40 +02:00
|
|
|
$fiscalyearstatic->ref = $obj->rowid;
|
2016-02-01 15:07:12 +01:00
|
|
|
$fiscalyearstatic->id = $obj->rowid;
|
2023-04-25 20:51:40 +02:00
|
|
|
$fiscalyearstatic->statut = $obj->status;
|
|
|
|
|
$fiscalyearstatic->status = $obj->status;
|
2020-08-16 23:33:50 +02:00
|
|
|
|
2017-04-07 14:25:33 +02:00
|
|
|
print '<tr class="oddeven">';
|
2020-08-16 23:33:50 +02:00
|
|
|
print '<td>';
|
|
|
|
|
print $fiscalyearstatic->getNomUrl(1);
|
|
|
|
|
print '</td>';
|
2019-11-13 19:35:02 +01:00
|
|
|
print '<td class="left">'.$obj->label.'</td>';
|
|
|
|
|
print '<td class="left">'.dol_print_date($db->jdate($obj->date_start), 'day').'</td>';
|
|
|
|
|
print '<td class="left">'.dol_print_date($db->jdate($obj->date_end), 'day').'</td>';
|
|
|
|
|
print '<td class="center">'.$object->getAccountancyEntriesByFiscalYear($obj->date_start, $obj->date_end).'</td>';
|
|
|
|
|
print '<td class="center">'.$object->getAccountancyMovementsByFiscalYear($obj->date_start, $obj->date_end).'</td>';
|
|
|
|
|
print '<td class="right">'.$fiscalyearstatic->LibStatut($obj->statut, 5).'</td>';
|
2016-02-01 15:07:12 +01:00
|
|
|
print '</tr>';
|
2017-11-28 11:01:02 +01:00
|
|
|
$i++;
|
2016-02-01 15:07:12 +01:00
|
|
|
}
|
|
|
|
|
} else {
|
2019-11-13 19:35:02 +01:00
|
|
|
print '<tr class="oddeven"><td colspan="7" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
|
2016-02-01 15:07:12 +01:00
|
|
|
}
|
2014-05-28 05:34:10 +02:00
|
|
|
print '</table>';
|
2018-12-02 11:01:11 +01:00
|
|
|
print '</div>';
|
2016-02-01 15:07:12 +01:00
|
|
|
} else {
|
2014-05-28 05:34:10 +02:00
|
|
|
dol_print_error($db);
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-28 14:02:33 +02:00
|
|
|
// End of page
|
2014-05-28 05:34:10 +02:00
|
|
|
llxFooter();
|
2018-05-26 23:52:52 +02:00
|
|
|
$db->close();
|