dolibarr  16.0.5
fiscalyear.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2013-2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
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 require '../../main.inc.php';
25 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
26 require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php';
27 
28 $action = GETPOST('action', 'aZ09');
29 
30 // Load variable for pagination
31 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
32 $sortfield = GETPOST('sortfield', 'aZ09comma');
33 $sortorder = GETPOST('sortorder', 'aZ09comma');
34 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
35 if (empty($page) || $page == -1) {
36  $page = 0;
37 } // If $page is not defined, or '' or -1
38 $offset = $limit * $page;
39 $pageprev = $page - 1;
40 $pagenext = $page + 1;
41 if (!$sortfield) {
42  $sortfield = "f.rowid"; // Set here default search field
43 }
44 if (!$sortorder) {
45  $sortorder = "ASC";
46 }
47 
48 // Load translation files required by the page
49 $langs->loadLangs(array("admin", "compta"));
50 
51 // Security check
52 if ($user->socid > 0) {
54 }
55 if (empty($user->rights->accounting->fiscalyear->write)) { // If we can read accounting records, we should be able to see fiscal year.
57 }
58 
59 $error = 0;
60 
61 // List of status
62 static $tmpstatut2label = array(
63  '0' => 'OpenFiscalYear',
64  '1' => 'CloseFiscalYear'
65 );
66 $statut2label = array(
67  ''
68 );
69 foreach ($tmpstatut2label as $key => $val) {
70  $statut2label[$key] = $langs->trans($val);
71 }
72 
73 $errors = array();
74 
75 $object = new Fiscalyear($db);
76 
77 
78 /*
79  * Actions
80  */
81 
82 
83 
84 /*
85  * View
86  */
87 
88 $max = 100;
89 
90 $form = new Form($db);
91 $fiscalyearstatic = new Fiscalyear($db);
92 
93 $title = $langs->trans('AccountingPeriods');
94 
95 $help_url = "EN:Module_Double_Entry_Accounting";
96 
97 llxHeader('', $title, $help_url);
98 
99 $sql = "SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut as status, f.entity";
100 $sql .= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear as f";
101 $sql .= " WHERE f.entity = ".$conf->entity;
102 $sql .= $db->order($sortfield, $sortorder);
103 
104 // Count total nb of records
105 $nbtotalofrecords = '';
106 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
107  $result = $db->query($sql);
108  $nbtotalofrecords = $db->num_rows($result);
109  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
110  $page = 0;
111  $offset = 0;
112  }
113 }
114 
115 $sql .= $db->plimit($limit + 1, $offset);
116 
117 $result = $db->query($sql);
118 if ($result) {
119  $num = $db->num_rows($result);
120 
121  $i = 0;
122 
123 
124  $addbutton .= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->rights->accounting->fiscalyear->write);
125 
126 
127  $title = $langs->trans('AccountingPeriods');
128  print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $addbutton, '', $limit, 1);
129 
130  print '<div class="div-table-responsive">';
131  print '<table class="tagtable liste centpercent">';
132  print '<tr class="liste_titre">';
133  print '<td>'.$langs->trans("Ref").'</td>';
134  print '<td>'.$langs->trans("Label").'</td>';
135  print '<td>'.$langs->trans("DateStart").'</td>';
136  print '<td>'.$langs->trans("DateEnd").'</td>';
137  print '<td class="center">'.$langs->trans("NumberOfAccountancyEntries").'</td>';
138  print '<td class="center">'.$langs->trans("NumberOfAccountancyMovements").'</td>';
139  print '<td class="right">'.$langs->trans("Statut").'</td>';
140  print '</tr>';
141 
142  if ($num) {
143  while ($i < $num && $i < $max) {
144  $obj = $db->fetch_object($result);
145 
146  $fiscalyearstatic->ref = $obj->rowid;
147  $fiscalyearstatic->id = $obj->rowid;
148  $fiscalyearstatic->statut = $obj->status;
149  $fiscalyearstatic->status = $obj->status;
150 
151  print '<tr class="oddeven">';
152  print '<td>';
153  print $fiscalyearstatic->getNomUrl(1);
154  print '</td>';
155  print '<td class="left">'.$obj->label.'</td>';
156  print '<td class="left">'.dol_print_date($db->jdate($obj->date_start), 'day').'</td>';
157  print '<td class="left">'.dol_print_date($db->jdate($obj->date_end), 'day').'</td>';
158  print '<td class="center">'.$object->getAccountancyEntriesByFiscalYear($obj->date_start, $obj->date_end).'</td>';
159  print '<td class="center">'.$object->getAccountancyMovementsByFiscalYear($obj->date_start, $obj->date_end).'</td>';
160  print '<td class="right">'.$fiscalyearstatic->LibStatut($obj->statut, 5).'</td>';
161  print '</tr>';
162  $i++;
163  }
164  } else {
165  print '<tr class="oddeven"><td colspan="7" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
166  }
167  print '</table>';
168  print '</div>';
169 } else {
170  dol_print_error($db);
171 }
172 
173 // End of page
174 llxFooter();
175 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
Fiscalyear
Class to manage fiscal year.
Definition: fiscalyear.class.php:31
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:116
dolGetButtonTitle
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.
Definition: functions.lib.php:10605
print_barre_liste
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.
Definition: functions.lib.php:5257
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59