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"));
 
   35if ($user->socid > 0) {
 
   38if (!$user->hasRight(
'accounting', 
'fiscalyear', 
'write')) {
 
   44$action = 
GETPOST(
'action', 
'aZ09');
 
   45$confirm = 
GETPOST(
'confirm', 
'alpha');
 
   49static $tmpstatut2label = array(
 
   50    '0' => 
'OpenFiscalYear',
 
   51    '1' => 
'CloseFiscalYear' 
   56foreach ($tmpstatut2label as $key => $val) {
 
   57  $statut2label[$key] = $langs->trans($val);
 
   70if ($action == 
'confirm_delete' && $confirm == 
"yes") {
 
   71  $result = $object->delete($id);
 
   73    header(
"Location: fiscalyear.php");
 
   78} elseif ($action == 
'add') {
 
   79  if (!
GETPOST(
'cancel', 
'alpha')) {
 
   82    $object->date_start = $date_start;
 
   83    $object->date_end = $date_end;
 
   84    $object->label = 
GETPOST(
'label', 
'alpha');
 
   85    $object->statut = 
GETPOST(
'statut', 
'int');
 
   88    if (empty($object->date_start) && empty($object->date_end)) {
 
   89      setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")), 
null, 
'errors');
 
   92    if (empty($object->label)) {
 
   93      setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")), 
null, 
'errors');
 
  100      $id = $object->create($user);
 
  105        header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
 
  117    header(
"Location: ./fiscalyear.php");
 
  120} elseif ($action == 
'update') {
 
  122  if (!
GETPOST(
'cancel', 
'alpha')) {
 
  123    $result = $object->fetch($id);
 
  125    $object->date_start = 
GETPOST(
"fiscalyear") ? $date_start : 
'';
 
  126    $object->date_end = 
GETPOST(
"fiscalyearend") ? $date_end : 
'';
 
  127    $object->label = 
GETPOST(
'label', 
'alpha');
 
  128    $object->statut = 
GETPOST(
'statut', 
'int');
 
  130    $result = $object->update($user);
 
  133      header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
 
  139    header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
 
  150$form = 
new Form($db);
 
  152$title = $langs->trans(
"Fiscalyear").
" - ".$langs->trans(
"Card");
 
  154$help_url = 
"EN:Module_Double_Entry_Accounting";
 
  158if ($action == 
'create') {
 
  161  print 
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
 
  162  print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  163  print 
'<input type="hidden" name="action" value="add">';
 
  167  print 
'<table class="border centpercent">';
 
  170  print 
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Label").
'</td><td><input name="label" size="32" value="'.
GETPOST(
'label', 
'alpha').
'"></td></tr>';
 
  173  print 
'<tr><td class="fieldrequired">'.$langs->trans(
"DateStart").
'</td><td>';
 
  174  print $form->selectDate(($date_start ? $date_start : 
''), 
'fiscalyear');
 
  178  print 
'<tr><td class="fieldrequired">'.$langs->trans(
"DateEnd").
'</td><td>';
 
  179  print $form->selectDate(($date_end ? $date_end : - 1), 
'fiscalyearend');
 
  195  print 
'<div class="center">';
 
  196  print 
'<input class="button button-save" type="submit" value="'.$langs->trans(
"Save").
'">';
 
  197  print 
'     ';
 
  198  print 
'<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
 
  203  $result = $object->fetch($id);
 
  207    if ($action == 
'edit') {
 
  210      print 
'<form name="update" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
 
  211      print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  212      print 
'<input type="hidden" name="action" value="update">';
 
  213      print 
'<input type="hidden" name="id" value="'.$id.
'">';
 
  215      print 
'<table class="border centpercent">';
 
  219      print 
'<td class="titlefieldcreate titlefield">'.$langs->trans(
"Ref").
'</td><td>';
 
  224      print 
'<tr><td class="fieldrequired">'.$langs->trans(
"Label").
'</td><td>';
 
  225      print 
'<input name="label" class="flat" size="32" value="'.$object->label.
'">';
 
  229      print 
'<tr><td class="fieldrequired">'.$langs->trans(
"DateStart").
'</td><td>';
 
  230      print $form->selectDate($object->date_start ? $object->date_start : - 1, 
'fiscalyear');
 
  234      print 
'<tr><td class="fieldrequired">'.$langs->trans(
"DateEnd").
'</td><td>';
 
  235      print $form->selectDate($object->date_end ? $object->date_end : - 1, 
'fiscalyearend');
 
  239      print 
'<tr><td>'.$langs->trans(
"Statut").
'</td><td>';
 
  241      print $object->getLibStatut(4);
 
  246      print $form->buttonsSaveCancel();
 
  255      if ($action == 
'delete') {
 
  256        print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"DeleteFiscalYear"), $langs->trans(
"ConfirmDeleteFiscalYear"), 
"confirm_delete");
 
  261      print 
'<table class="border centpercent">';
 
  263      $linkback = 
'<a href="'.DOL_URL_ROOT.
'/accountancy/admin/fiscalyear.php">'.$langs->trans(
"BackToList").
'</a>';
 
  266      print 
'<tr><td class="titlefield">'.$langs->trans(
"Ref").
'</td><td width="50%">';
 
  273      print 
'<tr><td class="tdtop">';
 
  274      print $form->editfieldkey(
"Label", 
'label', $object->label, $object, 1, 
'alpha:32');
 
  275      print 
'</td><td colspan="2">';
 
  276      print $form->editfieldval(
"Label", 
'label', $object->label, $object, 1, 
'alpha:32');
 
  281      print $form->editfieldkey(
"DateStart", 
'date_start', $object->date_start, $object, 1, 
'datepicker');
 
  282      print 
'</td><td colspan="2">';
 
  283      print $form->editfieldval(
"DateStart", 
'date_start', $object->date_start, $object, 1, 
'datepicker');
 
  288      print $form->editfieldkey(
"DateEnd", 
'date_end', $object->date_end, $object, 1, 
'datepicker');
 
  289      print 
'</td><td colspan="2">';
 
  290      print $form->editfieldval(
"DateEnd", 
'date_end', $object->date_end, $object, 1, 
'datepicker');
 
  294      print 
'<tr><td>'.$langs->trans(
"Status").
'</td><td colspan="2">'.$object->getLibStatut(4).
'</td></tr>';
 
  303      if ($user->hasRight(
'accounting', 
'fiscalyear', 
'write')) {
 
  304        print 
'<div class="tabsAction">';
 
  306        print 
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.newToken().
'&id='.$id.
'">'.$langs->trans(
'Modify').
'</a>';
 
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 informations (by default a local PHP server timestamp) Re...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_now($mode='auto')
Return date for now.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.