Merge pull request #1113 from atm-maxime/develop

Work on shipment
This commit is contained in:
Juanjo Menent 2013-07-22 00:02:56 -07:00
commit fbdb764d41
8 changed files with 138 additions and 33 deletions

View File

@ -4,6 +4,8 @@ English Dolibarr ChangeLog
***** ChangeLog for 3.5 compared to 3.4 *****
For users:
- New: [ task #862 ] Add ODT on shipments
- New: [ task #149 ] Add # of notes and attachments in tabs
- New: Can edit customer ref at eny time.
- New: [ task #877 ] Reorganize menus.
- New: [ task #858 ] Holiday module: note on manual holiday assignation.

View File

@ -260,7 +260,7 @@ if (! empty($conf->banque->enabled))
print '<tr>';
print '<td>'.$langs->trans('CheckReceipt').'</td>';
print '<td colspan="3">';
print $bordereau->getNomUrl(1,0,'showall');
print $bordereau->getNomUrl(1);
print '</td>';
print '</tr>';
}

View File

@ -304,6 +304,99 @@ abstract class CommonDocGenerator
'line_date_end'=>$line->date_end
);
}
/**
* Define array with couple substitution key => substitution value
*
* @param Object $object Main object to use as data source
* @param Translate $outputlangs Lang object to use for output
* @param array_key $array_key Name of the key for return array
* @return array Array of substitution
*/
function get_substitutionarray_shipment($object,$outputlangs,$array_key='object')
{
global $conf;
dol_include_once('/core/lib/product.lib.php');
$object->list_delivery_methods($object->shipping_method_id);
$calculatedVolume=($object->trueWidth * $object->trueHeight * $object->trueDepth);
$array_shipment=array(
$array_key.'_id'=>$object->id,
$array_key.'_ref'=>$object->ref,
$array_key.'_ref_ext'=>$object->ref_ext,
$array_key.'_ref_customer'=>$object->ref_customer,
$array_key.'_date_delivery'=>dol_print_date($object->date_delivery,'day'),
$array_key.'_hour_delivery'=>dol_print_date($object->date_delivery,'hour'),
$array_key.'_date_creation'=>dol_print_date($object->date_creation,'day'),
$array_key.'_total_ht'=>price($object->total_ht),
$array_key.'_total_vat'=>price($object->total_tva),
$array_key.'_total_ttc'=>price($object->total_ttc),
$array_key.'_total_discount_ht' => price($object->getTotalDiscount()),
$array_key.'_note_private'=>$object->note_private,
$array_key.'_note'=>$object->note_public,
$array_key.'_tracking_number'=>$object->tracking_number,
$array_key.'_tracking_url'=>$object->tracking_url,
$array_key.'_shipping_method'=>$object->listmeths[0]['libelle'],
$array_key.'_weight'=>$object->trueWeight.' '.measuring_units_string($object->weight_units, 'weight'),
$array_key.'_width'=>$object->trueWidth.' '.measuring_units_string($object->width_units, 'size'),
$array_key.'_height'=>$object->trueHeight.' '.measuring_units_string($object->height_units, 'size'),
$array_key.'_depth'=>$object->trueDepth.' '.measuring_units_string($object->depth_units, 'size'),
$array_key.'_size'=>$calculatedVolume.' '.measuring_units_string(0, 'volume'),
);
// Add vat by rates
foreach ($object->lines as $line)
{
if (empty($array_shipment[$array_key.'_total_vat_'.$line->tva_tx])) $array_shipment[$array_key.'_total_vat_'.$line->tva_tx]=0;
$array_shipment[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva;
}
// Retrieve extrafields
/*if(is_array($object->array_options) && count($object->array_options))
{
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label('shipment',true);
$object->fetch_optionals($object->id,$extralabels);
$array_shipment = $this->fill_substitutionarray_with_extrafields($object,$array_shipment,$extrafields,$array_key,$outputlangs);
}*/
return $array_shipment;
}
/**
* Define array with couple substitution key => substitution value
*
* @param array $line Array of lines
* @param Translate $outputlangs Lang object to use for output
* @return array Substitution array
*/
function get_substitutionarray_shipment_lines($line,$outputlangs)
{
global $conf;
dol_include_once('/core/lib/product.lib.php');
return array(
'line_fulldesc'=>doc_getlinedesc($line,$outputlangs),
'line_product_ref'=>$line->product_ref,
'line_product_label'=>$line->product_label,
'line_desc'=>$line->desc,
'line_vatrate'=>vatrate($line->tva_tx,true,$line->info_bits),
'line_up'=>price($line->subprice),
'line_qty'=>$line->qty,
'line_qty_shipped'=>$line->qty_shipped,
'line_qty_asked'=>$line->qty_asked,
'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''),
'line_price_ht'=>price($line->total_ht),
'line_price_ttc'=>price($line->total_ttc),
'line_price_vat'=>price($line->total_tva),
'line_weight'=>empty($line->weight) ? '' : $line->weight*$line->qty_shipped.' '.measuring_units_string($line->weight_units, 'weight'),
'line_length'=>empty($line->length) ? '' : $line->length*$line->qty_shipped.' '.measuring_units_string($line->length_units, 'size'),
'line_surface'=>empty($line->surface) ? '' : $line->surface*$line->qty_shipped.' '.measuring_units_string($line->surface_units, 'surface'),
'line_volume'=>empty($line->volume) ? '' : $line->volume*$line->qty_shipped.' '.measuring_units_string($line->volume_units, 'volume'),
);
}
/**
* Fill array with couple extrafield key => extrafield value

View File

@ -98,29 +98,29 @@ class doc_generic_shipment_odt extends ModelePdfExpedition
global $conf;
$resarray=array(
'object_id'=>$object->id,
'object_ref'=>$object->ref,
'object_ref_ext'=>$object->ref_ext,
'object_ref_customer'=>$object->ref_client,
'object_hour'=>dol_print_date($object->date,'hour'),
'object_date'=>dol_print_date($object->date,'day'),
'object_date_delivery'=>dol_print_date($object->date_livraison,'dayhour'),
'object_date_creation'=>dol_print_date($object->date_creation,'day'),
'object_date_modification'=>(! empty($object->date_modification)?dol_print_date($object->date_modification,'day'):''),
'object_date_validation'=>(! empty($object->date_validation)?dol_print_date($object->date_validation,'dayhour'):''),
'object_date_delivery_planed'=>(! empty($object->date_livraison)?dol_print_date($object->date_livraison,'day'):''),
'object_date_close'=>dol_print_date($object->date_cloture,'dayhour'),
'object_payment_mode_code'=>$object->mode_reglement_code,
'object_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code)!='PaymentType'.$object->mode_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code):$object->mode_reglement),
'object_payment_term_code'=>$object->cond_reglement_code,
'object_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code)!='PaymentCondition'.$object->cond_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code):$object->cond_reglement),
'object_total_ht'=>price($object->total_ht,0,$outputlangs),
'object_total_vat'=>price($object->total_tva,0,$outputlangs),
'object_total_ttc'=>price($object->total_ttc,0,$outputlangs),
'object_total_discount_ht' => price($object->getTotalDiscount(), 0, $outputlangs),
'object_vatrate'=>vatrate($object->tva),
'object_note_private'=>$object->note,
'object_note'=>$object->note_public,
'object_id'=>$object->id,
'object_ref'=>$object->ref,
'object_ref_ext'=>$object->ref_ext,
'object_ref_customer'=>$object->ref_client,
'object_hour'=>dol_print_date($object->date,'hour'),
'object_date'=>dol_print_date($object->date,'day'),
'object_date_delivery'=>dol_print_date($object->date_livraison,'dayhour'),
'object_date_creation'=>dol_print_date($object->date_creation,'day'),
'object_date_modification'=>(! empty($object->date_modification)?dol_print_date($object->date_modification,'day'):''),
'object_date_validation'=>(! empty($object->date_validation)?dol_print_date($object->date_validation,'dayhour'):''),
'object_date_delivery_planed'=>(! empty($object->date_livraison)?dol_print_date($object->date_livraison,'day'):''),
'object_date_close'=>dol_print_date($object->date_cloture,'dayhour'),
'object_payment_mode_code'=>$object->mode_reglement_code,
'object_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code)!='PaymentType'.$object->mode_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code):$object->mode_reglement),
'object_payment_term_code'=>$object->cond_reglement_code,
'object_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code)!='PaymentCondition'.$object->cond_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code):$object->cond_reglement),
'object_total_ht'=>price($object->total_ht,0,$outputlangs),
'object_total_vat'=>price($object->total_tva,0,$outputlangs),
'object_total_ttc'=>price($object->total_ttc,0,$outputlangs),
'object_total_discount_ht' => price($object->getTotalDiscount(), 0, $outputlangs),
'object_vatrate'=>vatrate($object->tva),
'object_note_private'=>$object->note,
'object_note'=>$object->note_public,
);
// Add vat by rates
@ -468,7 +468,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition
}
}
// Replace tags of object + external modules
$tmparray=$this->get_substitutionarray_object($object,$outputlangs);
$tmparray=$this->get_substitutionarray_shipment($object,$outputlangs);
complete_substitutions_array($tmparray, $outputlangs, $object);
// Call the ODTSubstitution hook
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
@ -496,7 +496,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition
$listlines = $odfHandler->setSegment('lines');
foreach ($object->lines as $line)
{
$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
$tmparray=$this->get_substitutionarray_shipment_lines($line,$outputlangs);
complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
// Call the ODTSubstitutionLine hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);

View File

@ -978,13 +978,14 @@ class Expedition extends CommonObject
$line->volume_units = $obj->volume_units;
// For invoicing
$tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $info_bits, $obj->fk_product_type); // We force type to 0
$line->desc = $obj->description; // We need ->desc because some code into CommonObject use desc (property defined for other elements)
$line->qty = $obj->qty_shipped;
$line->total_ht = $obj->total_ht;
$line->total_localtax1 = $obj->total_localtax1;
$line->total_localtax2 = $obj->total_localtax2;
$line->total_ttc = $obj->total_ttc;
$line->total_tva = $obj->total_tva;
$line->total_ht = $tabprice[0];
$line->total_localtax1 = $tabprice[9];
$line->total_localtax2 = $tabprice[10];
$line->total_ttc = $tabprice[2];
$line->total_tva = $tabprice[1];
$line->tva_tx = $obj->tva_tx;
$line->localtax1_tx = $obj->localtax1_tx;
$line->localtax2_tx = $obj->localtax2_tx;
@ -992,7 +993,6 @@ class Expedition extends CommonObject
$line->subprice = $obj->subprice;
$line->remise_percent = $obj->remise_percent;
$tabprice = calcul_price_total($obj->qty_shipped, $obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $info_bits, $obj->fk_product_type); // We force type to 0
$this->total_ht+= $tabprice[0];
$this->total_tva+= $tabprice[1];
$this->total_ttc+= $tabprice[2];

View File

@ -1115,6 +1115,12 @@ else
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 ($object->trueWeight && $object->weight_units!='')?' '.measuring_units_string($object->weight_units,"weight"):'';
if ($totalWeight > 0)
{
if (!empty($object->trueWeight)) print ' ('.$langs->trans("SumOfProductWeights").': ';
print $totalWeight.' '.measuring_units_string(0,"weight");
if (!empty($object->trueWeight)) print ')';
}
print '</td></tr>';
// Width
@ -1152,7 +1158,7 @@ else
if ($totalVolume > 0)
{
if ($calculatedVolume) print ' ('.$langs->trans("SumOfProductVolumes").': ';
print $totalVolume;
print $totalVolume.' '.measuring_units_string(0,"volume");
if ($calculatedVolume) print ')';
}
print "</td>\n";

View File

@ -71,3 +71,5 @@ DocumentModelSirocco=Simple document model for delivery receipts
DocumentModelTyphon=More complete document model for delivery receipts (logo...)
Error_EXPEDITION_ADDON_NUMBER_NotDefined=Constant EXPEDITION_ADDON_NUMBER not defined
SumOfProductVolumes=Sum of product volumes
SumOfProductWeights=Sum of product weights

View File

@ -71,3 +71,5 @@ DocumentModelSirocco=Modèle de bon de réception/livraison simple
DocumentModelTyphon=Modèle de bon de réception/livraison complet (logo…)
Error_EXPEDITION_ADDON_NUMBER_NotDefined=Constante EXPEDITION_ADDON_NUMBER non définie
SumOfProductVolumes=Somme des volumes des produits
SumOfProductWeights=Somme des poids des produits