Bug fix & add tab info
This commit is contained in:
parent
a2ac578712
commit
be78e96313
@ -66,7 +66,7 @@ print_fiche_titre($langs->trans('FiscalYears'));
|
||||
|
||||
dol_htmloutput_errors($mesg);
|
||||
|
||||
$sql = "SELECT f.rowid, f.label, f.datestart, f.dateend, f.statut, f.entity";
|
||||
$sql = "SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut, f.entity";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear as f";
|
||||
$sql.= " WHERE f.entity = ".$conf->entity;
|
||||
|
||||
@ -103,8 +103,8 @@ if ($result)
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td><a href="fiscalyear_card.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowFiscalYear"),"technic").' '.$obj->rowid.'</a></td>';
|
||||
print '<td align="left">'.$obj->label.'</td>';
|
||||
print '<td align="left">'.dol_print_date($db->jdate($obj->datestart),'day').'</td>';
|
||||
print '<td align="left">'.dol_print_date($db->jdate($obj->dateend),'day').'</td>';
|
||||
print '<td align="left">'.dol_print_date($db->jdate($obj->date_start),'day').'</td>';
|
||||
print '<td align="left">'.dol_print_date($db->jdate($obj->date_end),'day').'</td>';
|
||||
print '<td>'.$fiscalyearstatic->LibStatut($obj->statut,5).'</td>';
|
||||
print '</tr>';
|
||||
$var=!$var;
|
||||
|
||||
@ -79,12 +79,13 @@ else if ($action == 'add')
|
||||
|
||||
$db->begin();
|
||||
|
||||
$object->datestart = $date_start;
|
||||
$object->dateend = $date_end;
|
||||
$object->date_start = $date_start;
|
||||
$object->date_end = $date_end;
|
||||
$object->label = GETPOST('label','alpha');
|
||||
$object->statut = GETPOST('statut','int');;
|
||||
$object->statut = GETPOST('statut','int');
|
||||
$object->datec = dol_now();
|
||||
|
||||
if (empty($object->datestart) && empty($object->dateend))
|
||||
if (empty($object->date_start) && empty($object->date_end))
|
||||
{
|
||||
$mesg.=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date"));
|
||||
$error++;
|
||||
@ -129,10 +130,10 @@ else if ($action == 'update')
|
||||
{
|
||||
$result = $object->fetch($id);
|
||||
|
||||
$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');
|
||||
$object->statut = GETPOST('statut','int');
|
||||
$object->date_start = empty($_POST["fiscalyear"])?'':$date_start;
|
||||
$object->date_end = empty($_POST["fiscalyearend"])?'':$date_end;
|
||||
$object->label = GETPOST('label','alpha');
|
||||
$object->statut = GETPOST('statut','int');
|
||||
|
||||
$result = $object->update($user);
|
||||
|
||||
@ -180,19 +181,21 @@ if ($action == 'create')
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input name="label" size="32" value="' . GETPOST("label") . '"></td></tr>';
|
||||
|
||||
// Date start
|
||||
print '<tr><td>'.$langs->trans("DateStart").'</td><td>';
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("DateStart").'</td><td>';
|
||||
print $form->select_date(($date_start?$date_start:''),'fiscalyear');
|
||||
print '</td></tr>';
|
||||
|
||||
// Date end
|
||||
print '<tr><td>'.$langs->trans("DateEnd").'</td><td>';
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("DateEnd").'</td><td>';
|
||||
print $form->select_date(($date_end?$date_end:-1),'fiscalyearend');
|
||||
print '</td></tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr>';
|
||||
print '<td class="fieldrequired">'.$langs->trans("Statut").'</td><td class="valeur">'.$form->selectarray('statut',$statut2label,GETPOST('statut')).'</td>';
|
||||
print '</tr>';
|
||||
print '<td class="fieldrequired">'.$langs->trans("Statut").'</td>';
|
||||
print '<td class="valeur">';
|
||||
print $form->selectarray('statut',$statut2label,GETPOST('statut'));
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
@ -234,13 +237,18 @@ else if ($id)
|
||||
|
||||
// Date start
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("DateStart").'</td><td>';
|
||||
print $form->select_date($object->datestart,'','','','','update');
|
||||
print $form->select_date($object->date_start?$object->date_start:-1,'fiscalyear');
|
||||
print '</td></tr>';
|
||||
|
||||
// Date end
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("DateEnd").'</td><td>';
|
||||
print $form->select_date($object->dateend,'','','','','update');
|
||||
print $form->select_date($object->date_end?$object->date_end:-1,'fiscalyearend');
|
||||
print '</td></tr>';
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Statut").'</td><td>';
|
||||
print $form->selectarray('statut',$statut2label,$object->statut);
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
@ -283,16 +291,16 @@ else if ($id)
|
||||
|
||||
// Date start
|
||||
print '<tr><td>';
|
||||
print $form->editfieldkey("Date",'datestart',$object->datestart,$object,$conf->global->MAIN_EDIT_ALSO_INLINE,'datepicker');
|
||||
print $form->editfieldkey("Date",'date_start',$object->date_start,$object,$conf->global->MAIN_EDIT_ALSO_INLINE,'datepicker');
|
||||
print '</td><td colspan="2">';
|
||||
print $form->editfieldval("Date",'datestart',$object->datestart,$object,$conf->global->MAIN_EDIT_ALSO_INLINE,'datepicker');
|
||||
print $form->editfieldval("Date",'date_start',$object->date_start,$object,$conf->global->MAIN_EDIT_ALSO_INLINE,'datepicker');
|
||||
print '</td></tr>';
|
||||
|
||||
// Date end
|
||||
print '<tr><td>';
|
||||
print $form->editfieldkey("Date",'dateend',$object->dateend,$object,$conf->global->MAIN_EDIT_ALSO_INLINE,'datepicker');
|
||||
print $form->editfieldkey("Date",'date_end',$object->date_end,$object,$conf->global->MAIN_EDIT_ALSO_INLINE,'datepicker');
|
||||
print '</td><td colspan="2">';
|
||||
print $form->editfieldval("Date",'dateend',$object->dateend,$object,$conf->global->MAIN_EDIT_ALSO_INLINE,'datepicker');
|
||||
print $form->editfieldval("Date",'date_end',$object->date_end,$object,$conf->global->MAIN_EDIT_ALSO_INLINE,'datepicker');
|
||||
print '</td></tr>';
|
||||
|
||||
// Statut
|
||||
|
||||
60
htdocs/admin/fiscalyear_info.php
Normal file
60
htdocs/admin/fiscalyear_info.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/* Copyright (C) 2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
*
|
||||
* 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 '<table width="100%"><tr><td>';
|
||||
dol_print_object_info($object);
|
||||
print '</td></tr></table>';
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter();
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -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');
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user