diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 330349b0842..195b59ed85d 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -151,7 +151,7 @@ class modProduct extends DolibarrModules $this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_label[$r]="Products"; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("produit","export")); - $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode','p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification'); + $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.width'=>"Width",'p.height'=>"Height",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode','p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification'); if ($mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly']='NPR'; if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.barcode'=>'BarCode')); @@ -159,13 +159,13 @@ class modProduct extends DolibarrModules if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('p.cost_price'=>'CostPrice')); if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('group_concat(cat.label)'=>'Categories')); if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r],array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel','l.description'=>'TranslatedDescription','l.note'=>'TranslatedNote')); - $this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date'); + $this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.length'=>"Numeric",'p.width'=>"Numeric",'p.height'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date'); if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('p.barcode'=>'Text')); if (! empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('s.nom'=>'Text','pf.ref_fourn'=>'Text','pf.unitprice'=>'Numeric')); if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array('l.lang'=>'Text', 'l.label'=>'Text','l.description'=>'Text','l.note'=>'Text')); if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r],array("group_concat(cat.label)"=>'Text')); - $this->export_entities_array[$r]=array('p.rowid'=>"product",'p.ref'=>"product",'p.label'=>"product",'p.description'=>"product",'p.url'=>"product",'p.accountancy_code_sell'=>'product','p.accountancy_code_sell'=>'product','p.note'=>"product",'p.length'=>"product",'p.surface'=>"product",'p.volume'=>"product",'p.weight'=>"product",'p.customcode'=>'product','p.price_base_type'=>"product",'p.price'=>"product",'p.price_ttc'=>"product",'p.tva_tx'=>"product",'p.tosell'=>"product",'p.tobuy'=>"product",'p.datec'=>"product",'p.tms'=>"product"); + $this->export_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array("group_concat(cat.label)"=>'category')); if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.stock'=>'product','p.pmp'=>'product')); if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r],array('p.barcode'=>'product')); diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 19e79408e4e..5a7158cd190 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -284,10 +284,8 @@ if (empty($reshook)) $object->length = GETPOST('size'); $object->length_units = GETPOST('size_units'); $object->width = GETPOST('sizewidth'); - $object->width_units = GETPOST('sizewidth_units'); $object->height = GETPOST('sizeheight'); - $object->height_units = GETPOST('sizeheight_units'); - $object->surface = GETPOST('surface'); + $object->surface = GETPOST('surface'); $object->surface_units = GETPOST('surface_units'); $object->volume = GETPOST('volume'); $object->volume_units = GETPOST('volume_units'); @@ -385,9 +383,7 @@ if (empty($reshook)) $object->length = GETPOST('size'); $object->length_units = GETPOST('size_units'); $object->width = GETPOST('sizewidth'); - $object->width_units = GETPOST('sizewidth_units'); $object->height = GETPOST('sizeheight'); - $object->height_units = GETPOST('sizeheight_units'); $object->surface = GETPOST('surface'); $object->surface_units = GETPOST('surface_units'); @@ -1021,21 +1017,12 @@ else // Length if (empty($conf->global->PRODUCT_DISABLE_SIZE)) { - print ''.$langs->trans("Length").''; - print ''; + print ''.$langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").''; + print ' x '; + print ' x '; + print ''; print $formproduct->select_measuring_units("size_units","size"); print ''; - - print ''.$langs->trans("Width").''; - print ''; - print $formproduct->select_measuring_units("sizewidth_units","size"); - print ''; - - print ''.$langs->trans("Height").''; - print ''; - print $formproduct->select_measuring_units("sizeheight_units","size"); - print ''; - } if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) { @@ -1346,21 +1333,13 @@ else print ''; if (empty($conf->global->PRODUCT_DISABLE_SIZE)) { - // Length - print ''.$langs->trans("Length").''; - print ' '; - print $formproduct->select_measuring_units("size_units", "size", $object->length_units); - print ''; - - print ''.$langs->trans("Width").''; - print ' '; - print $formproduct->select_measuring_units("sizewidth_units","size", $object->width_units); - print ''; - - print ''.$langs->trans("Height").''; - print ' '; - print $formproduct->select_measuring_units("sizeheight_units","size", $object->height_units); - print ''; + // Length + print ''.$langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").''; + print 'x'; + print 'x'; + print ' '; + print $formproduct->select_measuring_units("size_units", "size", $object->length_units); + print ''; } if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) { @@ -1370,11 +1349,14 @@ else print $formproduct->select_measuring_units("surface_units", "surface", $object->surface_units); print ''; } - // Volume - print ''.$langs->trans("Volume").''; - print ' '; - print $formproduct->select_measuring_units("volume_units", "volume", $object->volume_units); - print ''; + if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) + { + // Volume + print ''.$langs->trans("Volume").''; + print ' '; + print $formproduct->select_measuring_units("volume_units", "volume", $object->volume_units); + print ''; + } } // Units if($conf->global->PRODUCT_USE_UNITS) @@ -1668,32 +1650,19 @@ else if (empty($conf->global->PRODUCT_DISABLE_SIZE)) { // Length - print ''.$langs->trans("Length").''; - if ($object->length != '') + print ''.$langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").''; + if ($object->length != '' || $object->width != '' || $object->height != '') { - print $object->length." ".measuring_units_string($object->length_units,"size"); + print $object->length; + if ($object->width) print " x ".$object->width; + if ($object->height) print " x ".$object->height; + print ' '.measuring_units_string($object->length_units,"size"); } else { print ' '; } print "\n"; - - print ''.$langs->trans("Width").''; - if ($object->width != '') { - print $object->width." ".measuring_units_string($object->width_units,"size"); - } - else - print ' '; - print "\n"; - - print ''.$langs->trans("Height").''; - if ($object->height != '') { - print $object->height." ".measuring_units_string($object->height_units,"size"); - } - else - print ' '; - print "\n"; } if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) { @@ -1709,17 +1678,20 @@ else } print "\n"; } - // Volume - print ''.$langs->trans("Volume").''; - if ($object->volume != '') + if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) { - print $object->volume." ".measuring_units_string($object->volume_units,"volume"); + // Volume + print ''.$langs->trans("Volume").''; + if ($object->volume != '') + { + print $object->volume." ".measuring_units_string($object->volume_units,"volume"); + } + else + { + print ' '; + } + print "\n"; } - else - { - print ' '; - } - print "\n"; } // Unit diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index f7e3881108a..27fb4a4c11c 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -640,15 +640,16 @@ class Product extends CommonObject $this->width_units = trim($this->width_units); $this->height = price2num($this->height); $this->height_units = trim($this->height_units); + // set unit not defined + if (! $this->width_units && $this->length_units) $this->width_units = $this->length_units; // Not used yet + if (! $this->height_units && $this->length_units) $this->height_units = $this->length_units; // Not used yet // Automated compute surface and volume if not filled - if (empty($this->surface) && !empty($this->length) && !empty($this->width) - && $this->length_units == $this->with_units - ) { + if (empty($this->surface) && !empty($this->length) && !empty($this->width) && $this->length_units == $this->width_units) + { $this->surface = $this->length * $this->width; $this->surface_units = $this->width_units; - if (empty($this->volume) && !empty($this->height) - && $this->length_units == $this->height_units - ) { + if (empty($this->volume) && !empty($this->height) && $this->length_units == $this->height_units) + { $this->volume = $this->surface * $this->height; $this->volume_units = $this->height_units; }