Fix: task #11248 : there is no DB transaction on products->delete
Qual: Mutualize code to see of an object as child
This commit is contained in:
parent
058636e01b
commit
be5333589e
@ -571,20 +571,6 @@ class Product extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
|
||||||
{
|
|
||||||
$sqlz = "DELETE FROM ".MAIN_DB_PREFIX."product";
|
|
||||||
$sqlz.= " WHERE rowid = ".$id;
|
|
||||||
dol_syslog(get_class($this).'::delete sql='.$sql, LOG_DEBUG);
|
|
||||||
$resultz = $this->db->query($sqlz);
|
|
||||||
if ( ! $resultz )
|
|
||||||
{
|
|
||||||
$error++;
|
|
||||||
$this->error = $this->db->lasterror();
|
|
||||||
dol_syslog(get_class($this).'::delete error '.$this->error, LOG_ERR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
// Actions on extra fields (by external module or standard code)
|
// Actions on extra fields (by external module or standard code)
|
||||||
@ -606,6 +592,21 @@ class Product extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete product
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$sqlz = "DELETE FROM ".MAIN_DB_PREFIX."product";
|
||||||
|
$sqlz.= " WHERE rowid = ".$id;
|
||||||
|
dol_syslog(get_class($this).'::delete sql='.$sql, LOG_DEBUG);
|
||||||
|
$resultz = $this->db->query($sqlz);
|
||||||
|
if ( ! $resultz )
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$this->error = $this->db->lasterror();
|
||||||
|
dol_syslog(get_class($this).'::delete error '.$this->error, LOG_ERR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
|
|||||||
@ -85,6 +85,8 @@ $parameters=array('socid'=>$socid);
|
|||||||
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||||
$error=$hookmanager->error; $errors=$hookmanager->errors;
|
$error=$hookmanager->error; $errors=$hookmanager->errors;
|
||||||
|
|
||||||
|
if (empty($reshook))
|
||||||
|
{
|
||||||
if ($action == 'setproductaccountancycodebuy')
|
if ($action == 'setproductaccountancycodebuy')
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$product = new Product($db);
|
||||||
@ -351,35 +353,32 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->produit->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Delete a product
|
||||||
* Suppression d'un produit/service pas encore affect
|
|
||||||
*/
|
|
||||||
if ($action == 'confirm_delete' && $confirm == 'yes')
|
if ($action == 'confirm_delete' && $confirm == 'yes')
|
||||||
{
|
{
|
||||||
$product = new Product($db);
|
$object = new Product($db);
|
||||||
$product->fetch($id);
|
$object->fetch($id);
|
||||||
|
|
||||||
if ( ($product->type == 0 && $user->rights->produit->supprimer) || ($product->type == 1 && $user->rights->service->supprimer) )
|
if ( ($object->type == 0 && $user->rights->produit->supprimer) || ($object->type == 1 && $user->rights->service->supprimer) )
|
||||||
{
|
{
|
||||||
$result = $product->delete($id);
|
$result = $object->delete($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
Header('Location: '.DOL_URL_ROOT.'/product/liste.php?delprod='.urlencode($product->ref));
|
Header('Location: '.DOL_URL_ROOT.'/product/liste.php?delprod='.urlencode($object->ref));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$mesg=$object->error;
|
||||||
$reload = 0;
|
$reload = 0;
|
||||||
$action='';
|
$action='';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
// Add product into proposal
|
||||||
* Ajout du produit dans une propal
|
|
||||||
*/
|
|
||||||
if ($action == 'addinpropal')
|
if ($action == 'addinpropal')
|
||||||
{
|
{
|
||||||
$propal = new Propal($db);
|
$propal = new Propal($db);
|
||||||
@ -459,9 +458,7 @@ if ($action == 'addinpropal')
|
|||||||
$mesg = $langs->trans("ErrorUnknown").": $result";
|
$mesg = $langs->trans("ErrorUnknown").": $result";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Add product into order
|
||||||
* Ajout du produit dans une commande
|
|
||||||
*/
|
|
||||||
if ($action == 'addincommande')
|
if ($action == 'addincommande')
|
||||||
{
|
{
|
||||||
$commande = new Commande($db);
|
$commande = new Commande($db);
|
||||||
@ -543,9 +540,7 @@ if ($action == 'addincommande')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Add product into invoice
|
||||||
* Ajout du produit dans une facture
|
|
||||||
*/
|
|
||||||
if ($action == 'addinfacture' && $user->rights->facture->creer)
|
if ($action == 'addinfacture' && $user->rights->facture->creer)
|
||||||
{
|
{
|
||||||
$facture = New Facture($db);
|
$facture = New Facture($db);
|
||||||
@ -628,8 +623,9 @@ if ($action == 'addinfacture' && $user->rights->facture->creer)
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($_POST["cancel"] == $langs->trans("Cancel"))
|
if (GETPOST("cancel") == $langs->trans("Cancel"))
|
||||||
{
|
{
|
||||||
$action = '';
|
$action = '';
|
||||||
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_POST["id"]);
|
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_POST["id"]);
|
||||||
|
|||||||
@ -938,20 +938,6 @@ class Societe extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove third party
|
|
||||||
if (! $error)
|
|
||||||
{
|
|
||||||
$sql = "DELETE from ".MAIN_DB_PREFIX."societe";
|
|
||||||
$sql.= " WHERE rowid = " . $id;
|
|
||||||
dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG);
|
|
||||||
if (! $this->db->query($sql))
|
|
||||||
{
|
|
||||||
$error++;
|
|
||||||
$this->error = $this->db->lasterror();
|
|
||||||
dol_syslog(get_class($this)."::delete erreur -3 ".$this->error, LOG_ERR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
// Actions on extra fields (by external module or standard code)
|
// Actions on extra fields (by external module or standard code)
|
||||||
@ -973,6 +959,20 @@ class Societe extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove third party
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$sql = "DELETE from ".MAIN_DB_PREFIX."societe";
|
||||||
|
$sql.= " WHERE rowid = " . $id;
|
||||||
|
dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG);
|
||||||
|
if (! $this->db->query($sql))
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$this->error = $this->db->lasterror();
|
||||||
|
dol_syslog(get_class($this)."::delete erreur -3 ".$this->error, LOG_ERR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
|
|||||||
@ -424,9 +424,9 @@ if (empty($reshook))
|
|||||||
$object->fetch($socid);
|
$object->fetch($socid);
|
||||||
$result = $object->delete($socid);
|
$result = $object->delete($socid);
|
||||||
|
|
||||||
if ($result >= 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
Header("Location: ".DOL_URL_ROOT."/societe/societe.php?delsoc=".$object->nom."");
|
Header("Location: ".DOL_URL_ROOT."/societe/societe.php?delsoc=".urlencode($object->name));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -498,6 +498,7 @@ $formcompany = new FormCompany($db);
|
|||||||
|
|
||||||
$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
|
$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
|
||||||
|
|
||||||
|
|
||||||
// TODO Mutualize this part of code (same than product/fiche.php and contact/fiche.php)
|
// TODO Mutualize this part of code (same than product/fiche.php and contact/fiche.php)
|
||||||
if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
||||||
{
|
{
|
||||||
@ -538,6 +539,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
// When used in standard mode
|
// When used in standard mode
|
||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user