From bd229a941702b7321ef12ea8fef81f2c735de280 Mon Sep 17 00:00:00 2001 From: jfefe Date: Tue, 5 Mar 2013 09:43:45 +0100 Subject: [PATCH] Add param to define key name in return array of substitution function for propal --- .../core/class/commondocgenerator.class.php | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 481e2c2ac33..2b225c7c5cf 100755 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -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;