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