Skip to content
Snippets Groups Projects
Commit 9add45ae authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Qual: Mutualize code.

parent 845f764f
No related branches found
No related tags found
No related merge requests found
......@@ -299,100 +299,132 @@ abstract class CommonDocGenerator
}
/**
* 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
/**
* 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_propal($object,$outputlangs,$array_key='object')
{
global $conf;
* @return array Array of substitution
*/
function get_substitutionarray_object($object,$outputlangs,$array_key='object')
{
global $conf;
$array_propal=array(
$array_key.'_id'=>$object->id,
$array_key.'_ref'=>$object->ref,
$array_key.'_ref_ext'=>$object->ref_ext,
$array_key.'_ref_customer'=>$object->ref_client,
$array_key.'_hour'=>dol_print_date($object->date,'hour'),
$array_key.'_date'=>dol_print_date($object->date,'day'),
$array_key.'_date_end'=>dol_print_date($object->fin_validite,'day'),
$array_key.'_date_creation'=>dol_print_date($object->date_creation,'day'),
$array_key.'_date_modification'=>dol_print_date($object->date_modification,'day'),
$array_key.'_date_validation'=>dol_print_date($object->date_validation,'dayhour'),
$array_key.'_payment_mode_code'=>$object->mode_reglement_code,
$array_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),
$array_key.'_payment_term_code'=>$object->cond_reglement_code,
$array_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),
$array_key.'_total_ht_locale'=>price($object->total_ht,0,$outputlangs),
$array_key.'_total_vat_locale'=>price($object->total_tva,0,$outputlangs),
$array_key.'_total_localtax1_locale'=>price($object->total_localtax1,0,$outputlangs),
$array_key.'_total_localtax2_locale'=>price($object->total_localtax2,0,$outputlangs),
$array_key.'_total_ttc_locale'=>price($object->total_ttc,0,$outputlangs),
$array_key.'_total_discount_ht_locale' => price($object->getTotalDiscount(),0,$outputlangs),
$array_key.'_total_ht'=>price2num($object->total_ht),
$array_key.'_total_vat'=>price2num($object->total_tva),
$array_key.'_total_localtax1'=>price2num($object->total_localtax1),
$array_key.'_total_localtax2'=>price2num($object->total_localtax2),
$array_key.'_total_ttc'=>price2num($object->total_ttc),
$array_key.'_total_discount_ht' => price2num($object->getTotalDiscount()),
$array_key.'_vatrate'=>vatrate($object->tva),
$array_key.'_note_private'=>$object->note,
$array_key.'_note'=>$object->note_public,
);
$sumpayed=''; $alreadypayed='';
if ($object->element == 'facture')
{
$invoice_source=new Facture($this->db);
if ($object->fk_facture_source > 0)
{
$invoice_source->fetch($object->fk_facture_source);
}
$sumpayed = $object->getSommePaiement();
$alreadypayed=price($sumpayed,0,$outputlangs);
}
// Add vat by rates
foreach ($object->lines as $line)
{
if (empty($array_propal[$array_key.'_total_vat_'.$line->tva_tx])) $array_propal[$array_key.'_total_vat_'.$line->tva_tx]=0;
$array_propal[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva;
}
$resarray=array(
$array_key.'_id'=>$object->id,
$array_key.'_ref'=>$object->ref,
$array_key.'_ref_ext'=>$object->ref_ext,
$array_key.'_ref_customer'=>$object->ref_client,
$array_key.'_ref_supplier'=>(! empty($object->ref_fournisseur)?$object->ref_fournisseur:''),
$array_key.'_source_invoice_ref'=>$invoice_source->ref,
$array_key.'_hour'=>dol_print_date($object->date,'hour'),
$array_key.'_date'=>dol_print_date($object->date,'day'),
$array_key.'_date_rfc'=>dol_print_date($object->date,'dayrfc'),
$array_key.'_date_limit'=>(! empty($object->date_lim_reglement)?dol_print_date($object->date_lim_reglement,'day'):''),
$array_key.'_date_end'=>(! empty($object->fin_validite)?dol_print_date($object->fin_validite,'day'):''),
$array_key.'_date_creation'=>dol_print_date($object->date_creation,'day'),
$array_key.'_date_modification'=>(! empty($object->date_modification)?dol_print_date($object->date_modification,'day'):''),
$array_key.'_date_validation'=>(! empty($object->date_validation)?dol_print_date($object->date_validation,'dayhour'):''),
$array_key.'_date_delivery_planed'=>(! empty($object->date_livraison)?dol_print_date($object->date_livraison,'day'):''),
$array_key.'_date_close'=>(! empty($object->date_cloture)?dol_print_date($object->date_cloture,'dayhour'):''),
$array_key.'_payment_mode_code'=>$object->mode_reglement_code,
$array_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),
$array_key.'_payment_term_code'=>$object->cond_reglement_code,
$array_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),
$array_key.'_total_ht_locale'=>price($object->total_ht, 0, $outputlangs),
$array_key.'_total_vat_locale'=>price($object->total_tva, 0, $outputlangs),
$array_key.'_total_localtax1_locale'=>price($object->total_localtax1, 0, $outputlangs),
$array_key.'_total_localtax2_locale'=>price($object->total_localtax2, 0, $outputlangs),
$array_key.'_total_ttc_locale'=>price($object->total_ttc, 0, $outputlangs),
$array_key.'_total_discount_ht_locale' => price($object->getTotalDiscount(), 0, $outputlangs),
$array_key.'_total_ht'=>price2num($object->total_ht),
$array_key.'_total_vat'=>price2num($object->total_tva),
$array_key.'_total_localtax1'=>price2num($object->total_localtax1),
$array_key.'_total_localtax2'=>price2num($object->total_localtax2),
$array_key.'_total_ttc'=>price2num($object->total_ttc),
$array_key.'_total_discount_ht' => price2num($object->getTotalDiscount()),
$array_key.'_note_private'=>$object->note,
$array_key.'_note'=>$object->note_public,
// Payments
$array_key.'_already_payed_locale'=>price($alreadypayed, 0, $outputlangs),
$array_key.'_remain_to_pay_locale'=>price($object->total_ttc - $sumpayed, 0, $outputlangs),
$array_key.'_already_payed'=>$alreadypayed,
$array_key.'_remain_to_pay'=>price2num($object->total_ttc - $sumpayed)
);
// 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('propal',true);
$object->fetch_optionals($object->id,$extralabels);
// Add vat by rates
foreach ($object->lines as $line)
{
if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0;
$resarray[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva;
$resarray[$array_key.'_total_vat_locale_'.$line->tva_tx]=price($resarray[$array_key.'_total_vat_'.$line->tva_tx]);
}
$array_propal = $this->fill_substitutionarray_with_extrafields($object,$array_propal,$extrafields,$array_key,$outputlangs);
}
return $array_propal;
}
// Retrieve extrafields
if (is_array($object->array_options) && count($object->array_options))
{
$extrafieldkey=$this->element;
'facture';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label('facture',true);
$object->fetch_optionals($object->id,$extralabels);
/**
* 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_propal_lines($line,$outputlangs)
{
global $conf;
$resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key=$array_key,$outputlangs);
}
return $resarray;
}
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_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_date_start'=>$line->date_start,
'line_date_end'=>$line->date_end
);
}
/**
* 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 Return a substitution array
*/
function get_substitutionarray_lines($line,$outputlangs)
{
global $conf;
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'=>price2num($line->subprice),
'line_up_locale'=>price($line->subprice, 0, $outputlangs),
'line_qty'=>$line->qty,
'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''),
'line_price_ht'=>price2num($line->total_ht),
'line_price_ttc'=>price2num($line->total_ttc),
'line_price_vat'=>price2num($line->total_tva),
'line_price_ht_locale'=>price($line->total_ht, 0, $outputlangs),
'line_price_ttc_locale'=>price($line->total_ttc, 0, $outputlangs),
'line_price_vat_locale'=>price($line->total_tva, 0, $outputlangs),
'line_date_start'=>$line->date_start,
'line_date_start_rfc'=>dol_print_date($line->date_start,'rfc'),
'line_date_end'=>$line->date_end,
'line_date_end_rfc'=>dol_print_date($line->date_end,'rfc')
);
}
/**
* Define array with couple substitution key => substitution value
......
......@@ -87,104 +87,6 @@ class doc_generic_order_odt extends ModelePDFCommandes
}
/**
* 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
* @return array Array of substitution
*/
function get_substitutionarray_object($object, Translate $outputlangs)
{
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_locale'=>price($object->total_ht, 0, $outputlangs),
'object_total_vat_locale'=>price($object->total_tva, 0, $outputlangs),
'object_total_localtax1_locale'=>price($object->total_localtax1, 0, $outputlangs),
'object_total_localtax2_locale'=>price($object->total_localtax2, 0, $outputlangs),
'object_total_ttc_locale'=>price($object->total_ttc, 0, $outputlangs),
'object_total_discount_ht_locale' => price($object->getTotalDiscount(), 0, $outputlangs),
'object_total_ht'=>price2num($object->total_ht),
'object_total_vat'=>price2num($object->total_tva),
'object_total_localtax1'=>price2num($object->total_localtax1),
'object_total_localtax2'=>price2num($object->total_localtax2),
'object_total_ttc'=>price2num($object->total_ttc),
'object_total_discount_ht' => price2num($object->getTotalDiscount()),
'object_vatrate'=>vatrate($object->tva),
'object_note_private'=>$object->note,
'object_note'=>$object->note_public,
);
// Add vat by rates
foreach ($object->lines as $line)
{
if (empty($resarray['object_total_vat_'.$line->tva_tx])) $resarray['object_total_vat_'.$line->tva_tx]=0;
$resarray['object_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('commande',true);
$object->fetch_optionals($object->id,$extralabels);
$resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key='object',$outputlangs);
}
return $resarray;
}
/**
* 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 Return a substitution array
*/
function get_substitutionarray_lines($line,$outputlangs)
{
global $conf;
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, 0, $outputlangs),
'line_qty'=>$line->qty,
'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''),
'line_price_ht'=>price($line->total_ht, 0, $outputlangs),
'line_price_ttc'=>price($line->total_ttc, 0, $outputlangs),
'line_price_vat'=>price($line->total_tva, 0, $outputlangs),
'line_price_ht_locale'=>price($line->total_ht, 0, $outputlangs),
'line_price_ttc_locale'=>price($line->total_ttc, 0, $outputlangs),
'line_price_vat_locale'=>price($line->total_tva, 0, $outputlangs),
'line_date_start'=>$line->date_start,
'line_date_end'=>$line->date_end
);
}
/**
* Return description of a module
*
......@@ -239,7 +141,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
$texte.= '<br></div></div>';
// Scan directories
if (count($listofdir)) $texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
......
......@@ -87,94 +87,6 @@ class doc_generic_shipment_odt extends ModelePdfExpedition
}
/**
* 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
* @return array Array of substitution
*/
function get_substitutionarray_object($object,$outputlangs)
{
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_locale'=>price($object->total_ht, 0, $outputlangs),
'object_total_vat_locale'=>price($object->total_tva, 0, $outputlangs),
'object_total_localtax1_locale'=>price($object->total_localtax1, 0, $outputlangs),
'object_total_localtax2_locale'=>price($object->total_localtax2, 0, $outputlangs),
'object_total_ttc_locale'=>price($object->total_ttc, 0, $outputlangs),
'object_total_discount_ht_locale' => price($object->getTotalDiscount(), 0, $outputlangs),
'object_total_ht'=>price2num($object->total_ht),
'object_total_vat'=>price2num($object->total_tva),
'object_total_localtax1'=>price2num($object->total_localtax1),
'object_total_localtax2'=>price2num($object->total_localtax2),
'object_total_ttc'=>price2num($object->total_ttc),
'object_total_discount_ht' => price2num($object->getTotalDiscount()),
'object_vatrate'=>vatrate($object->tva),
'object_note_private'=>$object->note,
'object_note'=>$object->note_public,
);
// Add vat by rates
foreach ($object->lines as $line)
{
if (empty($resarray['object_total_vat_'.$line->tva_tx])) $resarray['object_total_vat_'.$line->tva_tx]=0;
$resarray['object_total_vat_'.$line->tva_tx]+=$line->total_tva;
}
return $resarray;
}
/**
* 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 Return a substitution array
*/
function get_substitutionarray_lines($line, Translate $outputlangs)
{
global $conf;
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, 0, $outputlangs),
'line_qty'=>$line->qty,
'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''),
'line_price_ht'=>price2num($line->total_ht),
'line_price_ttc'=>price2num($line->total_ttc),
'line_price_vat'=>price2num($line->total_tva),
'line_price_ht_locale'=>price($line->total_ht, 0, $outputlangs),
'line_price_ttc_locale'=>price($line->total_ttc, 0, $outputlangs),
'line_price_vat_locale'=>price($line->total_tva, 0, $outputlangs),
'line_date_start'=>$line->date_start,
'line_date_end'=>$line->date_end
);
}
/**
* Return description of a module
*
......@@ -229,7 +141,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition
$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
$texte.= '<br></div></div>';
// Scan directories
if (count($listofdir)) $texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
......
......@@ -2,7 +2,7 @@
/* Copyright (C) 2010-2012 Laurent Destailleur <ely@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
......@@ -87,119 +87,6 @@ class doc_generic_invoice_odt extends ModelePDFFactures
}
/**
* 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
* @return array Array of substitution
*/
function get_substitutionarray_object($object,$outputlangs)
{
global $conf;
$invoice_source=new Facture($this->db);
if ($object->fk_facture_source > 0)
{
$invoice_source->fetch($object->fk_facture_source);
}
$sumpayed = $object->getSommePaiement();
$alreadypayed=price($sumpayed,0,$outputlangs);
$resarray=array(
'object_id'=>$object->id,
'object_ref'=>$object->ref,
'object_ref_ext'=>$object->ref_ext,
'object_ref_customer'=>$object->ref_client,
'object_ref_supplier'=>(! empty($object->ref_fournisseur)?$object->ref_fournisseur:''),
'object_source_invoice_ref'=>$invoice_source->ref,
'object_hour'=>dol_print_date($object->date,'hour'),
'object_date'=>dol_print_date($object->date,'day'),
'object_date_rfc'=>dol_print_date($object->date,'dayrfc'),
'object_date_limit'=>dol_print_date($object->date_lim_reglement,'day'),
'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_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_locale'=>price($object->total_ht, 0, $outputlangs),
'object_total_vat_locale'=>price($object->total_tva, 0, $outputlangs),
'object_total_localtax1_locale'=>price($object->total_localtax1, 0, $outputlangs),
'object_total_localtax2_locale'=>price($object->total_localtax2, 0, $outputlangs),
'object_total_ttc_locale'=>price($object->total_ttc, 0, $outputlangs),
'object_total_discount_ht_locale' => price($object->getTotalDiscount(), 0, $outputlangs),
'object_total_ht'=>price2num($object->total_ht),
'object_total_vat'=>price2num($object->total_tva),
'object_total_localtax1'=>price2num($object->total_localtax1),
'object_total_localtax2'=>price2num($object->total_localtax2),
'object_total_ttc'=>price2num($object->total_ttc),
'object_total_discount_ht' => price2num($object->getTotalDiscount()),
'object_vatrate'=>(isset($object->tva)?vatrate($object->tva):''),
'object_note_private'=>$object->note,
'object_note'=>$object->note_public,
// Payments
'object_already_payed_locale'=>price($alreadypayed, 0, $outputlangs),
'object_remain_to_pay_locale'=>price($object->total_ttc - $sumpayed, 0, $outputlangs),
'object_already_payed'=>$alreadypayed,
'object_remain_to_pay'=>price2num($object->total_ttc - $sumpayed)
);
// Add vat by rates
foreach ($object->lines as $line)
{
if (empty($resarray['object_total_vat_'.$line->tva_tx])) $resarray['object_total_vat_'.$line->tva_tx]=0;
$resarray['object_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('facture',true);
$object->fetch_optionals($object->id,$extralabels);
$resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key='object',$outputlangs);
}
return $resarray;
}
/**
* 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 Return substitution array
*/
function get_substitutionarray_lines($line, Translate $outputlangs)
{
global $conf;
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, 0, $outputlangs),
'line_qty'=>$line->qty,
'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''),
'line_price_ht'=>price2num($line->total_ht),
'line_price_ttc'=>price2num($line->total_ttc),
'line_price_vat'=>price2num($line->total_tva),
'line_price_ht_locale'=>price($line->total_ht, 0, $outputlangs),
'line_price_ttc_locale'=>price($line->total_ttc, 0, $outputlangs),
'line_price_vat_locale'=>price($line->total_tva, 0, $outputlangs),
'line_date_start'=>dol_print_date($line->date_start, 'day', false, $outputlangs),
'line_date_end'=>dol_print_date($line->date_end, 'day', false, $outputlangs),
);
}
/**
* Return description of a module
*
......@@ -455,7 +342,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures
$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
$array_propal=is_object($propal_object)?$this->get_substitutionarray_propal($propal_object,$outputlangs,'propal'):array();
$array_propal=is_object($propal_object)?$this->get_substitutionarray_object($propal_object,$outputlangs,'propal'):array();
$array_other=$this->get_substitutionarray_other($user,$outputlangs);
$tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_propal);
......
......@@ -146,7 +146,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
$texte.= '<br></div></div>';
// Scan directories
if (count($listofdir))
{
......@@ -425,7 +425,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
}
}
// Replace tags of object + external modules
$tmparray=$this->get_substitutionarray_propal($object,$outputlangs);
$tmparray=$this->get_substitutionarray_object($object,$outputlangs);
//print_r($tmparray); exit;
complete_substitutions_array($tmparray, $outputlangs, $object);
// Call the ODTSubstitution hook
......@@ -454,7 +454,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
$listlines = $odfHandler->setSegment('lines');
foreach ($object->lines as $line)
{
$tmparray=$this->get_substitutionarray_propal_lines($line,$outputlangs);
$tmparray=$this->get_substitutionarray_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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment