Fix: Regression. Le contact doit toujours apparaitre dans la liste des contacts car il doit pouvoir etre slectionner pour un autre type.
Fix: bug #21119 : Mettre un message d'erreur plus clair si doublon contact
This commit is contained in:
parent
e65cc0ab87
commit
51468b6c0a
@ -17,7 +17,6 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -62,9 +61,18 @@ if ($_POST["action"] == 'addcontact' && $user->rights->propale->creer)
|
||||
{
|
||||
Header("Location: contact.php?propalid=".$propal->id);
|
||||
exit;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg = '<div class="error">'.$propal->error.'</div>';
|
||||
if ($propal->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
{
|
||||
$langs->load("errors");
|
||||
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg = '<div class="error">'.$propal->error.'</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
// modification d'un contact. On enregistre le type
|
||||
@ -221,7 +229,7 @@ if ($id > 0)
|
||||
|
||||
print '<td colspan="1">';
|
||||
// On récupère les id des users déjà sélectionnés
|
||||
$userAlreadySelected = $propal->getListContactId('internal');
|
||||
//$userAlreadySelected = $propal->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type
|
||||
$html->select_users($user->id,'contactid',0,$userAlreadySelected);
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
@ -252,7 +260,7 @@ if ($id > 0)
|
||||
|
||||
print '<td colspan="1">';
|
||||
// On récupère les id des contacts déjà sélectionnés
|
||||
$contactAlreadySelected = $propal->getListContactId('external');
|
||||
//$contactAlreadySelected = $propal->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type
|
||||
$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected);
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
|
||||
@ -62,9 +62,18 @@ if ($_POST["action"] == 'addcontact' && $user->rights->commande->creer)
|
||||
{
|
||||
Header("Location: contact.php?id=".$commande->id);
|
||||
exit;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg = '<div class="error">'.$commande->error.'</div>';
|
||||
if ($commande->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
{
|
||||
$langs->load("errors");
|
||||
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg = '<div class="error">'.$commande->error.'</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
// modification d'un contact. On enregistre le type
|
||||
@ -233,7 +242,7 @@ if ($id > 0)
|
||||
|
||||
print '<td colspan="1">';
|
||||
// On récupère les id des users déjà sélectionnés
|
||||
$userAlreadySelected = $commande->getListContactId('internal');
|
||||
//$userAlreadySelected = $commande->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type
|
||||
$html->select_users($user->id,'contactid',0,$userAlreadySelected);
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
@ -264,7 +273,7 @@ if ($id > 0)
|
||||
|
||||
print '<td colspan="1">';
|
||||
// On récupère les id des contacts déjà sélectionnés
|
||||
$contactAlreadySelected = $commande->getListContactId('external');
|
||||
// $contactAlreadySelected = $commande->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type
|
||||
$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected);
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -101,9 +100,17 @@ class CommonObject
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error()." - $sql";
|
||||
dolibarr_syslog($this->error,LOG_ERR);
|
||||
return -1;
|
||||
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
{
|
||||
$this->error=$this->db->errno();
|
||||
return -2;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error()." - $sql";
|
||||
dolibarr_syslog($this->error,LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,8 +177,8 @@ class CommonObject
|
||||
if ($source == 'external') $sql.=" t.fk_soc as socid,";
|
||||
$sql.=" t.name as nom,";
|
||||
$sql.= "tc.source, tc.element, tc.code, tc.libelle";
|
||||
$sql.= " FROM (".MAIN_DB_PREFIX."element_contact ec,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."c_type_contact tc)";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact tc,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."element_contact ec";
|
||||
if ($source == 'internal') $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."user t on ec.fk_socpeople = t.rowid";
|
||||
if ($source == 'external') $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."socpeople t on ec.fk_socpeople = t.rowid";
|
||||
$sql.= " WHERE ec.element_id =".$this->id;
|
||||
@ -286,7 +293,7 @@ class CommonObject
|
||||
* Exemple: contact client de livraison ('external', 'SHIPPING')
|
||||
* Exemple: contact interne suivi paiement ('internal', 'SALESREPFOLL')
|
||||
* \param source 'external' or 'internal'
|
||||
* \param source 'BILLING', 'SHIPPING', 'SALESREPFOLL', ...
|
||||
* \param code 'BILLING', 'SHIPPING', 'SALESREPFOLL', ...
|
||||
* \return array Liste des id contacts
|
||||
*/
|
||||
function getIdContact($source,$code)
|
||||
|
||||
@ -60,9 +60,18 @@ if ($_POST["action"] == 'addcontact' && $user->rights->facture->creer)
|
||||
{
|
||||
Header("Location: contact.php?facid=".$facture->id);
|
||||
exit;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg = '<div class="error">'.$facture->error.'</div>';
|
||||
if ($facture->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
{
|
||||
$langs->load("errors");
|
||||
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg = '<div class="error">'.$facture->error.'</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
// modification d'un contact. On enregistre le type
|
||||
@ -213,7 +222,7 @@ if ($id > 0)
|
||||
|
||||
print '<td colspan="1">';
|
||||
// On récupère les id des users déjà sélectionnés
|
||||
$userAlreadySelected = $facture->getListContactId('internal');
|
||||
//$userAlreadySelected = $facture->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type
|
||||
$html->select_users($user->id,'contactid',0,$userAlreadySelected);
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
@ -244,7 +253,7 @@ if ($id > 0)
|
||||
|
||||
print '<td colspan="1">';
|
||||
// On récupère les id des contacts déjà sélectionnés
|
||||
$contactAlreadySelected = $facture->getListContactId('external');
|
||||
//$contactAlreadySelected = $facture->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type
|
||||
$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected);
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
|
||||
@ -60,9 +60,18 @@ if ($_POST["action"] == 'addcontact' && $user->rights->contrat->creer)
|
||||
{
|
||||
Header("Location: contact.php?id=".$contrat->id);
|
||||
exit;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg = '<div class="error">'.$contrat->error.'</div>';
|
||||
if ($contrat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
{
|
||||
$langs->load("errors");
|
||||
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg = '<div class="error">'.$contrat->error.'</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
// modification d'un contact. On enregistre le type
|
||||
@ -234,7 +243,7 @@ if ($id > 0)
|
||||
|
||||
print '<td colspan="1">';
|
||||
// On récupère les id des users déjà sélectionnés
|
||||
$userAlreadySelected = $contrat->getListContactId('internal');
|
||||
//$userAlreadySelected = $contrat->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type
|
||||
$html->select_users($user->id,'contactid',0,$userAlreadySelected);
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
@ -265,7 +274,7 @@ if ($id > 0)
|
||||
|
||||
print '<td colspan="1">';
|
||||
// On récupère les id des contacts déjà sélectionnés
|
||||
$contactAlreadySelected = $contrat->getListContactId('external');
|
||||
//$contactAlreadySelected = $contrat->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type
|
||||
$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected);
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
|
||||
@ -62,7 +62,15 @@ if ($_POST["action"] == 'addcontact' && $user->rights->ficheinter->creer)
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg = '<div class="error">'.$fichinter->error.'</div>';
|
||||
if ($fichinter->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
|
||||
{
|
||||
$langs->load("errors");
|
||||
$mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg = '<div class="error">'.$fichinter->error.'</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
// modification d'un contact. On enregistre le type
|
||||
@ -219,7 +227,7 @@ if ($id > 0)
|
||||
|
||||
print '<td colspan="1">';
|
||||
// On récupère les id des users déjà sélectionnés
|
||||
$userAlreadySelected = $fichinter->getListContactId('internal');
|
||||
//$userAlreadySelected = $fichinter->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type
|
||||
$html->select_users($user->id,'contactid',0,$userAlreadySelected);
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
@ -250,7 +258,7 @@ if ($id > 0)
|
||||
|
||||
print '<td colspan="1">';
|
||||
// On récupère les id des contacts déjà sélectionnés
|
||||
$contactAlreadySelected = $fichinter->getListContactId('external');
|
||||
//$contactAlreadySelected = $fichinter->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type
|
||||
$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected);
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
|
||||
@ -862,47 +862,47 @@ class Form
|
||||
*/
|
||||
function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude='')
|
||||
{
|
||||
// Permettre l'exclusion d'utilisateurs
|
||||
if (is_array($exclude))
|
||||
{
|
||||
$excludeUsers = implode("','",$exclude);
|
||||
}
|
||||
|
||||
// On recherche les utilisateurs
|
||||
$sql = "SELECT u.rowid, u.name, u.firstname FROM ";
|
||||
$sql.= MAIN_DB_PREFIX ."user as u";
|
||||
if (is_array($exclude) && $excludeUsers) $sql.= " WHERE u.rowid NOT IN ('".$excludeUsers."')";
|
||||
$sql.= " ORDER BY u.name ASC";
|
||||
// Permettre l'exclusion d'utilisateurs
|
||||
if (is_array($exclude))
|
||||
{
|
||||
$excludeUsers = implode("','",$exclude);
|
||||
}
|
||||
|
||||
// On recherche les utilisateurs
|
||||
$sql = "SELECT u.rowid, u.name, u.firstname FROM ";
|
||||
$sql.= MAIN_DB_PREFIX ."user as u";
|
||||
if (is_array($exclude) && $excludeUsers) $sql.= " WHERE u.rowid NOT IN ('".$excludeUsers."')";
|
||||
$sql.= " ORDER BY u.name ASC";
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
print '<select class="flat" name="'.$htmlname.'">';
|
||||
if ($show_empty) print '<option value="-1"'.($id==-1?' selected="true"':'').'> </option>'."\n";
|
||||
$num = $this->db->num_rows();
|
||||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object();
|
||||
|
||||
if ($selected && $selected == $obj->rowid)
|
||||
{
|
||||
print '<option value="'.$obj->rowid.'" selected="true">'.$obj->name.' '.$obj->firstname.'</option>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<option value="'.$obj->rowid.'">'.$obj->name.' '.$obj->firstname.'</option>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
print '</select>';
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
}
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
print '<select class="flat" name="'.$htmlname.'">';
|
||||
if ($show_empty) print '<option value="-1"'.($id==-1?' selected="true"':'').'> </option>'."\n";
|
||||
$num = $this->db->num_rows();
|
||||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object();
|
||||
|
||||
if ($selected && $selected == $obj->rowid)
|
||||
{
|
||||
print '<option value="'.$obj->rowid.'" selected="true">'.$obj->name.' '.$obj->firstname.'</option>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<option value="'.$obj->rowid.'">'.$obj->name.' '.$obj->firstname.'</option>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
print '</select>';
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
# Dolibarr language file - en_US - errors
|
||||
ErrorDuplicateTrigger=A trigger file named '<b>%s</b>' is already loaded. Remove duplicate trigger file in directory '<b>%s</b>'.
|
||||
ErrorFailToDeleteFile=Failed to remove file '<b>%s</b>'.
|
||||
ErrorThisContactIsAlreadyDefinedAsThisType=this contact is already defined as contact for this type.
|
||||
@ -1,3 +1,4 @@
|
||||
# Dolibarr language file - fr_FR - errors
|
||||
ErrorDuplicateTrigger=Un fichier trigger du nom de '<b>%s</b>' est deja chargé. Supprimer le doublon du répertoire '<b>%s</b>'.
|
||||
ErrorFailToDeleteFile=Echec de l'effacement du fichier '<b>%s</b>'.
|
||||
ErrorFailToDeleteFile=Echec de l'effacement du fichier '<b>%s</b>'.
|
||||
ErrorThisContactIsAlreadyDefinedAsThisType=Ce contact est déjà défini comme contact pour ce type.
|
||||
@ -21,7 +21,6 @@
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user