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