Gestion des erreurs de creation

This commit is contained in:
Rodolphe Quiedeville 2004-12-03 13:16:31 +00:00
parent f1927e5df8
commit 064f71b877

View File

@ -31,7 +31,7 @@ class LigneTel {
global $config; global $config;
$this->db = $DB; $this->db = $DB;
$this->error_message = '';
$this->statuts[-1] = "En attente"; $this->statuts[-1] = "En attente";
$this->statuts[1] = "A commander"; $this->statuts[1] = "A commander";
$this->statuts[2] = "Commandée chez le fournisseur"; $this->statuts[2] = "Commandée chez le fournisseur";
@ -104,7 +104,8 @@ class LigneTel {
*/ */
function create($user) function create($user)
{ {
if (strlen(trim($this->numero)) == 10)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_societe_ligne"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_societe_ligne";
$sql .= " (fk_soc, fk_client_comm, ligne, fk_soc_facture, fk_fournisseur, note, remise, fk_commercial, statut, fk_user_creat, fk_concurrent)"; $sql .= " (fk_soc, fk_client_comm, ligne, fk_soc_facture, fk_fournisseur, note, remise, fk_commercial, statut, fk_user_creat, fk_concurrent)";
$sql .= " VALUES ("; $sql .= " VALUES (";
@ -113,12 +114,30 @@ class LigneTel {
if ( $this->db->query($sql) ) if ( $this->db->query($sql) )
{ {
$this->id = $this->db->last_insert_id(); $this->id = $this->db->last_insert_id();
return 1; return 0;
} }
else else
{ {
print $this->db->error(); $lex = new LigneTel($this->db);
return 0; if ($lex->fetch($this->numero) == 1)
{
$this->error_message = "Echec de la création de la ligne, cette ligne existe déjà !";
dolibarr_syslog("LigneTel::Create Error -3");
return -3;
}
else
{
$this->error_message = "Echec de la création de la ligne";
dolibarr_syslog("LigneTel::Create Error -1");
return -1;
}
}
}
else
{
$this->error_message = "Echec de la création de la ligne, le numéro de la ligne est incorrect !";
dolibarr_syslog("LigneTel::Create Error -2");
return -2;
} }
} }
/* /*