Merge pull request #6114 from defrance/patch-52

NEW Allow to change heigth and width on product
This commit is contained in:
Laurent Destailleur 2017-01-16 10:19:47 +01:00 committed by GitHub
commit 81d76f8600
2 changed files with 85 additions and 11 deletions

View File

@ -283,7 +283,11 @@ if (empty($reshook))
$object->weight_units = GETPOST('weight_units');
$object->length = GETPOST('size');
$object->length_units = GETPOST('size_units');
$object->surface = GETPOST('surface');
$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');
$object->volume = GETPOST('volume');
$object->volume_units = GETPOST('volume_units');
@ -380,6 +384,11 @@ if (empty($reshook))
$object->weight_units = GETPOST('weight_units');
$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');
$object->volume = GETPOST('volume');
@ -1010,12 +1019,23 @@ else
print $formproduct->select_measuring_units("weight_units","weight");
print '</td></tr>';
// Length
if (empty($conf->global->PRODUCT_DISABLE_LENGTH))
if (empty($conf->global->PRODUCT_DISABLE_SIZE))
{
print '<tr><td>'.$langs->trans("Length").'</td><td colspan="3">';
print '<input name="size" size="4" value="'.GETPOST('size').'">';
print $formproduct->select_measuring_units("size_units","size");
print '</td></tr>';
print '<tr><td>'.$langs->trans("Width").'</td><td colspan="3">';
print '<input name="sizewidth" size="4" value="'.GETPOST('sizewidth').'">';
print $formproduct->select_measuring_units("sizewidth_units","size");
print '</td></tr>';
print '<tr><td>'.$langs->trans("Height").'</td><td colspan="3">';
print '<input name="sizeheight" size="4" value="'.GETPOST('sizeheight').'">';
print $formproduct->select_measuring_units("sizeheight_units","size");
print '</td></tr>';
}
if (empty($conf->global->PRODUCT_DISABLE_SURFACE))
{
@ -1324,13 +1344,23 @@ else
print '<input name="weight" size="5" value="'.$object->weight.'"> ';
print $formproduct->select_measuring_units("weight_units", "weight", $object->weight_units);
print '</td></tr>';
if (empty($conf->global->PRODUCT_DISABLE_LENGTH))
if (empty($conf->global->PRODUCT_DISABLE_SIZE))
{
// Length
print '<tr><td>'.$langs->trans("Length").'</td><td colspan="3">';
print '<input name="size" size="5" value="'.$object->length.'"> ';
print $formproduct->select_measuring_units("size_units", "size", $object->length_units);
print '</td></tr>';
// Length
print '<tr><td>'.$langs->trans("Length").'</td><td colspan="3">';
print '<input name="size" size="5" value="'.$object->length.'"> ';
print $formproduct->select_measuring_units("size_units", "size", $object->length_units);
print '</td></tr>';
print '<tr><td>'.$langs->trans("Width").'</td><td colspan="3">';
print '<input name="sizewidth" size="5" value="'.$object->width.'"> ';
print $formproduct->select_measuring_units("sizewidth_units","size", $object->width_units);
print '</td></tr>';
print '<tr><td>'.$langs->trans("Height").'</td><td colspan="3">';
print '<input name="sizeheight" size="5" value="'.$object->height.'"> ';
print $formproduct->select_measuring_units("sizeheight_units","size", $object->height_units);
print '</td></tr>';
}
if (empty($conf->global->PRODUCT_DISABLE_SURFACE))
{
@ -1635,7 +1665,7 @@ else
print '&nbsp;';
}
print "</td></tr>\n";
if (empty($conf->global->PRODUCT_DISABLE_LENGTH))
if (empty($conf->global->PRODUCT_DISABLE_SIZE))
{
// Length
print '<tr><td>'.$langs->trans("Length").'</td><td colspan="2">';
@ -1648,6 +1678,22 @@ else
print '&nbsp;';
}
print "</td></tr>\n";
print '<tr><td>'.$langs->trans("Width").'</td><td colspan="2">';
if ($object->width != '') {
print $object->width." ".measuring_units_string($object->width_units,"size");
}
else
print '&nbsp;';
print "</td></tr>\n";
print '<tr><td>'.$langs->trans("Height").'</td><td colspan="2">';
if ($object->height != '') {
print $object->height." ".measuring_units_string($object->height_units,"size");
}
else
print '&nbsp;';
print "</td></tr>\n";
}
if (empty($conf->global->PRODUCT_DISABLE_SURFACE))
{

View File

@ -636,6 +636,24 @@ class Product extends CommonObject
$this->weight_units = trim($this->weight_units);
$this->length = price2num($this->length);
$this->length_units = trim($this->length_units);
$this->width = price2num($this->width);
$this->width_units = trim($this->width_units);
$this->height = price2num($this->height);
$this->height_units = trim($this->height_units);
// Automated compute surface and volume if not filled
if (empty($this->surface) && !empty($this->length) && !empty($this->width)
&& $this->length_units == $this->with_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
) {
$this->volume = $this->surface * $this->height;
$this->volume_units = $this->height_units;
}
}
$this->surface = price2num($this->surface);
$this->surface_units = trim($this->surface_units);
$this->volume = price2num($this->volume);
@ -750,6 +768,10 @@ class Product extends CommonObject
$sql.= ", weight_units = " . ($this->weight_units!='' ? "'".$this->weight_units."'": 'null');
$sql.= ", length = " . ($this->length!='' ? "'".$this->length."'" : 'null');
$sql.= ", length_units = " . ($this->length_units!='' ? "'".$this->length_units."'" : 'null');
$sql.= ", width= " . ($this->width!='' ? "'".$this->width."'" : 'null');
$sql.= ", width_units = " . ($this->width_units!='' ? "'".$this->width_units."'" : 'null');
$sql.= ", height = " . ($this->height!='' ? "'".$this->height."'" : 'null');
$sql.= ", height_units = " . ($this->height_units!='' ? "'".$this->height_units."'" : 'null');
$sql.= ", surface = " . ($this->surface!='' ? "'".$this->surface."'" : 'null');
$sql.= ", surface_units = " . ($this->surface_units!='' ? "'".$this->surface_units."'" : 'null');
$sql.= ", volume = " . ($this->volume!='' ? "'".$this->volume."'" : 'null');
@ -1673,8 +1695,9 @@ class Product extends CommonObject
$sql = "SELECT rowid, ref, ref_ext, label, description, url, note as note_private, customcode, fk_country, price, price_ttc,";
$sql.= " price_min, price_min_ttc, price_base_type, cost_price, default_vat_code, tva_tx, recuperableonly as tva_npr, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, tosell,";
$sql.= " tobuy, fk_product_type, duration, seuil_stock_alerte, canvas,";
$sql.= " weight, weight_units, length, length_units, surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,";
$sql.= " tobuy, fk_product_type, duration, seuil_stock_alerte, canvas, weight, weight_units,";
$sql.= " length, length_units, width, width_units, height, height_units,";
$sql.= " surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,";
$sql.= " accountancy_code_buy, accountancy_code_sell, stock, pmp,";
$sql.= " datec, tms, import_key, entity, desiredstock, tobatch, fk_unit,";
$sql.= " fk_price_expression, price_autogen";
@ -1736,6 +1759,11 @@ class Product extends CommonObject
$this->weight_units = $obj->weight_units;
$this->length = $obj->length;
$this->length_units = $obj->length_units;
$this->width = $obj->width;
$this->width_units = $obj->width_units;
$this->height = $obj->height;
$this->height_units = $obj->height_units;
$this->surface = $obj->surface;
$this->surface_units = $obj->surface_units;
$this->volume = $obj->volume;