1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
| Sub PysDateJour
'Lancée au changement d'enregistrement
'Met la date du jour dans le contrôle Date
dim PysCtrlDate as object
dim PysDate as variant, PysDateLong as long
'Pointe vers le contrôle Date dans
' le formulaire nommé "Standard" dans
' la collection des formulaires dans
' la couche "dessin"
' du document courant
PysCtrlDate = thiscomponent.DrawPage.Forms.getByName("DONNEES").getByName("date_creation_fiche")
'La fonction Date retourne la date en texte : JJ/MM/AAAA
'On crée un tableau en découpant au "/"
PysDate = split(Date, "/")
'Conversion en type Long et mise au format AAAAMMJJ
PysDateLong = PysDate(2) & PysDate(1) & PysDate(0)
'Si la date est vide
'Affectation de cette valeur à la propriété Date du contrôle
if isEmpty(PysCtrlDate.Date) then
PysCtrlDate.Date = PysDateLong
'Validation du contrôle
PysCtrlDate.commit
end if
End Sub
REM ***** BASIC *****
' Rechercher un code point de vente dans la table TPVente
Sub Rechercher()
Dim sTexte As String
Dim oMForm As Object
Dim sSQL As String
oMForm = thisComponent.DrawPage.Forms.getByName("MainForm") 'objet formulaire
sTexte = oMForm.getByName("d1").Text ' le texte entré
'sSQL = "SELECT * FROM ""TPVente"" WHERE ""Code point de vente"" LIKE '%" & sTexte & "%'"
'sSQL+=" WHERE `contrats`.`DateFin` > {D '2000-07-14' }"
oldSQL=oMForm.command
oMForm.command = sSQL 'maj ordre SQL dans le formulaire
oMForm.reload 'rechargement du formulaire
End Sub
Sub changeFstURL()
dim aze as Variant
dim fst as variant
aze = thiscomponent.DrawPage.Forms.getByName("DONNEES").getByName("B1")
fst=thiscomponent.DrawPage.Forms.getByName("DONNEES").getByName("num_fiche_suiveuse").Text
'aze.label=fst
aze.TargetURL="http://10.0.0.3/ebpweb/suivicmdclient.php?saisie_recherche="+fst+"&type_recherche=code"
End Sub
Sub findGeoloc()
'Recuperation de l'adresse depuis les differents champs
Dim adresse as Variant
Dim codePostal as Variant
Dim ville as Variant
adresse = thiscomponent.DrawPage.Forms.getByName("DONNEES").getByName("client_adresse").Text
codePostal = thiscomponent.DrawPage.Forms.getByName("DONNEES").getByName("client_code_postal").Text
ville = thiscomponent.DrawPage.Forms.getByName("DONNEES").getByName("client_ville").Text
adresse = Replace(adresse, " ", ",+")
'Domande a Google des informations sur l'adresse
'Attention Google peut retourner plusieurs adresses (qu'il trouve similaire)
Dim oXMLHTTP as Object
Dim oXMLDoc as Object
Set oXMLHTTP = CreateObject("Microsoft.XMLHTTP")
oXMLHTTP.Open "GET", "http://maps.googleapis.com/maps/api/geocode/xml?address="+adresse+",+"+codePostal+",+"+ville+"®ion=fr&sensor=false"
'oXMLHTTP.Open "GET", "http://maps.googleapis.com/maps/api/geocode/xml?address=valence®ion=fr&sensor=false"
oXMLHTTP.Send
Do While oXMLHTTP.readyState <> 4
DoEvents
Loop
Set oXMLDoc = CreateObject("MSXML2.DOMDocument")
oXMLDoc.LoadXML (oXMLHTTP.responseText)
If oXMLDoc.parseError.errorCode <> 0 Then
MsgBox "Erreur:"+oXMLDoc.parseError.reason
Goto err
End If
'MsgBox "xml="+oXMLDoc.xml+"!"
'Creation d'une boite de dialogue pour que l'utilisateur choisisse parmi les reponses
Dim oPDialog as Object
Dim oListBox as Object
exitOK = com.sun.star.ui.dialogs.ExecutableDialogResults.OK
DialogLibraries.Loadlibrary("Standard")
oPDialog = CreateUnoDialog(DialogLibraries.Standard.geolocDiag)
oListBox = oPDialog.getControl("ListBox1")
oListBox.setMultipleMode(false)
'Parse le resultat de la demande Google (au format XML)
Dim oNodeResult as Object
Dim oNodeAddress as Object
Dim foundAddress as Variant
Dim i as Integer, j as Integer
oNodeResult = oXMLDoc.DocumentElement.getElementsByTagName("result")
For i=0 To oNodeResult.length-1
'MsgBox "result="+oNodeResult.Item(i).nodeTypedValue+"!"
oNodeAddress = oNodeResult.Item(i).getElementsByTagName("address_component")
For j=0 To oNodeAddress.length-1
foundAddress = foundAddress + oNodeAddress.Item(j).getElementsByTagName("long_name").Item(0).nodeTypedValue + ", "
Next
oListBox.addItem(foundAddress, i)
'MsgBox "adresse="+foundAddress+"!"
Next
oListBox.selectItemPos(0, true)
'Execute la boite de dialogue avec les choix possible
iDialogResult = oPDialog.Execute()
If iDialogResult <> exitOK Then
'MsgBox "Exec res=Annuler"
Goto err
End If
'Recuperation des coordonnees GPS a partir du choix de l'utilisateur
Dim oNodeGPS as Object
Dim lat as String
Dim lng as String
'MsgBox "Exec res="+oListBox.getSelectedItemPos+"!"
oNodeGPS = oNodeResult.Item(oListBox.getSelectedItemPos).getElementsByTagName("geometry")
lat = oNodeGPS.Item(0).getElementsByTagName("lat").Item(0).nodeTypedValue
lng = oNodeGPS.Item(0).getElementsByTagName("lng").Item(0).nodeTypedValue
'MsgBox "lattitude="+lat+" et "+"longitude="+lng+"!"
'Mise a jour du champ coordonnees GPS
Dim geolocField as Variant
geolocField = thiscomponent.DrawPage.Forms.getByName("DONNEES").getByName("géoloc")
geolocField.Text = lat+", "+lng
geolocField.commit
err:
Set oXMLHTTP = Nothing
Set oXMLDoc = Nothing
End Sub
Sub rafSubForm()
Dim oMForm As Object
Dim x As Object
'oMForm = thisComponent.DrawPage.Forms.getByName("MainForm").getByName("SubForm") 'objet formulaire
oMForm = thisComponent.DrawPage.Forms.getByName("MainForm")
x=oMForm.getByName("fmtrevendeur_id")
' oMForm.dispose()
oMForm.updateRow()
oMForm.reload 'rechargement du sous formulaire
End Sub |
Partager