From d9bf0723092ced12e07b664964d56be7715c9cfc Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@users.sourceforge.net>
Date: Mon, 21 May 2007 20:28:24 +0000
Subject: [PATCH] =?UTF-8?q?New:=20Ajout=20export=20des=20r=E8glements=20cl?=
 =?UTF-8?q?ients?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 htdocs/includes/modules/modFacture.class.php  | 39 ++++++++++++-------
 .../includes/modules/modFournisseur.class.php | 21 +++++++++-
 htdocs/includes/modules/modTax.class.php      |  2 +-
 htdocs/langs/en_US/bills.lang                 |  1 +
 htdocs/langs/fr_FR/bills.lang                 |  1 +
 5 files changed, 46 insertions(+), 18 deletions(-)

diff --git a/htdocs/includes/modules/modFacture.class.php b/htdocs/includes/modules/modFacture.class.php
index b7c3565e257..fe4e150d573 100644
--- a/htdocs/includes/modules/modFacture.class.php
+++ b/htdocs/includes/modules/modFacture.class.php
@@ -163,31 +163,23 @@ class modFacture extends DolibarrModules
     
         $r++;
         $this->rights[$r][0] = 1321;
-        $this->rights[$r][1] = 'Exporter les factures clients et attributs';
+        $this->rights[$r][1] = 'Exporter les factures clients, attributs et r�glements';
         $this->rights[$r][2] = 'r';
         $this->rights[$r][3] = 0;
         $this->rights[$r][4] = 'facture';
         $this->rights[$r][5] = 'export';
     
-/*
-        $r++;
-        $this->rights[$r][0] = 1325;
-        $this->rights[$r][1] = 'Exporter les paiements';
-        $this->rights[$r][2] = 'r';
-        $this->rights[$r][3] = 0;
-        $this->rights[$r][4] = 'paiement';
-        $this->rights[$r][5] = 'export';
-*/    
-        // Exports
+
+		// Exports
         //--------
         $r=0;
     
         $r++;
         $this->export_code[$r]=$this->id.'_'.$r;
         $this->export_label[$r]='Factures clients et lignes de facture';
-        $this->export_fields_array[$r]=array('s.idp'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.cp'=>'Zip','s.ville'=>'Town','s.fk_pays'=>'Country','s.tel'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','f.rowid'=>"Id",'f.facnumber'=>"Ref",'f.fk_soc'=>"IdCompany",'f.datec'=>"DateCreation",'f.datef'=>"DateInvoice",'f.amount'=>"Amount",'f.remise_percent'=>"GlobalDiscount",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.paye'=>"BillShortStatusPayed",'f.fk_statut'=>'Status','f.note'=>"Note",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LinePrice",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.tva_taux'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd");
-		$this->export_entities_array[$r]=array('s.idp'=>"company",'s.nom'=>'company','s.address'=>'company','s.cp'=>'company','s.ville'=>'company','s.fk_pays'=>'company','s.tel'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.fk_soc'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.amount'=>"invoice",'f.remise_percent'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_taux'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line");
-        $this->export_alias_array[$r]=array('s.idp'=>"socid",'s.nom'=>'soc_name','s.address'=>'soc_adres','s.cp'=>'soc_zip','s.ville'=>'soc_ville','s.fk_pays'=>'soc_pays','s.tel'=>'soc_tel','s.siren'=>'soc_siren','s.siret'=>'soc_siret','s.ape'=>'soc_ape','s.idprof4'=>'soc_idprof4','f.rowid'=>"invoiceid",'f.facnumber'=>"ref",'f.fk_soc'=>"fk_soc",'f.datec'=>"datecreation",'f.datef'=>"dateinvoice",'f.amount'=>"amount",'f.remise_percent'=>"globaldiscount",'f.total'=>"totalht",'f.total_ttc'=>"totalttc",'f.paye'=>"paid",'f.fk_statut'=>'status','f.note'=>"note",'fd.rowid'=>'lineid','fd.description'=>"linedescription",'fd.price'=>"lineprice",'fd.total_ht'=>"linetotalht",'fd.total_tva'=>"linetotaltva",'fd.total_ttc'=>"linetotalttc",'fd.tva_taux'=>"linevatrate",'fd.qty'=>"lineqty",'fd.date_start'=>"linedatestart",'fd.date_end'=>"linedateend");
+        $this->export_fields_array[$r]=array('s.idp'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.cp'=>'Zip','s.ville'=>'Town','s.fk_pays'=>'Country','s.tel'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','f.rowid'=>"Id",'f.facnumber'=>"Ref",'f.datec'=>"DateCreation",'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"BillShortStatusPayed",'f.fk_statut'=>'Status','f.note'=>"Note",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LinePrice",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.tva_taux'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd");
+		$this->export_entities_array[$r]=array('s.idp'=>"company",'s.nom'=>'company','s.address'=>'company','s.cp'=>'company','s.ville'=>'company','s.fk_pays'=>'company','s.tel'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_taux'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line");
+        $this->export_alias_array[$r]=array('s.idp'=>"socid",'s.nom'=>'soc_name','s.address'=>'soc_adres','s.cp'=>'soc_zip','s.ville'=>'soc_ville','s.fk_pays'=>'soc_pays','s.tel'=>'soc_tel','s.siren'=>'soc_siren','s.siret'=>'soc_siret','s.ape'=>'soc_ape','s.idprof4'=>'soc_idprof4','f.rowid'=>"invoiceid",'f.facnumber'=>"ref",'f.datec'=>"datecreation",'f.datef'=>"dateinvoice",'f.total'=>"totalht",'f.total_ttc'=>"totalttc",'f.tva'=>"totalvat",'f.paye'=>"paid",'f.fk_statut'=>'status','f.note'=>"note",'fd.rowid'=>'lineid','fd.description'=>"linedescription",'fd.price'=>"lineprice",'fd.total_ht'=>"linetotalht",'fd.total_tva'=>"linetotaltva",'fd.total_ttc'=>"linetotalttc",'fd.tva_taux'=>"linevatrate",'fd.qty'=>"lineqty",'fd.date_start'=>"linedatestart",'fd.date_end'=>"linedateend");
         $this->export_sql[$r]="select distinct ";
         $i=0;
         foreach ($this->export_alias_array[$r] as $key => $value)
@@ -198,7 +190,24 @@ class modFacture extends DolibarrModules
         }
         $this->export_sql[$r].=' from '.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s WHERE f.fk_soc = s.idp AND f.rowid = fd.fk_facture';
         $this->export_permission[$r]=array(array("facture","facture","export"));
-    
+
+        $r++;
+        $this->export_code[$r]=$this->id.'_'.$r;
+        $this->export_label[$r]='Factures clients et r�glements';
+        $this->export_fields_array[$r]=array('s.idp'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.cp'=>'Zip','s.ville'=>'Town','s.fk_pays'=>'Country','s.tel'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','f.rowid'=>"Id",'f.facnumber'=>"Ref",'f.datec'=>"DateCreation",'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"BillShortStatusPayed",'f.fk_statut'=>'Status','f.note'=>"Note",'pf.amount'=>'AmountPayment','p.datep'=>'DatePayment','p.num_paiement'=>'Numero');
+		$this->export_entities_array[$r]=array('s.idp'=>"company",'s.nom'=>'company','s.address'=>'company','s.cp'=>'company','s.ville'=>'company','s.fk_pays'=>'company','s.tel'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'pf.amount'=>'payment','p.datep'=>'payment','p.num_paiement'=>'payment');
+        $this->export_alias_array[$r]=array('s.idp'=>"socid",'s.nom'=>'soc_name','s.address'=>'soc_adres','s.cp'=>'soc_zip','s.ville'=>'soc_ville','s.fk_pays'=>'soc_pays','s.tel'=>'soc_tel','s.siren'=>'soc_siren','s.siret'=>'soc_siret','s.ape'=>'soc_ape','s.idprof4'=>'soc_idprof4','f.rowid'=>"invoiceid",'f.facnumber'=>"ref",'f.datec'=>"datecreation",'f.datef'=>"dateinvoice",'f.total'=>"totalht",'f.total_ttc'=>"totalttc",'f.tva'=>"totalvat",'f.paye'=>"paid",'f.fk_statut'=>'status','f.note'=>"note",'pf.amount'=>'amount_payment','p.datep'=>'date_payment','p.num_paiement'=>'num_payment');
+        $this->export_sql[$r]="select distinct ";
+        $i=0;
+        foreach ($this->export_alias_array[$r] as $key => $value)
+        {
+            if ($i > 0) $this->export_sql[$r].=', ';
+            else $i++;
+            $this->export_sql[$r].=$key.' as '.$value;
+        }
+        $this->export_sql[$r].=' from ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'societe as s) LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid LEFT JOIN '.MAIN_DB_PREFIX.'paiement as p ON pf.fk_paiement = p.rowid WHERE f.fk_soc = s.idp';
+        $this->export_permission[$r]=array(array("facture","facture","export"));
+		
     }
 
 
diff --git a/htdocs/includes/modules/modFournisseur.class.php b/htdocs/includes/modules/modFournisseur.class.php
index 80c6810f385..5eb83f665bf 100644
--- a/htdocs/includes/modules/modFournisseur.class.php
+++ b/htdocs/includes/modules/modFournisseur.class.php
@@ -210,7 +210,7 @@ class modFournisseur extends DolibarrModules
 
 	    $r++;
 	    $this->rights[$r][0] = 1236;
-	    $this->rights[$r][1] = 'Exporter les factures fournisseurs et attributs';
+	    $this->rights[$r][1] = 'Exporter les factures fournisseurs, attributs et r�glements';
 	    $this->rights[$r][2] = 'r';
 	    $this->rights[$r][3] = 0;
 	    $this->rights[$r][4] = 'facture';
@@ -237,7 +237,24 @@ class modFournisseur extends DolibarrModules
         }
         $this->export_sql[$r].=' from '.MAIN_DB_PREFIX.'facture_fourn as f, '.MAIN_DB_PREFIX.'facture_fourn_det as fd, '.MAIN_DB_PREFIX.'societe as s WHERE f.fk_soc = s.idp AND f.rowid = fd.fk_facture_fourn';
         $this->export_permission[$r]=array(array("fournisseur","facture","export"));
-    
+
+        $r++;
+        $this->export_code[$r]=$this->id.'_'.$r;
+        $this->export_label[$r]='Factures fournisseurs et r�glements';
+        $this->export_fields_array[$r]=array('s.idp'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.cp'=>'Zip','s.ville'=>'Town','s.fk_pays'=>'Country','s.tel'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','f.rowid'=>"Id",'f.facnumber'=>"Ref",'f.datec'=>"DateCreation",'f.datef'=>"DateInvoice",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.paye'=>"BillShortStatusPayed",'f.fk_statut'=>'Status','f.note'=>"Note",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_taux'=>"LineVATRate",'fd.qty'=>"LineQty");
+        $this->export_entities_array[$r]=array('s.idp'=>"company",'s.nom'=>'company','s.address'=>'company','s.cp'=>'company','s.ville'=>'company','s.fk_pays'=>'company','s.tel'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.tva_taux'=>"invoice_line",'fd.qty'=>"invoice_line");
+        $this->export_alias_array[$r]=array('s.idp'=>"socid",'s.nom'=>'soc_name','s.address'=>'soc_adres','s.cp'=>'soc_zip','s.ville'=>'soc_ville','s.fk_pays'=>'soc_pays','s.tel'=>'soc_tel','s.siren'=>'soc_siren','s.siret'=>'soc_siret','s.ape'=>'soc_ape','s.idprof4'=>'soc_idprof4','f.rowid'=>"invoiceid",'f.facnumber'=>"ref",'f.datec'=>"datecreation",'f.datef'=>"dateinvoice",'f.total_ht'=>"totalht",'f.total_ttc'=>"totalttc",'f.paye'=>"paid",'f.fk_statut'=>'status','f.note'=>"note",'fd.rowid'=>'lineid','fd.description'=>"linedescription",'fd.tva_taux'=>"linevatrate",'fd.qty'=>"lineqty");
+        $this->export_sql[$r]="select distinct ";
+        $i=0;
+        foreach ($this->export_alias_array[$r] as $key => $value)
+        {
+            if ($i > 0) $this->export_sql[$r].=', ';
+            else $i++;
+            $this->export_sql[$r].=$key.' as '.$value;
+        }
+        $this->export_sql[$r].=' from '.MAIN_DB_PREFIX.'facture_fourn as f, '.MAIN_DB_PREFIX.'facture_fourn_det as fd, '.MAIN_DB_PREFIX.'societe as s WHERE f.fk_soc = s.idp AND f.rowid = fd.fk_facture_fourn';
+        $this->export_permission[$r]=array(array("fournisseur","facture","export"));
+		
     }
 
 
diff --git a/htdocs/includes/modules/modTax.class.php b/htdocs/includes/modules/modTax.class.php
index 3ca29413d8f..77578586e9b 100644
--- a/htdocs/includes/modules/modTax.class.php
+++ b/htdocs/includes/modules/modTax.class.php
@@ -128,7 +128,7 @@ class modTax extends DolibarrModules
     
         $r++;
         $this->export_code[$r]=$this->id.'_'.$r;
-        $this->export_label[$r]='Taxes et charges sociales, et leurs �ventuels r�glements';
+        $this->export_label[$r]='Taxes et charges sociales, et leurs r�glements';
         $this->export_fields_array[$r]=array('cc.libelle'=>"Type",'c.libelle'=>"Label",'c.date_ech'=>'DateDue','c.periode'=>'Period','c.amount'=>"AmountExpected","c.paye"=>"Status",'p.datep'=>'DatePayment','p.amount'=>'AmountPayment','p.num_paiement'=>'Numero');
         $this->export_entities_array[$r]=array('cc.libelle'=>"tax_type",'c.libelle'=>'tax','c.date_ech'=>'tax','c.periode'=>'tax','c.amount'=>"tax","c.paye"=>"tax",'p.datep'=>'payment','p.amount'=>'payment','p.num_paiement'=>'payment');
         $this->export_alias_array[$r]=array('cc.libelle'=>"type",'c.libelle'=>'label','c.date_ech'=>'datedue','c.periode'=>'period','c.amount'=>"amount_clamed","c.paye"=>"status",'p.datep'=>'date_payment','p.amount'=>'amount_payment','p.num_paiement'=>'num_payment');
diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang
index 716bc3f9b1c..ecef7dad84d 100644
--- a/htdocs/langs/en_US/bills.lang
+++ b/htdocs/langs/en_US/bills.lang
@@ -43,6 +43,7 @@ Payment=Payment
 PaymentBack=Payment back
 Payments=Payments
 PaymentsBack=Payments back
+DatePayment=Payment date
 DeletePayment=Delete payment
 ConfirmDeletePayment=Are you sure you want to delete this payment ?
 ConfirmConvertToReduc=Do you want to convert this credit note into absolute discount ?<br>The amount of this credit note will so be saved among all discounts and could be used as a discount for a future invoice for this customer.
diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang
index e897a53665f..5d21db6dc6b 100644
--- a/htdocs/langs/fr_FR/bills.lang
+++ b/htdocs/langs/fr_FR/bills.lang
@@ -43,6 +43,7 @@ Payment=R
 PaymentBack=Remboursement
 Payments=R�glements
 PaymentsBack=Remboursements
+DatePayment=Date paiement
 DeletePayment=Supprimer le paiement
 ConfirmDeletePayment=Etes vous sur de vouloir supprimer ce paiement ?
 ConfirmConvertToReduc=Voulez-vous convertir cet avoir en r�duction future ?<br>Le montant de cet avoir sera alors stock� en r�duction fixe en attente pour le client. Cette derni�re pourra �tre utilis�e pour r�duire le montant d'une prochaine facture de ce client.
-- 
GitLab