Effectivement, votre macro m'ouvre un document writer avec 3 cadres bien
visibles.
Je ne comprend en effet pas pourquoi ma macro se comporte comme ça.
Je vous poste dessous l'intégralité de mon module. C'est un peu long ! si
vous avez le courage de le parcourir ... Sinon ce n'est pas grave puisque de
toute façon maintenant cela fonctionne.
Merci,
Martin
'=========================
'Visualisation des factures
'=========================
Option Explicit
Private Moncurseur as object, MonTexte as object, MaCellule as object,
Curseur2 as object
Private EtrangerFactureVisual as Boolean, LangueFactureVisual as string
Sub Affichage_facture(ID_facture as string,Facture_visual_logo as boolean)
Dim matos_conso as boolean, Jour_camion as integer, Cout_peage as double,
NB_kilometre as integer
Dim Paris as boolean, Livraison as boolean, Prix_Nnovia as double, Nnovia as
integer
Dim Prix_QP as double, Quatorze_pouce as double, Vingt_pouce as double,
Prix_VP as double
Dim CT_trans as double, CT as double, Prix_CT as double, Frais_off as
integer, NB_frais_off as integer
Dim Frais_T as integer, NB_frais_T as integer, NB_off as double, Salaire as
integer, NB_Tech as double
Dim Titre as string, Client_Select as string, TVAintra as string,
montant_accompte as double
Dim date_facture as date, N_facture as string, Heures_sup as double,
Nombre_heures_sup as integer
Dim conso_carburant as double, MonDocument as object, adresseDoc as string,
propFich()
Dim Date_debutFactureVisual as date, Date_FinFactureVisual as Date,
PubFactureVisual as Boolean
Dim RemiseFactureVisual as integer, AssurFactureVisual as Boolean,
PaiementFactureVisual as string
Dim Montant_facture as double
adresseDoc = "private:factory/swriter" 'convention pour indiquer un nouveau
document writer
MonDocument = StarDesktop.LoadComponentFromURL(adresseDoc,"_blank", 0,
propFich)
'Récupération de la valeur des champs dans la base Facture'
'--------------------------------------------------------
Dim maRequete_facturevisual As Object, ResultSet As Object
maRequete_facturevisual = maConnexion.createStatement()
ResultSet = maRequete_facturevisual.executeQuery("SELECT * FROM Liste_fact
WHERE ID='"& ID_facture &"'"
If Not IsNull(ResultSet) Then
While ResultSet.next
Titre = ResultSet.getString(2)
Client_Select = ResultSet.getString(3)
N_facture = ResultSet.getString(4)
Date_debutFactureVisual = ResultSet.getString(5)
Date_FinFactureVisual = ResultSet.getString(6)
PubFactureVisual = ResultSet.getString(7)
RemiseFactureVisual = ResultSet.getString(8)
AssurFactureVisual = ResultSet.getString(9)
PaiementFactureVisual = ResultSet.getString(10)
NB_Tech = ResultSet.getString(11)
Salaire = ResultSet.getString(12)
NB_off = ResultSet.getString(13)
NB_frais_T = ResultSet.getString(14)
Frais_T = ResultSet.getString(15)
NB_frais_off = ResultSet.getString(16)
Frais_off = ResultSet.getString(17)
Heures_sup = ResultSet.getString(18)
Nombre_heures_sup = ResultSet.getString(19)
CT = ResultSet.getString(20)
Prix_CT = ResultSet.getString(21)
CT_trans = ResultSet.getString(22)
Vingt_pouce = ResultSet.getString(23)
Prix_VP = ResultSet.getString(24)
Quatorze_pouce = ResultSet.getString(25)
Prix_QP = ResultSet.getString(26)
Nnovia = ResultSet.getString(27)
Prix_Nnovia = ResultSet.getString(28)
Livraison = ResultSet.getString(29)
Paris = ResultSet.getString(30)
NB_kilometre = ResultSet.getString(31)
Cout_peage = ResultSet.getString(32)
Jour_camion = ResultSet.getString(33)
conso_carburant = ResultSet.getString(34)
date_facture = ResultSet.getString(35)
montant_accompte = ResultSet.getString(36)
matos_conso = ResultSet.getString(37)
EtrangerFactureVisual = Resultset.getstring(39)
LangueFactureVisual = Resultset.getstring(40)
Montant_facture = Resultset.getstring(43)
Wend
End if
'---------------------------------------
'Récupération des coordonnées du client
'---------------------------------------
Dim Rue as string, CP as string, Ville as string, maRequete_facturevisual2
as object
maRequete_facturevisual2 = maConnexion.createStatement()
ResultSet = maRequete_facturevisual2.executeQuery("SELECT * FROM Clients
WHERE Societe="& Quote(Client_Select) &""
If Not IsNull(ResultSet) Then
While ResultSet.next
Rue = ResultSet.getString(2)
CP = ResultSet.getString(3)
Ville = ResultSet.getString(4)
TVAintra = Resultset.getString(7)
Wend
End if
'Récupération du vocabulaire dans la base traduction
'----------------------------------------------------
Dim Mot_Cfilm as string, Mot_Titre as string, Mot_Datedebut as string,
Mot_Datefin as string
Dim Mot_Devis as string, Mot_Design as string, Mot_PU as string, Mot_Remise
as string
Dim Mot_Qtite as string, Mot_Techni_Fact as string, Mot_CineTool as string,
Mot_VingtP as string
Dim Mot_Quatorze as string, Mot_Livraiso as string, Mot_Heures as string,
Mot_Heures2 as string
Dim Mot_Hsup as string, Mot_Hnuit as string, Mot_Paiement as string, Mot_BPA
as string
Dim Mot_CGL as string, Mot_TotalHT as string, Mot_TransOf1 as string,
Mot_TransOf2 as string
Dim Mot_Nnovia as string, Mot_FraisT as string, Mot_Fraisoff as string,
Mot_Location as string
Dim Mot_Kilometres as string, Mot_Peages as string, Mot_TVA as string,
Mot_TVA2 as string
Dim Mot_Facture as string, Mot_CGI as string, Mot_Carburant as string
Dim marequete_facturevisual_vocabulaire as object
marequete_facturevisual_vocabulaire = maConnexion.createStatement()
ResultSet = marequete_facturevisual_vocabulaire.executeQuery("SELECT * FROM
Mots WHERE Langue="& Quote(LangueFactureVisual) &""
If Not IsNull(ResultSet) Then
While ResultSet.next
Mot_Cfilm = ResultSet.getstring(2)
Mot_Titre = ResultSet.getstring(3)
Mot_Datedebut = ResultSet.getstring(4)
Mot_Datefin = ResultSet.getstring(5)
Mot_Devis = ResultSet.getstring(6)
Mot_Design = ResultSet.getstring(7)
Mot_PU = ResultSet.getstring(8)
Mot_Remise = ResultSet.getstring(9)
Mot_Qtite = ResultSet.getstring(10)
Mot_Techni_Fact = ResultSet.getstring(11)
Mot_CineTool = ResultSet.getstring(12)
Mot_VingtP = ResultSet.getstring(13)
Mot_Quatorze = ResultSet.getstring(14)
Mot_Livraiso = ResultSet.getstring(15)
Mot_Heures = ResultSet.getstring(16)
Mot_Heures2 = ResultSet.getstring(17)
Mot_Hsup = ResultSet.getstring(18)
Mot_Hnuit = ResultSet.getstring(19)
Mot_Paiement = ResultSet.getstring(20)
Mot_BPA = ResultSet.getstring(21)
Mot_CGL = ResultSet.getstring(22)
Mot_TotalHT = ResultSet.getstring(23)
Mot_TransOf1 = ResultSet.getstring(24)
Mot_TransOf2 = ResultSet.getstring(25)
Mot_Nnovia = ResultSet.getstring(26)
Mot_FraisT = ResultSet.getstring(27)
Mot_Fraisoff = ResultSet.getstring(28)
Mot_Location = ResultSet.getstring(29)
Mot_Kilometres = ResultSet.getstring(30)
Mot_Peages = ResultSet.getstring(31)
Mot_TVA = ResultSet.getstring(32)
Mot_TVA2 = ResultSet.getstring(33)
Mot_Facture = ResultSet.getstring(34)
Mot_CGI = ResultSet.getstring(35)
Mot_Carburant = ResultSet.getstring(36)
Wend
End if
MonDocument.lockControllers
'Affichage du cadre Client
'--------------------------
MonDocument = ThisComponent
Dim Taille1 As New com.sun.star.awt.Size
MonTexte = MonDocument.Text
Moncurseur = MonTexte.createTextCursor
Dim MonCadre1 as object
MonCadre1 =
MonDocument.createInstance("com.sun.star.drawing.RectangleShape")
Taille1.Width = 8000 ' largeur en 1/100 de mm
Taille1.Height = 3000 ' largeur en 1/100 de mm
With MonCadre1
.CornerRadius = 600
.FillColor = RGB (255,255,255)
.AnchorType = com.sun.star.text.TextContentAnchorType.AT_PARAGRAPH
.VertOrient = com.sun.star.text.VertOrientation.NONE
.VertOrientPosition = 1500
.HoriOrient = com.sun.star.text.HoriOrientation.NONE
.HoriOrientPosition = 8000
.Size = Taille1
.lineStyle = com.sun.star.drawing.LineStyle.SOLID
End With
MonCadre1.name = " Cadre Client "
MonTexte.insertTextContent(Moncurseur, MonCadre1, false)
MonCadre1.LayerId = 1
'Affichage du cadre Film
'-------------------------
Dim MonCadre_Film as object
MonCadre_Film =
MonDocument.createInstance("com.sun.star.drawing.RectangleShape")
Taille1.Width = 6000 ' largeur en 1/100 de mm
Taille1.Height = 2500 ' largeur en 1/100 de mm
With MonCadre_Film
.CornerRadius = 600
.FillColor = RGB (255,255,255)
.AnchorType = com.sun.star.text.TextContentAnchorType.AT_PARAGRAPH
.VertOrient = com.sun.star.text.VertOrientation.NONE
.VertOrientPosition = 4500
.HoriOrient = com.sun.star.text.HoriOrientation.NONE
.HoriOrientPosition = 500
.Size = Taille1
End With
MonTexte.insertTextContent(Moncurseur, MonCadre_Film, false)
MonCadre_Film.LayerId = 1
MonCadre_Film.name = " Cadre Film "
'Affichage de l'intitulé du cadre Film ( Dans un cadre invisible )
'---------------------------------------------------------------------
Dim MonCadre3 as object
MonCadre3 =
MonDocument.createInstance("com.sun.star.drawing.RectangleShape") 'création
du cadre
Taille1.Width = 2000
Taille1.Height = 500
With MonCadre3
.LineStyle = com.sun.star.drawing.LineStyle.NONE
.FillColor = RGB (255,255,255)
.AnchorType = com.sun.star.text.TextContentAnchorType.AT_PARAGRAPH
.VertOrient = com.sun.star.text.VertOrientation.NONE
.VertOrientPosition = 4250
.HoriOrient = com.sun.star.text.HoriOrientation.NONE
.HoriOrientPosition = 2500
.Size = Taille1
End With
MonTexte.insertTextContent(MonCurseur, MonCadre3, false) ' affichage du
cadre
MonCadre3.LayerId = 1
MonCadre3.name = " Intitulé du cadre Film "
MonTexte = MonCadre3.Text ' Ecriture du texte dans le cadre
Moncurseur = MonTexte.createTextCursor
Moncurseur.CharWeight = com.sun.star.awt.FontWeight.BOLD
Moncurseur.CharPosture = com.sun.star.awt.FontSlant.ITALIC
MonTexte.insertString(Moncurseur, Mot_Cfilm,False)
'Affichage de l'intitulé du cadre Client ( Dans un cadre invisible )
'---------------------------------------------------------------------
Dim MonCadre2 as object
MonCadre2 =
MonDocument.createInstance("com.sun.star.drawing.RectangleShape") 'création
du cadre
Taille1.Width = 2000
Taille1.Height = 500
With MonCadre2
.LineStyle = com.sun.star.drawing.LineStyle.NONE
.FillColor = RGB (255,255,255)
.AnchorType = com.sun.star.text.TextContentAnchorType.AT_PARAGRAPH
.VertOrient = com.sun.star.text.VertOrientation.NONE
.VertOrientPosition = 1230
.HoriOrient = com.sun.star.text.HoriOrientation.NONE
.HoriOrientPosition = 11200
.Size = Taille1
End With
MonTexte = MonDocument.Text
Moncurseur = MonTexte.createTextCursor
MonTexte.insertTextContent(Moncurseur, MonCadre2, false) 'affichage du cadre
MonCadre2.LayerId = 1
MonCadre1.name = " Intitulé du cadre Client "
MonTexte = MonCadre2.text 'écriture du texte dans le cadre
Moncurseur = MonTexte.createTextCursor
Moncurseur.CharWeight = com.sun.star.awt.FontWeight.BOLD
Moncurseur.CharPosture = com.sun.star.awt.FontSlant.ITALIC
MonTexte.insertString(Moncurseur, "Client",False)
' Remplissage du cadre Client
'---------------------------
MonTexte = MonCadre1.Text
Moncurseur = MonTexte.createTextCursor
Moncurseur.CharWeight = com.sun.star.awt.FontWeight.BOLD
MonTexte.insertString(Moncurseur, Client_Select, false) ' insert le nom du
client
Retour_ligne(1,MonCadre1.Text,Moncurseur)
MonTexte.insertString(Moncurseur, Rue, false) ' insert la rue du client
Retour_ligne(1,MonCadre1.Text,Moncurseur)
MonTexte.insertString(Moncurseur, CP &" "& Ville, false)
' Remplissage du cadre Film
'---------------------------
MonTexte = MonCadre_Film.Text
Moncurseur = MonTexte.createTextCursor
Moncurseur.CharWeight = com.sun.star.awt.FontWeight.BOLD
MonTexte.insertString(Moncurseur, Mot_Titre &" "& Titre, false) ' insert le
nom du client
Retour_ligne(1,MonCadre_Film.Text,Moncurseur)
MonTexte.insertString(Moncurseur,Mot_Datedebut &" "&
Date_debutFactureVisual, false) ' insert la rue du client
Retour_ligne(1,MonCadre_Film.Text,Moncurseur)
MonTexte.insertString(Moncurseur,Mot_Datefin &" "& Date_FinFactureVisual,
false)
'Affichage du logo Cine Soft si demandé
'---------------------------------------
If Facture_visual_logo = True then
MonDocument = ThisComponent
MonTexte = MonDocument.Text
Moncurseur = MonTexte.createTextCursor
Moncurseur.gotoStart(False)
Dim MonImage as object
Dim Path as string
DeconnecterSource()
Path = Get_Config("Logo")
MonImage = MonDocument.createInstance("com.sun.star.text.GraphicObject")
MonImage.GraphicURL = ConvertToURL(Path)
MonImage.name = "Logo"
MonImage.GraphicURL = ConvertToURL(Path)
MonImage.name = "Logo"
Taille1.Width = 4400 ' largeur en 1/100 de mm
Taille1.Height = 3200 ' largeur en 1/100 de mm
With MonImage
.AnchorType = com.sun.star.text.TextContentAnchorType.AT_PAGE
.VertOrient = com.sun.star.text.VertOrientation.NONE
.VertOrientPosition = 1000
.HoriOrient = com.sun.star.text.HoriOrientation.NONE
.HoriOrientPosition = 1000
.Surround = com.sun.star.text.WrapTextMode.THROUGHT 'Adaptation au texte :
le texte continue sous l'image
.Size = Taille1
End With
MonTexte.insertTextContent(Moncurseur, MonImage, false)
End if
'Affichage de la date de création de la facture
'-----------------------------------------
MonTexte = MonDocument.Text
Moncurseur = MonTexte.createTextCursor
Moncurseur.gotoStart(False)
MonTexte.insertString(Moncurseur, Chr(9)& Chr(9) & Chr(9)& Chr(9) & Chr(9) &
Chr(9) &Chr(9)&Chr(9)&Chr(9) &_
" Aubervilliers le "& date_facture, false)
Retour_ligne(12,MonDocument,Moncurseur)
Moncurseur.CharWeight = com.sun.star.awt.FontWeight.BOLD
MonTexte.insertString(Moncurseur, Chr(9)& Chr(9) & Chr(9)& Mot_Facture &" "&
N_facture, false)
'Création du tableau
'------------------------
Retour_ligne(6,MonDocument,Moncurseur)
Dim MonTableau as object
MonTableau = MonDocument.createInstance("com.sun.star.text.TextTable")
Dim Nbre_de_colonnes as integer
If EtrangerFactureVisual = False then
If RemiseFactureVisual <> 0 then
Nbre_de_colonnes = 7
Else
Nbre_de_colonnes = 6
end if
Else
If RemiseFactureVisual <> 0 then
Nbre_de_colonnes = 5
Else
Nbre_de_colonnes = 4
end if
End if
with MonTableau
.HoriOrient = com.sun.star.text.HoriOrientation.NONE
.Name = "Facture"
end With
MonTableau.initialize(1,Nbre_de_colonnes)
MonTexte.insertTextContent(Moncurseur, MonTableau, False) 'Affichage du
tableau
' modidification de la largeur des colonnes selon qu'il y a une remise ou
non
Dim LesSep as Variant, LesColonnes as object, largeur as double
largeur = MonTableau.TableColumnRelativeSum
LesColonnes = MonTableau.Columns
LesSep = MonTableau.TableColumnSeparators
If Nbre_de_colonnes = 4 then
LesSep(0).Position = largeur*0.5
LesSep(1).Position = largeur*0.7
LesSep(2).Position = largeur*0.85
End if
If Nbre_de_colonnes = 5 then
LesSep(0).Position = largeur*0.5
LesSep(1).Position = largeur*0.6
LesSep(2).Position = largeur*0.7
LesSep(3).Position = largeur*0.87
End if
If Nbre_de_colonnes = 6 then
LesSep(0).Position = largeur*0.5
LesSep(1).Position = largeur*0.57
LesSep(2).Position = largeur*0.62
LesSep(3).Position = largeur*0.74
LesSep(4).Position = largeur*0.875
End if
If Nbre_de_colonnes = 7 then
LesSep(0).Position = largeur*0.42
LesSep(1).Position = largeur*0.5
LesSep(2).Position = largeur*0.58
LesSep(3).Position = largeur*0.63
LesSep(4).Position = largeur*0.74
LesSep(5).Position = largeur*0.875
End if
MonTableau.TableColumnSeparators = LesSep
'Remplissage de l'intitulé des colonnes
MaCellule = MonTableau.getCellByName("A1")
Style_Character(True,True,"Center",MaCellule.createTextCursor)
Moncurseur = MaCellule.CreateTextCursor
MaCellule.insertString(Moncurseur,Mot_Design, false)
If RemiseFactureVisual <> 0 then
MaCellule = MonTableau.getCellByName("B1")
Style_Character(True,True,"Center",MaCellule.createTextCursor)
MaCellule.String = Mot_PU
MaCellule = MonTableau.getCellByName("C1")
Style_Character(True,True,"Center",MaCellule.createTextCursor)
MaCellule.String = Mot_Remise
MaCellule = MonTableau.getCellByName("D1")
Style_Character(True,True,"Center",MaCellule.createTextCursor)
MaCellule.String = Mot_Qtite
MaCellule = MonTableau.getCellByName("E1")
Style_Character(True,True,"Center",MaCellule.createTextCursor)
MaCellule.String = Mot_TotalHT
If EtrangerFactureVisual = False then
MaCellule = MonTableau.getCellByName("F1")
Style_Character(True,True,"Center",MaCellule.createTextCursor)
MaCellule.String = "T.V.A. 19,6%"
MaCellule = MonTableau.getCellByName("G1")
Style_Character(True,True,"Center",MaCellule.createTextCursor)
MaCellule.String = "Total T.T.C."
End if
Else
MaCellule = MonTableau.getCellByName("B1")
Style_Character(True,True,"Center",MaCellule.createTextCursor)
MaCellule.String = Mot_PU
MaCellule = MonTableau.getCellByName("C1")
Style_Character(True,True,"Center",MaCellule.createTextCursor)
MaCellule.String = Mot_Qtite
MaCellule = MonTableau.getCellByName("D1")
Style_Character(True,True,"Center",MaCellule.createTextCursor)
MaCellule.String = Mot_TotalHT
If EtrangerFactureVisual = False then
MaCellule = MonTableau.getCellByName("E1")
Style_Character(True,True,"Center",MaCellule.createTextCursor)
MaCellule.String = "T.V.A. 19,6%"
MaCellule = MonTableau.getCellByName("F1")
Style_Character(True,True,"Center",MaCellule.createTextCursor)
MaCellule.String = "Total T.T.C."
End if
End if
' Remplissage des lignes du tableau
MaCellule = MonTableau.getCellByName("A2")
If NB_Tech <> 0 Then
InsererLigne("Facture")
Remplir_Ligne2("Facture",Mot_Techni_Fact,RemiseFactureVisual, Salaire, 0,
NB_Tech)
End if
If Nombre_heures_sup <> 0 Then
InsererLigne("Facture")
Remplir_Ligne2("Facture",Mot_Hsup,RemiseFactureVisual,Heures_sup,0,Nombre_heures_sup)End ifIf NB_off <> 0 Then InsererLigne("Facture") Remplir_Ligne2("Facture",Mot_TransOf1,RemiseFactureVisual, Salaire/2,
0,NB_off)End IfIf CT <> 0 Then InsererLigne("Facture") Remplir_Ligne2("Facture",Mot_CineTool,RemiseFactureVisual, Prix_CT,RemiseFactureVisual, CT)End ifIf CT_trans <> 0 Then InsererLigne("Facture")
Remplir_Ligne2("Facture",Mot_TransOf2,RemiseFactureVisual, Prix_CT/2,RemiseFactureVisual, CT_trans)End ifIf Vingt_Pouce <> 0 Then InsererLigne("Facture")
Remplir_Ligne2("Facture",Mot_VingtP,RemiseFactureVisual, Prix_VP,RemiseFactureVisual, Vingt_pouce)End ifIf Quatorze_pouce <> 0 Then InsererLigne("Facture")
Remplir_Ligne2("Facture",Mot_Quatorze,RemiseFactureVisual, Prix_QP,RemiseFactureVisual, Quatorze_pouce)End ifIf Nnovia <> 0 Then InsererLigne("Facture") Remplir_Ligne2("Facture",Mot_Nnovia,RemiseFactureVisual,
Prix_Nnovia,RemiseFactureVisual, Nnovia)End if'Recherche de matéri
el sup ayant l'ID de la facture dans la BDDMatos_facture'---------------------------------------------------------------------Dim materiel(7) as string, prix(7) as double, qtite(7) as double,Assurance(7) as BooleanDim total_matos as double, n as integerDim marequete_facturevisual_materiel as objectmarequete_facturevisual_materiel = maConnexion.createStatement()ResultSet = marequete_facturevisual_materiel.executeQuery("SELECT * FROMMatos_facture "&" WHERE Num_factur="& Quote(ID_facture) &"")If matos_conso <> False then If Not IsNull(ResultSet) Then n = 0 While ResultSet.next total_matos = 0 materiel(n) = Resultset.getString(n+3) prix(n) = Resultset.getString(n+4) qtite(n) = Resultset.getString(n+5) Assurance(n) = Resultset.getString(n+6) If Assurance(n) = TRUE then total_matos = total_matos + (prix(n)*qtite(n)) End if If materiel(n) <> "" then InsererLigne("Facture") Remplir_Ligne2("Facture",materiel(n),RemiseFactureVisual, prix(n), "",qtite(n))
end if Wend End ifEnd if'Calcul de l'assurance'-----------------------dim Montant_assur as DoubleIf AssurFactureVisual = TRUE then Montant_assur = ((Prix_CT*CT)+ ((Prix_CT/2)*CT_trans)_ + (Prix_VP*Vingt_pouce)+(Prix_QP*Quatorze_pouce)_ +(Prix_Nnovia*Nnovia)+ total_matos)*0.05 InsererLigne("Facture") Remplir_Ligne2("Facture","Assurance 5%",RemiseFactureVisual, Montant_assur,"", 1)End ifIf NB_frais_T <> 0 then InsererLigne("Facture") Remplir_Ligne2("Facture",Mot_FraisT,RemiseFactureVisual,Frais_T,"",NB_frais_T)End ifIf NB_frais_off <> 0 then InsererLigne("Facture") Remplir_Ligne2("Facture",Mot_Fraisoff,RemiseFactureVisual,Frais_off,"",NB_frais_off)End if'Livraison'--------------If Livraison = TRUE then If Paris = TRUE then InsererLigne("Facture") Remplir_Ligne2("Facture",Mot_Livraiso,RemiseFactureVisual,75,"",1) Else If Jour_camion <> 0 Then InsererLigne("Facture") Remplir_Ligne2("Facture",Mot_Location,RemiseFactureVisual,39,"",Jour_camion) End if If NB_kilometre <>
0 Then InsererLigne("Facture") Remplir_Ligne2("Facture",Mot_Kilometres,RemiseFactureVisual,0.15,"",NB_kilometre) End if If Cout_peage <> 0 Then InsererLigne("Facture") Remplir_Ligne2("Facture",Mot_Peages,RemiseFactureVisual,Cout_peage,"",1) End if If conso_carburant <> 0 Then InsererLigne("Facture") Remplir_Ligne2("Facture",Mot_Carburant,RemiseFactureVisual,conso_carburant,"",1) End if End ifEnd ifMoncurseur = monDocument.CurrentController.ViewCursorRetour_ligne(3,MonDocument,Moncurseur)'Affichage du cadre Total''-------------------------Dim MonCadre_Total as objectMonCadre_Total =MonDocument.createInstance("com.sun.star.drawing.RectangleShape")'MonTexte.insertTextContent(Moncurseur, MonCadre_Total, false)If montant_accompte = 0 then Taille1.Width = 4800' largeur en 1/100 de mm MonCadre_Total.HoriOrientPosition = 11990Else Taille1.Width = 6150 MonCadre_Total.HoriOrientPosition = 10700End ifIf EtrangerFactureVisual = False then If montant_accompte = 0 then
Taille1.Height = 1950 Else Taille1.Height = 3300 End ifElse If montant_accompte = 0 then Taille1.Height = 630 Else Taille1.Height = 900 End ifEnd ifWith MonCadre_Total .RightMargin = 200 .CornerRadius = 600 .FillColor = RGB (255,255,255) .AnchorType = com.sun.star.text.TextContentAnchorType.AT_PARAGRAPH .VertOrient = com.sun.star.text.VertOrientation.NONE .HoriOrient = com.sun.star.text.HoriOrientation.NONE .VertOrientPosition = 1460 .Size = Taille1 .lineStyle = com.sun.star.drawing.LineStyle.SOLID .FillTransparence = 100End WithMonTexte.insertTextContent(Moncurseur, MonCadre_Total, false)MonCadre_Total.LayerId = 1MonCadre_Total.name = " Cadre Total "'Calcul du total'--------------------Dim Total_HT as double, Total_TVA as double, Total_TTC as double,Tableau_total as object, LesBords as objectTableau_total = MonDocument.createInstance("com.sun.star.text.TextTable")If montant_accompte = 0 then Tableau_total.initialize(3,3)Else Tableau_total.initialize(5,3)' une ligne de p
lus pour l'accompteEnd ifwith Tableau_total .HoriOrient = com.sun.star.text.HoriOrientation.NONE .RightMargin = 200end WithMoncurseur.goUp(1,False)Dim marre as variantMonTexte.insertTextContent(Moncurseur, Tableau_total, False) 'Affichage dutableaulargeur = Tableau_total.TableColumnRelativeSumLesColonnes = Tableau_total.Columnsmarre = Tableau_total.TableColumnSeparatorsIf montant_accompte = 0 then marre(0).Position = largeur*0.715 marre(1).Position = largeur*0.87 Tableau_total.TableColumnSeparators = marreElse marre(0).Position = largeur*0.64 marre(1).Position = largeur*0.87 Tableau_total.TableColumnSeparators = marreEnd ifDim unBord As new com.sun.star.table.BorderLineLesBords = Tableau_total.TableBorderWith LesBords .TopLine = unBord .LeftLine = unBord .RightLine = unBord .BottomLine = unBordEnd WithTableau_total.TableBorder = LesBordsDim MesLignes as objectMonTableau = MonDocument.TextTables(0)MesLignes = MonTableau.RowsDim i as integeri = MesLignes.Count-1For n = 1 to i
If RemiseFactureVisual <> 0 Then MaCellule = MonTableau.GetCellByPosition(4,n) Total_HT = Total_HT + MaCellule.value Else MaCellule = MonTableau.GetCellByPosition(3,n) Total_HT = Total_HT + MaCellule.value End ifNext nTotal_TVA = Total_HT * 0.196Total_TTC = Total_HT * 1.196'remplissage du champs total dans la base de donnée "liste facture" sicelui-ci est vide'---------------------------------------------------------------------------------------If Montant_facture = 0 then maRequete = maConnexion.createStatement() ResultSet = maRequete.executeQuery("SELECT * FROM Liste_fact WHERE ID='"&id_facture &"'" If Not IsNull(ResultSet) Then While ResultSet.next ResultSet.UpdateDouble(43,Total_TTC) ResultSet.UpdateRow Wend End ifEnd if'Remplissage du tableau Total'-----------------------------Dim MyFormat as stringMonTableau = MonDocument.TextTables(1)MyFormat = "0.00"MaCellule = MonTableau.getCellByPosition(0,0)MaCellule.RightBorder = unbordMaCellule.BottomBorder = unbordIf
NB_Tech <> 0 Then n = 1Else n = 0End ifIf EtrangerFactureVisual = False then MaCellule = MonTableau.getCellByPosition(0,n) MaCellule.RightBorder = unbord MaCellule.BottomBorder = unbord Style_Character(False,False,"Left",MaCellule.createTextCursor) MaCellule.string = Mot_TVA MaCellule = MonTableau.getCellByPosition(0,n+1) MaCellule.RightBorder = unbord MaCellule.BottomBorder = unbord Style_Character(False,False,"Left",MaCellule.createTextCursor) MaCellule.string = Mot_TVA2 & " " & TVAintra MaCellule = MonTableau.getCellByPosition(1,0) Style_Character(True,True,"Center",MaCellule.createTextCursor) MaCellule.LeftBorder = unbord MaCellule.String = Mot_TotalHT MaCellule = MonTableau.getCellByPosition(2,0) Style_Character(False,False,"Center",MaCellule.createTextCursor) MaCellule.String = Format(Total_HT, MyFormat) MaCellule = MonTableau.getCellByPosition(1,1) Style_Character(True,True,"Center",MaCellule.createTextCursor) MaCellule.LeftBorder = unbord Moncurseur.paraAdjust = com
.sun.star.style.ParagraphAdjust.CENTER MaCellule.String = "T.V.A. 19,6%" MaCellule = MonTableau.getCellByPosition(2,1)
Style_Character(False,False,"Center",MaCellule.createTextCursor) MaCellule.String = Format(Total_TVA, MyFormat) MaCellule =
MonTableau.getCellByPosition(1,2) Style_Character(True,True,"Center",MaCellule.createTextCursor) MaCellule.LeftBorder = unbord
Moncurseur.paraAdjust = com.sun.star.style.ParagraphAdjust.CENTER MaCellule.String = "Total T.T.C." MaCellule =
MonTableau.getCellByPosition(2,2) Style_Character(False,False,"Center",MaCellule.createTextCursor) MaCellule.String = Format(Total_TTC, MyFormat)
If montant_accompte <> 0 then MaCellule = MonTableau.getCellByPosition(0,3)
Style_Character(True,True,"Center",MaCellule.createTextCursor) MaCellule.LeftBorder = unbord MaCellule.BottomBorder = unbord MaCellule =
MonTableau.getCellByPosition(0,2) Style_Character(True,True,"Center",MaCellule.createTextCursor) MaCellule.LeftBorder = unbord MaCellule.B
ottomBorder = unbord MaCellule = MonTableau.getCellByPosition(1,3)
Style_Character(True,True,"Center",MaCellule.createTextCursor) MaCellule.LeftBorder = unbord Moncurseur.paraAdjust =
com.sun.star.style.ParagraphAdjust.CENTER MaCellule.String = "Accompte perçu T.T.C." MaCellule =
MonTableau.getCellByPosition(2,3) Style_Character(False,False,"Center",MaCellule.createTextCursor) MaCellule.RightBorder =
unbord Moncurseur.paraAdjust = com.sun.star.style.ParagraphAdjust.CENTER MaCellule.String = Format(montant_accompte, MyFormat)
MaCellule = MonTableau.getCellByPosition(1,4) Style_Character(True,True,"Center",MaCellule.createTextCursor)
MaCellule.LeftBorder = unbord Moncurseur.paraAdjust = com.sun.star.style.ParagraphAdjust.CENTER MaCellule.String = "Net à payer
T.T.C." MaCellule = MonTableau.getCellByPosition(2,4) Style_Character(False,False,"Center",MaCellule.createTextCursor)
MaCellule.RightBorder = unbord Moncurseur.paraAdjust = com.sun.star.style.Paragr
aphAdjust.CENTER MaCellule.String =Format(Total_TTC - montant_accompte,MyFormat) End if MonTexte = MonDocument.Text Moncurseur =
MonDocument.CurrentController.ViewCursor Moncurseur.CharWeight = com.sun.star.awt.FontWeight.NORMAL Retour_ligne(2,MonDocument,Moncurseur)
Style_Character(True,False,"Left",Moncurseur) Moncurseur.CharHeight = 12 MonTexte.insertString(Moncurseur, Mot_Paiement & "
" &PaiementFactureVisual, False)Else ' Il s'agit d'une facture pour l'étrangerMaCellule = MonTableau.getCellByPosition(0,n)
MaCellule.RightBorder = unbord MaCellule.BottomBorder = unbord Style_Character(False,False,"Left",MaCellule.createTextCursor)
MaCellule.string = Mot_TVA MaCellule = MonTableau.getCellByPosition(0,n+1) MaCellule.RightBorder = unbord MaCellule.BottomBorder = unbord
Moncurseur.paraAdjust = com.sun.star.style.ParagraphAdjust.LEFT MaCellule.string = Mot_TVA2 & " " & TVAintra MaCellule =
MonTableau.getCellByPosition(1,0) Style_Character(True,True,"Center",MaCellule.createT
extCursor) MaCellule.LeftBorder = unbord MaCellule.BottomBorder = unbord MaCellule.String =
Mot_TotalHT MaCellule = MonTableau.getCellByPosition(2,0)
Style_Character(False,False,"Center",MaCellule.createTextCursor) MaCellule.BottomBorder =
unbord MaCellule.String = Format(Total_HT, MyFormat) MaCellule = MonTableau.getCellByPosition(1,1)
MaCellule.LeftBorder = unbord MaCellule.BottomBorder = unbord MaCellule =
MonTableau.getCellByPosition(2,1) MaCellule.LeftBorder = unbord MaCellule.BottomBorder = unbord
MaCellule = MonTableau.getCellByPosition(1,2) MaCellule.LeftBorder = unbord MaCellule.BottomBorder
= unbord MaCellule = MonTableau.getCellByPosition(2,2) MaCellule.LeftBorder = unbord
MaCellule.BottomBorder = unbord MonTexte = MonDocument.Text Moncurseur =
MonDocument.CurrentController.ViewCursor Moncurseur.CharWeight = com.sun.star.awt.FontWeight.NORMAL
Retour_ligne(2,MonDocument,Moncurseur) Style_Character(True,False,"Left",Moncurseur)
Moncurseur.CharHeight = 10 MonTexte.i
nsertString(Moncurseur,Mot_CGI, False) Retour_ligne(4,MonDocument,Moncurseur) Moncurseur.CharHeight = 12
MonTexte.insertString(Moncurseur, Mot_Paiement & PaiementFactureVisual,False)End
ifMonDocument.unlockControllersEnd SubPublic Sub Remplir_Ligne2(Nom_Tableau as string,Intitule as string,
Remiseas integer,cel1 as double, cel2 as integer, cel3 as double)'Cel1 = Prix unitaire, Cel2 = Remise, Cel3 =
QtitéDim MonDocument As Object, MonTableau as objectDim MesLignes as objectMonDocument =
ThisComponentMonTableau = MonDocument.TextTables.getByName(Nom_Tableau)MesLignes = MonTableau.RowsDim i as
integeri = MesLignes.Count-1If EtrangerFactureVisual = False Then If Remise <> 0 Then MaCellule =
MonTableau.getCellByPosition(0,i) Style_Character(True,True,"Left",MaCellule.createTextCursor)
MaCellule.String = Intitule MaCellule = MonTableau.getCellByPosition(1,i)
Style_Character(False,False,"Center",MaCellule.createTextCursor) MaCellule.Value = cel1 MaCellule
= MonTableau.getCel
lByPosition(2,i) If Cel2 <> 0 Then Style_Character(False,false,"Center",MaCellule.createTextCursor) MaCellule.String = Cel2 &"%" Else MaCellule.String = "" End if MaCellule = MonTableau.getCellByPosition(3,i) Style_Character(False,False,"Center",MaCellule.createTextCursor) MaCellule.Value = cel3 MaCellule = MonTableau.getCellByPosition(4,i) Style_Character(False,false,"Center",MaCellule.createTextCursor) MaCellule.Value = (cel3*cel1)*(1-(cel2/100)) MaCellule = MonTableau.getCellByPosition(5,i) Style_Character(False,false,"Center",MaCellule.createTextCursor) MaCellule.Value = (cel3*cel1)*(1-(cel2/100))*0.196 MaCellule = MonTableau.getCellByPosition(6,i) Style_Character(False,false,"Center",MaCellule.createTextCursor) MaCellule.Value = (cel3*cel1)*(1-(cel2/100))*1.196 Else MaCellule = MonTableau.getCellByPosition(0,i) Style_Character(True,True,"Left",MaCellule.createTextCursor) MaCellule.String = Intitule MaCellule = MonTableau.getCellByPosition(1,i)
Style_Character(False,False,"Center",MaCellule.createTextCursor) MaCellule.Value = cel1 MaCellule = MonTableau.getCellByPosition(2,i) Style_Character(False,False,"Center",MaCellule.createTextCursor) MaCellule.Value = cel3 MaCellule = MonTableau.getCellByPosition(3,i) Style_Character(False,False,"Center",MaCellule.createTextCursor) MaCellule.Value = (cel3*cel1) MaCellule = MonTableau.getCellByPosition(4,i) Style_Character(False,False,"Center",MaCellule.createTextCursor) MaCellule.Value = (cel3*cel1)*0.196 MaCellule = MonTableau.getCellByPosition(5,i) Style_Character(False,False,"Center",MaCellule.createTextCursor) MaCellule.Value = (cel3*cel1)*1.196 End ifElse 'Il s'agit d'une facture Hors TVA - Donc 4 ou 5 colonnes If Remise <> 0 Then MaCellule = MonTableau.getCellByPosition(0,i) Style_Character(True,True,"Left",MaCellule.createTextCursor) MaCellule.String = Intitule MaCellule = MonTableau.getCellByPosition(1,i) Style_Character(False,False,"Center",MaCellu
le.createTextCursor) MaCellule.Value = cel1 MaCellule = MonTableau.getCellByPosition(2,i) If Cel2 <> 0 Then
Style_Character(False,false,"Center",MaCellule.createTextCursor) MaCellule.String = Cel2 &"%" Else MaCellule.String = "" End if
MaCellule = MonTableau.getCellByPosition(3,i) Style_Character(False,False,"Center",MaCellule.createTextCursor) MaCellule.Value = cel3 MaCellule =
MonTableau.getCellByPosition(4,i) Style_Character(False,false,"Center",MaCellule.createTextCursor) MaCellule.Value = (cel3*cel1)*(1-(cel2/100)) Else
MaCellule = MonTableau.getCellByPosition(0,i) Style_Character(True,True,"Left",MaCellule.createTextCursor) MaCellule.String = Intitule MaCellule =
MonTableau.getCellByPosition(1,i) Style_Character(False,False,"Center",MaCellule.createTextCursor) MaCellule.Value = cel1 MaCellule =
MonTableau.getCellByPosition(2,i) Style_Character(False,False,"Center",MaCellule.createTextCursor) MaCellule.Value = cel3 MaCellule = MonTableau.getC
ellByPosition(3,i)
Style_Character(False,False,"Center",MaCellule.createTextCursor)
MaCellule.Value = (cel3*cel1) End ifEnd ifEnd Sub
---------------------------------------------------------------------
To unsubscribe, e-mail: prog-unsubscr...@fr.openoffice.org
For additional commands, e-mail: prog-h...@fr.openoffice.org