Skip to content
Snippets Groups Projects
Commit 8d302627 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix: register_globals=off

Fix: Meilleure gestion erreur.
parent c5fa921e
No related branches found
No related tags found
No related merge requests found
......@@ -76,7 +76,14 @@ if ($_POST["action"] == 'add' or $_POST["action"] == 'update')
if ($_POST["action"] == 'add')
{
$socid = $soc->create();
Header("Location: soc.php?socid=$socid");
if ($socid > 0) {
Header("Location: soc.php?socid=$socid");
}
else {
$mesg="Erreur, cette socit existe dj";
$_GET["actions"]='create';
}
}
}
......@@ -99,7 +106,10 @@ if ($_GET["action"] == 'create')
if ($_GET["type"]=='c') { $soc->client=1; }
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 '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="fournisseur" value="0">';
......
......@@ -70,10 +70,14 @@ class Societe {
if ($this->db->query($sql) ) {
$id = $this->db->last_insert_id();
$this->update($id);
$result=$this->update($id);
if ($result < 0) { return $result; }
return $id;
}
} else {
dolibarr_print_error($this->db);
}
}
/*
*
......@@ -102,7 +106,6 @@ class Societe {
* TODO simpliste pour l'instant mais remplit 95% des cas
* amliorer
*/
if ($this->departement_id == -1 && $this->pays_id == 1)
{
if (strlen(trim($this->cp)) == 5)
......@@ -139,18 +142,20 @@ class Societe {
$sql .= ",client = '" . $this->client ."'";
$sql .= ",fournisseur = '" . $this->fournisseur ."'";
$sql .= " WHERE idp = '" . $id ."';";
if ($this->db->query($sql))
{
return 0;
return 0;
}
else
{
if ($this->db->errno() == 1062)
{
// Doublons sur le prefix commercial
return -1;
}
print $this->db->error();
if ($this->db->errno() == $this->db->ERROR_DUPLICATE)
{
// Doublon
return -1;
}
dolibarr_print_error($this->db);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment