Merge pull request #2926 from hregis/develop_origin

Fix: possibility to shared facnumber between entities
This commit is contained in:
Laurent Destailleur 2015-05-29 17:16:02 +02:00
commit 58dbfd38a9
3 changed files with 13 additions and 12 deletions

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2007-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2009 Regis Houssin <regis.houssin@capnetworks.com>
/* Copyright (C) 2007-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2015 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
@ -58,6 +58,7 @@ function check_user_password_dolibarr($usertotest,$passwordtotest,$entitytotest=
$sql.=' WHERE ('.$usernamecol1." = '".$db->escape($usertotest)."'";
if (preg_match('/@/',$usertotest)) $sql.=' OR '.$usernamecol2." = '".$db->escape($usertotest)."'";
$sql.=') AND '.$entitycol." IN (0," . ($entity ? $entity : 1) . ")";
$sql.=' AND statut = 1';
$resql=$db->query($sql);
if ($resql)

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
@ -127,10 +127,10 @@ class mod_facture_mars extends ModeleNumRefFactures
*/
function getNextValue($objsoc,$facture,$mode='next')
{
global $db,$conf;
global $db;
$prefix=$this->prefixinvoice;
if ($facture->type == 1) $prefix=$this->prefixreplacement;
else if ($facture->type == 2) $prefix=$this->prefixcreditnote;
else if ($facture->type == 3) $prefix=$this->prefixdeposit;
@ -141,7 +141,7 @@ class mod_facture_mars extends ModeleNumRefFactures
$sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$prefix."____-%'";
$sql.= " AND entity = ".$conf->entity;
$sql.= " AND entity IN (".getEntity('facture', 1).")";
$resql=$db->query($sql);
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
@ -165,7 +165,7 @@ class mod_facture_mars extends ModeleNumRefFactures
$sql = "SELECT facnumber as ref";
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'";
$sql.= " AND entity = ".$conf->entity;
$sql.= " AND entity IN (".getEntity('facture', 1).")";
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
$resql=$db->query($sql);

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.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
@ -111,7 +111,7 @@ class mod_facture_terre extends ModeleNumRefFactures
$this->error=$langs->trans('ErrorNumRefModel',$max);
return false;
}
// Check deposit num
$fayymm='';
@ -146,7 +146,7 @@ class mod_facture_terre extends ModeleNumRefFactures
*/
function getNextValue($objsoc,$facture,$mode='next')
{
global $db,$conf;
global $db;
if ($facture->type == 2) $prefix=$this->prefixcreditnote;
else if ($facture->type == 3) $prefix=$this->prefixdeposit;
@ -157,7 +157,7 @@ class mod_facture_terre extends ModeleNumRefFactures
$sql = "SELECT MAX(CAST(SUBSTRING(facnumber FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$prefix."____-%'";
$sql.= " AND entity = ".$conf->entity;
$sql.= " AND entity IN (".getEntity('facture', 1).")";
$resql=$db->query($sql);
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
@ -181,7 +181,7 @@ class mod_facture_terre extends ModeleNumRefFactures
$sql = "SELECT facnumber as ref";
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'";
$sql.= " AND entity = ".$conf->entity;
$sql.= " AND entity IN (".getEntity('facture', 1).")";
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
$resql=$db->query($sql);