Fix: Fix corrupted data on date of trips
This commit is contained in:
parent
214c5464da
commit
9e2eccbe4c
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2009 Regis Houssin <regis@dolibarr.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -21,7 +21,7 @@
|
|||||||
/**
|
/**
|
||||||
* \file htdocs/compta/deplacement/class/deplacement.class.php
|
* \file htdocs/compta/deplacement/class/deplacement.class.php
|
||||||
* \ingroup deplacement
|
* \ingroup deplacement
|
||||||
* \brief Fichier de la classe des deplacements
|
* \brief File of class to manage trips
|
||||||
* \version $Id$
|
* \version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -42,6 +42,9 @@ class Deplacement extends CommonObject
|
|||||||
var $ismultientitymanaged = 0; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
var $ismultientitymanaged = 0; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||||
|
|
||||||
var $id;
|
var $id;
|
||||||
|
|
||||||
|
var $datec; // Creation date
|
||||||
|
var $dated;
|
||||||
var $fk_user_author;
|
var $fk_user_author;
|
||||||
var $fk_user;
|
var $fk_user;
|
||||||
var $km;
|
var $km;
|
||||||
@ -85,10 +88,13 @@ class Deplacement extends CommonObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$now=dol_now();
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."deplacement (";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."deplacement (";
|
||||||
$sql.= "datec";
|
$sql.= "datec";
|
||||||
|
//$sql.= ", dated";
|
||||||
$sql.= ", entity";
|
$sql.= ", entity";
|
||||||
$sql.= ", fk_user_author";
|
$sql.= ", fk_user_author";
|
||||||
$sql.= ", fk_user";
|
$sql.= ", fk_user";
|
||||||
@ -98,7 +104,7 @@ class Deplacement extends CommonObject
|
|||||||
$sql.= ", fk_projet";
|
$sql.= ", fk_projet";
|
||||||
$sql.= ", fk_soc";
|
$sql.= ", fk_soc";
|
||||||
$sql.= ") VALUES (";
|
$sql.= ") VALUES (";
|
||||||
$sql.= $this->db->idate(mktime());
|
$sql.= " '".$this->db->idate($now)."'";
|
||||||
$sql.= ", ".$conf->entity;
|
$sql.= ", ".$conf->entity;
|
||||||
$sql.= ", ".$user->id;
|
$sql.= ", ".$user->id;
|
||||||
$sql.= ", ".$this->fk_user;
|
$sql.= ", ".$this->fk_user;
|
||||||
@ -147,6 +153,11 @@ class Deplacement extends CommonObject
|
|||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
if (! is_numeric($this->km)) $this->km = 0;
|
if (! is_numeric($this->km)) $this->km = 0;
|
||||||
|
if (empty($this->date))
|
||||||
|
{
|
||||||
|
$this->error='ErrorBadParameter';
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (empty($this->type) || $this->type < 0)
|
if (empty($this->type) || $this->type < 0)
|
||||||
{
|
{
|
||||||
$this->error='ErrorBadParameter';
|
$this->error='ErrorBadParameter';
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -69,18 +69,23 @@ if ($_POST["action"] == 'add' && $user->rights->deplacement->creer)
|
|||||||
{
|
{
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
$deplacement = new Deplacement($db);
|
$dated=dol_mktime(12, 0, 0,
|
||||||
|
|
||||||
$deplacement->date = dol_mktime(12, 0, 0,
|
|
||||||
$_POST["remonth"],
|
$_POST["remonth"],
|
||||||
$_POST["reday"],
|
$_POST["reday"],
|
||||||
$_POST["reyear"]);
|
$_POST["reyear"]);
|
||||||
|
|
||||||
|
$deplacement = new Deplacement($db);
|
||||||
|
$deplacement->date = $dated;
|
||||||
$deplacement->km = $_POST["km"];
|
$deplacement->km = $_POST["km"];
|
||||||
$deplacement->type = $_POST["type"];
|
$deplacement->type = $_POST["type"];
|
||||||
$deplacement->socid = $_POST["socid"];
|
$deplacement->socid = $_POST["socid"];
|
||||||
$deplacement->fk_user = $_POST["fk_user"];
|
$deplacement->fk_user = $_POST["fk_user"];
|
||||||
|
|
||||||
|
if (! $deplacement->date)
|
||||||
|
{
|
||||||
|
$mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date"));
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
if ($deplacement->type == '-1') // Otherwise it is TF_LUNCH,...
|
if ($deplacement->type == '-1') // Otherwise it is TF_LUNCH,...
|
||||||
{
|
{
|
||||||
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'</div>';
|
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'</div>';
|
||||||
@ -179,7 +184,7 @@ if ($_GET["action"] == 'create')
|
|||||||
{
|
{
|
||||||
print_fiche_titre($langs->trans("NewTrip"));
|
print_fiche_titre($langs->trans("NewTrip"));
|
||||||
|
|
||||||
if ($mesg) print $mesg."<br>";
|
if ($mesg) dol_htmloutput_errors($mesg);
|
||||||
|
|
||||||
$datec = dol_mktime(12, 0, 0,
|
$datec = dol_mktime(12, 0, 0,
|
||||||
$_POST["remonth"],
|
$_POST["remonth"],
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (c) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (c) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -66,6 +66,7 @@ $stats = new DeplacementStats($db, $socid);
|
|||||||
|
|
||||||
// Build graphic number of object
|
// Build graphic number of object
|
||||||
// $data = array(array('Lib',val1,val2,val3),...)
|
// $data = array(array('Lib',val1,val2,val3),...)
|
||||||
|
//print "$endyear, $startyear";
|
||||||
$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
|
$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
|
||||||
//var_dump($data);
|
//var_dump($data);
|
||||||
|
|
||||||
|
|||||||
@ -39,13 +39,14 @@ class Stats
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return nb of entity by month for several years
|
* Return nb of entity by month for several years
|
||||||
*
|
|
||||||
* @param endyear Start year
|
* @param endyear Start year
|
||||||
* @param startyear End year
|
* @param startyear End year
|
||||||
* @return array Array of values
|
* @return array Array of values
|
||||||
*/
|
*/
|
||||||
function getNbByMonthWithPrevYear($endyear,$startyear)
|
function getNbByMonthWithPrevYear($endyear,$startyear)
|
||||||
{
|
{
|
||||||
|
if ($startyear > $endyear) return -1;
|
||||||
|
|
||||||
$datay=array();
|
$datay=array();
|
||||||
|
|
||||||
$year=$startyear;
|
$year=$startyear;
|
||||||
@ -81,6 +82,8 @@ class Stats
|
|||||||
*/
|
*/
|
||||||
function getAmountByMonthWithPrevYear($endyear,$startyear)
|
function getAmountByMonthWithPrevYear($endyear,$startyear)
|
||||||
{
|
{
|
||||||
|
if ($startyear > $endyear) return -1;
|
||||||
|
|
||||||
$datay=array();
|
$datay=array();
|
||||||
|
|
||||||
$year=$startyear;
|
$year=$startyear;
|
||||||
@ -108,9 +111,9 @@ class Stats
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Return nb of elements by year
|
* Return nb of elements by year
|
||||||
* \param sql SQL request
|
* @param sql SQL request
|
||||||
* \return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _getNbByYear($sql)
|
function _getNbByYear($sql)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -10,6 +10,9 @@
|
|||||||
-- To change type of field: ALTER TABLE llx_table MODIFY name varchar(60);
|
-- To change type of field: ALTER TABLE llx_table MODIFY name varchar(60);
|
||||||
--
|
--
|
||||||
|
|
||||||
|
-- Fix correupted data
|
||||||
|
update llx_deplacement set dated='2010-01-01' where dated < '2000-01-01';
|
||||||
|
|
||||||
RENAME TABLE llx_c_methode_commande_fournisseur TO llx_c_input_method;
|
RENAME TABLE llx_c_methode_commande_fournisseur TO llx_c_input_method;
|
||||||
|
|
||||||
ALTER TABLE llx_adherent MODIFY login varchar(50);
|
ALTER TABLE llx_adherent MODIFY login varchar(50);
|
||||||
@ -122,7 +125,7 @@ ALTER TABLE llx_expedition ADD COLUMN ref_int varchar(30) AFTER ref_ext;
|
|||||||
ALTER TABLE llx_livraison ADD COLUMN ref_ext varchar(30) AFTER fk_soc;
|
ALTER TABLE llx_livraison ADD COLUMN ref_ext varchar(30) AFTER fk_soc;
|
||||||
ALTER TABLE llx_livraison ADD COLUMN ref_int varchar(30) AFTER ref_ext;
|
ALTER TABLE llx_livraison ADD COLUMN ref_int varchar(30) AFTER ref_ext;
|
||||||
|
|
||||||
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,active) VALUES (4,'LETTREMAX','Lettre max','Courrier suivi et lettre max',0);
|
INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,active) VALUES (4,'LETTREMAX','Lettre Max','Courrier Suivi et Lettre Max',0);
|
||||||
|
|
||||||
--Add Chile data (id pays=67)
|
--Add Chile data (id pays=67)
|
||||||
-- Regions Chile
|
-- Regions Chile
|
||||||
|
|||||||
@ -20,3 +20,5 @@ delete from llx_facture where facnumber = '';
|
|||||||
delete from llx_commande where ref = '';
|
delete from llx_commande where ref = '';
|
||||||
-- V4.1 delete from llx_propaldet where fk_propal in (select rowid from llx_propal where ref = '');
|
-- V4.1 delete from llx_propaldet where fk_propal in (select rowid from llx_propal where ref = '');
|
||||||
delete from llx_propal where ref = '';
|
delete from llx_propal where ref = '';
|
||||||
|
|
||||||
|
update llx_deplacement set dated='2010-01-01' where dated < '2000-01-01';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user