';
// Statut
diff --git a/htdocs/admin/fiscalyear_info.php b/htdocs/admin/fiscalyear_info.php
new file mode 100644
index 00000000000..c59d75c8376
--- /dev/null
+++ b/htdocs/admin/fiscalyear_info.php
@@ -0,0 +1,60 @@
+
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, seehttp://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file htdocs/admin/fiscalyear_card.php
+ * \brief Page to show info of a fiscal year
+ */
+
+require '../main.inc.php';
+
+require_once DOL_DOCUMENT_ROOT.'/core/lib/fiscalyear.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php';
+
+
+$langs->load("admin");
+$langs->load("compta");
+
+// Security check
+if (! $user->admin) accessforbidden();
+
+$id = GETPOST('id','int');
+
+// View
+llxHeader();
+
+if ($id)
+{
+ $object = new Fiscalyear($db);
+ $object->fetch($id);
+ $object->info($id);
+
+ $head = fiscalyear_prepare_head($object);
+
+ dol_fiche_head($head, 'info', $langs->trans("FiscalYearCard"), 0, 'cron');
+
+ print '
';
+ dol_print_object_info($object);
+ print '
';
+
+ print '';
+}
+
+$db->close();
+
+llxFooter();
diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php
index 6956884e733..21dfa6f2381 100644
--- a/htdocs/core/class/fiscalyear.class.php
+++ b/htdocs/core/class/fiscalyear.class.php
@@ -38,8 +38,8 @@ class Fiscalyear
var $rowid;
var $label;
- var $datestart;
- var $dateend;
+ var $date_start;
+ var $date_end;
var $statut; // 0=open, 1=closed
var $entity;
@@ -71,24 +71,30 @@ class Fiscalyear
global $conf;
$error = 0;
+
+ $now=dol_now();
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_fiscalyear (";
$sql.= "label";
- $sql.= ", datestart";
- $sql.= ", dateend";
+ $sql.= ", date_start";
+ $sql.= ", date_end";
$sql.= ", statut";
$sql.= ", entity";
+ $sql.= ", datec";
+ $sql.= ", fk_user_author";
$sql.= ") VALUES (";
- $sql.= " '".$this->label;
- $sql.= "', ".$this->db->idate($this->datestart);
- $sql.= ", ".$this->db->idate($this->dateend);
+ $sql.= " '".$this->label."'";
+ $sql.= ", '".$this->db->idate($this->date_start)."'";
+ $sql.= ", '".$this->db->idate($this->date_end)."'";
$sql.= ", ".$this->statut;
$sql.= ", ".$conf->entity;
+ $sql.= ", '".$this->db->idate($now)."'";
+ $sql.= ", ". $user->id;
$sql.= ")";
- dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
+ dol_syslog(get_class($this)."::create", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
@@ -117,7 +123,7 @@ class Fiscalyear
return $this->rowid;
}
- dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
+ dol_syslog(get_class($this)."::create=", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
@@ -155,7 +161,7 @@ class Fiscalyear
global $langs;
// Check parameters
- if (empty($this->datestart) && empty($this->dateend))
+ if (empty($this->date_start) && empty($this->date_end))
{
$this->error='ErrorBadParameter';
return -1;
@@ -164,13 +170,15 @@ class Fiscalyear
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_fiscalyear ";
- $sql .= " SET label = ".$this->label;
- $sql .= " , datestart = '".$this->db->idate($this->datestart)."'";
- $sql .= " , dateend = '".$this->db->idate($this->dateend)."'";
- $sql .= " , statut = '".$this->statut."'";
+ $sql .= " SET label = '".$this->label."'";
+ $sql .= ", date_start = '".$this->db->idate($this->date_start)."'";
+ $sql .= ", date_end = '".$this->db->idate($this->date_end)."'";
+ $sql .= ", statut = '".$this->statut."'";
+ $sql .= ", datec = " . ($this->datec != '' ? $this->db->idate($this->datec) : 'null');
+ $sql .= ", fk_user_modif = " . $user->id;
$sql .= " WHERE rowid = ".$this->id;
- dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
+ dol_syslog(get_class($this)."::update", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
@@ -193,11 +201,11 @@ class Fiscalyear
*/
function fetch($id)
{
- $sql = "SELECT rowid, label, datestart, dateend, statut";
+ $sql = "SELECT rowid, label, date_start, date_end, statut";
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear";
$sql.= " WHERE rowid = ".$id;
- dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
+ dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$result = $this->db->query($sql);
if ( $result )
{
@@ -205,8 +213,8 @@ class Fiscalyear
$this->id = $obj->rowid;
$this->ref = $obj->rowid;
- $this->datestart = $this->db->jdate($obj->datestart);
- $this->dateend = $this->db->jdate($obj->dateend);
+ $this->date_start = $this->db->jdate($obj->date_start);
+ $this->date_end = $this->db->jdate($obj->date_end);
$this->label = $obj->label;
$this->statut = $obj->statut;
@@ -231,7 +239,7 @@ class Fiscalyear
$sql = "DELETE FROM ".MAIN_DB_PREFIX."accounting_fiscalyear WHERE rowid = ".$id;
- dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG);
+ dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
@@ -297,5 +305,50 @@ class Fiscalyear
if ($statut==1 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut8');
}
}
+
+ /**
+ * Information on record
+ *
+ * @param int $id Id of record
+ * @return void
+ */
+ function info($id)
+ {
+ $sql = 'SELECT fy.rowid, fy.datec, fy.fk_user_author, fy.fk_user_modif,';
+ $sql.= ' fy.tms';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'accounting_fiscalyear as fy';
+ $sql.= ' WHERE fy.rowid = '.$id;
+
+ dol_syslog(get_class($this)."::fetch info", LOG_DEBUG);
+ $result = $this->db->query($sql);
+
+ if ($result)
+ {
+ if ($this->db->num_rows($result))
+ {
+ $obj = $this->db->fetch_object($result);
+ $this->id = $obj->rowid;
+ if ($obj->fk_user_author)
+ {
+ $cuser = new User($this->db);
+ $cuser->fetch($obj->fk_user_author);
+ $this->user_creation = $cuser;
+ }
+ if ($obj->fk_user_modif)
+ {
+ $muser = new User($this->db);
+ $muser->fetch($obj->fk_user_modif);
+ $this->user_modification = $muser;
+ }
+ $this->date_creation = $this->db->jdate($obj->datec);
+ $this->date_modification = $this->db->jdate($obj->tms);
+ }
+ $this->db->free($result);
+ }
+ else
+ {
+ dol_print_error($this->db);
+ }
+ }
}
\ No newline at end of file
diff --git a/htdocs/core/lib/fiscalyear.lib.php b/htdocs/core/lib/fiscalyear.lib.php
index 6865c875efa..60b2c810294 100644
--- a/htdocs/core/lib/fiscalyear.lib.php
+++ b/htdocs/core/lib/fiscalyear.lib.php
@@ -44,6 +44,11 @@ function fiscalyear_prepare_head($object)
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'fiscalyear');
+
+ $head[$h][0] = DOL_URL_ROOT . '/admin/fiscalyear_info.php?id=' . $object->id;
+ $head[$h][1] = $langs->trans("Info");
+ $head[$h][2] = 'info';
+ $h++;
complete_head_from_modules($conf,$langs,$object,$head,$h,'fiscalyear','remove');
diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql
index f5757a39754..e1c5285f603 100644
--- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql
+++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql
@@ -58,3 +58,19 @@ ALTER TABLE llx_c_tva MODIFY COLUMN localtax2 varchar(10);
ALTER TABLE llx_localtax ADD COLUMN localtaxtype tinyint(4) after entity;
ALTER TABLE llx_societe ADD COLUMN localtax1_value double(6,3) after localtax1_assuj;
ALTER TABLE llx_societe ADD COLUMN localtax2_value double(6,3) after localtax2_assuj;
+
+-- Fiscal years
+create table llx_accounting_fiscalyear
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ label varchar(128) NOT NULL,
+ date_start date,
+ date_end date,
+ statut tinyint DEFAULT 0 NOT NULL,
+ entity integer DEFAULT 1 NOT NULL, -- multi company id
+ datec datetime NOT NULL,
+ tms timestamp NULL,
+ fk_user_author integer NULL,
+ fk_user_modif integer NULL
+)ENGINE=innodb;
+
diff --git a/htdocs/install/mysql/tables/llx_accounting_fiscalyear.sql b/htdocs/install/mysql/tables/llx_accounting_fiscalyear.sql
index fe8563d7250..eba284e4002 100644
--- a/htdocs/install/mysql/tables/llx_accounting_fiscalyear.sql
+++ b/htdocs/install/mysql/tables/llx_accounting_fiscalyear.sql
@@ -18,10 +18,14 @@
create table llx_accounting_fiscalyear
(
- rowid integer AUTO_INCREMENT PRIMARY KEY,
- label varchar(128) NOT NULL,
- datestart date,
- dateend date,
- statut tinyint DEFAULT 0 NOT NULL,
- entity integer DEFAULT 1 NOT NULL -- multi company id
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ label varchar(128) NOT NULL,
+ date_start date,
+ date_end date,
+ statut tinyint DEFAULT 0 NOT NULL,
+ entity integer DEFAULT 1 NOT NULL, -- multi company id
+ datec datetime NOT NULL,
+ tms timestamp DEFAULT NULL,
+ fk_user_author integer DEFAULT NULL,
+ fk_user_modif integer DEFAULT NULL
)ENGINE=innodb;
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index a10074e0f04..a4ba3d464ab 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -1514,9 +1514,15 @@ TaskModelModule=Tasks reports document model
ECMSetup = GED Setup
ECMAutoTree = Automatic tree folder and document
##### Fiscal Year #####
-Fiscalyear=Fiscal years
+FiscalYears=Fiscal years
+FiscalYear=Fiscal year
+FiscalYearCard=Fiscal year card
+NewFiscalYear=New fiscal year
+EditFiscalYear=Edit fiscal year
OpenFiscalYear=Open fiscal year
CloseFiscalYear=Close fiscal year
+DeleteFiscalYear=Delete fiscal year
+ConfirmDeleteFiscalYear=Are you sure to delete this fiscal year ?
Opened=Opened
Closed=Closed