dolibarr  7.0.0-beta
fiscalyear.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com>
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 <http://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','alpha');
33 $sortorder = GETPOST('sortorder','alpha');
34 $page = 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 $langs->load("admin");
43 $langs->load("compta");
44 
45 // Security check
46 if ($user->societe_id > 0)
48 if (! $user->rights->accounting->fiscalyear) // If we can read accounting records, we shoul 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 
83 $title = $langs->trans('AccountingPeriods');
84 $helpurl = "";
85 llxHeader('', $title, $helpurl);
86 
87 $sql = "SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut, f.entity";
88 $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_fiscalyear as f";
89 $sql .= " WHERE f.entity = " . $conf->entity;
90 $sql.=$db->order($sortfield,$sortorder);
91 
92 // Count total nb of records
93 $nbtotalofrecords = '';
94 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
95 {
96  $result = $db->query($sql);
97  $nbtotalofrecords = $db->num_rows($result);
98 }
99 
100 $sql.= $db->plimit($limit+1, $offset);
101 
102 $result = $db->query($sql);
103 if ($result)
104 {
105  $num = $db->num_rows($result);
106 
107  $i = 0;
108 
109  if (! empty($user->rights->accounting->fiscalyear))
110  {
111  $addbutton = '<a class="butAction" href="fiscalyear_card.php?action=create">' . $langs->trans("NewFiscalYear") . '</a>';
112  }
113  else
114  {
115  $addbutton = '<a class="butActionRefused" href="#">' . $langs->trans("NewFiscalYear") . '</a>';
116  }
117 
118  $title = $langs->trans('AccountingPeriods');
119  print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $addbutton, '', $limit, 1);
120 
121  // Load attribute_label
122  print '<table class="noborder" width="100%">';
123  print '<tr class="liste_titre">';
124  print '<td>' . $langs->trans("Ref") . '</td>';
125  print '<td>' . $langs->trans("Label") . '</td>';
126  print '<td>' . $langs->trans("DateStart") . '</td>';
127  print '<td>' . $langs->trans("DateEnd") . '</td>';
128  print '<td align="right">' . $langs->trans("Statut") . '</td>';
129  print '</tr>';
130 
131  if ($num) {
132  $fiscalyearstatic = new Fiscalyear($db);
133 
134  while ( $i < $num && $i < $max ) {
135  $obj = $db->fetch_object($result);
136  $fiscalyearstatic->id = $obj->rowid;
137  print '<tr class="oddeven">';
138  print '<td><a href="fiscalyear_card.php?id=' . $obj->rowid . '">' . img_object($langs->trans("ShowFiscalYear"), "technic") . ' ' . $obj->rowid . '</a></td>';
139  print '<td align="left">' . $obj->label . '</td>';
140  print '<td align="left">' . dol_print_date($db->jdate($obj->date_start), 'day') . '</td>';
141  print '<td align="left">' . dol_print_date($db->jdate($obj->date_end), 'day') . '</td>';
142  print '<td align="right">' . $fiscalyearstatic->LibStatut($obj->statut, 5) . '</td>';
143  print '</tr>';
144  $i++;
145  }
146  } else {
147  print '<tr class="oddeven"><td colspan="5" class="opacitymedium">' . $langs->trans("None") . '</td></tr>';
148  }
149  print '</table>';
150 } else {
151  dol_print_error($db);
152 }
153 
154 
155 llxFooter();
156 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
if(empty($reshook)) $form
View.
Definition: perms.php:103
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage generation of HTML components Only common components must be here.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='title_generic.png', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0)
Print a title with navigation controls for pagination.
if($_POST["cancel"]==$langs->trans("Cancel")&&!$id) if($action== 'setdatev'&&$user->rights->tax->charges->creer) if($action== 'add'&&$_POST["cancel"]<> $langs->trans("Cancel")) if($action== 'delete') $title
Actions.
Definition: card.php:183
Class to manage fiscal year.
llxHeader()
Empty header.
Definition: wrapper.php:46
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
print
Draft customers invoices.
Definition: index.php:91