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