2
0
forked from Wavyzz/dolibarr

Fix: Error message was not thrown

This commit is contained in:
Laurent Destailleur
2008-04-22 18:02:55 +00:00
parent 10b3f64e70
commit aae72bb7ac
2 changed files with 36 additions and 33 deletions

View File

@@ -23,7 +23,7 @@
/**
\file htdocs/soc.php
\ingroup societe
\brief Onglet societe d'une societe
\brief Third party card page
\version $Id$
*/
@@ -237,20 +237,21 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"])
if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' && $user->rights->societe->supprimer)
{
$soc = new Societe($db);
$soc->fetch($socid);
$result = $soc->delete($socid);
if ($result == 0)
{
Header("Location: ".DOL_URL_ROOT."/societe.php?delsoc=".$soc->nom."");
exit;
}
else
{
$reload = 0;
$_GET["action"]='';
}
$soc = new Societe($db);
$soc->fetch($socid);
$result = $soc->delete($socid);
if ($result >= 0)
{
Header("Location: ".DOL_URL_ROOT."/societe.php?delsoc=".$soc->nom."");
exit;
}
else
{
$reload = 0;
$mesg=$soc->error;
$_GET["action"]='';
}
}
@@ -961,11 +962,10 @@ else
print "<br />\n";
}
if ($soc->error)
if ($mesg)
{
print '<div class="error">';
print $soc->error;
print $mesg;
print '</div>';
}

View File

@@ -682,45 +682,48 @@ class Societe extends CommonObject
dolibarr_syslog("Societe::Delete");
$sqr = 0;
// \Todo
// Check if third party can be deleted
if ( $this->db->begin())
{
$sql = "DELETE from ".MAIN_DB_PREFIX."socpeople ";
$sql .= " WHERE fk_soc = " . $id .";";
$sql = "DELETE from ".MAIN_DB_PREFIX."socpeople";
$sql.= " WHERE fk_soc = " . $id;
if ($this->db->query($sql))
{
$sqr++;
}
else
{
$this->error .= "Impossible de supprimer les contacts.\n";
dolibarr_syslog("Societe::Delete erreur -1");
$this->error .= $this->db->lasterror();
dolibarr_syslog("Societe::Delete erreur -1 ".$this->error);
}
$sql = "DELETE from ".MAIN_DB_PREFIX."societe_rib ";
$sql .= " WHERE fk_soc = " . $id .";";
$sql = "DELETE from ".MAIN_DB_PREFIX."societe_rib";
$sql.= " WHERE fk_soc = " . $id;
if ($this->db->query($sql))
{
$sqr++;
}
else
{
$this->error .= "Impossible de supprimer le RIB.\n";
dolibarr_syslog("Societe::Delete erreur -2");
$this->error = $this->db->lasterror();
dolibarr_syslog("Societe::Delete erreur -2 ".$this->error);
}
$sql = "DELETE from ".MAIN_DB_PREFIX."societe ";
$sql .= " WHERE rowid = " . $id .";";
$sql = "DELETE from ".MAIN_DB_PREFIX."societe";
$sql.= " WHERE rowid = " . $id;
if ($this->db->query($sql))
{
$sqr++;
}
else
{
$this->error .= "Impossible de supprimer la soci<63>t<EFBFBD>.\n";
dolibarr_syslog("Societe::Delete erreur -3");
$this->error = $this->db->lasterror();
dolibarr_syslog("Societe::Delete erreur -3 ".$this->error);
}
if ($sqr == 3)