dolibarr 21.0.0-alpha
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 = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
33$sortfield = GETPOST('sortfield', 'aZ09comma');
34$sortorder = GETPOST('sortorder', 'aZ09comma');
35$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
36if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
37 // If $page is not defined, or '' or -1 or if we click on clear filters
38 $page = 0;
39}
40$offset = $limit * $page;
41$pageprev = $page - 1;
42$pagenext = $page + 1;
43if (!$sortfield) {
44 $sortfield = "f.rowid"; // Set here default search field
45}
46if (!$sortorder) {
47 $sortorder = "ASC";
48}
49
50// Load translation files required by the page
51$langs->loadLangs(array("admin", "compta"));
52
53$error = 0;
54$errors = array();
55
56// List of status
57static $tmpstatut2label = array(
58 '0' => 'OpenFiscalYear',
59 '1' => 'CloseFiscalYear'
60);
61
62// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
63$object = new Fiscalyear($db);
64$hookmanager->initHooks(array('fiscalyearlist'));
65
66// Security check
67if ($user->socid > 0) {
69}
70if (!$user->hasRight('accounting', 'fiscalyear', 'write')) { // If we can read accounting records, we should be able to see fiscal year.
72}
73
74/*
75 * Actions
76 */
77
78
79
80/*
81 * View
82 */
83
84$max = 100;
85
86$form = new Form($db);
87$fiscalyearstatic = new Fiscalyear($db);
88
89$title = $langs->trans('AccountingPeriods');
90
91$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
92
93llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-accountancy page-admin_fiscalyear');
94
95$sql = "SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut as status, f.entity";
96$sql .= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear as f";
97$sql .= " WHERE f.entity = ".$conf->entity;
98$sql .= $db->order($sortfield, $sortorder);
99
100// Count total nb of records
101$nbtotalofrecords = '';
102if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) {
103 $result = $db->query($sql);
104 $nbtotalofrecords = $db->num_rows($result);
105 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
106 $page = 0;
107 $offset = 0;
108 }
109}
110
111$sql .= $db->plimit($limit + 1, $offset);
112
113$result = $db->query($sql);
114if ($result) {
115 $num = $db->num_rows($result);
116 $param = '';
117
118 $parameters = array('param' => $param);
119 $reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
120 if ($reshook < 0) {
121 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
122 }
123
124 $newcardbutton = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint;
125
126 if (empty($reshook)) {
127 $newcardbutton .= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->hasRight('accounting', 'fiscalyear', 'write'));
128 }
129
130 $title = $langs->trans('AccountingPeriods');
131 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'calendar', 0, $newcardbutton, '', $limit, 1);
132
133 print '<div class="div-table-responsive">';
134 print '<table class="tagtable liste centpercent noborder">';
135 print '<tr class="liste_titre">';
136 print '<td>'.$langs->trans("Ref").'</td>';
137 print '<td>'.$langs->trans("Label").'</td>';
138 print '<td>'.$langs->trans("DateStart").'</td>';
139 print '<td>'.$langs->trans("DateEnd").'</td>';
140 print '<td class="center">'.$langs->trans("NumberOfAccountancyEntries").'</td>';
141 print '<td class="center">'.$langs->trans("NumberOfAccountancyMovements").'</td>';
142 print '<td class="right">'.$langs->trans("Status").'</td>';
143 print '</tr>';
144
145 // Loop on record
146 // --------------------------------------------------------------------
147 $i = 0;
148 if ($num) {
149 while ($i < $num && $i < $max) {
150 $obj = $db->fetch_object($result);
151
152 $fiscalyearstatic->ref = $obj->rowid;
153 $fiscalyearstatic->id = $obj->rowid;
154 $fiscalyearstatic->date_start = $obj->date_start;
155 $fiscalyearstatic->date_end = $obj->date_end;
156 $fiscalyearstatic->statut = $obj->status;
157 $fiscalyearstatic->status = $obj->status;
158
159 print '<tr class="oddeven">';
160 print '<td>';
161 print $fiscalyearstatic->getNomUrl(1);
162 print '</td>';
163 print '<td class="left">'.$obj->label.'</td>';
164 print '<td class="left">'.dol_print_date($db->jdate($obj->date_start), 'day').'</td>';
165 print '<td class="left">'.dol_print_date($db->jdate($obj->date_end), 'day').'</td>';
166 print '<td class="center">'.$object->getAccountancyEntriesByFiscalYear($obj->date_start, $obj->date_end).'</td>';
167 print '<td class="center">'.$object->getAccountancyMovementsByFiscalYear($obj->date_start, $obj->date_end).'</td>';
168 print '<td class="right">'.$fiscalyearstatic->LibStatut($obj->status, 5).'</td>';
169 print '</tr>';
170 $i++;
171 }
172 } else {
173 print '<tr class="oddeven"><td colspan="7"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
174 }
175 print '</table>';
176 print '</div>';
177} else {
178 dol_print_error($db);
179}
180
181// End of page
182llxFooter();
183$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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
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...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.