26require
'../../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/lib/fiscalyear.lib.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/fiscalyear.class.php';
32$langs->loadLangs(array(
"admin",
"compta"));
38$action =
GETPOST(
'action',
'aZ09');
39$confirm =
GETPOST(
'confirm',
'alpha');
40$cancel =
GETPOST(
'cancel',
'aZ09');
41$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
42$backtopage =
GETPOST(
'backtopage',
'alpha');
43$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
44$backtopagejsfields =
GETPOST(
'backtopagejsfields',
'alpha');
45$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
47if (!empty($backtopagejsfields)) {
48 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
49 $dol_openinpopup = preg_replace(
'/[^a-z0-9_]/i',
'', $tmpbacktopagejsfields[0]);
59include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
62static $tmpstatus2label = array(
63 '0' =>
'OpenFiscalYear',
64 '1' =>
'CloseFiscalYear'
69foreach ($tmpstatus2label as $key => $val) {
70 $status2label[$key] = $langs->trans($val);
76$permissiontoadd = $user->hasRight(
'accounting',
'fiscalyear',
'write');
79if ($user->socid > 0) {
82if (!$permissiontoadd) {
92$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
97if ($action ==
'confirm_delete' && $confirm ==
"yes" && $permissiontoadd) {
98 $result =
$object->delete($user);
100 header(
"Location: fiscalyear.php");
105} elseif ($action ==
'add' && $permissiontoadd) {
106 if (!
GETPOST(
'cancel',
'alpha')) {
109 $object->date_start = $date_start;
116 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
120 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
132 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
144 header(
"Location: ./fiscalyear.php");
147} elseif ($action ==
'update' && $permissiontoadd) {
149 if (!
GETPOST(
'cancel',
'alpha')) {
157 $result =
$object->update($user);
160 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
166 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
169} elseif ($action ==
'reopen' && $permissiontoadd &&
getDolGlobalString(
'ACCOUNTING_CAN_REOPEN_CLOSED_PERIOD')) {
173 $result =
$object->update($user);
176 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
188$form =
new Form($db);
190$title = $langs->trans(
"Fiscalyear").
" - ".$langs->trans(
"Card");
191if ($action ==
'create') {
192 $title = $langs->trans(
"NewFiscalYear");
195$help_url =
'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration';
197llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-accountancy page-fiscalyear');
199if ($action ==
'create') {
202 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
203 print
'<input type="hidden" name="token" value="'.newToken().
'">';
204 print
'<input type="hidden" name="action" value="add">';
208 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
211 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td><td><input name="label" size="32" value="'.
GETPOST(
'label',
'alpha').
'"></td></tr>';
214 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DateStart").
'</td><td>';
215 print $form->selectDate(($date_start ? $date_start :
''),
'fiscalyear');
219 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DateEnd").
'</td><td>';
220 print $form->selectDate(($date_end ? $date_end : - 1),
'fiscalyearend');
238 print
'</table>'.
"\n";
242 print $form->buttonsSaveCancel(
"Create");
251if (($id || $ref) && $action ==
'edit') {
252 print
load_fiche_titre($langs->trans(
"Fiscalyear"),
'',
'object_'.$object->picto);
254 print
'<form method="POST" name="update" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
255 print
'<input type="hidden" name="token" value="'.newToken().
'">';
256 print
'<input type="hidden" name="action" value="update">';
257 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
259 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
261 if ($backtopageforcancel) {
262 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
267 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
271 print
'<td class="titlefieldcreate titlefield">'.$langs->trans(
"Ref").
'</td><td>';
276 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Label").
'</td><td>';
277 print
'<input name="label" class="flat" size="32" value="'.$object->label.
'">';
281 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DateStart").
'</td><td>';
282 print $form->selectDate(
$object->date_start ?
$object->date_start : - 1,
'fiscalyear');
286 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DateEnd").
'</td><td>';
287 print $form->selectDate(
$object->date_end ?
$object->date_end : - 1,
'fiscalyearend');
291 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
292 print
$object->getLibStatut(4);
305 print $form->buttonsSaveCancel();
311if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
314 print
dol_get_fiche_head($head,
'card', $langs->trans(
"Fiscalyear"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
323 if ($action ==
'delete') {
324 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"DeleteFiscalYear"), $langs->trans(
"ConfirmDeleteFiscalYear"),
"confirm_delete",
'', 0, 1);
332 $linkback =
'<a href="'.DOL_URL_ROOT.
'/accountancy/admin/fiscalyear.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
334 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
337 print
'<div class="fichecenter">';
338 print
'<div class="fichehalfleft">';
339 print
'<div class="underbanner clearboth"></div>';
340 print
'<table class="border centpercent tableforfield">'.
"\n";
343 print
'<tr><td class="tdtop">';
344 print $form->editfieldkey(
"Label",
'label',
$object->label, $object, 0,
'alpha:32');
346 print $form->editfieldval(
"Label",
'label',
$object->label, $object, 0,
'alpha:32');
351 print $form->editfieldkey(
"DateStart",
'date_start',
$object->date_start, $object, 0,
'datepicker');
353 print $form->editfieldval(
"DateStart",
'date_start',
$object->date_start, $object, 0,
'datepicker');
358 print $form->editfieldkey(
"DateEnd",
'date_end',
$object->date_end, $object, 0,
'datepicker');
360 print $form->editfieldval(
"DateEnd",
'date_end',
$object->date_end, $object, 0,
'datepicker');
367 print
'<div class="clearboth"></div>';
375 if ($user->hasRight(
'accounting',
'fiscalyear',
'write')) {
376 print
'<div class="tabsAction">';
379 print
dolGetButtonAction($langs->trans(
"ReOpen"),
'',
'reopen', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=reopen&token='.
newToken(),
'reopen', $permissiontoadd);
382 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'&id='.$id.
'">'.$langs->trans(
'Modify').
'</a>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage fiscal year.
fiscalyear_prepare_head(Fiscalyear $object)
Prepare array with list of tabs.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_now($mode='auto')
Return date for now.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return 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.