26require
'../../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/lib/fiscalyear.lib.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/fiscalyear.class.php';
40$langs->loadLangs(array(
"admin",
"compta"));
46$action =
GETPOST(
'action',
'aZ09');
47$confirm =
GETPOST(
'confirm',
'alpha');
48$cancel =
GETPOST(
'cancel',
'aZ09');
49$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
50$backtopage =
GETPOST(
'backtopage',
'alpha');
51$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
52$backtopagejsfields =
GETPOST(
'backtopagejsfields',
'alpha');
53$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
55if (!empty($backtopagejsfields)) {
56 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
57 $dol_openinpopup = preg_replace(
'/[^a-z0-9_]/i',
'', $tmpbacktopagejsfields[0]);
67include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
70static $tmpstatus2label = array(
71 '0' =>
'OpenFiscalYear',
72 '1' =>
'CloseFiscalYear'
77foreach ($tmpstatus2label as $key => $val) {
78 $status2label[$key] = $langs->trans($val);
84$permissiontoadd = $user->hasRight(
'accounting',
'fiscalyear',
'write');
87if ($user->socid > 0) {
90if (!$permissiontoadd) {
100$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
105if ($action ==
'confirm_delete' && $confirm ==
"yes" && $permissiontoadd) {
106 $result =
$object->delete($user);
108 header(
"Location: fiscalyear.php");
113} elseif ($action ==
'add' && $permissiontoadd) {
114 if (!
GETPOST(
'cancel',
'alpha')) {
117 $object->date_start = $date_start;
124 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
128 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
140 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
152 header(
"Location: ./fiscalyear.php");
155} elseif ($action ==
'update' && $permissiontoadd) {
157 if (!
GETPOST(
'cancel',
'alpha')) {
165 $result =
$object->update($user);
168 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
174 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
177} elseif ($action ==
'reopen' && $permissiontoadd &&
getDolGlobalString(
'ACCOUNTING_CAN_REOPEN_CLOSED_PERIOD')) {
181 $result =
$object->update($user);
184 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
196$form =
new Form($db);
198$title = $langs->trans(
"Fiscalyear").
" - ".$langs->trans(
"Card");
199if ($action ==
'create') {
200 $title = $langs->trans(
"NewFiscalYear");
203$help_url =
'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration';
205llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-accountancy page-fiscalyear');
207if ($action ==
'create') {
210 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
211 print
'<input type="hidden" name="token" value="'.newToken().
'">';
212 print
'<input type="hidden" name="action" value="add">';
216 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
219 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td><td><input name="label" size="32" value="'.
GETPOST(
'label',
'alpha').
'"></td></tr>';
222 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DateStart").
'</td><td>';
223 print $form->selectDate(($date_start ? $date_start :
''),
'fiscalyear');
227 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DateEnd").
'</td><td>';
228 print $form->selectDate(($date_end ? $date_end : - 1),
'fiscalyearend');
246 print
'</table>'.
"\n";
250 print $form->buttonsSaveCancel(
"Create");
259if (($id || $ref) && $action ==
'edit') {
260 print
load_fiche_titre($langs->trans(
"Fiscalyear"),
'',
'object_'.$object->picto);
262 print
'<form method="POST" name="update" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
263 print
'<input type="hidden" name="token" value="'.newToken().
'">';
264 print
'<input type="hidden" name="action" value="update">';
265 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
267 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
269 if ($backtopageforcancel) {
270 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
275 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
279 print
'<td class="titlefieldcreate titlefield">'.$langs->trans(
"Ref").
'</td><td>';
284 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Label").
'</td><td>';
285 print
'<input name="label" class="flat" size="32" value="'.$object->label.
'">';
289 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DateStart").
'</td><td>';
290 print $form->selectDate(
$object->date_start ?
$object->date_start : - 1,
'fiscalyear');
294 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DateEnd").
'</td><td>';
295 print $form->selectDate(
$object->date_end ?
$object->date_end : - 1,
'fiscalyearend');
299 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
300 print
$object->getLibStatut(4);
313 print $form->buttonsSaveCancel();
319if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
322 print
dol_get_fiche_head($head,
'card', $langs->trans(
"Fiscalyear"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
331 if ($action ==
'delete') {
332 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"DeleteFiscalYear"), $langs->trans(
"ConfirmDeleteFiscalYear"),
"confirm_delete",
'', 0, 1);
340 $linkback =
'<a href="'.DOL_URL_ROOT.
'/accountancy/admin/fiscalyear.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
342 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
345 print
'<div class="fichecenter">';
346 print
'<div class="fichehalfleft">';
347 print
'<div class="underbanner clearboth"></div>';
348 print
'<table class="border centpercent tableforfield">'.
"\n";
351 print
'<tr><td class="tdtop">';
352 print $form->editfieldkey(
"Label",
'label',
$object->label, $object, 0,
'alpha:32');
354 print $form->editfieldval(
"Label",
'label',
$object->label, $object, 0,
'alpha:32');
359 print $form->editfieldkey(
"DateStart",
'date_start',
$object->date_start, $object, 0,
'datepicker');
361 print $form->editfieldval(
"DateStart",
'date_start',
$object->date_start, $object, 0,
'datepicker');
366 print $form->editfieldkey(
"DateEnd",
'date_end',
$object->date_end, $object, 0,
'datepicker');
368 print $form->editfieldval(
"DateEnd",
'date_end',
$object->date_end, $object, 0,
'datepicker');
375 print
'<div class="clearboth"></div>';
383 if ($user->hasRight(
'accounting',
'fiscalyear',
'write')) {
384 print
'<div class="tabsAction">';
387 print
dolGetButtonAction($langs->trans(
"ReOpen"),
'',
'reopen', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=reopen&token='.
newToken(),
'reopen', $permissiontoadd);
390 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($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.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
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.