Skip to content
Snippets Groups Projects
Commit ecfff563 authored by Cédric Salvador's avatar Cédric Salvador
Browse files

rename is_in_cat to containsObject

parent abe76708
No related branches found
No related tags found
No related merge requests found
......@@ -573,22 +573,43 @@ class Categorie
/**
* check for the presence of an object in a category
* @param string $field table field
* @param string $category_table category table name
* @param string $type object type
* @param int $object_id id of the object to search
* @return int nb number of occurrences
*/
function is_in_cat($field, $category_table, $object_id)
function containsObject($type, $object_id)
{
$field = ''; $classname = ''; $category_table = ''; $object_table = '';
if ($type == 'product') {
$field = 'product';
}
if ($type == 'customer') {
$field = 'societe';
}
if ($type == 'supplier') {
$field = 'societe';
$category_table = 'fournisseur';
}
if ($type == 'member') {
$field = 'member';
$category_table = '';
}
if ($type == 'contact') {
$field = 'socpeople';
$category_table = 'contact';
}
if (empty($category_table)) {
$category_table = $field;
}
$sql = "SELECT COUNT(*) as nb FROM " . MAIN_DB_PREFIX . "categorie_" . $category_table;
$sql .= " WHERE fk_categorie = " . $this->id . " AND fk_" . $field . " = " . $object_id;
dol_syslog(get_class($this)."::product_exists sql=".$sql);
dol_syslog(get_class($this)."::containsObject sql=".$sql);
$resql = $this->db->query($sql);
if ($resql) {
return $this->db->fetch_object($resql)->nb;
} else {
$this->error=$this->db->error().' sql='.$sql;
dol_syslog(get_class($this)."::get_type ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::containsObject ".$this->error, LOG_ERR);
return -1;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment