Fix: Some fix in volume calculation
This commit is contained in:
parent
7386dc3aef
commit
46976bd009
@ -709,12 +709,12 @@ class Expedition extends CommonObject
|
|||||||
$sql.= " fk_expedition_methode=".((isset($this->expedition_method_id) && $this->expedition_method_id > 0)?$this->expedition_method_id:"null").",";
|
$sql.= " fk_expedition_methode=".((isset($this->expedition_method_id) && $this->expedition_method_id > 0)?$this->expedition_method_id:"null").",";
|
||||||
$sql.= " tracking_number=".(isset($this->tracking_number)?"'".$this->db->escape($this->tracking_number)."'":"null").",";
|
$sql.= " tracking_number=".(isset($this->tracking_number)?"'".$this->db->escape($this->tracking_number)."'":"null").",";
|
||||||
$sql.= " fk_statut=".(isset($this->statut)?$this->statut:"null").",";
|
$sql.= " fk_statut=".(isset($this->statut)?$this->statut:"null").",";
|
||||||
$sql.= " height=".(isset($this->trueHeight)?$this->trueHeight:"null").",";
|
$sql.= " height=".(($this->trueHeight != '')?$this->trueHeight:"null").",";
|
||||||
$sql.= " width=".(isset($this->trueWidth)?$this->trueWidth:"null").",";
|
$sql.= " width=".(($this->trueWidth != '')?$this->trueWidth:"null").",";
|
||||||
$sql.= " size_units=".(isset($this->size_units)?$this->size_units:"null").",";
|
$sql.= " size_units=".(isset($this->size_units)?$this->size_units:"null").",";
|
||||||
$sql.= " size=".(isset($this->trueDepth)?$this->trueDepth:"null").",";
|
$sql.= " size=".(($this->trueDepth != '')?$this->trueDepth:"null").",";
|
||||||
$sql.= " weight_units=".(isset($this->weight_units)?$this->weight_units:"null").",";
|
$sql.= " weight_units=".(isset($this->weight_units)?$this->weight_units:"null").",";
|
||||||
$sql.= " weight=".(isset($this->trueWeight)?$this->trueWeight:"null").",";
|
$sql.= " weight=".(($this->trueWeight != '')?$this->trueWeight:"null").",";
|
||||||
$sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").",";
|
$sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").",";
|
||||||
$sql.= " model_pdf=".(isset($this->model_pdf)?"'".$this->db->escape($this->model_pdf)."'":"null").",";
|
$sql.= " model_pdf=".(isset($this->model_pdf)?"'".$this->db->escape($this->model_pdf)."'":"null").",";
|
||||||
$sql.= " entity=".$conf->entity;
|
$sql.= " entity=".$conf->entity;
|
||||||
@ -858,7 +858,8 @@ class Expedition extends CommonObject
|
|||||||
$sql.= ", cd.total_ht, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.total_tva";
|
$sql.= ", cd.total_ht, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.total_tva";
|
||||||
$sql.= ", cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.price, cd.subprice";
|
$sql.= ", cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx, cd.price, cd.subprice";
|
||||||
$sql.= ", ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot";
|
$sql.= ", ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot";
|
||||||
$sql.= ", p.ref as product_ref, p.label as product_label, p.fk_product_type, p.weight, p.weight_units, p.volume, p.volume_units";
|
$sql.= ", p.ref as product_ref, p.label as product_label, p.fk_product_type";
|
||||||
|
$sql.= ", p.weight, p.weight_units, p.length, p.length_units, p.surface, p.surface_units, p.volume, p.volume_units";
|
||||||
$sql.= " FROM (".MAIN_DB_PREFIX."expeditiondet as ed,";
|
$sql.= " FROM (".MAIN_DB_PREFIX."expeditiondet as ed,";
|
||||||
$sql.= " ".MAIN_DB_PREFIX."commandedet as cd)";
|
$sql.= " ".MAIN_DB_PREFIX."commandedet as cd)";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = cd.fk_product";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = cd.fk_product";
|
||||||
@ -900,6 +901,10 @@ class Expedition extends CommonObject
|
|||||||
$line->qty_shipped = $obj->qty_shipped;
|
$line->qty_shipped = $obj->qty_shipped;
|
||||||
$line->weight = $obj->weight;
|
$line->weight = $obj->weight;
|
||||||
$line->weight_units = $obj->weight_units;
|
$line->weight_units = $obj->weight_units;
|
||||||
|
$line->length = $obj->length;
|
||||||
|
$line->length_units = $obj->length_units;
|
||||||
|
$line->surface = $obj->surface;
|
||||||
|
$line->surface_units = $obj->surface_units;
|
||||||
$line->volume = $obj->volume;
|
$line->volume = $obj->volume;
|
||||||
$line->volume_units = $obj->volume_units;
|
$line->volume_units = $obj->volume_units;
|
||||||
|
|
||||||
|
|||||||
@ -285,10 +285,9 @@ else if ($action == 'settrackingnumber' || $action == 'settrackingurl'
|
|||||||
header("Location: fiche.php?id=".$shipping->id);
|
header("Location: fiche.php?id=".$shipping->id);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$mesg=$shipping->error;
|
setEventMessage($shipping->error,'errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
$mesg='<div class="error">'.$mesg.'</div>';
|
|
||||||
$action="";
|
$action="";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -937,8 +936,8 @@ else
|
|||||||
if ($ret == 'html') print '<br>';
|
if ($ret == 'html') print '<br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate ture totalVeight and totalVolume for all products
|
// Calculate true totalWeight and totalVolume for all products
|
||||||
// by adding weight and volume of each line.
|
// by adding weight and volume of each product line.
|
||||||
$totalWeight = '';
|
$totalWeight = '';
|
||||||
$totalVolume = '';
|
$totalVolume = '';
|
||||||
$weightUnit=0;
|
$weightUnit=0;
|
||||||
@ -949,6 +948,7 @@ else
|
|||||||
$volumeUnit=0;
|
$volumeUnit=0;
|
||||||
if (! empty($lines[$i]->weight_units)) $weightUnit = $lines[$i]->weight_units;
|
if (! empty($lines[$i]->weight_units)) $weightUnit = $lines[$i]->weight_units;
|
||||||
if (! empty($lines[$i]->volume_units)) $volumeUnit = $lines[$i]->volume_units;
|
if (! empty($lines[$i]->volume_units)) $volumeUnit = $lines[$i]->volume_units;
|
||||||
|
|
||||||
// TODO Use a function addvalueunits(val1,unit1,val2,unit2)=>(val,unit)
|
// TODO Use a function addvalueunits(val1,unit1,val2,unit2)=>(val,unit)
|
||||||
if ($lines[$i]->weight_units < 50)
|
if ($lines[$i]->weight_units < 50)
|
||||||
{
|
{
|
||||||
@ -973,8 +973,6 @@ else
|
|||||||
$totalVolume += $lines[$i]->volume*$lines[$i]->qty_shipped;
|
$totalVolume += $lines[$i]->volume*$lines[$i]->qty_shipped;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$totalVolume=$totalVolume;
|
|
||||||
//print "totalVolume=".$totalVolume." volumeUnit=".$volumeUnit;
|
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
@ -1053,49 +1051,50 @@ else
|
|||||||
// Weight
|
// Weight
|
||||||
print '<tr><td>'.$form->editfieldkey("Weight",'trueWeight',$object->trueWeight,$object,$user->rights->expedition->creer).'</td><td colspan="3">';
|
print '<tr><td>'.$form->editfieldkey("Weight",'trueWeight',$object->trueWeight,$object,$user->rights->expedition->creer).'</td><td colspan="3">';
|
||||||
print $form->editfieldval("Weight",'trueWeight',$object->trueWeight,$object,$user->rights->expedition->creer);
|
print $form->editfieldval("Weight",'trueWeight',$object->trueWeight,$object,$user->rights->expedition->creer);
|
||||||
print $object->weight_units?measuring_units_string($object->weight_units,"weight"):'';
|
print ($object->weight_units!='')?' '.measuring_units_string($object->weight_units,"weight"):'';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Volume Total
|
|
||||||
print '<tr><td>'.$langs->trans("Volume").'</td>';
|
|
||||||
print '<td colspan="3">';
|
|
||||||
if (! empty($object->trueVolume)) // FIXME trueVolume not exist
|
|
||||||
{
|
|
||||||
// If sending volume defined
|
|
||||||
print $object->trueVolume.' '.measuring_units_string($object->volumeUnit,"volume");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// If sending volume not defined we use sum of products
|
|
||||||
if ($totalVolume > 0)
|
|
||||||
{
|
|
||||||
print $totalVolume.' ';
|
|
||||||
if ($volumeUnit < 50) print measuring_units_string(0,"volume");
|
|
||||||
else print measuring_units_string($volumeUnit,"volume");
|
|
||||||
}
|
|
||||||
else print ' ';
|
|
||||||
}
|
|
||||||
print "</td>\n";
|
|
||||||
print '</tr>';
|
|
||||||
|
|
||||||
// Width
|
// Width
|
||||||
print '<tr><td>'.$form->editfieldkey("Width",'trueWidth',$object->trueWidth,$object,$user->rights->expedition->creer).'</td><td colspan="3">';
|
print '<tr><td>'.$form->editfieldkey("Width",'trueWidth',$object->trueWidth,$object,$user->rights->expedition->creer).'</td><td colspan="3">';
|
||||||
print $form->editfieldval("Width",'trueWidth',$object->trueWidth,$object,$user->rights->expedition->creer);
|
print $form->editfieldval("Width",'trueWidth',$object->trueWidth,$object,$user->rights->expedition->creer);
|
||||||
print $object->trueWidth?measuring_units_string($object->width_units,"size"):'';
|
print ($object->trueWidth!='')?' '.measuring_units_string($object->width_units,"size"):'';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Height
|
// Height
|
||||||
print '<tr><td>'.$form->editfieldkey("Height",'trueHeight',$object->trueHeight,$object,$user->rights->expedition->creer).'</td><td colspan="3">';
|
print '<tr><td>'.$form->editfieldkey("Height",'trueHeight',$object->trueHeight,$object,$user->rights->expedition->creer).'</td><td colspan="3">';
|
||||||
print $form->editfieldval("Height",'trueHeight',$object->trueHeight,$object,$user->rights->expedition->creer);
|
print $form->editfieldval("Height",'trueHeight',$object->trueHeight,$object,$user->rights->expedition->creer);
|
||||||
print $object->trueHeight?measuring_units_string($object->height_units,"size"):'';
|
print ($object->trueHeight!='')?' '.measuring_units_string($object->height_units,"size"):'';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Depth
|
// Depth
|
||||||
print '<tr><td>'.$form->editfieldkey("Depth",'trueDepth',$object->trueDepth,$object,$user->rights->expedition->creer).'</td><td colspan="3">';
|
print '<tr><td>'.$form->editfieldkey("Depth",'trueDepth',$object->trueDepth,$object,$user->rights->expedition->creer).'</td><td colspan="3">';
|
||||||
print $form->editfieldval("Depth",'trueDepth',$object->trueDepth,$object,$user->rights->expedition->creer);
|
print $form->editfieldval("Depth",'trueDepth',$object->trueDepth,$object,$user->rights->expedition->creer);
|
||||||
print $object->trueDepth?measuring_units_string($object->depth_units,"size"):'';
|
print ($object->trueDepth!='')?' '.measuring_units_string($object->depth_units,"size"):'';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Volume
|
||||||
|
print '<tr><td>';
|
||||||
|
print $langs->trans("Volume");
|
||||||
|
print '</td>';
|
||||||
|
print '<td colspan="3">';
|
||||||
|
$calculatedVolume=0;
|
||||||
|
if ($object->trueWidth && $object->trueHeight && $object->trueDepth) $calculatedVolume=($object->trueWidth * $object->trueHeight * $object->trueDepth);
|
||||||
|
// If sending volume not defined we use sum of products
|
||||||
|
if ($calculatedVolume > 0)
|
||||||
|
{
|
||||||
|
print $calculatedVolume.' ';
|
||||||
|
if ($volumeUnit < 50) print measuring_units_string(0,"volume");
|
||||||
|
else print measuring_units_string($volumeUnit,"volume");
|
||||||
|
}
|
||||||
|
if ($totalVolume > 0)
|
||||||
|
{
|
||||||
|
if ($calculatedVolume) print ' ('.$langs->trans("SumOfProductVolumes").': ';
|
||||||
|
print $totalVolume;
|
||||||
|
if ($calculatedVolume) print ')';
|
||||||
|
}
|
||||||
|
print "</td>\n";
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
print '<tr><td>'.$langs->trans("Status").'</td>';
|
print '<tr><td>'.$langs->trans("Status").'</td>';
|
||||||
print '<td colspan="3">'.$object->getLibStatut(4)."</td>\n";
|
print '<td colspan="3">'.$object->getLibStatut(4)."</td>\n";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user