26require
'../../main.inc.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/fiscalyear.class.php';
38$action =
GETPOST(
'action',
'aZ09');
42$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
43$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
45if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
49$offset = $limit * $page;
53 $sortfield =
"f.rowid";
60$langs->loadLangs(array(
"admin",
"compta"));
66static $tmpstatut2label = array(
67 '0' =>
'OpenFiscalYear',
68 '1' =>
'CloseFiscalYear'
73$hookmanager->initHooks(array(
'fiscalyearlist'));
76if ($user->socid > 0) {
79if (!$user->hasRight(
'accounting',
'fiscalyear',
'write')) {
86if ($action ==
'setdefault') {
91 $defaultFiscalYearLabel =
GETPOST(
'label',
'alpha');
93 if (!empty($defaultFiscalYear)) {
100 setEventMessages($langs->trans(
"FiscalYearSetAsDefault", $defaultFiscalYearLabel),
null,
'mesgs');
116$title = $langs->trans(
'AccountingPeriods');
118$help_url =
'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration';
120llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-accountancy page-admin_fiscalyear');
122$sql =
"SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut as status, f.entity";
123$sql .=
" FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear as f";
124$sql .=
" WHERE f.entity = ".((int)
$conf->entity);
126$sql .=
$db->order($sortfield, $sortorder);
129$nbtotalofrecords =
'';
131 $result =
$db->query($sql);
132 $nbtotalofrecords =
$db->num_rows($result);
133 if (($page * $limit) > (int) $nbtotalofrecords) {
139$sql .=
$db->plimit($limit + 1, $offset);
141$result =
$db->query($sql);
143 $num =
$db->num_rows($result);
146 $parameters = array(
'param' => $param);
147 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtonsList', $parameters, $object, $action);
152 $newcardbutton = empty($hookmanager->resPrint) ?
'' : $hookmanager->resPrint;
154 if (empty($reshook)) {
155 $newcardbutton .= dolGetButtonTitle($langs->trans(
'NewFiscalYear'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/accountancy/admin/fiscalyear_card.php?action=create',
'', $user->hasRight(
'accounting',
'fiscalyear',
'write'));
158 $title = $langs->trans(
'AccountingPeriods');
159 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder,
'', $num, $nbtotalofrecords,
'calendar', 0, $newcardbutton,
'', $limit, 1);
161 print
'<div class="div-table-responsive">';
162 print
'<table class="tagtable liste centpercent noborder">';
163 print
'<tr class="liste_titre">';
164 print
'<td>'.$langs->trans(
"Ref").
'</td>';
165 print
'<td>'.$langs->trans(
"Label").
'</td>';
166 print
'<td>'.$langs->trans(
"DateStart").
'</td>';
167 print
'<td>'.$langs->trans(
"DateEnd").
'</td>';
168 print
'<td class="center">'.$langs->trans(
"NumberOfAccountancyEntries").
'</td>';
169 print
'<td class="center">'.$langs->trans(
"NumberOfAccountancyMovements").
'</td>';
170 print
'<td class="center">'.$langs->trans(
"Default").
'</td>';
171 print
'<td class="right">'.$langs->trans(
"Status").
'</td>';
178 while ($i < $num && $i < $max) {
179 $obj =
$db->fetch_object($result);
181 $fiscalyearstatic->ref = $obj->rowid;
182 $fiscalyearstatic->id = $obj->rowid;
183 $fiscalyearstatic->label = $obj->label;
184 $fiscalyearstatic->date_start = $obj->date_start;
185 $fiscalyearstatic->date_end = $obj->date_end;
186 $fiscalyearstatic->statut = $obj->status;
187 $fiscalyearstatic->status = $obj->status;
189 print
'<tr class="oddeven">';
191 print $fiscalyearstatic->getNomUrl(1);
193 print
'<td class="left">'.$obj->label.
'</td>';
194 print
'<td class="left">'.dol_print_date(
$db->jdate($obj->date_start),
'day').
'</td>';
195 print
'<td class="left">'.dol_print_date(
$db->jdate($obj->date_end),
'day').
'</td>';
196 print
'<td class="center">'.$object->getAccountancyEntriesByFiscalYear($obj->date_start, $obj->date_end).
'</td>';
197 print
'<td class="center">'.$object->getAccountancyMovementsByFiscalYear($obj->date_start, $obj->date_end).
'</td>';
200 print
'<td class="center">';
201 if (
getDolGlobalString(
'ACCOUNTANCY_FISCALYEAR_DEFAULT') == (
int) $fiscalyearstatic->ref) {
202 print
img_picto($langs->trans(
"Default"),
'on');
204 print
'<a class="reposition" href="'.dolBuildUrl($_SERVER[
"PHP_SELF"], [
'action' =>
'setdefault',
'value' => $fiscalyearstatic->ref,
'label'=>$fiscalyearstatic->label],
true).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"SetAsDefault"),
'off').
'</a>';
208 print
'<td class="right">'.$fiscalyearstatic->LibStatut($obj->status, 5).
'</td>';
213 print
'<tr class="oddeven"><td colspan="8"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
if(! $sortfield) if(! $sortorder) $object
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
Class to manage fiscal year.
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.