dolibarr 19.0.3
fiscalyear.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2013-2024 Alexandre Spangaro <aspangaro@easya.solutions>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
24// Load Dolibarr environment
25require '../../main.inc.php';
26require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
27require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php';
28
29$action = GETPOST('action', 'aZ09');
30
31// Load variable for pagination
32$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
33$sortfield = GETPOST('sortfield', 'aZ09comma');
34$sortorder = GETPOST('sortorder', 'aZ09comma');
35$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
36if (empty($page) || $page == -1) {
37 $page = 0;
38} // If $page is not defined, or '' or -1
39$offset = $limit * $page;
40$pageprev = $page - 1;
41$pagenext = $page + 1;
42if (!$sortfield) {
43 $sortfield = "f.rowid"; // Set here default search field
44}
45if (!$sortorder) {
46 $sortorder = "ASC";
47}
48
49// Load translation files required by the page
50$langs->loadLangs(array("admin", "compta"));
51
52$error = 0;
53$errors = array();
54
55// List of status
56static $tmpstatut2label = array(
57 '0' => 'OpenFiscalYear',
58 '1' => 'CloseFiscalYear'
59);
60
61// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
62$object = new Fiscalyear($db);
63$hookmanager->initHooks(array('fiscalyearlist'));
64
65// Security check
66if ($user->socid > 0) {
68}
69if (!$user->hasRight('accounting', 'fiscalyear', 'write')) { // If we can read accounting records, we should be able to see fiscal year.
71}
72
73/*
74 * Actions
75 */
76
77
78
79/*
80 * View
81 */
82
83$max = 100;
84
85$form = new Form($db);
86$fiscalyearstatic = new Fiscalyear($db);
87
88$title = $langs->trans('AccountingPeriods');
89
90$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
91
92llxHeader('', $title, $help_url);
93
94$sql = "SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut as status, f.entity";
95$sql .= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear as f";
96$sql .= " WHERE f.entity = ".$conf->entity;
97$sql .= $db->order($sortfield, $sortorder);
98
99// Count total nb of records
100$nbtotalofrecords = '';
101if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
102 $result = $db->query($sql);
103 $nbtotalofrecords = $db->num_rows($result);
104 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
105 $page = 0;
106 $offset = 0;
107 }
108}
109
110$sql .= $db->plimit($limit + 1, $offset);
111
112$result = $db->query($sql);
113if ($result) {
114 $num = $db->num_rows($result);
115 $param = '';
116
117 $parameters = array('param' => $param);
118 $reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
119 if ($reshook < 0) {
120 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
121 }
122
123 $newcardbutton = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint;
124
125 if (empty($reshook)) {
126 $newcardbutton .= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->hasRight('accounting', 'fiscalyear', 'write'));
127 }
128
129 $title = $langs->trans('AccountingPeriods');
130 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'calendar', 0, $newcardbutton, '', $limit, 1);
131
132 print '<div class="div-table-responsive">';
133 print '<table class="tagtable liste centpercent">';
134 print '<tr class="liste_titre">';
135 print '<td>'.$langs->trans("Ref").'</td>';
136 print '<td>'.$langs->trans("Label").'</td>';
137 print '<td>'.$langs->trans("DateStart").'</td>';
138 print '<td>'.$langs->trans("DateEnd").'</td>';
139 print '<td class="center">'.$langs->trans("NumberOfAccountancyEntries").'</td>';
140 print '<td class="center">'.$langs->trans("NumberOfAccountancyMovements").'</td>';
141 print '<td class="right">'.$langs->trans("Status").'</td>';
142 print '</tr>';
143
144 // Loop on record
145 // --------------------------------------------------------------------
146 $i = 0;
147 if ($num) {
148 while ($i < $num && $i < $max) {
149 $obj = $db->fetch_object($result);
150
151 $fiscalyearstatic->ref = $obj->rowid;
152 $fiscalyearstatic->id = $obj->rowid;
153 $fiscalyearstatic->date_start = $obj->date_start;
154 $fiscalyearstatic->date_end = $obj->date_end;
155 $fiscalyearstatic->statut = $obj->status;
156 $fiscalyearstatic->status = $obj->status;
157
158 print '<tr class="oddeven">';
159 print '<td>';
160 print $fiscalyearstatic->getNomUrl(1);
161 print '</td>';
162 print '<td class="left">'.$obj->label.'</td>';
163 print '<td class="left">'.dol_print_date($db->jdate($obj->date_start), 'day').'</td>';
164 print '<td class="left">'.dol_print_date($db->jdate($obj->date_end), 'day').'</td>';
165 print '<td class="center">'.$object->getAccountancyEntriesByFiscalYear($obj->date_start, $obj->date_end).'</td>';
166 print '<td class="center">'.$object->getAccountancyMovementsByFiscalYear($obj->date_start, $obj->date_end).'</td>';
167 print '<td class="right">'.$fiscalyearstatic->LibStatut($obj->status, 5).'</td>';
168 print '</tr>';
169 $i++;
170 }
171 } else {
172 print '<tr class="oddeven"><td colspan="7"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
173 }
174 print '</table>';
175 print '</div>';
176} else {
177 dol_print_error($db);
178}
179
180// End of page
181llxFooter();
182$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
Class to manage fiscal year.
Class to manage generation of HTML components Only common components must be here.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
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.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.