diff --git a/htdocs/admin/fiscalyear.php b/htdocs/admin/fiscalyear.php
index 7929fd5046f..607630461fb 100644
--- a/htdocs/admin/fiscalyear.php
+++ b/htdocs/admin/fiscalyear.php
@@ -52,185 +52,6 @@ $object = new Fiscalyear($db);
* Actions
*/
-// Add
-if ($action == 'add')
-{
- if (! GETPOST('cancel','alpha'))
- {
- $error=0;
-
- $object->label = GETPOST('label','alpha');
- $object->datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int'));
- $object->dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int'));
- $object->statut = 0;
-
- if (! $object->label)
- {
- $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Label")).'
';
- $error++;
- }
- if (! $object->datestart)
- {
- $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("DateStart")).'
';
- $error++;
- }
- if (! $object->dateend)
- {
- $mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("DateEnd")).'
';
- $error++;
- }
-
- if (! $error)
- {
- $id = $object->create();
-
- if ($id > 0)
- {
- header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
- exit;
- }
- else
- {
- $mesg=$object->error;
- $action='create';
- }
- }
- else
- {
- $action='create';
- }
- }
- else
- {
- header("Location: index.php");
- exit;
- }
-
- if (! GETPOST('cancel','alpha'))
- {
- $error=0;
-
- // Check values
- $datestart = dol_mktime(12, 0, 0, $_POST['startmonth'], $_POST['startday'], $_POST['startyear']);
- $dateend = dol_mktime(12, 0, 0, $_POST['endmonth'], $_POST['endday'], $_POST['endyear']);
- $label = $_POST['label'];
-
- if (empty($label))
- {
- $mesgs[]=''.$langs->trans("ErrorFieldRequired",$langs->trans("Label")).'
';
- $error++;
- //$action='create';
- }
- if (empty($datestart) || empty($dateend))
- {
- $mesgs[]=''.$langs->trans("ErrorFieldRequired",$langs->trans("Date")).'
';
- $error++;
- //$action='create';
- }
-
- if (! $error)
- {
- $this->db->begin();
-
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_fiscalyear";
- $sql.= " (label, datestart, dateend, statut, entity)";
- $sql.= " VALUES('".$label."',";
- $sql.= " '".$datestart."',";
- $sql.= " '".$dateend."',";
- $sql.= " ' 0,";
- $sql.= " ".$conf->entity."'";
- $sql.=')';
-
- dol_syslog(get_class($this)."::create_label sql=".$sql);
- if ($this->db->query($sql))
- {
- return 1;
- }
- else
- {
- $this->error=$this->db->lasterror();
- $this->errno=$this->db->lasterrno();
- return -1;
- }
- }
- }
-}
-
-// Rename field
-if ($action == 'update')
-{
- if ($_POST["button"] != $langs->trans("Cancel"))
- {
- // Check values
- if (! GETPOST('type'))
- {
- $error++;
- $langs->load("errors");
- $mesg=$langs->trans("ErrorFieldRequired",$langs->trans("Type"));
- $action = 'create';
- }
- if (GETPOST('type')=='varchar' && $extrasize > $maxsizestring)
- {
- $error++;
- $langs->load("errors");
- $mesg=$langs->trans("ErrorSizeTooLongForVarcharType",$maxsizestring);
- $action = 'edit';
- }
- if (GETPOST('type')=='int' && $extrasize > $maxsizeint)
- {
- $error++;
- $langs->load("errors");
- $mesg=$langs->trans("ErrorSizeTooLongForIntType",$maxsizeint);
- $action = 'edit';
- }
-
- if (! $error)
- {
- if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_POST['attrname']))
- {
- $result=$extrafields->update($_POST['attrname'],$_POST['label'],$_POST['type'],$extrasize,$elementtype,(GETPOST('unique')?1:0));
- if ($result > 0)
- {
- header("Location: ".$_SERVER["PHP_SELF"]);
- exit;
- }
- else
- {
- $error++;
- $mesg=$extrafields->error;
- }
- }
- else
- {
- $error++;
- $langs->load("errors");
- $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
- }
- }
- }
-}
-
-// Delete attribute
-if ($action == 'delete')
-{
- if(isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_GET["attrname"]))
- {
- $result=$extrafields->delete($_GET["attrname"],$elementtype);
- if ($result >= 0)
- {
- header("Location: ".$_SERVER["PHP_SELF"]);
- exit;
- }
- else $mesg=$extrafields->error;
- }
- else
- {
- $error++;
- $langs->load("errors");
- $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
- }
-}
-
/*
* View
*/
@@ -239,9 +60,9 @@ $form = new Form($db);
llxHeader('',$title);
-$title = $langs->trans('Accountancysetup');
+$title = $langs->trans('FiscalYears');
-print_fiche_titre($langs->trans('Fiscalyear'));
+print_fiche_titre($langs->trans('FiscalYears'));
dol_htmloutput_errors($mesg);
diff --git a/htdocs/admin/fiscalyear_card.php b/htdocs/admin/fiscalyear_card.php
index d18fdbc3ec4..3845e689e79 100644
--- a/htdocs/admin/fiscalyear_card.php
+++ b/htdocs/admin/fiscalyear_card.php
@@ -17,13 +17,13 @@
/**
* \file htdocs/admin/fiscalyear_card.php
- * \brief Page to show a fiscal yeartrip
+ * \brief Page to show a fiscal year
*/
require '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+
+require_once DOL_DOCUMENT_ROOT.'/core/lib/fiscalyear.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$langs->load("admin");
@@ -50,12 +50,13 @@ $mesg = '';
$object = new Fiscalyear($db);
+$date_start=dol_mktime(0,0,0,GETPOST('fiscalyearmonth','int'),GETPOST('fiscalyearday','int'),GETPOST('fiscalyearyear','int'));
+$date_end=dol_mktime(0,0,0,GETPOST('fiscalyearendmonth','int'),GETPOST('fiscalyearendday','int'),GETPOST('fiscalyearendyear','int'));
+
/*
* Actions
*/
-include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
-
if ($action == 'confirm_delete' && $confirm == "yes")
{
$result=$object->delete($id);
@@ -76,18 +77,18 @@ else if ($action == 'add')
{
$error=0;
- $object->datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int'));
- $object->dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int'));
- $object->label = GETPOST('label','alpha');
+ $db->begin();
+
+ $object->datestart = $date_start;
+ $object->dateend = $date_end;
+ $object->label = GETPOST('label','alpha');
$object->statut = GETPOST('statut','int');;
- /*
if (empty($object->datestart) && empty($object->dateend))
{
- $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date"));
+ $mesg.=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date"));
$error++;
}
- */
if (empty($object->label))
{
$mesg=''.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Label")).'
';
@@ -116,7 +117,7 @@ else if ($action == 'add')
}
else
{
- header("Location: fiscalyear.php");
+ header("Location: ./fiscalyear.php");
exit;
}
}
@@ -169,10 +170,7 @@ if ($action == 'create')
dol_htmloutput_errors($mesg);
- $datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int'));
- $dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int'));
-
- print '