Skip to content
Snippets Groups Projects
Commit 73ab5386 authored by Regis Houssin's avatar Regis Houssin
Browse files

Fix: uniformize code

parent 299db387
No related branches found
No related tags found
No related merge requests found
...@@ -451,62 +451,23 @@ class Product extends CommonObject ...@@ -451,62 +451,23 @@ class Product extends CommonObject
function verif_prod_use($id) function verif_prod_use($id)
{ {
$sqr = 0; $sqr = 0;
$element = array('propaldet','commandedet','facturedet','contratdet');
$sql = "SELECT rowid"; foreach($element as $table)
$sql.= " FROM ".MAIN_DB_PREFIX."propaldet";
$sql.= " WHERE fk_product = ".$id;
$result = $this->db->query($sql);
if ($result)
{
$num = $this->db->num_rows($result);
if ($num != 0)
{
$sqr++;
}
}
$sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."facturedet";
$sql.= " WHERE fk_product = ".$id;
$result = $this->db->query($sql);
if ($result)
{
$num = $this->db->num_rows($result);
if ($num != 0)
{
$sqr++;
}
}
$sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet";
$sql.= " WHERE fk_product = ".$id;
$result = $this->db->query($sql);
if ($result)
{ {
$num = $this->db->num_rows($result); $sql = "SELECT rowid";
if ($num != 0) $sql.= " FROM ".MAIN_DB_PREFIX.$table;
{ $sql.= " WHERE fk_product = ".$id;
$sqr++;
}
}
$sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet";
$sql.= " WHERE fk_product = ".$id;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{
$num = $this->db->num_rows($result);
if ($num != 0)
{ {
$sqr++; $num = $this->db->num_rows($result);
if ($num != 0)
{
$sqr++;
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment