Qual: Mutualize code.
This commit is contained in:
parent
845f764f93
commit
9add45aea3
@ -299,6 +299,7 @@ abstract class CommonDocGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define array with couple substitution key => substitution value
|
* Define array with couple substitution key => substitution value
|
||||||
*
|
*
|
||||||
@ -307,21 +308,39 @@ abstract class CommonDocGenerator
|
|||||||
* @param array_key $array_key Name of the key for return array
|
* @param array_key $array_key Name of the key for return array
|
||||||
* @return array Array of substitution
|
* @return array Array of substitution
|
||||||
*/
|
*/
|
||||||
function get_substitutionarray_propal($object,$outputlangs,$array_key='object')
|
function get_substitutionarray_object($object,$outputlangs,$array_key='object')
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$array_propal=array(
|
$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);
|
||||||
|
}
|
||||||
|
|
||||||
|
$resarray=array(
|
||||||
$array_key.'_id'=>$object->id,
|
$array_key.'_id'=>$object->id,
|
||||||
$array_key.'_ref'=>$object->ref,
|
$array_key.'_ref'=>$object->ref,
|
||||||
$array_key.'_ref_ext'=>$object->ref_ext,
|
$array_key.'_ref_ext'=>$object->ref_ext,
|
||||||
$array_key.'_ref_customer'=>$object->ref_client,
|
$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.'_hour'=>dol_print_date($object->date,'hour'),
|
||||||
$array_key.'_date'=>dol_print_date($object->date,'day'),
|
$array_key.'_date'=>dol_print_date($object->date,'day'),
|
||||||
$array_key.'_date_end'=>dol_print_date($object->fin_validite,'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_creation'=>dol_print_date($object->date_creation,'day'),
|
||||||
$array_key.'_date_modification'=>dol_print_date($object->date_modification,'day'),
|
$array_key.'_date_modification'=>(! empty($object->date_modification)?dol_print_date($object->date_modification,'day'):''),
|
||||||
$array_key.'_date_validation'=>dol_print_date($object->date_validation,'dayhour'),
|
$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_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_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_code'=>$object->cond_reglement_code,
|
||||||
@ -340,40 +359,47 @@ abstract class CommonDocGenerator
|
|||||||
$array_key.'_total_ttc'=>price2num($object->total_ttc),
|
$array_key.'_total_ttc'=>price2num($object->total_ttc),
|
||||||
$array_key.'_total_discount_ht' => price2num($object->getTotalDiscount()),
|
$array_key.'_total_discount_ht' => price2num($object->getTotalDiscount()),
|
||||||
|
|
||||||
$array_key.'_vatrate'=>vatrate($object->tva),
|
|
||||||
$array_key.'_note_private'=>$object->note,
|
$array_key.'_note_private'=>$object->note,
|
||||||
$array_key.'_note'=>$object->note_public,
|
$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)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add vat by rates
|
// Add vat by rates
|
||||||
foreach ($object->lines as $line)
|
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;
|
if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0;
|
||||||
$array_propal[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva;
|
$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]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve extrafields
|
// Retrieve extrafields
|
||||||
if (is_array($object->array_options) && count($object->array_options))
|
if (is_array($object->array_options) && count($object->array_options))
|
||||||
{
|
{
|
||||||
|
$extrafieldkey=$this->element;
|
||||||
|
'facture';
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
$extrafields = new ExtraFields($this->db);
|
$extrafields = new ExtraFields($this->db);
|
||||||
$extralabels = $extrafields->fetch_name_optionals_label('propal',true);
|
$extralabels = $extrafields->fetch_name_optionals_label('facture',true);
|
||||||
$object->fetch_optionals($object->id,$extralabels);
|
$object->fetch_optionals($object->id,$extralabels);
|
||||||
|
|
||||||
$array_propal = $this->fill_substitutionarray_with_extrafields($object,$array_propal,$extrafields,$array_key,$outputlangs);
|
$resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key=$array_key,$outputlangs);
|
||||||
}
|
}
|
||||||
return $array_propal;
|
return $resarray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define array with couple substitution key => substitution value
|
* Define array with couple substitution key => substitution value
|
||||||
*
|
*
|
||||||
* @param array $line Array of lines
|
* @param array $line Array of lines
|
||||||
* @param Translate $outputlangs Lang object to use for output
|
* @param Translate $outputlangs Lang object to use for output
|
||||||
* @return array Substitution array
|
* @return array Return a substitution array
|
||||||
*/
|
*/
|
||||||
function get_substitutionarray_propal_lines($line,$outputlangs)
|
function get_substitutionarray_lines($line,$outputlangs)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
@ -383,14 +409,20 @@ abstract class CommonDocGenerator
|
|||||||
'line_product_label'=>$line->product_label,
|
'line_product_label'=>$line->product_label,
|
||||||
'line_desc'=>$line->desc,
|
'line_desc'=>$line->desc,
|
||||||
'line_vatrate'=>vatrate($line->tva_tx,true,$line->info_bits),
|
'line_vatrate'=>vatrate($line->tva_tx,true,$line->info_bits),
|
||||||
'line_up'=>price($line->subprice),
|
'line_up'=>price2num($line->subprice),
|
||||||
|
'line_up_locale'=>price($line->subprice, 0, $outputlangs),
|
||||||
'line_qty'=>$line->qty,
|
'line_qty'=>$line->qty,
|
||||||
'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''),
|
'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''),
|
||||||
'line_price_ht'=>price($line->total_ht),
|
'line_price_ht'=>price2num($line->total_ht),
|
||||||
'line_price_ttc'=>price($line->total_ttc),
|
'line_price_ttc'=>price2num($line->total_ttc),
|
||||||
'line_price_vat'=>price($line->total_tva),
|
'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'=>$line->date_start,
|
||||||
'line_date_end'=>$line->date_end
|
'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')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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
|
* Return description of a module
|
||||||
*
|
*
|
||||||
|
|||||||
@ -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
|
* Return description of a module
|
||||||
*
|
*
|
||||||
|
|||||||
@ -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
|
* 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_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
|
||||||
$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
|
$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
|
||||||
$array_objet=$this->get_substitutionarray_object($object,$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);
|
$array_other=$this->get_substitutionarray_other($user,$outputlangs);
|
||||||
|
|
||||||
$tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_propal);
|
$tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_propal);
|
||||||
|
|||||||
@ -425,7 +425,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Replace tags of object + external modules
|
// Replace tags of object + external modules
|
||||||
$tmparray=$this->get_substitutionarray_propal($object,$outputlangs);
|
$tmparray=$this->get_substitutionarray_object($object,$outputlangs);
|
||||||
//print_r($tmparray); exit;
|
//print_r($tmparray); exit;
|
||||||
complete_substitutions_array($tmparray, $outputlangs, $object);
|
complete_substitutions_array($tmparray, $outputlangs, $object);
|
||||||
// Call the ODTSubstitution hook
|
// Call the ODTSubstitution hook
|
||||||
@ -454,7 +454,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
|
|||||||
$listlines = $odfHandler->setSegment('lines');
|
$listlines = $odfHandler->setSegment('lines');
|
||||||
foreach ($object->lines as $line)
|
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");
|
complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
|
||||||
// Call the ODTSubstitutionLine hook
|
// Call the ODTSubstitutionLine hook
|
||||||
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
|
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user