Example #1
0
    def ApercuFactures(self, dictComptes={}):
        # Récupération des paramètres d'affichage
        dlg = DLG_Apercu_facture.Dialog(self, provisoire=True)
        if dlg.ShowModal() == wx.ID_OK:
            dictOptions = dlg.GetParametres()
            dlg.Destroy()
        else:
            dlg.Destroy()
            return False

        # Fabrication du PDF
        dlgAttente = PBI.PyBusyInfo(
            _(u"Création de l'aperçu au format PDF..."),
            parent=None,
            title=_(u"Veuillez patienter..."),
            icon=wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Logo.png"),
                           wx.BITMAP_TYPE_ANY))
        wx.Yield()
        try:
            UTILS_Impression_facture.Impression(
                dictComptes, dictOptions, IDmodele=dictOptions["IDmodele"])
            del dlgAttente
        except Exception, err:
            del dlgAttente
            traceback.print_exc(file=sys.stdout)
            dlg = wx.MessageDialog(
                self,
                _(u"Désolé, le problème suivant a été rencontré dans la création de l'aperçu des factures : \n\n%s"
                  ) % err, _(u"Erreur"), wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
            return False
Example #2
0
    def ApercuFactures(self, dictComptes={}):
        # Récupération des paramètres d'affichage
        dlg = DLG_Apercu_facture.Dialog(self, provisoire=True)
        if dlg.ShowModal() == wx.ID_OK:
            dictOptions = dlg.GetParametres()
            dlg.Destroy()
        else:
            dlg.Destroy()
            return False

        # Fabrication du PDF
        dlgAttente = wx.BusyInfo(_(u"Création de l'aperçu au format PDF..."),
                                 None)
        if 'phoenix' not in wx.PlatformInfo:
            wx.Yield()
        try:
            UTILS_Impression_facture.Impression(
                dictComptes, dictOptions, IDmodele=dictOptions["IDmodele"])
            del dlgAttente
        except Exception as err:
            del dlgAttente
            traceback.print_exc(file=sys.stdout)
            dlg = wx.MessageDialog(
                self,
                _(u"Désolé, le problème suivant a été rencontré dans la création de l'aperçu des factures : \n\n%s"
                  ) % err, _(u"Erreur"), wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
            return False
    def AfficherApercu(self, event=None):
        if len(self.Selection()) == 0:
            dlg = wx.MessageDialog(
                self,
                _(u"Vous n'avez sélectionné aucune facture dans la liste !"),
                _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            return
        track = self.Selection()[0]
        IDfamille = track.IDfamille
        IDcompte_payeur = track.IDcompte_payeur

        # Récupération des données
        dictCompte = self.dictComptes[IDcompte_payeur]

        # Récupération des paramètres d'affichage
        dlg = DLG_Apercu_facture.Dialog(self, provisoire=True)
        if dlg.ShowModal() == wx.ID_OK:
            dictOptions = dlg.GetParametres()
            dlg.Destroy()
        else:
            dlg.Destroy()
            return False

        # Fabrication du PDF
        dlgAttente = PBI.PyBusyInfo(
            _(u"Création de l'aperçu au format PDF..."),
            parent=None,
            title=_(u"Veuillez patienter..."),
            icon=wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Logo.png"),
                           wx.BITMAP_TYPE_ANY))
        wx.Yield()
        try:
            UTILS_Impression_facture.Impression(
                {IDcompte_payeur: dictCompte},
                dictOptions,
                IDmodele=dictOptions["IDmodele"])
            del dlgAttente
        except Exception, err:
            del dlgAttente
            traceback.print_exc(file=sys.stdout)
            dlg = wx.MessageDialog(
                self,
                _(u"Désolé, le problème suivant a été rencontré dans la création de l'aperçu de la facture : \n\n%s"
                  ) % err, _(u"Erreur"), wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
            return False
Example #4
0
    def OnBoutonOk(self, event):
        # Récupération du dictOptions
        dictOptions = self.ctrl_parametres.GetOptions()
        if dictOptions == False:
            return False

        # Récupération du signataire
        infosSignataire = self.ctrl_parametres.ctrl_parametres.GetInfosSignataire(
        )
        if infosSignataire == None:
            dlg = wx.MessageDialog(
                self, _(u"Vous n'avez sélectionné aucun signataire !"),
                _(u"Annulation"), wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            return False

        # Création du PDF
        dictComptes = self.ctrl_attestations.GetDonnees(
            dictOptions=dictOptions, infosSignataire=infosSignataire)

        # Si aucune attestation à créer
        if len(dictComptes) == 0:
            dlg = wx.MessageDialog(
                self, _(u"Il n'y a aucune attestation à créer !"),
                _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            return

        # Préparation des commentaires
        dictCommentaires = {}
        for track in self.listePrestations:
            if track["commentaire"] != "":
                dictCommentaires[(track["label"],
                                  track["IDactivite"])] = track["commentaire"]
        dictOptions["dictCommentaires"] = dictCommentaires

        # Détail
        if dictOptions["affichage_prestations"] == 0:
            detail = True
        else:
            detail = False

        # Création des PDF à l'unité
        repertoire = dictOptions["repertoire_copie"]
        if repertoire not in (None, ""):
            dlgAttente = wx.BusyInfo(
                _(u"Génération des attestations à l'unité au format PDF..."
                  ), None)
            if 'phoenix' not in wx.PlatformInfo:
                wx.Yield()
            try:
                index = 0
                for IDcompte_payeur, dictCompte in dictComptes.items():
                    IDattestation = dictCompte["num_attestation"]
                    nomTitulaires = Supprime_accent(
                        dictCompte["nomSansCivilite"])
                    nomFichier = _(u"Attestation %d - %s") % (IDattestation,
                                                              nomTitulaires)
                    cheminFichier = u"%s/%s.pdf" % (repertoire, nomFichier)
                    dictComptesTemp = {IDcompte_payeur: dictCompte}
                    self.EcritStatusbar(
                        _(u"Génération de l'attestation %d/%d : %s") %
                        (index, len(dictComptes), nomFichier))
                    UTILS_Impression_facture.Impression(
                        dictComptesTemp,
                        dictOptions,
                        IDmodele=dictOptions["IDmodele"],
                        mode="attestation",
                        ouverture=False,
                        nomFichier=cheminFichier)
                    index += 1
                self.EcritStatusbar("")
                del dlgAttente
            except Exception as err:
                del dlgAttente
                traceback.print_exc(file=sys.stdout)
                dlg = wx.MessageDialog(
                    self,
                    _(u"Désolé, le problème suivant a été rencontré dans la génération des attestations : \n\n%s"
                      ) % err, _(u"Erreur"), wx.OK | wx.ICON_ERROR)
                dlg.ShowModal()
                dlg.Destroy()
                return False

        # Fabrication du PDF global
        dlgAttente = wx.BusyInfo(
            _(u"Génération du lot d'attestations au format PDF..."), None)
        if 'phoenix' not in wx.PlatformInfo:
            wx.Yield()
        self.EcritStatusbar(
            _(u"Génération du lot d'attestations de rappel en cours... veuillez patienter..."
              ))
        try:
            UTILS_Impression_facture.Impression(
                dictComptes,
                dictOptions,
                IDmodele=dictOptions["IDmodele"],
                mode="attestation")
            self.EcritStatusbar("")
            del dlgAttente
        except Exception as err:
            del dlgAttente
            traceback.print_exc(file=sys.stdout)
            dlg = wx.MessageDialog(
                self,
                _(u"Désolé, le problème suivant a été rencontré dans la génération des attestations : \n\n%s"
                  ) % err, _(u"Erreur"), wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
            return False

        self.impressionEffectuee = True
        self.donnees = dictComptes
class Dialog(wx.Dialog):
    def __init__(self, parent, date_debut=None, date_fin=None, dateNaiss=None, listeActivites=[], listePrestations=[]):
        wx.Dialog.__init__(self, parent, -1, name="DLG_Attestations_selection", style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.MAXIMIZE_BOX|wx.MINIMIZE_BOX)
        self.parent = parent
        self.date_debut = date_debut
        self.date_fin = date_fin
        self.dateNaiss = dateNaiss
        self.listeActivites = listeActivites
        self.listePrestations = listePrestations
        
        self.impressionEffectuee = False
        self.donnees = {}
        
        # Attestations
        self.staticbox_attestations_staticbox = wx.StaticBox(self, -1, _(u"Attestations à créer"))
        self.ctrl_attestations = CTRL_Attestations_selection.CTRL(self, date_debut=self.date_debut, date_fin=self.date_fin, dateNaiss=self.dateNaiss, listeActivites=self.listeActivites, listePrestations=self.listePrestations)
        
        self.hyper_payes = Hyperlien(self, label=_(u"Sélectionner uniquement les payés"), infobulle=_(u"Cliquez ici pour sélectionner uniquement les payés"), URL="payes")
        self.label_separation_1 = wx.StaticText(self, -1, u"|")
        self.hyper_tout = Hyperlien(self, label=_(u"Tout sélectionner"), infobulle=_(u"Cliquez ici pour tout sélectionner"), URL="tout")
        self.label_separation_2 = wx.StaticText(self, -1, u"|")
        self.hyper_rien = Hyperlien(self, label=_(u"Tout désélectionner"), infobulle=_(u"Cliquez ici pour tout désélectionner"), URL="rien")

        # Options des documents
        self.ctrl_parametres = CTRL_Attestations_options.CTRL(self, listeActivites=listeActivites)

        # Boutons
        self.bouton_aide = CTRL_Bouton_image.CTRL(self, texte=_(u"Aide"), cheminImage="Images/32x32/Aide.png")
        self.bouton_liste = CTRL_Bouton_image.CTRL(self, texte=_(u"Liste"), cheminImage="Images/32x32/Imprimante.png")
        self.bouton_ok = CTRL_Bouton_image.CTRL(self, texte=_(u"Aperçu"), cheminImage="Images/32x32/Apercu.png")
        self.bouton_annuler = CTRL_Bouton_image.CTRL(self, texte=_(u"Fermer"), cheminImage="Images/32x32/Fermer.png")
        
        self.Bind(wx.EVT_BUTTON, self.OnBoutonAide, self.bouton_aide)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonListe, self.bouton_liste)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonOk, self.bouton_ok)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonAnnuler, self.bouton_annuler)
        self.Bind(wx.EVT_CLOSE, self.OnBoutonAnnuler)

        self.__set_properties()
        self.__do_layout()

        # Init contrôles
        self.ctrl_attestations.MAJ() 

    def __set_properties(self):
        self.SetTitle(_(u"Sélection des attestations à éditer"))
        self.bouton_aide.SetToolTip(wx.ToolTip(_(u"Cliquez ici pour obtenir de l'aide")))
        self.bouton_liste.SetToolTip(wx.ToolTip(_(u"Cliquez ici pour imprimer la liste affichée")))
        self.bouton_ok.SetToolTip(wx.ToolTip(_(u"Cliquez ici pour créer l'aperçu des attestations (PDF)")))
        self.bouton_annuler.SetToolTip(wx.ToolTip(_(u"Cliquez ici pour fermer")))
        self.SetMinSize((600, 650))

    def __do_layout(self):
        grid_sizer_base = wx.FlexGridSizer(rows=3, cols=1, vgap=10, hgap=10)
        
        # Attestations
        staticbox_attestations = wx.StaticBoxSizer(self.staticbox_attestations_staticbox, wx.VERTICAL)
        grid_sizer_attestations = wx.FlexGridSizer(rows=2, cols=1, vgap=5, hgap=10)
        grid_sizer_attestations.Add(self.ctrl_attestations, 1, wx.EXPAND, 0)
        
        grid_sizer_commandes = wx.FlexGridSizer(rows=1, cols=6, vgap=5, hgap=5)
        grid_sizer_commandes.Add( (5, 5), 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_commandes.Add(self.hyper_payes, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_commandes.Add(self.label_separation_1, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_commandes.Add(self.hyper_tout, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_commandes.Add(self.label_separation_2, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_commandes.Add(self.hyper_rien, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer_commandes.AddGrowableCol(0)
        
        grid_sizer_attestations.Add(grid_sizer_commandes, 1, wx.EXPAND, 0)
        grid_sizer_attestations.AddGrowableCol(0)
        grid_sizer_attestations.AddGrowableRow(0)
        
        staticbox_attestations.Add(grid_sizer_attestations, 1, wx.ALL|wx.EXPAND, 5)
        grid_sizer_base.Add(staticbox_attestations, 1, wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT, 10)        

        # Options
        grid_sizer_base.Add(self.ctrl_parametres, 1, wx.EXPAND|wx.LEFT|wx.RIGHT, 10)
        
        # Boutons
        grid_sizer_boutons = wx.FlexGridSizer(rows=1, cols=5, vgap=10, hgap=10)
        grid_sizer_boutons.Add(self.bouton_aide, 0, 0, 0)
        grid_sizer_boutons.Add(self.bouton_liste, 0, 0, 0)
        grid_sizer_boutons.Add((20, 20), 0, wx.EXPAND, 0)
        grid_sizer_boutons.Add(self.bouton_ok, 0, 0, 0)
        grid_sizer_boutons.Add(self.bouton_annuler, 0, 0, 0)
        grid_sizer_boutons.AddGrowableCol(2)
        grid_sizer_base.Add(grid_sizer_boutons, 1, wx.LEFT|wx.RIGHT|wx.BOTTOM|wx.EXPAND, 10)
        
        self.SetSizer(grid_sizer_base)
        grid_sizer_base.Fit(self)
        grid_sizer_base.AddGrowableRow(0)
        grid_sizer_base.AddGrowableCol(0)
        self.Layout()
        self.CenterOnScreen()

    def EcritStatusbar(self, texte=u""):
        try :
            topWindow = wx.GetApp().GetTopWindow() 
            topWindow.SetStatusText(texte)
        except : 
            pass
    
    def OnChoixIntitules(self, event=None):
        typeLabel = self.ctrl_intitules.GetID()
        self.ctrl_attestations.typeLabel = typeLabel
        self.ctrl_attestations.MAJ() 

    def CochePayes(self):
        self.ctrl_attestations.SelectPayes() 
        
    def CocheTout(self):
        self.ctrl_attestations.CocheTout()

    def DecocheTout(self):
        self.ctrl_attestations.DecocheTout()
    
    def OnBoutonListe(self, event):
        self.ctrl_attestations.ImpressionListe() 

    def OnBoutonAide(self, event):
        from Utils import UTILS_Aide
        UTILS_Aide.Aide("Gnration2")

    def OnBoutonAnnuler(self, event):
        if self.impressionEffectuee == True :
            self.Sauvegarder() 
        # Fermeture de la fenêtre
        self.EndModal(200)

    def OnBoutonOk(self, event):
        # Récupération du dictOptions
        dictOptions = self.ctrl_parametres.GetOptions() 
        if dictOptions == False :
            return False
        
        # Récupération du signataire
        infosSignataire = self.ctrl_parametres.ctrl_parametres.GetInfosSignataire() 
        if infosSignataire == None :
            dlg = wx.MessageDialog(self, _(u"Vous n'avez sélectionné aucun signataire !"), _(u"Annulation"), wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            return False
                
        # Création du PDF
        dictComptes = self.ctrl_attestations.GetDonnees(dictOptions=dictOptions, infosSignataire=infosSignataire) 
    
        # Si aucune attestation à créer
        if len(dictComptes) == 0 : 
            dlg = wx.MessageDialog(self, _(u"Il n'y a aucune attestation à créer !"), _(u"Erreur de saisie"), wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            return

        # Préparation des commentaires
        dictCommentaires = {}
        for track in self.listePrestations :
            if track["commentaire"] != "" :
                dictCommentaires[(track["label"], track["IDactivite"])] = track["commentaire"]
        dictOptions["dictCommentaires"] = dictCommentaires

        # Détail
        if dictOptions["affichage_prestations"] == 0 :
            detail = True
        else:
            detail = False

        # Création des PDF à l'unité
        repertoire = dictOptions["repertoire_copie"]
        if repertoire not in (None, "") :
            dlgAttente = PBI.PyBusyInfo(_(u"Génération des attestations à l'unité au format PDF..."), parent=None, title=_(u"Veuillez patienter..."), icon=wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Logo.png"), wx.BITMAP_TYPE_ANY))
            wx.Yield() 
            try :
                index = 0
                for IDcompte_payeur, dictCompte in dictComptes.iteritems() :
                    IDattestation = dictCompte["num_attestation"]
                    nomTitulaires = Supprime_accent(dictCompte["nomSansCivilite"])
                    nomFichier = _(u"Attestation %d - %s") % (IDattestation, nomTitulaires)
                    cheminFichier = u"%s/%s.pdf" % (repertoire, nomFichier)
                    dictComptesTemp = {IDcompte_payeur : dictCompte}
                    self.EcritStatusbar(_(u"Génération de l'attestation %d/%d : %s") % (index, len(dictComptes), nomFichier))
                    UTILS_Impression_facture.Impression(dictComptesTemp, dictOptions, IDmodele=dictOptions["IDmodele"], mode="attestation", ouverture=False, nomFichier=cheminFichier)
                    index += 1
                self.EcritStatusbar("")
                del dlgAttente
            except Exception, err:
                del dlgAttente
                traceback.print_exc(file=sys.stdout)
                dlg = wx.MessageDialog(self, _(u"Désolé, le problème suivant a été rencontré dans la génération des attestations : \n\n%s") % err, _(u"Erreur"), wx.OK | wx.ICON_ERROR)
                dlg.ShowModal()
                dlg.Destroy()
                return False

        # Fabrication du PDF global
        dlgAttente = PBI.PyBusyInfo(_(u"Génération du lot d'attestations au format PDF..."), parent=None, title=_(u"Veuillez patienter..."), icon=wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Logo.png"), wx.BITMAP_TYPE_ANY))
        wx.Yield() 
        self.EcritStatusbar(_(u"Génération du lot d'attestations de rappel en cours... veuillez patienter..."))
        try :
            UTILS_Impression_facture.Impression(dictComptes, dictOptions, IDmodele=dictOptions["IDmodele"], mode="attestation")
            self.EcritStatusbar("")
            del dlgAttente
        except Exception, err:
            del dlgAttente
            traceback.print_exc(file=sys.stdout)
            dlg = wx.MessageDialog(self, _(u"Désolé, le problème suivant a été rencontré dans la génération des attestations : \n\n%s") % err, _(u"Erreur"), wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
            return False