Add param to define key name in return array of substitution function
for propal
This commit is contained in:
parent
3cefb62621
commit
bd229a9417
@ -195,40 +195,41 @@ abstract class CommonDocGenerator
|
||||
*
|
||||
* @param Object $object Main object to use as data source
|
||||
* @param Translate $outputlangs Lang object to use for output
|
||||
* @param key $key Name of the key for return array
|
||||
* @return array Array of substitution
|
||||
*/
|
||||
function get_substitutionarray_propal($object,$outputlangs)
|
||||
function get_substitutionarray_propal($object,$outputlangs,$key='object')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$array_propal=array(
|
||||
'object_id'=>$object->id,
|
||||
'object_ref'=>$object->ref,
|
||||
'object_ref_ext'=>$object->ref_ext,
|
||||
'object_ref_customer'=>$object->ref_client,
|
||||
'object_date'=>dol_print_date($object->date,'day'),
|
||||
'object_date_end'=>dol_print_date($object->fin_validite,'day'),
|
||||
'object_date_creation'=>dol_print_date($object->date_creation,'day'),
|
||||
'object_date_modification'=>dol_print_date($object->date_modification,'day'),
|
||||
'object_date_validation'=>dol_print_date($object->date_validation,'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,
|
||||
$key.'_id'=>$object->id,
|
||||
$key.'_ref'=>$object->ref,
|
||||
$key.'_ref_ext'=>$object->ref_ext,
|
||||
$key.'_ref_customer'=>$object->ref_client,
|
||||
$key.'_date'=>dol_print_date($object->date,'day'),
|
||||
$key.'_date_end'=>dol_print_date($object->fin_validite,'day'),
|
||||
$key.'_date_creation'=>dol_print_date($object->date_creation,'day'),
|
||||
$key.'_date_modification'=>dol_print_date($object->date_modification,'day'),
|
||||
$key.'_date_validation'=>dol_print_date($object->date_validation,'dayhour'),
|
||||
$key.'_payment_mode_code'=>$object->mode_reglement_code,
|
||||
$key.'_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code)!='PaymentType'.$object->mode_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code):$object->mode_reglement),
|
||||
$key.'_payment_term_code'=>$object->cond_reglement_code,
|
||||
$key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code)!='PaymentCondition'.$object->cond_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code):$object->cond_reglement),
|
||||
$key.'_total_ht'=>price($object->total_ht,0,$outputlangs),
|
||||
$key.'_total_vat'=>price($object->total_tva,0,$outputlangs),
|
||||
$key.'_total_ttc'=>price($object->total_ttc,0,$outputlangs),
|
||||
$key.'_total_discount_ht' => price($object->getTotalDiscount(), 0, $outputlangs),
|
||||
$key.'_vatrate'=>vatrate($object->tva),
|
||||
$key.'_note_private'=>$object->note,
|
||||
$key.'_note'=>$object->note_public,
|
||||
);
|
||||
|
||||
// Add vat by rates
|
||||
foreach ($object->lines as $line)
|
||||
{
|
||||
if (empty($array_propal['object_total_vat_'.$line->tva_tx])) $array_propal['object_total_vat_'.$line->tva_tx]=0;
|
||||
$array_propal['object_total_vat_'.$line->tva_tx]+=$line->total_tva;
|
||||
if (empty($array_propal[$key.'_total_vat_'.$line->tva_tx])) $array_propal[$key.'_total_vat_'.$line->tva_tx]=0;
|
||||
$array_propal[$key.'_total_vat_'.$line->tva_tx]+=$line->total_tva;
|
||||
}
|
||||
|
||||
// Retrieve extrafields
|
||||
@ -250,7 +251,7 @@ abstract class CommonDocGenerator
|
||||
{
|
||||
$object->array_options['options_'.$key] = $extrafields->attribute_param[$key]['options'][$object->array_options['options_'.$key]];
|
||||
}
|
||||
$array_propal=array_merge($array_propal,array('propal_options_'.$key => $object->array_options['options_'.$key]));
|
||||
$array_propal=array_merge($array_propal,array($key.'_options_'.$key => $object->array_options['options_'.$key]));
|
||||
}
|
||||
}
|
||||
return $array_propal;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user