require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; $tmpobject = new Adherent($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'member'; } else { if ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) { require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; $tmpobject = new Contact($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'contact'; } } } } } $result = $object->del_type($tmpobject, $elementtype); if ($result < 0) { dol_print_error('', $object->error); } } if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confirm == 'yes') { if ($object->delete($user) >= 0) { header("Location: " . DOL_URL_ROOT . '/categories/index.php?type=' . $type); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); } } if ($type == Categorie::TYPE_PRODUCT && $elemid && $action == 'addintocategory' && ($user->rights->produit->creer || $user->rights->service->creer)) { require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; $newobject = new Product($db);
/** * Sets object to supplied categories. * * Deletes object from existing categories not supplied. * Adds it to non existing supplied categories. * Existing categories are left untouch. * * @param int[]|int $categories Category or categories IDs */ public function setCategories($categories) { // Handle single category if (!is_array($categories)) { $categories = array($categories); } // Get current categories require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; $c = new Categorie($this->db); $existing = $c->containing($this->id, Categorie::TYPE_PRODUCT, 'id'); // Diff if (is_array($existing)) { $to_del = array_diff($existing, $categories); $to_add = array_diff($categories, $existing); } else { $to_del = array(); // Nothing to delete $to_add = $categories; } // Process foreach ($to_del as $del) { $c->fetch($del); $c->del_type($this, 'product'); } foreach ($to_add as $add) { $c->fetch($add); $c->add_type($this, 'product'); } return; }
} if ($type == Categorie::TYPE_MEMBER && $user->rights->adherent->creer) { require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; $object = new Adherent($db); $result = $object->fetch($objectid); $elementtype = 'member'; } if ($type == Categorie::TYPE_CONTACT && $user->rights->societe->creer) { require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; $object = new Contact($db); $result = $object->fetch($objectid); $elementtype = 'contact'; } $cat = new Categorie($db); $result = $cat->fetch($removecat); $result = $cat->del_type($object, $elementtype); if ($result < 0) { setEventMessages($cat->error, $cat->errors, 'errors'); } } // Add object into a category if ($parent > 0) { if ($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) { require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; $object = new Product($db); $result = $object->fetch($id, $ref); $elementtype = 'product'; } if ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) { require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php'; $object = new Fournisseur($db);
/** * Sets object to supplied categories. * * Deletes object from existing categories not supplied. * Adds it to non existing supplied categories. * Existing categories are left untouch. * * @param int[]|int $categories Category or categories IDs * @param string $type Category type (customer or supplier) */ public function setCategories($categories, $type) { // Decode type if ($type == 'customer') { $type_id = Categorie::TYPE_CUSTOMER; $type_text = 'customer'; } elseif ($type == 'supplier') { $type_id = Categorie::TYPE_SUPPLIER; $type_text = 'supplier'; } else { dol_syslog(__METHOD__ . ': Type ' . $type . 'is an unknown company category type. Done nothing.', LOG_ERR); return; } // Handle single category if (!is_array($categories)) { $categories = array($categories); } // Get current categories require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; $c = new Categorie($this->db); $existing = $c->containing($this->id, $type_id, 'id'); // Diff if (is_array($existing)) { $to_del = array_diff($existing, $categories); $to_add = array_diff($categories, $existing); } else { $to_del = array(); // Nothing to delete $to_add = $categories; } // Process foreach ($to_del as $del) { if ($c->fetch($del) > 0) { $c->del_type($this, $type_text); } } foreach ($to_add as $add) { if ($c->fetch($add) > 0) { $c->add_type($this, $type_text); } } return; }
} if ($_REQUEST["type"]==2 && $user->rights->societe->creer) { $object = new Societe($db); $result = $object->fetch($objectid); } if ($_REQUEST["type"] == 3 && $user->rights->adherent->creer) { require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php"); $object = new Adherent($db); $result = $object->fetch($objectid); } $cat = new Categorie($db); $result=$cat->fetch($_REQUEST["removecat"]); $result=$cat->del_type($object,$type); } // Add object into a category if (isset($_REQUEST["catMere"]) && $_REQUEST["catMere"]>=0) { $_GET["id"]=$_REQUEST["id"]; $_GET["type"]=$_REQUEST["type"]; if ($_REQUEST["type"]==0 && ($user->rights->produit->creer || $user->rights->service->creer)) { require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); $object = new Product($db); if ($_REQUEST["ref"]) $result = $object->fetch('',$_REQUEST["ref"]); if ($_REQUEST["id"]) $result = $object->fetch($_REQUEST["id"]); $type = 'product';