Merge branch '5.0' of git@github.com:Dolibarr/dolibarr.git into develop

Conflicts:
	htdocs/filefunc.inc.php
This commit is contained in:
Laurent Destailleur 2017-01-04 17:06:02 +01:00
commit e57f834434
3 changed files with 32 additions and 9 deletions

View File

@ -331,16 +331,40 @@ class ExtraFields
$table=$elementtype.'_extrafields';
$error=0;
if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname))
{
$result=$this->db->DDLDropField(MAIN_DB_PREFIX.$table,$attrname); // This also drop the unique key
$result=$this->delete_label($attrname,$elementtype);
if ($result < 0)
{
$this->error=$this->db->lasterror();
$this->error=$this->db->lasterror();
$error++;
}
$result=$this->delete_label($attrname,$elementtype);
if (! $error)
{
$sql = "SELECT COUNT(rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."extrafields";
$sql.= " WHERE elementtype = '".$elementtype."'";
$sql.= " AND name = '".$attrname."'";
//$sql.= " AND entity IN (0,".$conf->entity.")"; Do not test on entity here. We want to see if there is still on field remaning in other entities before deleting field in table
$resql = $this->db->query($sql);
if ($resql)
{
$obj = $this->db->fetch_object($resql);
if ($obj->nb <= 0)
{
$result=$this->db->DDLDropField(MAIN_DB_PREFIX.$table,$attrname); // This also drop the unique key
if ($result < 0)
{
$this->error=$this->db->lasterror();
$error++;
}
}
}
}
return $result;
}
else

View File

@ -1207,15 +1207,14 @@ class ExpenseReport extends CommonObject
$expld_car = (empty($conf->global->NDF_EXPLODE_CHAR))?"-":$conf->global->NDF_EXPLODE_CHAR;
$num_car = (empty($conf->global->NDF_NUM_CAR_REF))?"5":$conf->global->NDF_NUM_CAR_REF;
$sql = 'SELECT de.ref_number_int';
$sql = 'SELECT MAX(de.ref_number_int) as max';
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' de';
$sql.= ' ORDER BY de.ref_number_int DESC';
$result = $this->db->query($sql);
if($this->db->num_rows($result) > 0):
$objp = $this->db->fetch_object($result);
$this->ref = $objp->ref_number_int;
$this->ref = $objp->max;
$this->ref++;
while(strlen($this->ref) < $num_car):
$this->ref = "0".$this->ref;

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Xavier Dutoit <doli@sydesy.com>
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com>