text
stringlengths
0
15.7k
source
stringlengths
6
112
logToFileAndToConsole("<---- Récupération des données de l'utilisateur")
AppDelegate copy 4.applescript
end recupDonneesDeLUtilisateur
AppDelegate copy 4.applescript
on recupInfosClientDansContacts()
AppDelegate copy 4.applescript
logToFileAndToConsole("----> Récupération des infos dans Contacts")
AppDelegate copy 4.applescript
set ficheclientTrouvees to every person whose name contains nomClient
AppDelegate copy 4.applescript
if (count of ficheclientTrouvees) = 0 then
AppDelegate copy 4.applescript
tell current application to my logToFileAndToConsole("Aucune personne ne porte ce nom.")
AppDelegate copy 4.applescript
display dialog "Aucun contact dont le nom de famille est \"" & ¬
AppDelegate copy 4.applescript
nomClient & "\" n'a été trouvé." & return & ¬
AppDelegate copy 4.applescript
"Veuillez créer le contact et relancer le programme." & return & ¬
AppDelegate copy 4.applescript
"Fin du programme." with title ¬
AppDelegate copy 4.applescript
"Facture" buttons {"Terminer"} cancel button "Terminer" default button "Terminer"
AppDelegate copy 4.applescript
else if (count of ficheclientTrouvees) = 1 then
AppDelegate copy 4.applescript
set ficheClient to first item of ficheclientTrouvees
AppDelegate copy 4.applescript
else if (count of ficheclientTrouvees) > 1 then
AppDelegate copy 4.applescript
set nomsClients to {}
AppDelegate copy 4.applescript
repeat with unClient in ficheclientTrouvees
AppDelegate copy 4.applescript
set end of nomsClients to name of unClient
AppDelegate copy 4.applescript
set listeReponse to choose from list nomsClients ¬
AppDelegate copy 4.applescript
with title ¬
AppDelegate copy 4.applescript
"Facture" with prompt "Il y a plus d'un contact qui porte le nom " & nomClient & return & ¬
AppDelegate copy 4.applescript
"Choisissez dans la liste le contact que vous recherchez." OK button name ¬
AppDelegate copy 4.applescript
"Annuler" without multiple selections allowed
AppDelegate copy 4.applescript
set nomClient to item 1 of listeReponse
AppDelegate copy 4.applescript
set pos to my list_position(nomClient, nomsClients)
AppDelegate copy 4.applescript
set ficheClient to item pos of ficheclientTrouvees
AppDelegate copy 4.applescript
set nomClient to name of ficheClient
AppDelegate copy 4.applescript
tell current application to my logToFileAndToConsole("Nom du client : " & nomClient)
AppDelegate copy 4.applescript
if company of ficheClient is true then
AppDelegate copy 4.applescript
set formeJuridiqueClient to "Entreprise"
AppDelegate copy 4.applescript
set formeJuridiqueClient to "Particulier"
AppDelegate copy 4.applescript
tell current application to my logToFileAndToConsole("Forme juridique du client : " & formeJuridiqueClient)
AppDelegate copy 4.applescript
set contactEmail to emails of ficheClient
AppDelegate copy 4.applescript
if contactEmail ≠ {} then
AppDelegate copy 4.applescript
display dialog "Aucune adresse mèle renseignée pour le client \"" & nomClient & "\"." & ¬
AppDelegate copy 4.applescript
return & ¬
AppDelegate copy 4.applescript
"Veuillez compléter la fiche client et relancer le programme." & return & ¬
AppDelegate copy 4.applescript
if (count of contactEmail) > 1 then
AppDelegate copy 4.applescript
set theEmails to {}
AppDelegate copy 4.applescript
repeat with anEmail in contactEmail
AppDelegate copy 4.applescript
set end of theEmails to label of anEmail & ": " & value of anEmail
AppDelegate copy 4.applescript
set contactEmail to first item of (choose from list theEmails with prompt "Veuillez sélectionner l'adresse mail à utiliser :")
AppDelegate copy 4.applescript
set adresseCourrierClient to text item -1 of contactEmail
AppDelegate copy 4.applescript
else if (count of contactEmail) = 1 then
AppDelegate copy 4.applescript
set adresseCourrierClient to value of first item of contactEmail
AppDelegate copy 4.applescript
tell current application to my logToFileAndToConsole("Adresse mail du client : " & adresseCourrierClient)
AppDelegate copy 4.applescript
set adresseClient to first item of address of ficheClient
AppDelegate copy 4.applescript
tell adresseClient
AppDelegate copy 4.applescript
if (street is missing value) then
AppDelegate copy 4.applescript
set adresseFormateeClient to zip & space & city
AppDelegate copy 4.applescript
set adresseFormateeClient to street & space & zip & space & city
AppDelegate copy 4.applescript
tell current application to my logToFileAndToConsole("Adresse formatée du client : " & adresseFormateeClient)
AppDelegate copy 4.applescript
display dialog "Aucune adresse renseignée pour le client \"" & nomClient & "\"." & ¬
AppDelegate copy 4.applescript
return & "Veuillez compléter la fiche client et relancer le programme." & return & ¬
AppDelegate copy 4.applescript
end tell -- application "Contacts"
AppDelegate copy 4.applescript
tfNomClient's setStringValue:nomClient
AppDelegate copy 4.applescript
logToFileAndToConsole("<---- Récupération des infos dans Contacts")
AppDelegate copy 4.applescript
end recupInfosClientDansContacts
AppDelegate copy 4.applescript
on creerFactureDansExcel()
AppDelegate copy 4.applescript
logToFileAndToConsole("----> Création de la facture dans Excel")
AppDelegate copy 4.applescript
set aliasTemporaryItems to (path to temporary items from user domain)
AppDelegate copy 4.applescript
open cheminPOSIXModeleFactureExcel as POSIX file
AppDelegate copy 4.applescript
tell worksheet "Sheet1" of active workbook
AppDelegate copy 4.applescript
set value of cell "D4" to numeroFacture
AppDelegate copy 4.applescript
set value of cell "B11" to numeroFacture
AppDelegate copy 4.applescript
set value of cell "B12" to short date string of dateIntervention
AppDelegate copy 4.applescript
set value of cell "B14" to nomClient
AppDelegate copy 4.applescript
set value of cell "B15" to adresseFormateeClient
AppDelegate copy 4.applescript
set value of cell "B16" to formeJuridiqueClient
AppDelegate copy 4.applescript
set value of cell "A21" to typeIntervention
AppDelegate copy 4.applescript
set value of cell "C21" to dureeIntervention
AppDelegate copy 4.applescript
set value of cell "D21" to dureeIntervention * prixHoraire
AppDelegate copy 4.applescript
end tell --worksheet "Sheet1" of active workbook
AppDelegate copy 4.applescript
set name of active sheet to (prefixNomFichierFacture & (numeroFacture as text))
AppDelegate copy 4.applescript
tell active sheet to save as filename ((aliasTemporaryItems as text) & "_" & extensionFichierFacture) file format PDF file format
AppDelegate copy 4.applescript
tell current application to my logToFileAndToConsole("Facture enregistrée en tant que : " & ((aliasTemporaryItems as text) & "_ " & nomFichierFacture))
AppDelegate copy 4.applescript
quit without saving
AppDelegate copy 4.applescript
end tell --application "Microsoft Excel"
AppDelegate copy 4.applescript
logToFileAndToConsole("<---- Création de la facture dans Excel")
AppDelegate copy 4.applescript
return ((aliasTemporaryItems as text) & "_ " & nomFichierFacture) as alias
AppDelegate copy 4.applescript
end creerFactureDansExcel
AppDelegate copy 4.applescript
on renommeElement(aliasElement, nouveauNom)
AppDelegate copy 4.applescript
tell application "Finder" to set name of aliasElement to nouveauNom
AppDelegate copy 4.applescript
end renommeElement
AppDelegate copy 4.applescript
on deplaceElement(aliasElement, aliasDestination)
AppDelegate copy 4.applescript
set retour to move aliasElement to aliasDestination
AppDelegate copy 4.applescript
display alert "Impossible de déplacer l'élément : " & ¬
AppDelegate copy 4.applescript
(POSIX path of aliasElement) & return ¬
AppDelegate copy 4.applescript
& "Un élément portant le même nom existe peut-être déjà." & return ¬
AppDelegate copy 4.applescript
& "Opération de déplacement annulée."
AppDelegate copy 4.applescript
set retour to aliasElement
AppDelegate copy 4.applescript
return retour
AppDelegate copy 4.applescript
end deplaceElement
AppDelegate copy 4.applescript
on envoieFactureAvecMail()
AppDelegate copy 4.applescript
set nouveauMessage to make new outgoing message with properties {sender:monAdresseCourrier, subject:monSujet, visible:true, content:contenuMessage}
AppDelegate copy 4.applescript
tell nouveauMessage
AppDelegate copy 4.applescript
make new recipient at end of to recipients with properties {address:adresseCourrierClient}
AppDelegate copy 4.applescript
make new attachment with properties {file name:(POSIX path of cheminPOSIXFactureFinal)} -- inséré à la fin du message
AppDelegate copy 4.applescript
click pop up button 1
AppDelegate copy 4.applescript
click menu item 3 of menu 1 of pop up button 1
AppDelegate copy 4.applescript