Fix: register_globals=off
Fix: Meilleure gestion erreur.
This commit is contained in:
parent
c5fa921e27
commit
8d30262717
@ -76,8 +76,15 @@ if ($_POST["action"] == 'add' or $_POST["action"] == 'update')
|
|||||||
if ($_POST["action"] == 'add')
|
if ($_POST["action"] == 'add')
|
||||||
{
|
{
|
||||||
$socid = $soc->create();
|
$socid = $soc->create();
|
||||||
|
|
||||||
|
if ($socid > 0) {
|
||||||
Header("Location: soc.php?socid=$socid");
|
Header("Location: soc.php?socid=$socid");
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$mesg="Erreur, cette société existe déjà";
|
||||||
|
$_GET["actions"]='create';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -99,7 +106,10 @@ if ($_GET["action"] == 'create')
|
|||||||
if ($_GET["type"]=='c') { $soc->client=1; }
|
if ($_GET["type"]=='c') { $soc->client=1; }
|
||||||
if ($_GET["type"]=='p') { $soc->client=2; }
|
if ($_GET["type"]=='p') { $soc->client=2; }
|
||||||
|
|
||||||
print '<div class="titre">'.$langs->trans("NewCompany").'</div><br>';
|
print_titre($langs->trans("NewCompany"));
|
||||||
|
print "<br>\n";
|
||||||
|
|
||||||
|
print $mesg;
|
||||||
print '<form action="soc.php" method="post">';
|
print '<form action="soc.php" method="post">';
|
||||||
print '<input type="hidden" name="action" value="add">';
|
print '<input type="hidden" name="action" value="add">';
|
||||||
print '<input type="hidden" name="fournisseur" value="0">';
|
print '<input type="hidden" name="fournisseur" value="0">';
|
||||||
|
|||||||
@ -70,10 +70,14 @@ class Societe {
|
|||||||
if ($this->db->query($sql) ) {
|
if ($this->db->query($sql) ) {
|
||||||
$id = $this->db->last_insert_id();
|
$id = $this->db->last_insert_id();
|
||||||
|
|
||||||
$this->update($id);
|
$result=$this->update($id);
|
||||||
|
if ($result < 0) { return $result; }
|
||||||
|
|
||||||
return $id;
|
return $id;
|
||||||
|
} else {
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
@ -102,7 +106,6 @@ class Societe {
|
|||||||
* TODO simpliste pour l'instant mais remplit 95% des cas
|
* TODO simpliste pour l'instant mais remplit 95% des cas
|
||||||
* à améliorer
|
* à améliorer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($this->departement_id == -1 && $this->pays_id == 1)
|
if ($this->departement_id == -1 && $this->pays_id == 1)
|
||||||
{
|
{
|
||||||
if (strlen(trim($this->cp)) == 5)
|
if (strlen(trim($this->cp)) == 5)
|
||||||
@ -139,18 +142,20 @@ class Societe {
|
|||||||
$sql .= ",client = '" . $this->client ."'";
|
$sql .= ",client = '" . $this->client ."'";
|
||||||
$sql .= ",fournisseur = '" . $this->fournisseur ."'";
|
$sql .= ",fournisseur = '" . $this->fournisseur ."'";
|
||||||
$sql .= " WHERE idp = '" . $id ."';";
|
$sql .= " WHERE idp = '" . $id ."';";
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($this->db->errno() == 1062)
|
if ($this->db->errno() == $this->db->ERROR_DUPLICATE)
|
||||||
{
|
{
|
||||||
// Doublons sur le prefix commercial
|
// Doublon
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
print $this->db->error();
|
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user