$this->export_code[$r]=$this->rights_class.‹ _ ›.$r;
$this->export_label[$r]=‹ CustomersInvoicesAndPayments ›; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_icon[$r]=‹ bill ›;
$this->export_permission[$r]=array(array(« facture »,« facture »,« export »));
$this->export_fields_array[$r]=array(‹ s.rowid ›=>« IdCompany »,‹ s.nom ›=>‹ CompanyName ›,‹ s.address ›=>‹ Address ›,‹ s.zip ›=>‹ Zip ›,‹ s.town ›=>‹ Town ›,‹ c.code ›=>‹ CountryCode ›,‹ s.phone ›=>‹ Phone ›,‹ s.siren ›=>‹ ProfId1 ›,‹ s.siret ›=>‹ ProfId2 ›,‹ s.ape ›=>‹ ProfId3 ›,‹ s.idprof4 ›=>‹ ProfId4 ›,‹ s.code_compta ›=>‹ CustomerAccountancyCode ›,‹ s.code_compta_fournisseur ›=>‹ SupplierAccountancyCode ›,‹ s.tva_intra ›=>‹ VATIntra ›,‹ f.rowid ›=>« InvoiceId »,‹ f.facnumber ›=>« InvoiceRef »,‹ f.datec ›=>« InvoiceDateCreation »,‹ f.datef ›=>« DateInvoice »,‹ f.date_lim_reglement ›=>« DateDue »,‹ f.total ›=>« TotalHT »,‹ f.total_ttc ›=>« TotalTTC »,‹ f.tva ›=>« TotalVAT »,‹ f.paye ›=>« InvoicePaid »,‹ f.fk_statut ›=>‹ InvoiceStatus ›,‹ f.note_private ›=>« NotePrivate »,‹ f.note_public ›=>« NotePublic »,‹ f.fk_user_author ›=>‹ CreatedById ›,‹ uc.login ›=>‹ CreatedByLogin ›,‹ f.fk_user_valid ›=>‹ ValidatedById ›,‹ uv.login ›=>‹ ValidatedByLogin ›,‹ pj.ref ›=>‹ ProjectRef ›,‹ p.rowid ›=>‹ PaymentId ›,‹ p.ref ›=>‹ PaymentRef ›,‹ p.amount ›=>‹ AmountPayment ›,‹ pf.amount ›=>‹ AmountPaymentDistributedOnInvoice ›,‹ p.datep ›=>‹ DatePayment ›,‹ p.num_paiement ›=>‹ PaymentNumber ›,‹ pt.code ›=>‹ IdPaymentMode ›,‹ pt.libelle ›=>‹ LabelPaymentMode ›,‹ p.note ›=>‹ PaymentNote ›,‹ p.fk_bank ›=>‹ IdTransaction ›,‹ ba.ref ›=>‹ AccountRef ›,‹ pr.accountancy_code_sell ›=>‹ ProductAccountancySellCode ›);
//$this->export_TypeFields_array[$r]=array(‹ s.rowid ›=>« List:societe:nom »,‹ s.nom ›=>‹ Text ›,‹ s.address ›=>‹ Text ›,‹ s.zip ›=>‹ Text ›,‹ s.town ›=>‹ Text ›,‹ c.code ›=>‹ Text ›,‹ s.phone ›=>‹ Text ›,‹ s.siren ›=>‹ Text ›,‹ s.siret ›=>‹ Text ›,‹ s.ape ›=>‹ Text ›,‹ s.idprof4 ›=>‹ Text ›,‹ s.code_compta ›=>‹ Text ›,‹ s.code_compta_fournisseur ›=>‹ Text ›,‹ s.tva_intra ›=>‹ Text ›,‹ f.rowid ›=>« List:facture:facnumber »,‹ f.facnumber ›=>« Text »,‹ f.datec ›=>« Date »,‹ f.datef ›=>« Date »,‹ f.date_lim_reglement ›=>« Date »,‹ f.total ›=>« Numeric »,‹ f.total_ttc ›=>« Numeric »,‹ f.tva ›=>« Numeric »,‹ f.paye ›=>« Boolean »,‹ f.fk_statut ›=>‹ Status ›,‹ f.note_private ›=>« Text »,‹ f.note_public ›=>« Text »,‹ pf.amount ›=>‹ Numeric ›,‹ p.datep ›=>‹ Date ›,‹ p.num_paiement ›=>‹ Numeric ›,‹ p.fk_bank ›=>‹ Numeric ›);
$this->export_TypeFields_array[$r]=array(‹ s.nom ›=>‹ Text ›,‹ s.address ›=>‹ Text ›,‹ s.zip ›=>‹ Text ›,‹ s.town ›=>‹ Text ›,‹ c.code ›=>‹ Text ›,‹ s.phone ›=>‹ Text ›,‹ s.siren ›=>‹ Text ›,‹ s.siret ›=>‹ Text ›,‹ s.ape ›=>‹ Text ›,‹ s.idprof4 ›=>‹ Text ›,‹ s.code_compta ›=>‹ Text ›,‹ s.code_compta_fournisseur ›=>‹ Text ›,‹ s.tva_intra ›=>‹ Text ›,‹ f.rowid ›=>« Numeric »,‹ f.facnumber ›=>« Text »,‹ f.datec ›=>« Date »,‹ f.datef ›=>« Date »,‹ f.date_lim_reglement ›=>« Date »,‹ f.total ›=>« Numeric »,‹ f.total_ttc ›=>« Numeric »,‹ f.tva ›=>« Numeric »,‹ f.paye ›=>« Boolean »,‹ f.fk_statut ›=>‹ Status ›,‹ f.note_private ›=>« Text »,‹ f.note_public ›=>« Text »,‹ pj.ref ›=>‹ Text ›,‹ p.amount ›=>‹ Numeric ›,‹ pf.amount ›=>‹ Numeric ›,‹ p.rowid ›=>‹ Numeric ›,‹ p.ref ›=>‹ Text ›,‹ p.datep ›=>‹ Date ›,‹ p.num_paiement ›=>‹ Numeric ›,‹ p.fk_bank ›=>‹ Numeric ›,‹ p.note ›=>‹ Text ›,‹ pt.code ›=>‹ Text ›,‹ pt.libelle ›=>‹ text ›,‹ ba.ref ›=>‹ Text ›,‹ pr.accountancy_code_sell ›=>‹ Text ›);
$this->export_entities_array[$r]=array(‹ s.rowid ›=>« company »,‹ s.nom ›=>‹ company ›,‹ s.address ›=>‹ company ›,‹ s.zip ›=>‹ company ›,‹ s.town ›=>‹ company ›,‹ c.code ›=>‹ company ›,‹ s.phone ›=>‹ company ›,‹ s.siren ›=>‹ company ›,‹ s.siret ›=>‹ company ›,‹ s.ape ›=>‹ company ›,‹ s.idprof4 ›=>‹ company ›,‹ s.code_compta ›=>‹ company ›,‹ s.code_compta_fournisseur ›=>‹ company ›,‹ s.tva_intra ›=>‹ company ›,‹ f.rowid ›=>« invoice »,‹ f.facnumber ›=>« invoice »,‹ f.datec ›=>« invoice »,‹ f.datef ›=>« invoice »,‹ f.date_lim_reglement ›=>« invoice »,‹ f.total ›=>« invoice »,‹ f.total_ttc ›=>« invoice »,‹ f.tva ›=>« invoice »,‹ f.paye ›=>« invoice »,‹ f.fk_statut ›=>‹ invoice ›,‹ f.note_private ›=>« invoice »,‹ f.note_public ›=>« invoice »,‹ pj.ref ›=>‹ project ›,‹ p.rowid ›=>‹ payment ›,‹ p.ref ›=>‹ payment ›,‹ p.amount ›=>‹ payment ›,‹ pf.amount ›=>‹ payment ›,‹ p.datep ›=>‹ payment ›,‹ p.num_paiement ›=>‹ payment ›,‹ pt.code ›=>‹ payment ›,‹ pt.libelle ›=>‹ payment ›,‹ p.note ›=>‹ payment ›,‹ f.fk_user_author ›=>‹ user ›,‹ uc.login ›=>‹ user ›,‹ f.fk_user_valid ›=>‹ user ›,‹ uv.login ›=>‹ user ›,‹ p.fk_bank ›=>‹ account ›,‹ ba.ref ›=>‹ account ›,‹ pr.accountancy_code_sell ›=>‹ product ›);
$this->export_dependencies_array[$r]=array(‹ payment ›=>‹ p.rowid ›); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
$keyforselect=‹ facture ›; $keyforelement=‹ invoice ›; $keyforaliasextra=‹ extra ›;
include DOL_DOCUMENT_ROOT.‹ /core/extrafieldsinexport.inc.php ›;
$this->export_sql_start[$r]=‹ SELECT DISTINCT ‹ ;
$this->export_sql_end[$r] = › FROM ‹ .MAIN_DB_PREFIX.‹ societe as s ›;
$this->export_sql_end[$r] .= › LEFT JOIN ‹ .MAIN_DB_PREFIX.‹ c_country as c on s.fk_pays = c.rowid, ›;
$this->export_sql_end[$r] .= › ‹ .MAIN_DB_PREFIX.‹ facture as f ›;
$this->export_sql_end[$r] .= › LEFT JOIN ‹ .MAIN_DB_PREFIX.‹ projet as pj ON f.fk_projet = pj.rowid ›;
$this->export_sql_end[$r] .= › LEFT JOIN ‹ .MAIN_DB_PREFIX.‹ user as uc ON f.fk_user_author = uc.rowid ›;
$this->export_sql_end[$r] .= › LEFT JOIN ‹ .MAIN_DB_PREFIX.‹ user as uv ON f.fk_user_valid = uv.rowid ›;
$this->export_sql_end[$r] .= › LEFT JOIN ‹ .MAIN_DB_PREFIX.‹ facture_extrafields as extra ON f.rowid = extra.fk_object ›;
$this->export_sql_end[$r] .= › LEFT JOIN ‹ .MAIN_DB_PREFIX.‹ paiement_facture as pf ON pf.fk_facture = f.rowid ›;
$this->export_sql_end[$r] .= › LEFT JOIN ‹ .MAIN_DB_PREFIX.‹ paiement as p ON pf.fk_paiement = p.rowid ›;
$this->export_sql_end[$r] .= › LEFT JOIN ‹ .MAIN_DB_PREFIX.‹ c_paiement as pt ON pt.id = p.fk_paiement ›;
$this->export_sql_end[$r] .= › LEFT JOIN ‹ .MAIN_DB_PREFIX.‹ bank as b ON b.rowid = p.fk_bank ›;
$this->export_sql_end[$r] .= › LEFT JOIN ‹ .MAIN_DB_PREFIX.‹ bank_account as ba ON ba.rowid = b.fk_account ›;
$this->export_sql_end[$r] .= › LEFT JOIN ‹ .MAIN_DB_PREFIX.‹ product as pr ON pf.fk_paiement = pr.accountancy_code_sell ›;
$this->export_sql_end[$r] .= › WHERE f.fk_soc = s.rowid ›;
$this->export_sql_end[$r] .=’ AND f.entity IN (‹ .getEntity(‹ facture ›,1). ›)';
$r++;