27require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/fiscalyear.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/fiscalyear.class.php';
41$langs->loadLangs(array(
"admin",
"compta"));
47$action =
GETPOST(
'action',
'aZ09');
48$confirm =
GETPOST(
'confirm',
'alpha');
50$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
51$backtopage =
GETPOST(
'backtopage',
'alpha');
52$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
53$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
62include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
65static $tmpstatus2label = array(
66 '0' =>
'OpenFiscalYear',
67 '1' =>
'CloseFiscalYear'
72foreach ($tmpstatus2label as $key => $val) {
73 $status2label[$key] = $langs->trans($val);
79$permissiontoadd = $user->hasRight(
'accounting',
'fiscalyear',
'write');
82if ($user->socid > 0) {
85if (!$permissiontoadd) {
95$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
100if ($action ==
'confirm_delete' && $confirm ==
"yes" && $permissiontoadd) {
101 $result =
$object->delete($user);
103 header(
"Location: fiscalyear.php");
108} elseif ($action ==
'add' && $permissiontoadd) {
109 if (!
GETPOST(
'cancel',
'alpha')) {
112 $object->date_start = $date_start;
119 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
123 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
133 header(
"Location: " . $_SERVER[
"PHP_SELF"] .
"?id=" . $id);
139 if ($id == -5 && !empty(
$object->errors[0])) {
150 header(
"Location: ./fiscalyear.php");
153} elseif ($action ==
'update' && $permissiontoadd) {
155 if (!
GETPOST(
'cancel',
'alpha')) {
163 $result =
$object->update($user);
165 header(
"Location: " . $_SERVER[
"PHP_SELF"] .
"?id=" . $id);
169 if ($result == -5 && !empty(
$object->errors[0])) {
176 header(
"Location: " . $_SERVER[
"PHP_SELF"] .
"?id=" . $id);
179} elseif ($action ==
'reopen' && $permissiontoadd &&
getDolGlobalString(
'ACCOUNTING_CAN_REOPEN_CLOSED_PERIOD')) {
183 $result =
$object->update($user);
186 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
198$form =
new Form($db);
200$title = $langs->trans(
"Fiscalyear").
" - ".$langs->trans(
"Card");
201if ($action ==
'create') {
202 $title = $langs->trans(
"NewFiscalYear");
205$help_url =
'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration';
207llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-accountancy page-fiscalyear');
209if ($action ==
'create') {
212 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
213 print
'<input type="hidden" name="token" value="'.newToken().
'">';
214 print
'<input type="hidden" name="action" value="add">';
218 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
221 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td><td>';
222 print
'<input name="label" size="32" value="'.GETPOST(
'label',
'alpha').
'">';
226 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DateStart").
'</td><td>';
227 print $form->selectDate(($date_start ? $date_start :
''),
'fiscalyear');
231 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DateEnd").
'</td><td>';
232 print $form->selectDate(($date_end ? $date_end : - 1),
'fiscalyearend');
250 print
'</table>'.
"\n";
254 print $form->buttonsSaveCancel(
"Create");
263if (($id || $ref) && $action ==
'edit') {
264 print
load_fiche_titre($langs->trans(
"Fiscalyear"),
'',
'object_'.$object->picto);
266 print
'<form method="POST" name="update" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
267 print
'<input type="hidden" name="token" value="'.newToken().
'">';
268 print
'<input type="hidden" name="action" value="update">';
269 print
'<input type="hidden" name="status" value="' .
$object->status .
'">';
270 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
272 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
274 if ($backtopageforcancel) {
275 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
280 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
284 print
'<td class="titlefieldcreate titlefield">'.$langs->trans(
"Ref").
'</td><td>';
289 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Label").
'</td><td>';
290 print
'<input name="label" class="flat" size="32" value="'.$object->label.
'">';
294 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DateStart").
'</td><td>';
295 print $form->selectDate(
$object->date_start ?
$object->date_start : - 1,
'fiscalyear');
299 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DateEnd").
'</td><td>';
300 print $form->selectDate(
$object->date_end ?
$object->date_end : - 1,
'fiscalyearend');
304 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
305 print
$object->getLibStatut(4);
318 print $form->buttonsSaveCancel();
324if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
327 print
dol_get_fiche_head($head,
'card', $langs->trans(
"Fiscalyear"), -1,
$object->picto, 0,
'',
'', 0,
'', 1);
336 if ($action ==
'delete') {
337 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"DeleteFiscalYear"), $langs->trans(
"ConfirmDeleteFiscalYear"),
"confirm_delete",
'', 0, 1);
345 $linkback =
'<a href="'.DOL_URL_ROOT.
'/accountancy/admin/fiscalyear.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
347 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
350 print
'<div class="fichecenter">';
351 print
'<div class="fichehalfleft">';
352 print
'<div class="underbanner clearboth"></div>';
353 print
'<table class="border centpercent tableforfield">'.
"\n";
356 print
'<tr><td class="tdtop">';
357 print $form->editfieldkey(
"Label",
'label',
$object->label, $object, 0,
'alpha:32');
359 print $form->editfieldval(
"Label",
'label',
$object->label, $object, 0,
'alpha:32');
364 print $form->editfieldkey(
"DateStart",
'date_start', (
string)
$object->date_start, $object, 0,
'datepicker');
366 print $form->editfieldval(
"DateStart",
'date_start',
$object->date_start, $object, 0,
'datepicker');
371 print $form->editfieldkey(
"DateEnd",
'date_end', (
string)
$object->date_end, $object, 0,
'datepicker');
373 print $form->editfieldval(
"DateEnd",
'date_end',
$object->date_end, $object, 0,
'datepicker');
380 print
'<div class="clearboth"></div>';
388 if ($user->hasRight(
'accounting',
'fiscalyear',
'write')) {
389 print
'<div class="tabsAction">';
392 print
dolGetButtonAction($langs->trans(
"ReOpen"),
'',
'reopen', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=reopen&token='.
newToken(),
'reopen', (
int) $permissiontoadd);
395 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'&id='.
$id.
'">'.$langs->trans(
'Modify').
'</a>';
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
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, $morecssdiv='')
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.