forked from Wavyzz/dolibarr
NEW Introduce option MAIN_WEIGHT_DEFAULT_UNIT and
MAIN_VOLUME_DEFAULT_UNIT to force output unit for weight and volume.
This commit is contained in:
@@ -1997,6 +1997,19 @@ if ($action == 'create' && $user->rights->commande->creer)
|
|||||||
}
|
}
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
if ($soc->outstanding_limit)
|
||||||
|
{
|
||||||
|
// Outstanding Bill
|
||||||
|
print '<tr><td>';
|
||||||
|
print $langs->trans('OutstandingBill');
|
||||||
|
print '</td><td colspan="3">';
|
||||||
|
print price($soc->get_OutstandingBill()) . ' / ';
|
||||||
|
print price($soc->outstanding_limit, 0, '', 1, - 1, - 1, $conf->currency);
|
||||||
|
print '</td>';
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Relative and absolute discounts
|
||||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||||
$filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final
|
$filterabsolutediscount = "fk_facture_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final
|
||||||
// invoice
|
// invoice
|
||||||
@@ -2006,7 +2019,6 @@ if ($action == 'create' && $user->rights->commande->creer)
|
|||||||
$filtercreditnote = "fk_facture_source IS NOT NULL AND description <> '(DEPOSIT)'";
|
$filtercreditnote = "fk_facture_source IS NOT NULL AND description <> '(DEPOSIT)'";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Relative and absolute discounts
|
|
||||||
$addrelativediscount = '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("EditRelativeDiscounts") . '</a>';
|
$addrelativediscount = '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("EditRelativeDiscounts") . '</a>';
|
||||||
$addabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("EditGlobalDiscounts") . '</a>';
|
$addabsolutediscount = '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("EditGlobalDiscounts") . '</a>';
|
||||||
$addcreditnote = '<a href="' . DOL_URL_ROOT . '/compta/facture.php?action=create&socid=' . $soc->id . '&type=2&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("AddCreditNote") . '</a>';
|
$addcreditnote = '<a href="' . DOL_URL_ROOT . '/compta/facture.php?action=create&socid=' . $soc->id . '&type=2&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("AddCreditNote") . '</a>';
|
||||||
@@ -2236,6 +2248,19 @@ if ($action == 'create' && $user->rights->commande->creer)
|
|||||||
// print '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=22&origin=order&originid='.$object->id.'">'.$langs->trans("DictionarySource").'</a>';
|
// print '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=22&origin=order&originid='.$object->id.'">'.$langs->trans("DictionarySource").'</a>';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
|
$tmparray=$object->getTotalWeightVolume();
|
||||||
|
$totalWeight=$tmparray['weight'];
|
||||||
|
$totalVolume=$tmparray['volume'];
|
||||||
|
if ($totalWeight || $totalVolume)
|
||||||
|
{
|
||||||
|
print '<tr><td>'.$langs->trans("CalculatedWeight").' / '.$langs->trans("CalculatedVolume").'</td>';
|
||||||
|
print '<td colspan="3">';
|
||||||
|
print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no');
|
||||||
|
print ' / ';
|
||||||
|
print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no');
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
// TODO How record was recorded OrderMode (llx_c_input_method)
|
// TODO How record was recorded OrderMode (llx_c_input_method)
|
||||||
|
|
||||||
// Project
|
// Project
|
||||||
@@ -2259,18 +2284,6 @@ if ($action == 'create' && $user->rights->commande->creer)
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($soc->outstanding_limit)
|
|
||||||
{
|
|
||||||
// Outstanding Bill
|
|
||||||
print '<tr><td>';
|
|
||||||
print $langs->trans('OutstandingBill');
|
|
||||||
print '</td><td align=right colspan=3>';
|
|
||||||
print price($soc->get_OutstandingBill()) . ' / ';
|
|
||||||
print price($soc->outstanding_limit, 0, '', 1, - 1, - 1, $conf->currency);
|
|
||||||
print '</td>';
|
|
||||||
print '</tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Incoterms
|
// Incoterms
|
||||||
if (!empty($conf->incoterm->enabled))
|
if (!empty($conf->incoterm->enabled))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1718,7 +1718,8 @@ class Commande extends CommonOrder
|
|||||||
$sql.= ' l.total_ht, l.total_ttc, l.total_tva, l.total_localtax1, l.total_localtax2, l.date_start, l.date_end,';
|
$sql.= ' l.total_ht, l.total_ttc, l.total_tva, l.total_localtax1, l.total_localtax2, l.date_start, l.date_end,';
|
||||||
$sql.= ' l.fk_unit,';
|
$sql.= ' l.fk_unit,';
|
||||||
$sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,';
|
$sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,';
|
||||||
$sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label';
|
$sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,';
|
||||||
|
$sql.= ' p.weight, p.weight_units, p.volume, p.volume_units';
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l';
|
||||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (p.rowid = l.fk_product)';
|
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (p.rowid = l.fk_product)';
|
||||||
$sql.= ' WHERE l.fk_commande = '.$this->id;
|
$sql.= ' WHERE l.fk_commande = '.$this->id;
|
||||||
@@ -1778,6 +1779,11 @@ class Commande extends CommonOrder
|
|||||||
$line->fk_product_type = $objp->fk_product_type; // Produit ou service
|
$line->fk_product_type = $objp->fk_product_type; // Produit ou service
|
||||||
$line->fk_unit = $objp->fk_unit;
|
$line->fk_unit = $objp->fk_unit;
|
||||||
|
|
||||||
|
$line->weight = $objp->weight;
|
||||||
|
$line->weight_units = $objp->weight_units;
|
||||||
|
$line->volume = $objp->volume;
|
||||||
|
$line->volume_units = $objp->volume_units;
|
||||||
|
|
||||||
$line->date_start = $this->db->jdate($objp->date_start);
|
$line->date_start = $this->db->jdate($objp->date_start);
|
||||||
$line->date_end = $this->db->jdate($objp->date_end);
|
$line->date_end = $this->db->jdate($objp->date_end);
|
||||||
|
|
||||||
|
|||||||
@@ -2939,6 +2939,68 @@ abstract class CommonObject
|
|||||||
return price2num($total_discount);
|
return price2num($total_discount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return into unit=0, the calculated total of weight and volume of all lines * qty
|
||||||
|
* Calculate by adding weight and volume of each product line, so properties ->volume/volume_units/weight/weight_units must be loaded on line.
|
||||||
|
*
|
||||||
|
* @return array array('weight'=>...,'volume'=>...)
|
||||||
|
*/
|
||||||
|
function getTotalWeightVolume()
|
||||||
|
{
|
||||||
|
$weightUnit=0;
|
||||||
|
$volumeUnit=0;
|
||||||
|
$totalWeight = '';
|
||||||
|
$totalVolume = '';
|
||||||
|
$totalOrdered = ''; // defined for shipment only
|
||||||
|
$totalToShip = ''; // defined for shipment only
|
||||||
|
|
||||||
|
foreach ($this->lines as $line)
|
||||||
|
{
|
||||||
|
|
||||||
|
$totalOrdered+=$line->qty_asked; // defined for shipment only
|
||||||
|
$totalToShip+=$line->qty_shipped; // defined for shipment only
|
||||||
|
|
||||||
|
// Define qty, weight, volume, weight_units, volume_units
|
||||||
|
if ($this->element == 'shipping') $qty=$line->qty_shipped; // for shipments
|
||||||
|
else $qty=$line->qty;
|
||||||
|
$weight=$line->weight;
|
||||||
|
$volume=$line->volume;
|
||||||
|
$weight_units=$line->weight_units;
|
||||||
|
$volume_units=$line->volume_units;
|
||||||
|
|
||||||
|
$weightUnit=0;
|
||||||
|
$volumeUnit=0;
|
||||||
|
if (! empty($weight_units)) $weightUnit = $weight_units;
|
||||||
|
if (! empty($volume_units)) $volumeUnit = $volume_units;
|
||||||
|
|
||||||
|
//var_dump($line->volume_units);
|
||||||
|
if ($weight_units < 50) // >50 means a standard unit (power of 10 of official unit) > 50 means an exotic unit (like inch)
|
||||||
|
{
|
||||||
|
$trueWeightUnit=pow(10, $weightUnit);
|
||||||
|
$totalWeight += $weight * $qty * $trueWeightUnit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$totalWeight += $weight * $qty; // This may be wrong if we mix different units
|
||||||
|
}
|
||||||
|
if ($volume_units < 50) // >50 means a standard unit (power of 10 of official unit) > 50 means an exotic unit (like inch)
|
||||||
|
{
|
||||||
|
//print $line->volume."x".$line->volume_units."x".($line->volume_units < 50)."x".$volumeUnit;
|
||||||
|
$trueVolumeUnit=pow(10, $volumeUnit);
|
||||||
|
//print $line->volume;
|
||||||
|
$totalVolume += $volume * $qty * $trueVolumeUnit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$totalVolume += $volume * $qty; // This may be wrong if we mix different units
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return array('weight'=>$totalWeight, 'volume'=>$totalVolume, 'ordered'=>$totalOrdered, 'toship'=>$totalToShip);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set extra parameters
|
* Set extra parameters
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -25,8 +25,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php';
|
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobjectline.class.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class CommonOrder
|
* Superclass for orders classes
|
||||||
* \brief Superclass for orders classes
|
|
||||||
*/
|
*/
|
||||||
abstract class CommonOrder extends CommonObject
|
abstract class CommonOrder extends CommonObject
|
||||||
{
|
{
|
||||||
@@ -34,8 +33,7 @@ abstract class CommonOrder extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class CommonOrderLine
|
* Superclass for orders classes
|
||||||
* \brief Superclass for orders classes
|
|
||||||
*/
|
*/
|
||||||
abstract class CommonOrderLine extends CommonObjectLine
|
abstract class CommonOrderLine extends CommonObjectLine
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3420,28 +3420,29 @@ function price2num($amount,$rounding='',$alreadysqlnb=0)
|
|||||||
* @param string $type 'weight', 'volume', ...
|
* @param string $type 'weight', 'volume', ...
|
||||||
* @param Translate $outputlangs Translate language object
|
* @param Translate $outputlangs Translate language object
|
||||||
* @param int $round -1 = non rounding, x = number of decimal
|
* @param int $round -1 = non rounding, x = number of decimal
|
||||||
|
* @param string $forceunitoutput 'no' or numeric (-3, -6, ...) compared to $unit
|
||||||
* @return string String to show dimensions
|
* @return string String to show dimensions
|
||||||
*/
|
*/
|
||||||
function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1)
|
function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitouput='no')
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
|
||||||
|
|
||||||
if ($dimension < 1/10000)
|
if (($forceunitouput == 'no' && $dimension < 1/10000) || (is_numeric($forceunitouput) && $forceunitouput == -6))
|
||||||
{
|
{
|
||||||
$dimension = $dimension * 1000000;
|
$dimension = $dimension * 1000000;
|
||||||
$unit = $unit - 6;
|
$unit = $unit - 6;
|
||||||
}
|
}
|
||||||
elseif ($dimension < 1/10)
|
elseif (($forceunitouput == 'no' && $dimension < 1/10) || (is_numeric($forceunitouput) && $forceunitouput == -3))
|
||||||
{
|
{
|
||||||
$dimension = $dimension * 1000;
|
$dimension = $dimension * 1000;
|
||||||
$unit = $unit - 3;
|
$unit = $unit - 3;
|
||||||
}
|
}
|
||||||
elseif ($dimension > 100000000)
|
elseif (($forceunitouput == 'no' && $dimension > 100000000) || (is_numeric($forceunitouput) && $forceunitouput == 6))
|
||||||
{
|
{
|
||||||
$dimension = $dimension / 1000000;
|
$dimension = $dimension / 1000000;
|
||||||
$unit = $unit + 6;
|
$unit = $unit + 6;
|
||||||
}
|
}
|
||||||
elseif ($dimension > 100000)
|
elseif (($forceunitouput == 'no' && $dimension > 100000) || (is_numeric($forceunitouput) && $forceunitouput == 3))
|
||||||
{
|
{
|
||||||
$dimension = $dimension / 1000;
|
$dimension = $dimension / 1000;
|
||||||
$unit = $unit + 3;
|
$unit = $unit + 3;
|
||||||
|
|||||||
@@ -1373,7 +1373,7 @@ else if ($id || $ref)
|
|||||||
{
|
{
|
||||||
if (!empty($object->trueWeight)) print ' ('.$langs->trans("SumOfProductWeights").': ';
|
if (!empty($object->trueWeight)) print ' ('.$langs->trans("SumOfProductWeights").': ';
|
||||||
//print $totalWeight.' '.measuring_units_string(0,"weight");
|
//print $totalWeight.' '.measuring_units_string(0,"weight");
|
||||||
print showDimensionInBestUnit($totalWeight, 0, "weight", $langs);
|
print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no');
|
||||||
//if (empty($object->trueWeight)) print ' ('.$langs->trans("Calculated").')';
|
//if (empty($object->trueWeight)) print ' ('.$langs->trans("Calculated").')';
|
||||||
if (!empty($object->trueWeight)) print ')';
|
if (!empty($object->trueWeight)) print ')';
|
||||||
}
|
}
|
||||||
@@ -1432,7 +1432,7 @@ else if ($id || $ref)
|
|||||||
if ($volumeUnit < 50)
|
if ($volumeUnit < 50)
|
||||||
{
|
{
|
||||||
//print $calculatedVolume.' '.measuring_units_string($volumeUnit,"volume");
|
//print $calculatedVolume.' '.measuring_units_string($volumeUnit,"volume");
|
||||||
print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs);
|
print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no');
|
||||||
}
|
}
|
||||||
else print $calculatedVolume.' '.measuring_units_string($volumeUnit,"volume");
|
else print $calculatedVolume.' '.measuring_units_string($volumeUnit,"volume");
|
||||||
}
|
}
|
||||||
@@ -1440,7 +1440,7 @@ else if ($id || $ref)
|
|||||||
{
|
{
|
||||||
if ($calculatedVolume) print ' ('.$langs->trans("SumOfProductVolumes").': ';
|
if ($calculatedVolume) print ' ('.$langs->trans("SumOfProductVolumes").': ';
|
||||||
//print $totalVolume.' '.measuring_units_string(0,"volume");
|
//print $totalVolume.' '.measuring_units_string(0,"volume");
|
||||||
print showDimensionInBestUnit($totalVolume, 0, "volume", $langs);
|
print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no');
|
||||||
//if (empty($calculatedVolume)) print ' ('.$langs->trans("Calculated").')';
|
//if (empty($calculatedVolume)) print ' ('.$langs->trans("Calculated").')';
|
||||||
if ($calculatedVolume) print ')';
|
if ($calculatedVolume) print ')';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1758,56 +1758,6 @@ class Expedition extends CommonObject
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return into unit=0, the calculated total of weight and volume of all lines * qty
|
|
||||||
* Calculate by adding weight and volume of each product line.
|
|
||||||
*
|
|
||||||
* @return array array('weight'=>...,'volume'=>...)
|
|
||||||
*/
|
|
||||||
function getTotalWeightVolume()
|
|
||||||
{
|
|
||||||
$weightUnit=0;
|
|
||||||
$volumeUnit=0;
|
|
||||||
$totalWeight = '';
|
|
||||||
$totalVolume = '';
|
|
||||||
$totalOrdered = '';
|
|
||||||
$totalToShip = '';
|
|
||||||
foreach ($this->lines as $line)
|
|
||||||
{
|
|
||||||
$totalOrdered+=$line->qty_asked;
|
|
||||||
$totalToShip+=$line->qty_shipped;
|
|
||||||
|
|
||||||
$weightUnit=0;
|
|
||||||
$volumeUnit=0;
|
|
||||||
if (! empty($line->weight_units)) $weightUnit = $line->weight_units;
|
|
||||||
if (! empty($line->volume_units)) $volumeUnit = $line->volume_units;
|
|
||||||
|
|
||||||
//var_dump($line->volume_units);
|
|
||||||
if ($line->weight_units < 50) // >50 means a standard unit (power of 10 of official unit) > 50 means an exotic unit (like inch)
|
|
||||||
{
|
|
||||||
$trueWeightUnit=pow(10,$weightUnit);
|
|
||||||
$totalWeight += $line->weight*$line->qty_shipped*$trueWeightUnit;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$totalWeight += $line->weight*$line->qty_shipped; // This may be wrong if we mix different units
|
|
||||||
}
|
|
||||||
if ($line->volume_units < 50) // >50 means a standard unit (power of 10 of official unit) > 50 means an exotic unit (like inch)
|
|
||||||
{
|
|
||||||
//print $line->volume."x".$line->volume_units."x".($line->volume_units < 50)."x".$volumeUnit;
|
|
||||||
$trueVolumeUnit=pow(10,$volumeUnit);
|
|
||||||
//print $line->volume;
|
|
||||||
$totalVolume += $line->volume*$line->qty_shipped*$trueVolumeUnit;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$totalVolume += $line->volume*$line->qty_shipped; // This may be wrong if we mix different units
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return array('weight'=>$totalWeight, 'volume'=>$totalVolume, 'ordered'=>$totalOrdered, 'toship'=>$totalToShip);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forge an set tracking url
|
* Forge an set tracking url
|
||||||
|
|||||||
Reference in New Issue
Block a user