camelCase and generic cloneCategories function
This commit is contained in:
parent
61f9aac887
commit
f167ad910e
@ -7517,4 +7517,35 @@ abstract class CommonObject
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* copy related categories to another object
|
||||
*
|
||||
* @param int $fromId Id object source
|
||||
* @param int $toId Id object cible
|
||||
* @param string $type Type of category ('product', ...)
|
||||
* @return int < 0 si erreur, > 0 si ok
|
||||
*/
|
||||
function cloneCategories($fromId, $toId, $type='')
|
||||
{
|
||||
$this->db->begin();
|
||||
|
||||
if (empty($type)) $type = $this->table_element;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
$categorystatic = new Categorie($this->db);
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_" . $categorystatic->MAP_CAT_TABLE[$type] . " (fk_categorie, fk_product)";
|
||||
$sql.= " SELECT fk_categorie, $toId FROM ".MAIN_DB_PREFIX."categorie_" . $categorystatic->MAP_CAT_TABLE[$type];
|
||||
$sql.= " WHERE fk_product = '".$fromId."'";
|
||||
|
||||
if (! $this->db->query($sql))
|
||||
{
|
||||
$this->db->rollback();die($sql);
|
||||
return -1;
|
||||
}
|
||||
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,6 +148,7 @@ CloneProduct=Clone product or service
|
||||
ConfirmCloneProduct=Are you sure you want to clone product or service <b>%s</b>?
|
||||
CloneContentProduct=Clone all main information of product/service
|
||||
ClonePricesProduct=Clone prices
|
||||
CloneCategoriesProduct=Clone tags/categories linked
|
||||
CloneCompositionProduct=Clone virtual product/service
|
||||
CloneCombinationsProduct=Clone product variants
|
||||
ProductIsUsed=This product is used
|
||||
|
||||
@ -147,6 +147,7 @@ CloneProduct=Cloner produit/service
|
||||
ConfirmCloneProduct=Êtes-vous sûr de vouloir cloner le produit ou service <b>%s</b> ?
|
||||
CloneContentProduct=Cloner les informations générales du produit/service
|
||||
ClonePricesProduct=Cloner les prix
|
||||
CloneCategoriesProduct=Cloner les catégories associées
|
||||
CloneCompositionProduct=Cloner le produits packagés
|
||||
CloneCombinationsProduct=Cloner les variantes
|
||||
ProductIsUsed=Ce produit est utilisé
|
||||
|
||||
@ -522,7 +522,7 @@ if (empty($reshook))
|
||||
|
||||
if (GETPOST('clone_categories'))
|
||||
{
|
||||
$result = $object->clone_categories($originalId, $id);
|
||||
$result = $object->cloneCategories($originalId, $id);
|
||||
|
||||
if ($result < 1)
|
||||
{
|
||||
@ -1995,7 +1995,7 @@ $formquestionclone=array(
|
||||
'text' => $langs->trans("ConfirmClone"),
|
||||
array('type' => 'text', 'name' => 'clone_ref','label' => $langs->trans("NewRefForClone"), 'value' => empty($tmpcode) ? $langs->trans("CopyOf").' '.$object->ref : $tmpcode, 'size'=>24),
|
||||
array('type' => 'checkbox', 'name' => 'clone_content','label' => $langs->trans("CloneContentProduct"), 'value' => 1),
|
||||
array('type' => 'checkbox', 'name' => 'clone_categories', 'label' => $langs->trans("CloneCategories"), 'value' => 1),
|
||||
array('type' => 'checkbox', 'name' => 'clone_categories', 'label' => $langs->trans("CloneCategoriesProduct"), 'value' => 1),
|
||||
array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("FeatureNotYetAvailable").')', 'value' => 0, 'disabled' => true),
|
||||
);
|
||||
if (! empty($conf->global->PRODUIT_SOUSPRODUITS))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user