mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Rename "attributes" into "variants" to avoid confusion with extrafields
This commit is contained in:
parent
b24f244f67
commit
e1a6e6e4ab
|
|
@ -51,8 +51,8 @@ if (! empty($conf->projet->enabled)) {
|
|||
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
|
||||
}
|
||||
|
||||
if (!empty($conf->attributes->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductCombination.class.php';
|
||||
if (!empty($conf->variants->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php';
|
||||
}
|
||||
|
||||
$langs->load('companies');
|
||||
|
|
@ -729,7 +729,7 @@ if (empty($reshook))
|
|||
$error ++;
|
||||
}
|
||||
|
||||
if (!$error && !empty($conf->attributes->enabled) && $prod_entry_mode != 'free') {
|
||||
if (!$error && !empty($conf->variants->enabled) && $prod_entry_mode != 'free') {
|
||||
if ($combinations = GETPOST('combinations', 'array')) {
|
||||
//Check if there is a product with the given combination
|
||||
$prodcomb = new ProductCombination($db);
|
||||
|
|
|
|||
|
|
@ -51,8 +51,8 @@ if (! empty($conf->projet->enabled)) {
|
|||
}
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
|
||||
|
||||
if (!empty($conf->attributes->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductCombination.class.php';
|
||||
if (!empty($conf->variants->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php';
|
||||
}
|
||||
|
||||
$langs->load('orders');
|
||||
|
|
@ -693,7 +693,7 @@ if (empty($reshook))
|
|||
$error++;
|
||||
}
|
||||
|
||||
if (!$error && !empty($conf->attributes->enabled) && $prod_entry_mode != 'free') {
|
||||
if (!$error && !empty($conf->variants->enabled) && $prod_entry_mode != 'free') {
|
||||
if ($combinations = GETPOST('combinations', 'array')) {
|
||||
//Check if there is a product with the given combination
|
||||
$prodcomb = new ProductCombination($db);
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ if (! empty($conf->projet->enabled)) {
|
|||
}
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
|
||||
|
||||
if (!empty($conf->attributes->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductCombination.class.php';
|
||||
if (!empty($conf->variants->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php';
|
||||
}
|
||||
|
||||
$langs->load('bills');
|
||||
|
|
@ -1428,7 +1428,7 @@ if (empty($reshook))
|
|||
$error ++;
|
||||
}
|
||||
|
||||
if (!$error && !empty($conf->attributes->enabled) && $prod_entry_mode != 'free') {
|
||||
if (!$error && !empty($conf->variants->enabled) && $prod_entry_mode != 'free') {
|
||||
if ($combinations = GETPOST('combinations', 'array')) {
|
||||
//Check if there is a product with the given combination
|
||||
$prodcomb = new ProductCombination($db);
|
||||
|
|
|
|||
|
|
@ -1673,7 +1673,7 @@ class Form
|
|||
}
|
||||
print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
|
||||
|
||||
if (!empty($conf->attributes->enabled)) {
|
||||
if (!empty($conf->variants->enabled)) {
|
||||
?>
|
||||
<script>
|
||||
|
||||
|
|
@ -1695,7 +1695,7 @@ class Form
|
|||
return;
|
||||
}
|
||||
|
||||
jQuery.getJSON("<?php echo dol_buildpath('/attributes/ajax/getCombinations.php', 2) ?>", {
|
||||
jQuery.getJSON("<?php echo dol_buildpath('/variants/ajax/getCombinations.php', 2) ?>", {
|
||||
id: jQuery(this).val()
|
||||
}, function (data) {
|
||||
jQuery('div#attributes_box').empty();
|
||||
|
|
|
|||
|
|
@ -94,16 +94,16 @@ function product_prepare_head($object)
|
|||
$head[$h][2] = 'referers';
|
||||
$h++;
|
||||
|
||||
if (!empty($conf->attributes->enabled) && $object->isProduct()) {
|
||||
if (!empty($conf->variants->enabled) && $object->isProduct()) {
|
||||
|
||||
global $db;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductCombination.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php';
|
||||
|
||||
$prodcomb = new ProductCombination($db);
|
||||
|
||||
if ($prodcomb->fetchByFkProductChild($object->id) == -1) {
|
||||
$head[$h][0] = DOL_URL_ROOT."/attributes/combinations.php?id=".$object->id;
|
||||
$head[$h][0] = DOL_URL_ROOT."/variants/combinations.php?id=".$object->id;
|
||||
$head[$h][1] = $langs->trans('ProductCombinations');
|
||||
$head[$h][2] = 'combinations';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* \defgroup produit Module product attributes
|
||||
* \defgroup produit Module product variants
|
||||
* \brief Module to manage product combinations based on product attributes
|
||||
* \file htdocs/core/modules/modAttributes.class.php
|
||||
* \ingroup produit
|
||||
|
|
@ -30,9 +30,9 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
|
|||
|
||||
|
||||
/**
|
||||
* Description and activation class for module Product attributes
|
||||
* Description and activation class for module Product variants
|
||||
*/
|
||||
class modAttributes extends DolibarrModules
|
||||
class modVariants extends DolibarrModules
|
||||
{
|
||||
/**
|
||||
* Constructor. Define names, constants, directories, boxes, permissions
|
||||
|
|
@ -49,7 +49,7 @@ class modAttributes extends DolibarrModules
|
|||
// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
|
||||
$this->numero = 610;
|
||||
// Key text used to identify module (for permissions, menus, etc...)
|
||||
$this->rights_class = 'attributes';
|
||||
$this->rights_class = 'variants';
|
||||
|
||||
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
|
||||
// It is used to group modules in module setup page
|
||||
|
|
@ -57,9 +57,9 @@ class modAttributes extends DolibarrModules
|
|||
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
|
||||
$this->name = preg_replace('/^mod/i','',get_class($this));
|
||||
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
|
||||
$this->description = 'Allows creating product combinations based on product attributes';
|
||||
$this->description = 'Allows creating products variant based on new attributes';
|
||||
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
|
||||
$this->version = 'dolibarr';
|
||||
$this->version = 'experimental';
|
||||
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
|
||||
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
|
||||
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
|
||||
|
|
@ -78,7 +78,7 @@ class modAttributes extends DolibarrModules
|
|||
|
||||
// Config pages. Put here list of php page, stored into mymodule/admin directory, to use to setup module.
|
||||
$this->config_page_url = array(
|
||||
'admin.php@attributes'
|
||||
'admin.php@variants'
|
||||
);
|
||||
|
||||
// Dependencies
|
||||
|
|
@ -97,7 +97,7 @@ class modAttributes extends DolibarrModules
|
|||
|
||||
// Array to add new pages in new tabs
|
||||
$this->tabs = array(
|
||||
// 'product:+combinations:Combinaciones:products:1:/attributes/combinations.php?id=__ID__'
|
||||
// 'product:+combinations:Combinaciones:products:1:/variants/combinations.php?id=__ID__'
|
||||
);
|
||||
|
||||
// Dictionaries
|
||||
|
|
@ -120,10 +120,10 @@ class modAttributes extends DolibarrModules
|
|||
array(
|
||||
'fk_menu' => 'fk_mainmenu=products,fk_leftmenu=product',
|
||||
'type' => 'left',
|
||||
'titre' => $langs->trans('Attributes'),
|
||||
'titre' => 'VariantAttributes',
|
||||
'mainmenu' => 'products',
|
||||
'leftmenu' => 'product',
|
||||
'url' => '/attributes/list.php',
|
||||
'url' => '/variants/list.php',
|
||||
'langs' => 'products',
|
||||
'position' => 100,
|
||||
'enabled' => '$conf->product->enabled',
|
||||
|
|
@ -240,7 +240,7 @@ else {
|
|||
|
||||
if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) {
|
||||
|
||||
if (!empty($conf->attributes->enabled)) {
|
||||
if (!empty($conf->variants->enabled)) {
|
||||
echo '<div id="attributes_box"></div>';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,8 +50,8 @@ if (!empty($conf->projet->enabled)) {
|
|||
}
|
||||
require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP
|
||||
|
||||
if (!empty($conf->attributes->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductCombination.class.php';
|
||||
if (!empty($conf->variants->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php';
|
||||
}
|
||||
|
||||
$langs->load('admin');
|
||||
|
|
@ -343,7 +343,7 @@ if (empty($reshook))
|
|||
$error++;
|
||||
}
|
||||
|
||||
if (!$error && !empty($conf->attributes->enabled) && $prod_entry_mode != 'free') {
|
||||
if (!$error && !empty($conf->variants->enabled) && $prod_entry_mode != 'free') {
|
||||
if ($combinations = GETPOST('combinations', 'array')) {
|
||||
//Check if there is a product with the given combination
|
||||
$prodcomb = new ProductCombination($db);
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ if (!empty($conf->projet->enabled)) {
|
|||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||
}
|
||||
|
||||
if (!empty($conf->attributes->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductCombination.class.php';
|
||||
if (!empty($conf->variants->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php';
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -941,7 +941,7 @@ if (empty($reshook))
|
|||
$error++;
|
||||
}
|
||||
|
||||
if (!$error && !empty($conf->attributes->enabled) && $prod_entry_mode != 'free') {
|
||||
if (!$error && !empty($conf->variants->enabled) && $prod_entry_mode != 'free') {
|
||||
if ($combinations = GETPOST('combinations', 'array')) {
|
||||
//Check if there is a product with the given combination
|
||||
$prodcomb = new ProductCombination($db);
|
||||
|
|
|
|||
|
|
@ -54,6 +54,47 @@ ALTER TABLE llx_projet_task_time ADD COLUMN tms timestamp;
|
|||
|
||||
ALTER TABLE llx_product_price_by_qty ADD COLUMN fk_user_creat integer;
|
||||
ALTER TABLE llx_product_price_by_qty ADD COLUMN fk_user_modif integer;
|
||||
ALTER TABLE llx_product_price_by_qty DROP COLUMN date_price;
|
||||
ALTER TABLE llx_product_price_by_qty ADD COLUMN tms timestamp;
|
||||
ALTER TABLE llx_product_price_by_qty ADD COLUMN import_key integer;
|
||||
|
||||
|
||||
|
||||
CREATE TABLE llx_product_attribute
|
||||
(
|
||||
rowid INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
||||
ref VARCHAR(255) NOT NULL,
|
||||
label VARCHAR(255) NOT NULL,
|
||||
rang INT DEFAULT 0 NOT NULL,
|
||||
entity INT DEFAULT 1 NOT NULL
|
||||
);
|
||||
ALTER TABLE llx_product_attribute ADD CONSTRAINT unique_ref UNIQUE (ref);
|
||||
|
||||
CREATE TABLE llx_product_attribute_value
|
||||
(
|
||||
rowid INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
||||
fk_product_attribute INT NOT NULL,
|
||||
ref VARCHAR(255) DEFAULT NULL,
|
||||
value VARCHAR(255) DEFAULT NULL,
|
||||
entity INT DEFAULT 1 NOT NULL
|
||||
);
|
||||
ALTER TABLE llx_product_attribute_value ADD CONSTRAINT unique_ref UNIQUE (fk_product_attribute,ref);
|
||||
|
||||
CREATE TABLE llx_product_attribute_combination2val
|
||||
(
|
||||
rowid INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
||||
fk_prod_combination INT NOT NULL,
|
||||
fk_prod_attr INT NOT NULL,
|
||||
fk_prod_attr_val INT NOT NULL
|
||||
);
|
||||
CREATE TABLE llx_product_attribute_combination
|
||||
(
|
||||
rowid INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
|
||||
fk_product_parent INT NOT NULL,
|
||||
fk_product_child INT NOT NULL,
|
||||
variation_price FLOAT NOT NULL,
|
||||
variation_price_percentage INT NULL,
|
||||
variation_weight FLOAT NOT NULL,
|
||||
entity INT DEFAULT 1 NOT NULL
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ create table llx_product_price_by_qty
|
|||
(
|
||||
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
fk_product_price integer NOT NULL,
|
||||
date_price timestamp NOT NULL,
|
||||
price double(24,8) DEFAULT 0,
|
||||
quantity double DEFAULT NULL,
|
||||
remise_percent double NOT NULL DEFAULT 0,
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ ConfirmCloneProduct=Are you sure you want to clone product or service <b>%s</b>?
|
|||
CloneContentProduct=Clone all main informations of product/service
|
||||
ClonePricesProduct=Clone main informations and prices
|
||||
CloneCompositionProduct=Clone packaged product/service
|
||||
CloneCombinationsProduct=Clone product combinations
|
||||
CloneCombinationsProduct=Clone product variants
|
||||
ProductIsUsed=This product is used
|
||||
NewRefForClone=Ref. of new product/service
|
||||
SellingPrices=Selling prices
|
||||
|
|
@ -262,36 +262,37 @@ ConfirmDeleteProductBuyPrice=Are you sure you want to delete this buying price?
|
|||
SubProduct=Sub product
|
||||
|
||||
#Attributes
|
||||
ProductAttributes=Product attributes
|
||||
ProductAttributeName=Attribute %s
|
||||
ProductAttribute=Attribute
|
||||
VariantAttributes=Variant attributes
|
||||
ProductAttributes=Variant attributes for products
|
||||
ProductAttributeName=Variant attribute %s
|
||||
ProductAttribute=Variant attribute
|
||||
ProductAttributeDeleteDialog=Are you sure you want to delete this attribute? All values will be deleted
|
||||
ProductAttributeValueDeleteDialog=Are you sure you want to delete the value "%s" with reference "%s" of this attribute?
|
||||
ProductCombinationDeleteDialog=Are you sure want to delete the combination of the product "%s"?
|
||||
ProductCombinationAlreadyUsed=There was an error while deleting the combination. Please check it is not being used in any object
|
||||
ProductCombinations=Combinations
|
||||
HideProductCombinations=Hide derived products from combinations in the product selector
|
||||
ProductCombination=Combination
|
||||
NewProductCombination=New combination
|
||||
EditProductCombination=Editing combination
|
||||
ProductCombinationGenerator=Combinations generator
|
||||
ProductCombinationDeleteDialog=Are you sure want to delete the variant of the product "<strong>%s</strong>"?
|
||||
ProductCombinationAlreadyUsed=There was an error while deleting the variant. Please check it is not being used in any object
|
||||
ProductCombinations=Variants
|
||||
HideProductCombinations=Hide products variant in the products selector
|
||||
ProductCombination=Variant
|
||||
NewProductCombination=New variant
|
||||
EditProductCombination=Editing variant
|
||||
ProductCombinationGenerator=Variants generator
|
||||
Features=Features
|
||||
PriceImpact=Price impact
|
||||
WeightImpact=Weight impact
|
||||
NewProductAttribute=New attribute
|
||||
NewProductAttributeValue=New attribute value
|
||||
ErrorCreatingProductAttributeValue=There was an error while creating the attribute value. It could be because there is already an existing value with that reference
|
||||
ProductCombinationGeneratorWarning=If you continue, before generating new combinations, all previous ones will be DELETED. Already existing ones will be updated with the new values
|
||||
TooMuchCombinationsWarning=Generating lots of combinations may result in high CPU, memory usage and Dolibarr not able to create them. Enabling the option "%s" may help reduce memory usage.
|
||||
DoNotRemovePreviousCombinations=Do not remove previous combinations
|
||||
ProductCombinationGeneratorWarning=If you continue, before generating new variants, all previous ones will be DELETED. Already existing ones will be updated with the new values
|
||||
TooMuchCombinationsWarning=Generating lots of variants may result in high CPU, memory usage and Dolibarr not able to create them. Enabling the option "%s" may help reduce memory usage.
|
||||
DoNotRemovePreviousCombinations=Do not remove previous variants
|
||||
UsePercentageVariations=Use percentage variations
|
||||
PercentageVariation=Percentage variation
|
||||
ErrorDeletingGeneratedProducts=There was an error while trying to delete existing product combinations
|
||||
ErrorDeletingGeneratedProducts=There was an error while trying to delete existing product variants
|
||||
NbProducts=No. of products
|
||||
ParentProduct=Parent product
|
||||
HideChildProducts=Hide child products
|
||||
ConfirmCloneProductCombinations=Would you like to copy all the product combinations to the product with the given reference?
|
||||
ConfirmCloneProductCombinations=Would you like to copy all the product variant to the product with the given reference?
|
||||
CloneDestinationReference=Destination product reference
|
||||
ErrorCopyProductCombinations=There was an error while copying the product combinations
|
||||
ErrorCopyProductCombinations=There was an error while copying the product variants
|
||||
ErrorDestinationProductNotFound=Destination product not found
|
||||
ErrorProductCombinationNotFound=Product combination not found
|
||||
ErrorProductCombinationNotFound=Product variant not found
|
||||
|
|
@ -1604,7 +1604,7 @@ else
|
|||
print '</td></tr>';
|
||||
|
||||
//Parent product.
|
||||
if (!empty($conf->attributes->enabled) && $object->isProduct()) {
|
||||
if (!empty($conf->variants->enabled) && $object->isProduct()) {
|
||||
|
||||
$combination = new ProductCombination($db);
|
||||
|
||||
|
|
|
|||
|
|
@ -960,9 +960,9 @@ class Product extends CommonObject
|
|||
|
||||
if (! $error)
|
||||
{
|
||||
if ($conf->attributes->enabled) {
|
||||
if ($conf->variants->enabled) {
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductCombination.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php';
|
||||
|
||||
$comb = new ProductCombination($this->db);
|
||||
|
||||
|
|
@ -1094,8 +1094,8 @@ class Product extends CommonObject
|
|||
|
||||
if (!$error) {
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductCombination.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductCombination2ValuePair.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination2ValuePair.class.php';
|
||||
|
||||
//If it is a parent product, then we remove the association with child products
|
||||
$prodcomb = new ProductCombination($this->db);
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ else
|
|||
$sql.= ' p.datec as date_creation, p.tms as date_update,';
|
||||
//$sql.= ' pfp.ref_fourn as ref_supplier, ';
|
||||
$sql.= ' MIN(pfp.unitprice) as minsellprice';
|
||||
if (!empty($conf->attributes->enabled) && $search_hidechildproducts && ($type === 0)) {
|
||||
if (!empty($conf->variants->enabled) && $search_hidechildproducts && ($type === 0)) {
|
||||
$sql .= ', pac.rowid prod_comb_id';
|
||||
}
|
||||
// Add fields from extrafields
|
||||
|
|
@ -264,7 +264,7 @@ else
|
|||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
|
||||
// multilang
|
||||
if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang = '".$langs->getDefaultLang() ."'";
|
||||
if (!empty($conf->attributes->enabled) && $search_hidechildproducts && ($type === 0)) {
|
||||
if (!empty($conf->variants->enabled) && $search_hidechildproducts && ($type === 0)) {
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac.fk_product_child = p.rowid";
|
||||
}
|
||||
|
||||
|
|
@ -292,7 +292,7 @@ else
|
|||
if ($search_accountancy_code_sell) $sql.= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy);
|
||||
// Add where from extra fields
|
||||
|
||||
if (!empty($conf->attributes->enabled) && $search_hidechildproducts && ($type === 0)) {
|
||||
if (!empty($conf->variants->enabled) && $search_hidechildproducts && ($type === 0)) {
|
||||
$sql .= " AND pac.rowid IS NULL";
|
||||
}
|
||||
|
||||
|
|
@ -316,7 +316,7 @@ else
|
|||
$sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,";
|
||||
$sql.= " p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,";
|
||||
$sql.= ' p.datec, p.tms, p.entity, p.tobatch, p.accountancy_code_sell, p.accountancy_code_buy';
|
||||
if (!empty($conf->attributes->enabled) && $search_hidechildproducts && ($type === 0)) {
|
||||
if (!empty($conf->variants->enabled) && $search_hidechildproducts && ($type === 0)) {
|
||||
$sql .= ', pac.rowid';
|
||||
}
|
||||
// Add fields from extrafields
|
||||
|
|
@ -451,7 +451,7 @@ else
|
|||
}
|
||||
|
||||
//Show/hide child products. Hidden by default
|
||||
if (!empty($conf->attributes->enabled) && $type === 0) {
|
||||
if (!empty($conf->variants->enabled) && $type === 0) {
|
||||
$moreforfilter.='<div class="divsearchfield">';
|
||||
$moreforfilter.= '<input type="checkbox" id="search_hidechildproducts" name="search_hidechildproducts" value="on"'.($search_hidechildproducts ? 'checked="checked"' : '').'>';
|
||||
$moreforfilter.= ' <label for="search_hidechildproducts">'.$langs->trans('HideChildProducts').'</label>';
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ define('NOREQUIRESOC','1');
|
|||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductCombination.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
|
|
@ -24,8 +24,8 @@ define('NOREQUIRESOC','1');
|
|||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductAttribute.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductAttributeValue.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttribute.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttributeValue.class.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ if (isset($_POST['roworder'])) {
|
|||
}
|
||||
}
|
||||
|
||||
require DOL_DOCUMENT_ROOT.'/attributes/class/ProductAttribute.class.php';
|
||||
require DOL_DOCUMENT_ROOT.'/variants/class/ProductAttribute.class.php';
|
||||
|
||||
ProductAttribute::bulkUpdateOrder($db, $newrowordertab);
|
||||
}
|
||||
|
|
@ -26,6 +26,7 @@ $action = GETPOST('action');
|
|||
$label = GETPOST('label');
|
||||
$ref = GETPOST('ref');
|
||||
$confirm = GETPOST('confirm');
|
||||
$cancel = GETPOST('cancel');
|
||||
|
||||
$prodattr = new ProductAttribute($db);
|
||||
$prodattrval = new ProductAttributeValue($db);
|
||||
|
|
@ -35,6 +36,12 @@ if ($prodattr->fetch($id) < 1) {
|
|||
die;
|
||||
}
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($cancel) $action='';
|
||||
|
||||
if ($_POST) {
|
||||
|
||||
if ($action == 'edit') {
|
||||
|
|
@ -46,7 +53,7 @@ if ($_POST) {
|
|||
setEventMessage($langs->trans('CoreErrorMessage'), 'errors');
|
||||
} else {
|
||||
setEventMessage($langs->trans('RecordSaved'));
|
||||
header('Location: '.dol_buildpath('/attributes/card.php?id='.$id, 2));
|
||||
header('Location: '.dol_buildpath('/variants/card.php?id='.$id, 2));
|
||||
die;
|
||||
}
|
||||
} elseif ($action == 'edit_value') {
|
||||
|
|
@ -63,7 +70,7 @@ if ($_POST) {
|
|||
}
|
||||
}
|
||||
|
||||
header('Location: '.dol_buildpath('/attributes/card.php?id='.$prodattr->id, 2));
|
||||
header('Location: '.dol_buildpath('/variants/card.php?id='.$prodattr->id, 2));
|
||||
die;
|
||||
}
|
||||
|
||||
|
|
@ -79,11 +86,11 @@ if ($confirm == 'yes') {
|
|||
if ($res < 1 || ($prodattr->delete() < 1)) {
|
||||
$db->rollback();
|
||||
setEventMessage($langs->trans('CoreErrorMessage'), 'errors');
|
||||
header('Location: '.dol_buildpath('/attributes/card.php?id='.$prodattr->id, 2));
|
||||
header('Location: '.dol_buildpath('/variants/card.php?id='.$prodattr->id, 2));
|
||||
} else {
|
||||
$db->commit();
|
||||
setEventMessage($langs->trans('RecordSaved'));
|
||||
header('Location: '.dol_buildpath('/attributes/list.php', 2));
|
||||
header('Location: '.dol_buildpath('/variants/list.php', 2));
|
||||
}
|
||||
|
||||
die;
|
||||
|
|
@ -97,7 +104,7 @@ if ($confirm == 'yes') {
|
|||
setEventMessage($langs->trans('RecordSaved'));
|
||||
}
|
||||
|
||||
header('Location: '.dol_buildpath('/attributes/card.php?id='.$prodattr->id, 2));
|
||||
header('Location: '.dol_buildpath('/variants/card.php?id='.$prodattr->id, 2));
|
||||
die;
|
||||
}
|
||||
}
|
||||
|
|
@ -150,7 +157,8 @@ if ($action == 'edit') { ?>
|
|||
<div style="text-align: center;">
|
||||
<div class="inline-block divButAction">
|
||||
<input type="submit" class="button" value="<?php echo $langs->trans('Save') ?>">
|
||||
<a href="card.php?id=<?php echo $prodattr->id ?>" class="butAction"><?php echo $langs->trans('Cancel') ?></a>
|
||||
|
||||
<input type="submit" class="button" name="cancel" value="<?php echo $langs->trans('Cancel') ?>">
|
||||
</div>
|
||||
</div></form>
|
||||
<?php } else {
|
||||
|
|
@ -212,7 +220,8 @@ if ($action == 'edit') { ?>
|
|||
<td><input type="text" name="value" value="<?php echo $attrval->value ?>"></td>
|
||||
<td style="text-align: right">
|
||||
<input type="submit" value="<?php echo $langs->trans('Save') ?>" class="button">
|
||||
<a href="card.php?id=<?php echo $prodattr->id ?>" class="butAction"><?php echo $langs->trans('Cancel') ?></a>
|
||||
|
||||
<input type="submit" name="cancel" value="<?php echo $langs->trans('Cancel') ?>" class="button">
|
||||
</td>
|
||||
<?php else: ?>
|
||||
<td><?php echo dol_htmlentities($attrval->ref) ?></td>
|
||||
|
|
@ -242,4 +251,4 @@ if ($action == 'edit') { ?>
|
|||
<?php
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
llxFooter();
|
||||
|
|
@ -73,7 +73,7 @@ class ProductAttribute
|
|||
return -1;
|
||||
}
|
||||
|
||||
require_once __DIR__.'/../lib/product_attributes.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/lib/product_variants.lib.php';
|
||||
|
||||
$sql = "SELECT rowid, ref, label, rang FROM ".MAIN_DB_PREFIX."product_attribute WHERE rowid = ".(int) $id." AND entity IN (".getProductEntities($this->db).")";
|
||||
|
||||
|
|
@ -94,31 +94,34 @@ class ProductAttribute
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns an array of all product attributes
|
||||
* Returns an array of all product variants
|
||||
*
|
||||
* @return ProductAttribute[]
|
||||
*/
|
||||
public function fetchAll()
|
||||
{
|
||||
require_once __DIR__.'/../lib/product_attributes.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/lib/product_variants.lib.php';
|
||||
|
||||
$return = array();
|
||||
|
||||
$sql = 'SELECT rowid, ref, label, rang FROM '.MAIN_DB_PREFIX."product_attribute WHERE entity IN (".getProductEntities($this->db).')';
|
||||
$sql .= $this->db->order('rang', 'asc');
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
while ($result = $this->db->fetch_object($query)) {
|
||||
|
||||
$tmp = new ProductAttribute($this->db);
|
||||
$tmp->id = $result->rowid;
|
||||
$tmp->ref = $result->ref;
|
||||
$tmp->label = $result->label;
|
||||
$tmp->rang = $result->rang;
|
||||
|
||||
$return[] = $tmp;
|
||||
if ($query)
|
||||
{
|
||||
while ($result = $this->db->fetch_object($query)) {
|
||||
|
||||
$tmp = new ProductAttribute($this->db);
|
||||
$tmp->id = $result->rowid;
|
||||
$tmp->ref = $result->ref;
|
||||
$tmp->label = $result->label;
|
||||
$tmp->rang = $result->rang;
|
||||
|
||||
$return[] = $tmp;
|
||||
}
|
||||
}
|
||||
|
||||
else dol_print_error($this->db);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
|
@ -187,7 +190,7 @@ class ProductAttribute
|
|||
*/
|
||||
public function countChildProducts()
|
||||
{
|
||||
require_once __DIR__.'/../lib/product_attributes.lib.php';
|
||||
require_once __DIR__.'/../lib/product_variants.lib.php';
|
||||
|
||||
$sql = "SELECT COUNT(*) count FROM ".MAIN_DB_PREFIX."product_attribute_combination2val pac2v
|
||||
LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac2v.fk_prod_combination = pac.rowid WHERE pac2v.fk_prod_attr = ".(int) $this->id." AND pac.entity IN (".getProductEntities($this->db).")";
|
||||
|
|
@ -200,7 +203,7 @@ class ProductAttribute
|
|||
}
|
||||
|
||||
/**
|
||||
* Reorders the order of the attributes.
|
||||
* Reorders the order of the variants.
|
||||
* This is an internal function used by moveLine function
|
||||
*
|
||||
* @return int <0 KO >0 OK
|
||||
|
|
@ -294,7 +297,7 @@ class ProductAttribute
|
|||
}
|
||||
|
||||
/**
|
||||
* Updates the order of all attributes. Used by AJAX page for drag&drop
|
||||
* Updates the order of all variants. Used by AJAX page for drag&drop
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param array $order Array with row id ordered in ascendent mode
|
||||
|
|
@ -68,7 +68,7 @@ class ProductAttributeValue
|
|||
*/
|
||||
public function fetch($valueid)
|
||||
{
|
||||
require_once __DIR__.'/../lib/product_attributes.lib.php';
|
||||
require_once __DIR__.'/../lib/product_variants.lib.php';
|
||||
|
||||
$sql = "SELECT rowid, fk_product_attribute, ref, value FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE rowid = ".(int) $valueid." AND entity IN (".getProductEntities($this->db).")";
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ class ProductAttributeValue
|
|||
*/
|
||||
public function fetchAllByProductAttribute($prodattr_id, $only_used = false)
|
||||
{
|
||||
require_once __DIR__.'/../lib/product_attributes.lib.php';
|
||||
require_once __DIR__.'/../lib/product_variants.lib.php';
|
||||
|
||||
$return = array();
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ class ProductCombination
|
|||
*/
|
||||
public function fetch($rowid)
|
||||
{
|
||||
require_once __DIR__.'/../lib/product_attributes.lib.php';
|
||||
require_once __DIR__.'/../lib/product_variants.lib.php';
|
||||
|
||||
$sql = "SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE rowid = ".(int) $rowid." AND entity IN (".getProductEntities($this->db).")";
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ class ProductCombination
|
|||
*/
|
||||
public function fetchByFkProductChild($fk_child)
|
||||
{
|
||||
require_once __DIR__.'/../lib/product_attributes.lib.php';
|
||||
require_once __DIR__.'/../lib/product_variants.lib.php';
|
||||
|
||||
$sql = "SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_child = ".(int) $fk_child." AND entity IN (".getProductEntities($this->db).")";
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ class ProductCombination
|
|||
*/
|
||||
public function fetchAllByFkProductParent($fk_product_parent)
|
||||
{
|
||||
require_once __DIR__.'/../lib/product_attributes.lib.php';
|
||||
require_once __DIR__.'/../lib/product_variants.lib.php';
|
||||
|
||||
$sql = "SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_parent = ".(int) $fk_product_parent." AND entity IN (".getProductEntities($this->db).")";
|
||||
|
||||
|
|
@ -361,7 +361,7 @@ class ProductCombination
|
|||
*/
|
||||
public function fetchByProductCombination2ValuePairs($prodid, array $features)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductCombination2ValuePair.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination2ValuePair.class.php';
|
||||
|
||||
$actual_comp = array();
|
||||
|
||||
|
|
@ -399,10 +399,10 @@ class ProductCombination
|
|||
*/
|
||||
public function getUniqueAttributesAndValuesByFkProductParent($productid)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductAttribute.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductAttributeValue.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttribute.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttributeValue.class.php';
|
||||
|
||||
$attributes = array();
|
||||
$variants = array();
|
||||
|
||||
//Attributes
|
||||
$sql = "SELECT DISTINCT fk_prod_attr, a.rang
|
||||
|
|
@ -432,10 +432,10 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1";
|
|||
$tmp->values[] = $val;
|
||||
}
|
||||
|
||||
$attributes[] = $tmp;
|
||||
$variants[] = $tmp;
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
return $variants;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -459,12 +459,12 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1";
|
|||
* @param bool|float $forced_weightvar If the weight variation is forced
|
||||
* @return int <0 KO, >0 OK
|
||||
*/
|
||||
public static function createProductCombination(Product $product, array $combinations, array $variations, $price_var_percent = false, $forced_pricevar = false, $forced_weightvar = false)
|
||||
public function createProductCombination(Product $product, array $combinations, array $variations, $price_var_percent = false, $forced_pricevar = false, $forced_weightvar = false)
|
||||
{
|
||||
global $db, $user;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductAttribute.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductAttributeValue.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttribute.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttributeValue.class.php';
|
||||
|
||||
$db->begin();
|
||||
|
||||
|
|
@ -552,6 +552,8 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1";
|
|||
|
||||
//In case the error is not related with an already existing product
|
||||
if ($newproduct->error != 'ErrorProductAlreadyExists') {
|
||||
$this->error[] = $newproduct->error;
|
||||
$this->errors = $newproduct->errors;
|
||||
$db->rollback();
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -572,6 +574,7 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1";
|
|||
$res = $newproduct->create($user);
|
||||
|
||||
if ($newproduct->error != 'ErrorProductAlreadyExists') {
|
||||
$this->errors[] = $newproduct->error;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -607,7 +610,7 @@ WHERE c.fk_product_parent = ".(int) $productid." AND p.tosell = 1";
|
|||
*/
|
||||
public function copyAll($origProductId, Product $destProduct)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductCombination2ValuePair.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination2ValuePair.class.php';
|
||||
|
||||
//To prevent a loop
|
||||
if ($origProductId == $destProduct->id) {
|
||||
|
|
@ -64,8 +64,8 @@ class ProductCombination2ValuePair
|
|||
*/
|
||||
public function __toString()
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductAttributeValue.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductAttribute.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttributeValue.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttribute.class.php';
|
||||
|
||||
$prodattr = new ProductAttribute($this->db);
|
||||
$prodattrval = new ProductAttributeValue($this->db);
|
||||
|
|
@ -19,10 +19,10 @@
|
|||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductAttribute.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductAttributeValue.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductCombination.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductCombination2ValuePair.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttribute.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttributeValue.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination2ValuePair.class.php';
|
||||
|
||||
$langs->load("products");
|
||||
$langs->load("other");
|
||||
|
|
@ -102,7 +102,7 @@ if ($_POST) {
|
|||
if (ProductCombination::createProductCombination($product, $sanit_features, array(), $price_impact_percent, $price_impact, $weight_impact)) {
|
||||
$db->commit();
|
||||
setEventMessage($langs->trans('RecordSaved'));
|
||||
header('Location: '.dol_buildpath('/attributes/combinations.php?id='.$id, 2));
|
||||
header('Location: '.dol_buildpath('/variants/combinations.php?id='.$id, 2));
|
||||
die;
|
||||
} else {
|
||||
setEventMessage($langs->trans('CoreErrorMessage'), 'errors');
|
||||
|
|
@ -180,7 +180,7 @@ if ($_POST) {
|
|||
|
||||
if ($prodcomb->update() > 0) {
|
||||
setEventMessage($langs->trans('RecordSaved'));
|
||||
header('Location: '.dol_buildpath('/attributes/combinations.php?id='.$id, 2));
|
||||
header('Location: '.dol_buildpath('/variants/combinations.php?id='.$id, 2));
|
||||
die;
|
||||
} else {
|
||||
setEventMessage($langs->trans('CoreErrorMessage'), 'errors');
|
||||
|
|
@ -199,7 +199,7 @@ if ($action === 'confirm_deletecombination') {
|
|||
if ($prodcomb->delete() > 0 && $prodstatic->fetch($prodcomb->fk_product_child) > 0 && $prodstatic->delete() > 0) {
|
||||
$db->commit();
|
||||
setEventMessage($langs->trans('RecordSaved'));
|
||||
header('Location: '.dol_buildpath('/attributes/combinations.php?id='.$product->id, 2));
|
||||
header('Location: '.dol_buildpath('/variants/combinations.php?id='.$product->id, 2));
|
||||
die;
|
||||
}
|
||||
|
||||
|
|
@ -229,7 +229,7 @@ if ($action === 'confirm_deletecombination') {
|
|||
//To prevent from copying to the same product
|
||||
if ($prodstatic->ref != $product->ref) {
|
||||
if ($prodcomb->copyAll($product->id, $prodstatic) > 0) {
|
||||
header('Location: '.dol_buildpath('/attributes/combinations.php?id='.$prodstatic->id, 2));
|
||||
header('Location: '.dol_buildpath('/variants/combinations.php?id='.$prodstatic->id, 2));
|
||||
die;
|
||||
} else {
|
||||
setEventMessage($langs->trans('ErrorCopyProductCombinations'), 'errors');
|
||||
|
|
@ -313,8 +313,8 @@ if (! empty($id) || ! empty($ref)) {
|
|||
|
||||
<script>
|
||||
|
||||
attributes_available = <?php echo json_encode($prodattr_alljson) ?>;
|
||||
attributes_selected = {
|
||||
variants_available = <?php echo json_encode($prodattr_alljson) ?>;
|
||||
variants_selected = {
|
||||
index: [],
|
||||
info: []
|
||||
};
|
||||
|
|
@ -322,9 +322,9 @@ if (! empty($id) || ! empty($ref)) {
|
|||
<?php foreach ($productCombination2ValuePairs1 as $pc2v):
|
||||
$prodattr_val->fetch($pc2v->fk_prod_attr_val);
|
||||
?>
|
||||
attributes_selected.index.push(<?php echo $pc2v->fk_prod_attr ?>);
|
||||
attributes_selected.info[<?php echo $pc2v->fk_prod_attr ?>] = {
|
||||
attribute: attributes_available[<?php echo $pc2v->fk_prod_attr ?>],
|
||||
variants_selected.index.push(<?php echo $pc2v->fk_prod_attr ?>);
|
||||
variants_selected.info[<?php echo $pc2v->fk_prod_attr ?>] = {
|
||||
attribute: variants_available[<?php echo $pc2v->fk_prod_attr ?>],
|
||||
value: {
|
||||
id: <?php echo $pc2v->fk_prod_attr_val ?>,
|
||||
label: '<?php echo $prodattr_val->value ?>'
|
||||
|
|
@ -335,8 +335,8 @@ if (! empty($id) || ! empty($ref)) {
|
|||
restoreAttributes = function() {
|
||||
jQuery("select[name=attribute]").empty().append('<option value=""></option>');
|
||||
|
||||
jQuery.each(attributes_available, function (key, val) {
|
||||
if (jQuery.inArray(val.id, attributes_selected.index) == -1) {
|
||||
jQuery.each(variants_available, function (key, val) {
|
||||
if (jQuery.inArray(val.id, variants_selected.index) == -1) {
|
||||
jQuery("select[name=attribute]").append('<option value="' + val.id + '">' + val.label + '</option>');
|
||||
}
|
||||
});
|
||||
|
|
@ -348,8 +348,8 @@ if (! empty($id) || ! empty($ref)) {
|
|||
select.empty();
|
||||
jQuery("form#combinationform input[type=hidden]").detach();
|
||||
|
||||
jQuery.each(attributes_selected.index, function (key, val) {
|
||||
var attr_info = attributes_selected.info[val];
|
||||
jQuery.each(variants_selected.index, function (key, val) {
|
||||
var attr_info = variants_selected.info[val];
|
||||
|
||||
var opt_key = val + ':' + attr_info.value.id;
|
||||
var opt_label = attr_info.attribute.label + ': ' + attr_info.value.label;
|
||||
|
|
@ -374,7 +374,7 @@ if (! empty($id) || ! empty($ref)) {
|
|||
|
||||
select.empty().append('<option value="">Loading...</option>');
|
||||
|
||||
jQuery.getJSON("<?php echo dol_buildpath('/attributes/ajax/get_attribute_values.php', 2) ?>", {
|
||||
jQuery.getJSON("<?php echo dol_buildpath('/variants/ajax/get_attribute_values.php', 2) ?>", {
|
||||
id: jQuery(this).val()
|
||||
}, function(data) {
|
||||
if (data.error) {
|
||||
|
|
@ -400,13 +400,13 @@ if (! empty($id) || ! empty($ref)) {
|
|||
|
||||
var selectedattr_val = parseInt(selectedattr.val());
|
||||
|
||||
if (jQuery.inArray(selectedattr_val, attributes_selected.index) != -1) {
|
||||
if (jQuery.inArray(selectedattr_val, variants_selected.index) != -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
attributes_selected.index.push(selectedattr_val);
|
||||
attributes_selected.info[selectedattr_val] = {
|
||||
attribute: attributes_available[selectedattr_val],
|
||||
variants_selected.index.push(selectedattr_val);
|
||||
variants_selected.info[selectedattr_val] = {
|
||||
attribute: variants_available[selectedattr_val],
|
||||
value: {
|
||||
id: selectedvalu.val(),
|
||||
label: selectedvalu.html()
|
||||
|
|
@ -422,11 +422,11 @@ if (! empty($id) || ! empty($ref)) {
|
|||
jQuery("#delfeature").click(function() {
|
||||
jQuery("#features option:selected").each(function (key, val) {
|
||||
var explode = jQuery(val).val().split(':');
|
||||
var indexOf = attributes_selected.index.indexOf(parseInt(explode[0]));
|
||||
var indexOf = variants_selected.index.indexOf(parseInt(explode[0]));
|
||||
|
||||
if (indexOf != -1) {
|
||||
attributes_selected.index.splice(indexOf, 1);
|
||||
jQuery(attributes_selected.info[parseInt(explode[0])]).detach();
|
||||
variants_selected.index.splice(indexOf, 1);
|
||||
jQuery(variants_selected.info[parseInt(explode[0])]).detach();
|
||||
}
|
||||
|
||||
jQuery(val).detach();
|
||||
|
|
@ -505,7 +505,7 @@ if (! empty($id) || ! empty($ref)) {
|
|||
print $form->formconfirm(
|
||||
"combinations.php?id=".$id."&valueid=".$valueid,
|
||||
$langs->trans('Delete'),
|
||||
$langs->trans('ProductCombinationDeleteDialog', $prodstatic->getNomUrl(1)),
|
||||
$langs->trans('ProductCombinationDeleteDialog', $prodstatic->ref),
|
||||
"confirm_deletecombination",
|
||||
'',
|
||||
0,
|
||||
|
|
@ -568,7 +568,7 @@ if (! empty($id) || ! empty($ref)) {
|
|||
<option value="delete"><?php echo $langs->trans('Delete') ?></option>
|
||||
</select>
|
||||
<input type="hidden" name="action" value="bulk_actions">
|
||||
<input type="submit" value="Aplicar" class="button">
|
||||
<input type="submit" value="<?php echo $langs->trans("Apply") ?>" class="button">
|
||||
<br>
|
||||
<br>
|
||||
<?php endif; ?>
|
||||
|
|
@ -612,8 +612,8 @@ if (! empty($id) || ! empty($ref)) {
|
|||
<td style="text-align: center;"><?php echo $prodstatic->getLibStatut(2, 0) ?></td>
|
||||
<td style="text-align: center;"><?php echo $prodstatic->getLibStatut(2, 1) ?></td>
|
||||
<td style="text-align: right">
|
||||
<a href="<?php echo dol_buildpath('/attributes/combinations.php?id='.$id.'&action=edit&valueid='.$currcomb->id, 2) ?>"><?php echo img_edit() ?></a>
|
||||
<a href="<?php echo dol_buildpath('/attributes/combinations.php?id='.$id.'&action=delete&valueid='.$currcomb->id, 2) ?>"><?php echo img_delete() ?></a>
|
||||
<a href="<?php echo dol_buildpath('/variants/combinations.php?id='.$id.'&action=edit&valueid='.$currcomb->id, 2) ?>"><?php echo img_edit() ?></a>
|
||||
<a href="<?php echo dol_buildpath('/variants/combinations.php?id='.$id.'&action=delete&valueid='.$currcomb->id, 2) ?>"><?php echo img_delete() ?></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php $var = !$var; endforeach ?>
|
||||
|
|
@ -34,7 +34,7 @@ if ($_POST) {
|
|||
|
||||
if ($prodattr->create()) {
|
||||
setEventMessage($langs->trans('RecordSaved'));
|
||||
header('Location: '.dol_buildpath('/attributes/list.php', 2));
|
||||
header('Location: '.dol_buildpath('/variants/list.php', 2));
|
||||
} else {
|
||||
setEventMessage($langs->trans('ErrorRecordAlreadyExists'), 'errors');
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ if ($_POST) {
|
|||
|
||||
if ($prodattrval->create() > 0) {
|
||||
setEventMessage($langs->trans('RecordSaved'));
|
||||
header('Location: '.dol_buildpath('/attributes/card.php?id='.$prodattr->id, 2));
|
||||
header('Location: '.dol_buildpath('/variants/card.php?id='.$prodattr->id, 2));
|
||||
die;
|
||||
} else {
|
||||
setEventMessage($langs->trans('ErrorCreatingProductAttributeValue'), 'errors');
|
||||
|
|
@ -19,10 +19,10 @@
|
|||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductAttribute.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductAttributeValue.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductCombination.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/attributes/class/ProductCombination2ValuePair.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttribute.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttributeValue.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination2ValuePair.class.php';
|
||||
|
||||
$langs->load("products");
|
||||
$langs->load('other');
|
||||
|
|
@ -103,22 +103,21 @@ if ($_POST) {
|
|||
|
||||
$res = 1;
|
||||
|
||||
foreach (cartesianArray($adapted_values) as $currcomb) {
|
||||
|
||||
$res = ProductCombination::createProductCombination($product, $currcomb, $sanitized_values, $price_var_percent);
|
||||
|
||||
foreach (cartesianArray($adapted_values) as $currcomb)
|
||||
{
|
||||
$res = $combination->createProductCombination($product, $currcomb, $sanitized_values, $price_var_percent);
|
||||
if ($res < 0) {
|
||||
break;
|
||||
$error++;
|
||||
setEventMessages($combination->error, $combination->errors, 'errors');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($res > 0) {
|
||||
$db->commit();
|
||||
setEventMessage($langs->trans('RecordSaved'));
|
||||
header('Location: '.dol_buildpath('/attributes/combinations.php?id='.$id, 2));
|
||||
die;
|
||||
} else {
|
||||
setEventMessage($langs->trans('CoreErrorMessage'), 'errors');
|
||||
header('Location: '.dol_buildpath('/variants/combinations.php?id='.$id, 2));
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
setEventMessage($langs->trans('ErrorDeletingGeneratedProducts'), 'errors');
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
|
||||
/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -17,12 +16,18 @@
|
|||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
require 'class/ProductAttribute.class.php';
|
||||
require DOL_DOCUMENT_ROOT.'/variants/class/ProductAttribute.class.php';
|
||||
|
||||
$rowid = GETPOST('rowid');
|
||||
$action = GETPOST('action');
|
||||
$object = new ProductAttribute($db);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'up') {
|
||||
$object->fetch($rowid);
|
||||
$object->moveUp();
|
||||
|
|
@ -37,12 +42,18 @@ if ($action == 'up') {
|
|||
die;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$langs->load('products');
|
||||
|
||||
$var = false;
|
||||
$title = $langs->trans($langs->trans('ProductAttributes'));
|
||||
|
||||
$attributes = $object->fetchAll();
|
||||
$variants = $object->fetchAll();
|
||||
|
||||
llxHeader('', $title);
|
||||
|
||||
|
|
@ -71,7 +82,7 @@ $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
|
|||
console.log('drop');
|
||||
var reloadpage = "<?php echo $forcereloadpage; ?>";
|
||||
var roworder = cleanSerialize($("#tablelines").tableDnDSerialize());
|
||||
$.post("<?php echo DOL_URL_ROOT; ?>/attributes/ajax/orderAttribute.php",
|
||||
$.post("<?php echo DOL_URL_ROOT; ?>/variants/ajax/orderAttribute.php",
|
||||
{
|
||||
roworder: roworder
|
||||
},
|
||||
|
|
@ -101,7 +112,7 @@ $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
|
|||
<th class="liste_titre"><?php print $langs->trans('NbProducts') ?></th>
|
||||
<th class="liste_titre" colspan="2"></th>
|
||||
</tr>
|
||||
<?php foreach ($attributes as $key => $attribute): ?>
|
||||
<?php foreach ($variants as $key => $attribute): ?>
|
||||
<tr id="row-<?php echo $attribute->id ?>" <?php echo $bcdd[$var] ?>>
|
||||
<td><a href="card.php?id=<?php echo $attribute->id ?>"><?php echo dol_htmlentities($attribute->ref) ?></a></td>
|
||||
<td><a href="card.php?id=<?php echo $attribute->id ?>"><?php echo dol_htmlentities($attribute->label) ?></a></td>
|
||||
|
|
@ -115,7 +126,7 @@ $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
|
|||
<a class="lineupdown"
|
||||
href="<?php echo $_SERVER['PHP_SELF'] ?>?action=up&rowid=<?php echo $attribute->id ?>"><?php echo img_up('default', 0, 'imgupforline'); ?></a>
|
||||
<?php endif ?>
|
||||
<?php if ($key < count($attributes)-1): ?>
|
||||
<?php if ($key < count($variants)-1): ?>
|
||||
<a class="lineupdown"
|
||||
href="<?php echo $_SERVER['PHP_SELF'] ?>?action=down&rowid=<?php echo $attribute->id ?>"><?php echo img_down('default', 0, 'imgdownforline'); ?></a>
|
||||
<?php endif ?>
|
||||
|
|
@ -128,8 +139,6 @@ $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
|
|||
|
||||
</table>
|
||||
|
||||
<br>
|
||||
|
||||
<div class="tabsAction">
|
||||
<div class="inline-block divButAction">
|
||||
<a href="create.php" class="butAction"><?php echo $langs->trans('Create') ?></a>
|
||||
Loading…
Reference in New Issue
Block a user