27require
'../../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/fiscalyear.lib.php';
37require_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',
'alpha');
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$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
60include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
76$permissiontoadd = $user->hasRight(
'accounting',
'fiscalyear',
'write');
79if ($user->socid > 0) {
82if (!$permissiontoadd) {
92$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
94 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
97if ($action ==
'confirm_delete' && $confirm ==
"yes" ) {
99 $result =
$object->delete($user);
101 header(
"Location: fiscalyear.php");
106} elseif ($action ==
'add' ) {
107 if (!
GETPOST(
'cancel',
'alpha')) {
117 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
121 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
131 header(
"Location: " . $_SERVER[
"PHP_SELF"] .
"?id=" . $id);
137 if ($id == -5 && !empty(
$object->errors[0])) {
138 setEventMessages($langs->trans(
$object->error,
$object->errors[0]),
null,
'errors');
148 header(
"Location: ./fiscalyear.php");
151} elseif ($action ==
'update' ) {
153 if (!
GETPOST(
'cancel',
'alpha')) {
161 $result =
$object->update($user);
163 header(
"Location: " . $_SERVER[
"PHP_SELF"] .
"?id=" . $id);
167 if ($result == -5 && !empty(
$object->errors[0])) {
168 setEventMessages($langs->trans(
$object->error,
$object->errors[0]),
null,
'errors');
174 header(
"Location: " . $_SERVER[
"PHP_SELF"] .
"?id=" . $id);
177} elseif ($action ==
'reopen' &&
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="'.dolBuildUrl($_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>';
220 print
'<input name="label" size="32" value="'.GETPOST(
'label',
'alpha').
'">';
224 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DateStart").
'</td><td>';
229 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DateEnd").
'</td><td>';
230 print $form->selectDate(($date_end ? $date_end : - 1),
'fiscalyearend');
248 print
'</table>'.
"\n";
252 print $form->buttonsSaveCancel(
"Create");
261if (($id || $ref) && $action ==
'edit') {
262 print
load_fiche_titre($langs->trans(
"Fiscalyear"),
'',
'object_'.$object->picto);
264 print
'<form method="POST" name="update" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
265 print
'<input type="hidden" name="token" value="'.newToken().
'">';
266 print
'<input type="hidden" name="action" value="update">';
267 print
'<input type="hidden" name="status" value="' .
$object->status .
'">';
268 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
270 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
272 if ($backtopageforcancel) {
273 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
278 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
282 print
'<td class="titlefieldcreate titlefield">'.$langs->trans(
"Ref").
'</td><td>';
287 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Label").
'</td><td>';
288 print
'<input name="label" class="flat" size="32" value="'.$object->label.
'">';
292 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DateStart").
'</td><td>';
293 print $form->selectDate(
$object->date_start ?
$object->date_start : - 1,
'fiscalyear');
297 print
'<tr><td class="fieldrequired">'.$langs->trans(
"DateEnd").
'</td><td>';
298 print $form->selectDate(
$object->date_end ?
$object->date_end : - 1,
'fiscalyearend');
302 print
'<tr><td>'.$langs->trans(
"Status").
'</td><td>';
303 print
$object->getLibStatut(4);
316 print $form->buttonsSaveCancel();
322if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
334 if ($action ==
'delete') {
335 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"DeleteFiscalYear"), $langs->trans(
"ConfirmDeleteFiscalYear"),
"confirm_delete",
'', 0, 1);
343 $linkback =
'<a href="'.DOL_URL_ROOT.
'/accountancy/admin/fiscalyear.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
345 dol_banner_tab($object,
'label', $linkback, 1,
'label',
'label', $morehtmlref);
348 print
'<div class="fichecenter">';
349 print
'<div class="fichehalfleft">';
350 print
'<div class="underbanner clearboth"></div>';
352 print
'<table class="border centpercent tableforfield">'.
"\n";
356 print
'<td class="titlefield">'.$langs->trans(
"Id").
'</td><td>';
361 print
'<tr><td class="tdtop">';
362 print $form->editfieldkey(
"Label",
'label',
$object->label, $object, 0,
'alpha:32');
364 print $form->editfieldval(
"Label",
'label',
$object->label, $object, 0,
'alpha:32');
369 print $form->editfieldkey(
"DateStart",
'date_start', (
string)
$object->date_start, $object, 0,
'datepicker');
371 print $form->editfieldval(
"DateStart",
'date_start',
$object->date_start, $object, 0,
'datepicker');
376 print $form->editfieldkey(
"DateEnd",
'date_end', (
string)
$object->date_end, $object, 0,
'datepicker');
378 print $form->editfieldval(
"DateEnd",
'date_end',
$object->date_end, $object, 0,
'datepicker');
386 print
'<div class="clearboth"></div>';
394 if ($user->hasRight(
'accounting',
'fiscalyear',
'write')) {
395 print
'<div class="tabsAction">';
398 print dolGetButtonAction($langs->trans(
"ReOpen"),
'',
'reopen', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=reopen&token='.
newToken(),
'reopen', (
int) $permissiontoadd);
401 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(! $sortfield) if(! $sortorder) $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.
$date_start
Variables from include:
dol_now($mode='gmt')
Return date for now.
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...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.