*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
/**
* \file htdocs/accountancy/admin/fiscalyear.php
* \ingroup Advanced accountancy
* \brief Setup page to configure fiscal year
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php';
$action = GETPOST('action','aZ09');
// Load variable for pagination
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (! $sortfield) $sortfield="f.rowid"; // Set here default search field
if (! $sortorder) $sortorder="ASC";
$langs->load("admin");
$langs->load("compta");
// Security check
if ($user->societe_id > 0)
accessforbidden();
if (! $user->rights->accounting->fiscalyear) // If we can read accounting records, we shoul be able to see fiscal year.
accessforbidden();
$error = 0;
// List of status
static $tmpstatut2label = array (
'0' => 'OpenFiscalYear',
'1' => 'CloseFiscalYear'
);
$statut2label = array (
''
);
foreach ( $tmpstatut2label as $key => $val )
$statut2label[$key] = $langs->trans($val);
$errors = array ();
$object = new Fiscalyear($db);
/*
* Actions
*/
/*
* View
*/
$max = 100;
$form = new Form($db);
$title = $langs->trans('AccountingPeriods');
$helpurl = "";
llxHeader('', $title, $helpurl);
$sql = "SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut, f.entity";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_fiscalyear as f";
$sql .= " WHERE f.entity = " . $conf->entity;
$sql.=$db->order($sortfield,$sortorder);
// Count total nb of records
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}
$sql.= $db->plimit($limit+1, $offset);
$result = $db->query($sql);
if ($result) {
$var = false;
$num = $db->num_rows($result);
$i = 0;
$title = $langs->trans('AccountingPeriods');
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit, 1);
// Load attribute_label
print '
';
print '';
print '' . $langs->trans("Ref") . ' | ';
print '' . $langs->trans("Label") . ' | ';
print '' . $langs->trans("DateStart") . ' | ';
print '' . $langs->trans("DateEnd") . ' | ';
print '' . $langs->trans("Statut") . ' | ';
print '
';
if ($num) {
$fiscalyearstatic = new Fiscalyear($db);
while ( $i < $num && $i < $max ) {
$obj = $db->fetch_object($result);
$fiscalyearstatic->id = $obj->rowid;
print '';
print '' . img_object($langs->trans("ShowFiscalYear"), "technic") . ' ' . $obj->rowid . ' | ';
print '' . $obj->label . ' | ';
print '' . dol_print_date($db->jdate($obj->date_start), 'day') . ' | ';
print '' . dol_print_date($db->jdate($obj->date_end), 'day') . ' | ';
print '' . $fiscalyearstatic->LibStatut($obj->statut, 5) . ' | ';
print '
';
$var = ! $var;
$i ++;
}
} else {
print '' . $langs->trans("None") . ' |
';
}
print '
';
} else {
dol_print_error($db);
}
dol_fiche_end();
// Buttons
print '';
llxFooter();
$db->close();