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

View File

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

View File

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