task #10500: Option to choose if professionnal id are unique.
This commit is contained in:
parent
f2277c6a3a
commit
b5d1b3ee46
@ -83,4 +83,5 @@ ErrorBadMaskFailedToLocatePosOfSequence=Error, sense número de seqüència en l
|
|||||||
ErrorBadMaskBadRazMonth=Error, valor de tornada a 0 incorrecte
|
ErrorBadMaskBadRazMonth=Error, valor de tornada a 0 incorrecte
|
||||||
ErrorSelectAtLeastOne=Error. Seleccioneu com a mínim una entrada.
|
ErrorSelectAtLeastOne=Error. Seleccioneu com a mínim una entrada.
|
||||||
ErrorProductWithRefNotExist=La referència de producte '<i>%s</i>' no existeix
|
ErrorProductWithRefNotExist=La referència de producte '<i>%s</i>' no existeix
|
||||||
ErrorDeleteNotPossibleLineIsConsolidated=Eliminació impossible ja que el registre està enllaçat a una transacció bancària conciliada
|
ErrorDeleteNotPossibleLineIsConsolidated=Eliminació impossible ja que el registre està enllaçat a una transacció bancària conciliada
|
||||||
|
ErrorProdIdAlreadyExist=%s es troba assignat a altre tercer
|
||||||
@ -82,4 +82,5 @@ ErrorBadMaskFailedToLocatePosOfSequence=Error, mask without sequence number
|
|||||||
ErrorBadMaskBadRazMonth=Error, bad reset value
|
ErrorBadMaskBadRazMonth=Error, bad reset value
|
||||||
ErrorSelectAtLeastOne=Error. Select at least one entry.
|
ErrorSelectAtLeastOne=Error. Select at least one entry.
|
||||||
ErrorProductWithRefNotExist=Product with reference '<i>%s</i>' don't exist
|
ErrorProductWithRefNotExist=Product with reference '<i>%s</i>' don't exist
|
||||||
ErrorDeleteNotPossibleLineIsConsolidated=Delete not possible because record is linked to a bank transation that is conciliated
|
ErrorDeleteNotPossibleLineIsConsolidated=Delete not possible because record is linked to a bank transation that is conciliated
|
||||||
|
ErrorProdIdAlreadyExist=%s is assigned to another third
|
||||||
@ -83,4 +83,5 @@ ErrorBadMaskFailedToLocatePosOfSequence=Error, sin número de secuencia en la m
|
|||||||
ErrorBadMaskBadRazMonth=Error, valor de vuelta a 0 incorrecto
|
ErrorBadMaskBadRazMonth=Error, valor de vuelta a 0 incorrecto
|
||||||
ErrorSelectAtLeastOne=Error. Seleccione al menos una entrada.
|
ErrorSelectAtLeastOne=Error. Seleccione al menos una entrada.
|
||||||
ErrorProductWithRefNotExist=La referencia de producto '<i>%s</i>' no existe
|
ErrorProductWithRefNotExist=La referencia de producto '<i>%s</i>' no existe
|
||||||
ErrorDeleteNotPossibleLineIsConsolidated=Eliminación imposible ya que el registro está enlazado a una transacción bancaria conciliada
|
ErrorDeleteNotPossibleLineIsConsolidated=Eliminación imposible ya que el registro está enlazado a una transacción bancaria conciliada
|
||||||
|
ErrorProdIdAlreadyExist=%s se encuentra asignado a otro tercero
|
||||||
@ -83,4 +83,5 @@ ErrorBadMaskFailedToLocatePosOfSequence=Erreur, masque sans numéro de séquence
|
|||||||
ErrorBadMaskBadRazMonth=Erreur, mauvais valeur de remise à zéro
|
ErrorBadMaskBadRazMonth=Erreur, mauvais valeur de remise à zéro
|
||||||
ErrorSelectAtLeastOne=Erreur. Sélectionnez au moins une entrée.
|
ErrorSelectAtLeastOne=Erreur. Sélectionnez au moins une entrée.
|
||||||
ErrorProductWithRefNotExist=La référence produit '<i>%s</i>' n'existe pas
|
ErrorProductWithRefNotExist=La référence produit '<i>%s</i>' n'existe pas
|
||||||
ErrorDeleteNotPossibleLineIsConsolidated=Suppression impossible car l'enregistrement porte sur au moins une transaction bancaire rapprochée
|
ErrorDeleteNotPossibleLineIsConsolidated=Suppression impossible car l'enregistrement porte sur au moins une transaction bancaire rapprochée
|
||||||
|
ErrorProdIdAlreadyExist=%s est attribué à un autre tiers
|
||||||
@ -6,7 +6,7 @@
|
|||||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||||
* Copyright (C) 2008 Patrick Raguin <patrick.raguin@auguria.net>
|
* Copyright (C) 2008 Patrick Raguin <patrick.raguin@auguria.net>
|
||||||
* Copyright (C) 2010 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
|
||||||
* 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
|
||||||
@ -26,7 +26,7 @@
|
|||||||
* \file htdocs/societe/class/societe.class.php
|
* \file htdocs/societe/class/societe.class.php
|
||||||
* \ingroup societe
|
* \ingroup societe
|
||||||
* \brief File for third party class
|
* \brief File for third party class
|
||||||
* \version $Id: societe.class.php,v 1.96 2011/08/10 22:47:35 eldy Exp $
|
* \version $Id: societe.class.php,v 1.97 2011/08/11 16:53:43 simnandez Exp $
|
||||||
*/
|
*/
|
||||||
require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
|
||||||
|
|
||||||
@ -1958,12 +1958,88 @@ class Societe extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if a profid sould be verified
|
||||||
|
* @param idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm)
|
||||||
|
* @return boolean true , false
|
||||||
|
*/
|
||||||
|
function id_prof_verifiable($idprof)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
switch($idprof)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
$ret=(!$conf->global->SOCIETE_IDPROF1_UNIQUE?false:true);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
$ret=(!$conf->global->SOCIETE_IDPROF2_UNIQUE?false:true);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
$ret=(!$conf->global->SOCIETE_IDPROF3_UNIQUE?false:true);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
$ret=(!$conf->global->SOCIETE_IDPROF4_UNIQUE?false:true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$ret=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify if a profid exists into database for others thirds
|
||||||
|
* @param idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm)
|
||||||
|
* @param value value of profid
|
||||||
|
* @param socid id of society if update
|
||||||
|
* @return boolean true if exists, false if not
|
||||||
|
*/
|
||||||
|
function id_prof_exists($idprof,$value,$socid=0)
|
||||||
|
{
|
||||||
|
switch($idprof)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
$field="siren";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
$field="siret";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
$field="ape";
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
$field="idprof4";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Verify duplicate entries
|
||||||
|
$sql = "SELECT COUNT(*) as idprof FROM ".MAIN_DB_PREFIX."societe WHERE ".$field." = '".$value."'";
|
||||||
|
if($socid) $sql .= " AND rowid <> ".$socid;
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$nump = $this->db->num_rows($resql);
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
$count = $obj->idprof;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$count = 0;
|
||||||
|
print $this->db->error();
|
||||||
|
}
|
||||||
|
$this->db->free($resql);
|
||||||
|
|
||||||
|
if ($count > 0) return true;
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifie la validite d'un identifiant professionnel en fonction du pays de la societe (siren, siret, ...)
|
* Verifie la validite d'un identifiant professionnel en fonction du pays de la societe (siren, siret, ...)
|
||||||
* @param idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm)
|
* @param idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm)
|
||||||
* @param soc Objet societe
|
* @param soc Objet societe
|
||||||
* @return int <=0 if KO, >0 if OK
|
* @return int <=0 if KO, >0 if OK, -10=idprofx already exist into database
|
||||||
* TODO not in business class
|
* TODO not in business class
|
||||||
*/
|
*/
|
||||||
function id_prof_check($idprof,$soc)
|
function id_prof_check($idprof,$soc)
|
||||||
@ -1973,7 +2049,7 @@ class Societe extends CommonObject
|
|||||||
$ok=1;
|
$ok=1;
|
||||||
|
|
||||||
if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) return 1;
|
if (! empty($conf->global->MAIN_DISABLEPROFIDRULES)) return 1;
|
||||||
|
|
||||||
// Verifie SIREN si pays FR
|
// Verifie SIREN si pays FR
|
||||||
if ($idprof == 1 && $soc->pays_code == 'FR')
|
if ($idprof == 1 && $soc->pays_code == 'FR')
|
||||||
{
|
{
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
* \file htdocs/societe/soc.php
|
* \file htdocs/societe/soc.php
|
||||||
* \ingroup societe
|
* \ingroup societe
|
||||||
* \brief Third party card page
|
* \brief Third party card page
|
||||||
* \version $Id: soc.php,v 1.132 2011/08/10 22:47:35 eldy Exp $
|
* \version $Id: soc.php,v 1.133 2011/08/11 16:53:43 simnandez Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("../main.inc.php");
|
require("../main.inc.php");
|
||||||
@ -133,7 +133,7 @@ if (empty($reshook))
|
|||||||
$object->fetch($socid);
|
$object->fetch($socid);
|
||||||
}
|
}
|
||||||
else if ($canvas) $object->canvas=$canvas;
|
else if ($canvas) $object->canvas=$canvas;
|
||||||
|
|
||||||
if (GETPOST("private") == 1)
|
if (GETPOST("private") == 1)
|
||||||
{
|
{
|
||||||
$object->particulier = GETPOST("private");
|
$object->particulier = GETPOST("private");
|
||||||
@ -230,8 +230,24 @@ if (empty($reshook))
|
|||||||
$error++; $errors[] = $langs->trans("ErrorSupplierModuleNotEnabled");
|
$error++; $errors[] = $langs->trans("ErrorSupplierModuleNotEnabled");
|
||||||
$action = ($action=='add'?'create':'edit');
|
$action = ($action=='add'?'create':'edit');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
if($action == 'add') $mode=0;
|
||||||
|
else $mode=1;
|
||||||
|
|
||||||
|
for ($i = 1; $i < 3; $i++)
|
||||||
|
{
|
||||||
|
$slabel="idprof".$i;
|
||||||
|
if (($_POST[$slabel] && $object->id_prof_verifiable($i)))
|
||||||
|
{
|
||||||
|
if($object->id_prof_exists($i,$_POST["$slabel"],$object->id))
|
||||||
|
{
|
||||||
|
$langs->load("errors");
|
||||||
|
$error++; $errors[] = $langs->transcountry('ProfId'.$i ,$object->pays_code)." ".$langs->trans("ErrorProdIdAlreadyExist",$_POST["$slabel"]);
|
||||||
|
$action = ($action=='add'?'create':'edit');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
if ($action == 'add')
|
if ($action == 'add')
|
||||||
@ -1959,5 +1975,5 @@ else
|
|||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
llxFooter('$Date: 2011/08/10 22:47:35 $ - $Revision: 1.132 $');
|
llxFooter('$Date: 2011/08/11 16:53:43 $ - $Revision: 1.133 $');
|
||||||
?>
|
?>
|
||||||
Loading…
Reference in New Issue
Block a user