Exemple #1
0
    def __init__(self, parent, track=None):
        if parent == None :
            dlgparent = None
        else :
            dlgparent = parent.parent
        wx.Dialog.__init__(self, dlgparent, -1, style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.MAXIMIZE_BOX|wx.MINIMIZE_BOX)
        self.parent = parent
        self.track = track
        self.reponse = ""

        # Bandeau
        intro = _(u"Vous pouvez gérer ici la demande de façon manuelle. Commencez par cliquer sur le bouton 'Appliquer la demande' pour voir apparaître les modifications demandées dans la grille des conso. Vous pouvez alors effectuer manuellement d'éventuelles modifications avant de valider.")
        titre = _(u"Traitement manuel des réservations")
        self.SetTitle(titre)
        self.ctrl_bandeau = CTRL_Bandeau.Bandeau(self, titre=titre, texte=intro, hauteurHtml=30, nomImage="Images/32x32/Calendrier_modifier.png")

        # Facturation
        self.box_facturation_staticbox = wx.StaticBox(self, wx.ID_ANY, _(u"Facturation"))
        self.ctrl_facturation = CTRL_Grille_facturation.CTRL(self)
        self.ctrl_facturation.SetMinSize((275, 100))

        # Détail demande
        self.box_demande_staticbox = wx.StaticBox(self, wx.ID_ANY, _(u"Détail de la demande"))
        self.ctrl_demande = CTRL_Html(self, couleurFond=self.GetBackgroundColour())
        self.ctrl_demande.SetMinSize((275, 100))

        # Grille
        self.box_grille_staticbox = wx.StaticBox(self, wx.ID_ANY, _(u"Grille des consommations"))
        self.ctrl_grille = DLG_Badgeage_grille.CTRL(self, panel_facturation=self.ctrl_facturation)

        # Journal
        self.box_journal_staticbox = wx.StaticBox(self, wx.ID_ANY, _(u"Journal d'évènements"))
        self.ctrl_log = CTRL_Log(self)
        self.ctrl_log.SetMinSize((100, 80))
        self.bouton_traiter = CTRL_Bouton_image.CTRL(self, texte=_(u"Appliquer la demande"), cheminImage="Images/32x32/Fleche_bas.png")
        self.bouton_reinit = CTRL_Bouton_image.CTRL(self, texte=_(u"Annuler les modifications"), cheminImage="Images/32x32/Actualiser.png")

        # Boutons
        self.bouton_aide = CTRL_Bouton_image.CTRL(self, texte=_(u"Aide"), cheminImage="Images/32x32/Aide.png")
        self.bouton_outils = CTRL_Bouton_image.CTRL(self, texte=_(u"Outils"), cheminImage="Images/32x32/Configuration.png")
        self.bouton_ok = CTRL_Bouton_image.CTRL(self, texte=_(u"Ok"), cheminImage="Images/32x32/Valider.png")
        self.bouton_fermer = CTRL_Bouton_image.CTRL(self, texte=_(u"Annuler"), cheminImage="Images/32x32/Annuler.png")

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.OnBoutonTraiter, self.bouton_traiter)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonReinit, self.bouton_reinit)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonAide, self.bouton_aide)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonOutils, self.bouton_outils)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonOk, self.bouton_ok)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonFermer, self.bouton_fermer)
        self.Bind(wx.EVT_CLOSE, self.OnBoutonFermer)

        # Init
        if self.parent != None :
            self.parent.Init_grille(ctrl_grille=self.ctrl_grille)
            self.ctrl_demande.SetTexte(self.parent.parent.ctrl_description.GetTexte())
class Dialog(wx.Dialog):
    def __init__(self, parent, track=None):
        if parent == None:
            dlgparent = None
        else:
            dlgparent = parent.parent
        wx.Dialog.__init__(self,
                           dlgparent,
                           -1,
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
                           | wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX)
        self.parent = parent
        self.track = track
        self.reponse = ""

        # Bandeau
        intro = _(
            u"Vous pouvez gérer ici la demande de façon manuelle. Commencez par cliquer sur le bouton 'Appliquer la demande' pour voir apparaître les modifications demandées sur le portail. Vous pouvez alors effectuer manuellement d'éventuelles modifications avant de valider."
        )
        titre = _(u"Traitement manuel des renseignements")
        self.SetTitle(titre)
        self.ctrl_bandeau = CTRL_Bandeau.Bandeau(
            self,
            titre=titre,
            texte=intro,
            hauteurHtml=30,
            nomImage="Images/32x32/Cotisation.png")

        # Détail demande
        self.box_demande_staticbox = wx.StaticBox(self, wx.ID_ANY,
                                                  _(u"Détail de la demande"))
        self.ctrl_demande = CTRL_Html(self,
                                      couleurFond=self.GetBackgroundColour())
        self.ctrl_demande.SetMinSize((275, 100))

        # Renseignements
        self.box_renseignements_staticbox = wx.StaticBox(
            self, wx.ID_ANY, _(u"Renseignements"))
        self.ctrl_renseignements = CTRL_Renseignements(self)

        # Journal
        self.box_journal_staticbox = wx.StaticBox(self, wx.ID_ANY,
                                                  _(u"Journal d'évènements"))
        self.ctrl_log = CTRL_Log(self)
        self.ctrl_log.SetMinSize((100, 80))
        self.bouton_traiter = CTRL_Bouton_image.CTRL(
            self,
            texte=_(u"Appliquer la demande"),
            cheminImage="Images/32x32/Fleche_bas.png")
        self.bouton_reinit = CTRL_Bouton_image.CTRL(
            self,
            texte=_(u"Annuler les modifications"),
            cheminImage="Images/32x32/Actualiser.png")

        # Boutons
        self.bouton_aide = CTRL_Bouton_image.CTRL(
            self, texte=_(u"Aide"), cheminImage="Images/32x32/Aide.png")
        self.bouton_ok = CTRL_Bouton_image.CTRL(
            self, texte=_(u"Ok"), cheminImage="Images/32x32/Valider.png")
        self.bouton_fermer = CTRL_Bouton_image.CTRL(
            self, texte=_(u"Annuler"), cheminImage="Images/32x32/Annuler.png")

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.OnBoutonTraiter, self.bouton_traiter)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonReinit, self.bouton_reinit)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonAide, self.bouton_aide)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonOk, self.bouton_ok)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonFermer, self.bouton_fermer)
        self.Bind(wx.EVT_CLOSE, self.OnBoutonFermer)

        # Init
        self.ctrl_renseignements.MAJ()

        # Importation
        if self.parent != None:
            self.ctrl_renseignements.MAJ(self.track.IDindividu)
            self.ctrl_demande.SetTexte(
                self.parent.parent.ctrl_description.GetTexte())

    def __set_properties(self):
        self.bouton_traiter.SetToolTip(
            wx.ToolTip(_(u"Cliquez ici pour appliquer la demande")))
        self.bouton_reinit.SetToolTip(
            wx.ToolTip(_(u"Cliquez ici pour annuler les modifications")))
        self.bouton_aide.SetToolTip(
            wx.ToolTip(_(u"Cliquez ici pour obtenir de l'aide")))
        self.bouton_ok.SetToolTip(
            wx.ToolTip(
                _(u"Cliquez ici pour commencer le traitement des demandes")))
        self.bouton_fermer.SetToolTip(wx.ToolTip(
            _(u"Cliquez ici pour fermer")))
        self.SetMinSize((900, 700))

    def __do_layout(self):
        grid_sizer_base = wx.FlexGridSizer(4, 1, 10, 10)
        grid_sizer_base.Add(self.ctrl_bandeau, 1, wx.EXPAND, 0)

        grid_sizer_contenu = wx.FlexGridSizer(2, 1, 10, 10)

        grid_sizer_haut = wx.FlexGridSizer(1, 2, 10, 10)

        # Renseignements
        box_grille = wx.StaticBoxSizer(self.box_renseignements_staticbox,
                                       wx.VERTICAL)
        box_grille.Add(self.ctrl_renseignements, 1, wx.ALL | wx.EXPAND, 10)

        grid_sizer_haut.Add(box_grille, 1, wx.EXPAND, 10)

        grid_sizer_droit = wx.FlexGridSizer(2, 1, 10, 10)

        # Demande
        box_demande = wx.StaticBoxSizer(self.box_demande_staticbox,
                                        wx.VERTICAL)
        box_demande.Add(self.ctrl_demande, 1, wx.ALL | wx.EXPAND, 10)
        grid_sizer_droit.Add(box_demande, 1, wx.EXPAND, 10)

        grid_sizer_droit.AddGrowableRow(0)
        grid_sizer_droit.AddGrowableRow(1)
        grid_sizer_droit.AddGrowableCol(0)

        grid_sizer_haut.Add(grid_sizer_droit, 1, wx.EXPAND, 10)
        grid_sizer_haut.AddGrowableRow(0)
        grid_sizer_haut.AddGrowableCol(0)

        grid_sizer_contenu.Add(grid_sizer_haut, 1, wx.EXPAND, 10)

        # Journal
        box_journal = wx.StaticBoxSizer(self.box_journal_staticbox,
                                        wx.VERTICAL)
        grid_sizer_journal = wx.FlexGridSizer(1, 2, 10, 10)
        grid_sizer_journal.Add(self.ctrl_log, 0, wx.EXPAND, 0)

        sizer_boutons = wx.BoxSizer(wx.VERTICAL)
        sizer_boutons.Add(self.bouton_traiter, 1, wx.EXPAND, 0)
        sizer_boutons.Add(self.bouton_reinit, 1, wx.EXPAND | wx.TOP, 5)
        grid_sizer_journal.Add(sizer_boutons, 1, wx.EXPAND, 0)

        grid_sizer_journal.AddGrowableRow(0)
        grid_sizer_journal.AddGrowableCol(0)
        box_journal.Add(grid_sizer_journal, 1, wx.ALL | wx.EXPAND, 10)

        grid_sizer_contenu.Add(box_journal, 1, wx.EXPAND, 10)

        grid_sizer_contenu.AddGrowableRow(0)
        grid_sizer_contenu.AddGrowableCol(0)
        grid_sizer_base.Add(grid_sizer_contenu, 1,
                            wx.LEFT | wx.RIGHT | wx.EXPAND, 10)

        # Boutons
        grid_sizer_boutons = wx.FlexGridSizer(1, 5, 10, 10)
        grid_sizer_boutons.Add(self.bouton_aide, 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_fermer, 0, 0, 0)
        grid_sizer_boutons.AddGrowableCol(1)
        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(1)
        grid_sizer_base.AddGrowableCol(0)
        self.Layout()
        UTILS_Dialogs.AjusteSizePerso(self, __file__)
        self.CenterOnScreen()

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

    def OnBoutonFermer(self, event):
        UTILS_Dialogs.SaveSizePerso(self, __file__)
        self.EndModal(wx.ID_CANCEL)

    def OnBoutonTraiter(self, event=None):
        self.parent.EcritLog(
            _(u"Application de la demande de modification de renseignements"),
            self.ctrl_log)

        # Recherche le détail des renseignements associés
        DB = GestionDB.DB()
        req = """SELECT champ, valeur
        FROM portail_renseignements
        WHERE IDaction=%d;""" % self.track.IDaction
        DB.ExecuterReq(req)
        listeRenseignements = DB.ResultatReq()
        DB.Close()

        liste_champs_importes = []
        listeAnomalies = []
        for champ, valeur in listeRenseignements:

            try:
                # Formatage des valeurs
                if champ == "date_naiss":
                    valeur = datetime.datetime.strptime(valeur, '%d/%m/%Y')
                    valeur = datetime.date(year=valeur.year,
                                           month=valeur.month,
                                           day=valeur.day)

                # Remplissage
                if "date" in champ:
                    self.ctrl_renseignements.GetCtrlByCode(champ).SetDate(
                        valeur)
                elif champ == "adresse_auto":
                    resultat = self.ctrl_renseignements.GetCtrlByCode(
                        "adresse").SetValeur("adresse_auto", valeur)
                elif champ == "rue_resid":
                    resultat = self.ctrl_renseignements.GetCtrlByCode(
                        "adresse").SetValeur("rue_resid", valeur)
                elif champ == "cp_resid":
                    resultat = self.ctrl_renseignements.GetCtrlByCode(
                        "adresse").SetValeur("cp_resid", valeur)
                elif champ == "ville_resid":
                    resultat = self.ctrl_renseignements.GetCtrlByCode(
                        "adresse").SetValeur("ville_resid", valeur)
                elif champ == "cp_naiss":
                    resultat = self.ctrl_renseignements.GetCtrlByCode(
                        "ville_naiss").SetValueCP(valeur)
                elif champ == "ville_naiss":
                    resultat = self.ctrl_renseignements.GetCtrlByCode(
                        "ville_naiss").SetValueVille(valeur)
                elif "tel" in champ:
                    self.ctrl_renseignements.GetCtrlByCode(champ).SetNumero(
                        valeur)
                elif "mail" in champ:
                    self.ctrl_renseignements.GetCtrlByCode(champ).SetMail(
                        valeur)
                else:
                    self.ctrl_renseignements.GetCtrlByCode(champ).SetValue(
                        valeur)

                # Coche la ligne
                if champ in ("adresse_auto", "rue_resid", "cp_resid",
                             "ville_resid"):
                    index = self.ctrl_renseignements.GetIndexByCode("adresse")
                elif champ == "cp_naiss":
                    index = self.ctrl_renseignements.GetIndexByCode(
                        "ville_naiss")
                else:
                    index = self.ctrl_renseignements.GetIndexByCode(champ)
                self.ctrl_renseignements.SetCoche(index, etat=True)

                liste_champs_importes.append(champ)

            except Exception as err:
                self.parent.EcritLog(
                    _(u"Le champ '%s' n'a pas pu être importé. Erreur : %s")
                    % (DICT_RENSEIGNEMENTS[champ], err), self.ctrl_log)
                listeAnomalies.append(champ)

        # Création du texte de réponse
        if len(liste_champs_importes) == 0:
            reponse = _(u"Aucun renseignement modifié")
        elif len(liste_champs_importes) == 1:
            reponse = _(u"1 renseignement modifié")
        else:
            reponse = _(u"%d renseignements modifiés") % len(
                liste_champs_importes)

        if len(liste_champs_importes) > 0:
            reponse += u" (%s)" % ", ".join([
                DICT_RENSEIGNEMENTS[champ] for champ in liste_champs_importes
            ])

        self.parent.EcritLog(_(u"Réponse : %s") % reponse, self.ctrl_log)

        self.reponse = reponse

    def OnBoutonReinit(self, event):
        self.ctrl_renseignements.MAJ(self.track.IDindividu)
        self.ctrl_renseignements.Importation(self.track.IDindividu)

    def OnBoutonOk(self, event=None):
        # Sauvegarde
        listeDonnees = []
        for champ, ctrl in self.ctrl_renseignements.GetCoches():

            # Validation
            if hasattr(ctrl, "Validation"):
                if ctrl.Validation() == False:
                    dlg = wx.MessageDialog(
                        self,
                        _(u"La valeur du champ '%s' semble incorrecte !") %
                        DICT_RENSEIGNEMENTS[champ], _(u"Erreur"),
                        wx.OK | wx.ICON_EXCLAMATION)
                    dlg.ShowModal()
                    dlg.Destroy()
                    return False

            # Préparation des données à sauvegarder
            if "date" in champ:
                listeDonnees.append((champ, ctrl.GetDate()))
            elif "adresse" in champ:
                valeurs = ctrl.GetValeurs()
                listeDonnees.append(("adresse_auto", valeurs["adresse_auto"]))
                listeDonnees.append(("rue_resid", valeurs["rue_resid"]))
                listeDonnees.append(("cp_resid", valeurs["cp_resid"]))
                listeDonnees.append(("ville_resid", valeurs["ville_resid"]))
            elif champ in ("cp_naiss", "ville_naiss"):
                listeDonnees.append(("cp_naiss", ctrl.GetValueCP()))
                listeDonnees.append(("ville_naiss", ctrl.GetValueVille()))
            elif "tel" in champ:
                listeDonnees.append((champ, ctrl.GetNumero()))
            elif "mail" in champ:
                listeDonnees.append((champ, ctrl.GetMail()))
            else:
                listeDonnees.append((champ, ctrl.GetValue()))

        # Enregistrement
        DB = GestionDB.DB()
        DB.ReqMAJ("individus", listeDonnees, "IDindividu",
                  self.track.IDindividu)
        DB.Close()

        # Fermeture de la dlg
        UTILS_Dialogs.SaveSizePerso(self, __file__)
        if event != None:
            self.EndModal(wx.ID_OK)

    def GetReponse(self):
        return self.reponse
Exemple #3
0
    def __init__(self, parent, track=None):
        if parent == None:
            dlgparent = None
        else:
            dlgparent = parent.parent
        wx.Dialog.__init__(self,
                           dlgparent,
                           -1,
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
                           | wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX)
        self.parent = parent
        self.track = track
        self.reponse = ""

        # Bandeau
        intro = _(
            u"Vous pouvez gérer ici la demande de façon manuelle. Commencez par cliquer sur le bouton 'Appliquer la demande' pour voir apparaître les modifications demandées sur le portail. Vous pouvez alors effectuer manuellement d'éventuelles modifications avant de valider."
        )
        titre = _(u"Traitement manuel des locations")
        self.SetTitle(titre)
        self.ctrl_bandeau = CTRL_Bandeau.Bandeau(
            self,
            titre=titre,
            texte=intro,
            hauteurHtml=30,
            nomImage="Images/32x32/Location.png")

        # Locations
        self.box_locations_staticbox = wx.StaticBox(
            self, wx.ID_ANY, _(u"Détail de la demande"))
        self.ctrl_locations = OL_Portail_locations.ListView(
            self,
            -1,
            style=wx.LC_REPORT | wx.LC_HRULES | wx.LC_VRULES | wx.LC_SINGLE_SEL
            | wx.SUNKEN_BORDER)

        # Journal
        self.box_journal_staticbox = wx.StaticBox(self, wx.ID_ANY,
                                                  _(u"Journal d'évènements"))
        self.ctrl_log = CTRL_Log(self)
        self.ctrl_log.SetMinSize((100, 80))
        self.bouton_traiter = CTRL_Bouton_image.CTRL(
            self,
            texte=_(u"Appliquer la demande"),
            cheminImage="Images/32x32/Fleche_bas.png")

        # Boutons
        self.bouton_aide = CTRL_Bouton_image.CTRL(
            self, texte=_(u"Aide"), cheminImage="Images/32x32/Aide.png")
        self.bouton_fermer = CTRL_Bouton_image.CTRL(
            self, texte=_(u"Fermer"), cheminImage="Images/32x32/Fermer.png")

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.OnBoutonTraiter, self.bouton_traiter)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonAide, self.bouton_aide)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonFermer, self.bouton_fermer)
        self.Bind(wx.EVT_CLOSE, self.OnBoutonFermer)

        # Init
        self.ctrl_locations.MAJ(track_demande=track)
Exemple #4
0
class Dialog(wx.Dialog):
    def __init__(self, parent, track=None):
        if parent == None:
            dlgparent = None
        else:
            dlgparent = parent.parent
        wx.Dialog.__init__(self,
                           dlgparent,
                           -1,
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
                           | wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX)
        self.parent = parent
        self.track = track
        self.reponse = ""

        # Bandeau
        intro = _(
            u"Vous pouvez gérer ici la demande de façon manuelle. Commencez par cliquer sur le bouton 'Appliquer la demande' pour voir apparaître les modifications demandées sur le portail. Vous pouvez alors effectuer manuellement d'éventuelles modifications avant de valider."
        )
        titre = _(u"Traitement manuel des locations")
        self.SetTitle(titre)
        self.ctrl_bandeau = CTRL_Bandeau.Bandeau(
            self,
            titre=titre,
            texte=intro,
            hauteurHtml=30,
            nomImage="Images/32x32/Location.png")

        # Locations
        self.box_locations_staticbox = wx.StaticBox(
            self, wx.ID_ANY, _(u"Détail de la demande"))
        self.ctrl_locations = OL_Portail_locations.ListView(
            self,
            -1,
            style=wx.LC_REPORT | wx.LC_HRULES | wx.LC_VRULES | wx.LC_SINGLE_SEL
            | wx.SUNKEN_BORDER)

        # Journal
        self.box_journal_staticbox = wx.StaticBox(self, wx.ID_ANY,
                                                  _(u"Journal d'évènements"))
        self.ctrl_log = CTRL_Log(self)
        self.ctrl_log.SetMinSize((100, 80))
        self.bouton_traiter = CTRL_Bouton_image.CTRL(
            self,
            texte=_(u"Appliquer la demande"),
            cheminImage="Images/32x32/Fleche_bas.png")

        # Boutons
        self.bouton_aide = CTRL_Bouton_image.CTRL(
            self, texte=_(u"Aide"), cheminImage="Images/32x32/Aide.png")
        self.bouton_fermer = CTRL_Bouton_image.CTRL(
            self, texte=_(u"Fermer"), cheminImage="Images/32x32/Fermer.png")

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.OnBoutonTraiter, self.bouton_traiter)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonAide, self.bouton_aide)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonFermer, self.bouton_fermer)
        self.Bind(wx.EVT_CLOSE, self.OnBoutonFermer)

        # Init
        self.ctrl_locations.MAJ(track_demande=track)

    def __set_properties(self):
        self.bouton_traiter.SetToolTip(
            wx.ToolTip(_(u"Cliquez ici pour appliquer la demande")))
        self.bouton_aide.SetToolTip(
            wx.ToolTip(_(u"Cliquez ici pour obtenir de l'aide")))
        self.bouton_fermer.SetToolTip(wx.ToolTip(
            _(u"Cliquez ici pour fermer")))
        self.SetMinSize((900, 700))

    def __do_layout(self):
        grid_sizer_base = wx.FlexGridSizer(4, 1, 10, 10)
        grid_sizer_base.Add(self.ctrl_bandeau, 1, wx.EXPAND, 0)

        grid_sizer_contenu = wx.FlexGridSizer(2, 1, 10, 10)

        # Locations
        box_grille = wx.StaticBoxSizer(self.box_locations_staticbox,
                                       wx.VERTICAL)
        box_grille.Add(self.ctrl_locations, 1, wx.ALL | wx.EXPAND, 10)
        grid_sizer_contenu.Add(box_grille, 1, wx.EXPAND, 10)

        # Journal
        box_journal = wx.StaticBoxSizer(self.box_journal_staticbox,
                                        wx.VERTICAL)
        grid_sizer_journal = wx.FlexGridSizer(1, 2, 10, 10)
        grid_sizer_journal.Add(self.ctrl_log, 0, wx.EXPAND, 0)

        sizer_boutons = wx.BoxSizer(wx.VERTICAL)
        sizer_boutons.Add(self.bouton_traiter, 1, wx.EXPAND, 0)
        grid_sizer_journal.Add(sizer_boutons, 1, wx.EXPAND, 0)

        grid_sizer_journal.AddGrowableRow(0)
        grid_sizer_journal.AddGrowableCol(0)
        box_journal.Add(grid_sizer_journal, 1, wx.ALL | wx.EXPAND, 10)

        grid_sizer_contenu.Add(box_journal, 1, wx.EXPAND, 10)

        grid_sizer_contenu.AddGrowableRow(0)
        grid_sizer_contenu.AddGrowableCol(0)
        grid_sizer_base.Add(grid_sizer_contenu, 1,
                            wx.LEFT | wx.RIGHT | wx.EXPAND, 10)

        # Boutons
        grid_sizer_boutons = wx.FlexGridSizer(1, 5, 10, 10)
        grid_sizer_boutons.Add(self.bouton_aide, 0, 0, 0)
        grid_sizer_boutons.Add((20, 20), 0, wx.EXPAND, 0)
        grid_sizer_boutons.Add(self.bouton_fermer, 0, 0, 0)
        grid_sizer_boutons.AddGrowableCol(1)
        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(1)
        grid_sizer_base.AddGrowableCol(0)
        self.Layout()
        UTILS_Dialogs.AjusteSizePerso(self, __file__)
        self.CenterOnScreen()

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

    def OnBoutonTraiter(self, event=None):
        self.parent.EcritLog(_(u"Application de la demande de locations"),
                             self.ctrl_log)

        resultats = {
            "ajouter": {
                True: 0,
                False: 0
            },
            "modifier": {
                True: 0,
                False: 0
            },
            "supprimer": {
                True: 0,
                False: 0
            }
        }

        DB = GestionDB.DB()
        for track in self.ctrl_locations.donnees:
            listeDonnees = [
                ("IDfamille", self.track.IDfamille),
                ("IDproduit", track.IDproduit),
                ("date_debut", track.date_debut),
                ("date_fin", track.date_fin),
                ("quantite", track.quantite),
            ]

            if track.resultat != "ok":
                if track.etat == "ajouter":
                    if track.action_possible == True:
                        listeDonnees.append(
                            ("date_saisie", datetime.date.today()))
                        listeDonnees.append(
                            ("IDlocation_portail", track.IDlocation))
                        IDlocation = DB.ReqInsert("locations", listeDonnees)
                        resultat = _(u"Ajout de %s du %s") % (
                            track.nom_produit, track.date_debut_txt)
                        DB.ReqMAJ("portail_reservations_locations",
                                  [("resultat", "ok")], "IDreservation",
                                  track.IDreservation)
                    else:
                        resultat = _(u"%s du %s : %s") % (track.nom_produit,
                                                          track.date_debut_txt,
                                                          track.statut)
                    self.parent.EcritLog(resultat, self.ctrl_log)

                if track.etat == "modifier":
                    if track.action_possible == True:
                        if "-" in track.IDlocation:
                            DB.ReqMAJ("locations",
                                      listeDonnees,
                                      "IDlocation_portail",
                                      track.IDlocation,
                                      IDestChaine=True)
                        else:
                            DB.ReqMAJ("locations", listeDonnees, "IDlocation",
                                      int(track.IDlocation))
                        resultat = _(u"Modification de %s du %s") % (
                            track.nom_produit, track.date_debut_txt)
                        DB.ReqMAJ("portail_reservations_locations",
                                  [("resultat", "ok")], "IDreservation",
                                  track.IDreservation)
                    else:
                        resultat = _(u"%s du %s : %s") % (track.nom_produit,
                                                          track.date_debut_txt,
                                                          track.statut)
                    self.parent.EcritLog(resultat, self.ctrl_log)

                if track.etat == "supprimer":
                    if track.action_possible == True:
                        if "-" in track.IDlocation:
                            DB.ReqDEL("locations",
                                      "IDlocation_portail",
                                      track.IDlocation,
                                      IDestChaine=True)
                        else:
                            DB.ReqDEL("locations", "IDlocation",
                                      int(track.IDlocation))
                        resultat = _(u"Suppression de %s du %s") % (
                            track.nom_produit, track.date_debut_txt)
                        DB.ReqMAJ("portail_reservations_locations",
                                  [("resultat", "ok")], "IDreservation",
                                  track.IDreservation)
                    else:
                        resultat = _(u"%s du %s : %s") % (track.nom_produit,
                                                          track.date_debut_txt,
                                                          track.statut)
                    self.parent.EcritLog(resultat, self.ctrl_log)

                # Mémorisation pour réponse
                resultats[track.etat][track.action_possible] += 1

        DB.Close()

        # Formatage de la réponse
        liste_resultats = []
        for etat, valeurs in resultats.items():
            for succes, quantite in valeurs.items():
                if quantite:
                    if succes == True:
                        txt_validation = u"validé"
                    else:
                        txt_validation = u"refusé"
                    if quantite == 1:
                        pluriel = ""
                    else:
                        pluriel = "s"

                    if etat == "ajouter":
                        liste_resultats.append(
                            u"%d ajout%s %s%s" %
                            (quantite, pluriel, txt_validation, pluriel))
                    if etat == "modifier":
                        liste_resultats.append(
                            u"%d modification%s %se%s" %
                            (quantite, pluriel, txt_validation, pluriel))
                    if etat == "supprimer":
                        liste_resultats.append(
                            u"%d suppression%s %se%s" %
                            (quantite, pluriel, txt_validation, pluriel))

        if liste_resultats:
            self.reponse = UTILS_Texte.ConvertListeToPhrase(
                liste_resultats) + "."
            self.parent.EcritLog(
                _(u"Réponse : %s") % self.reponse, self.ctrl_log)

            # MAJ de la liste des actions
            self.ctrl_locations.MAJ(track_demande=self.track)

    def OnBoutonFermer(self, event=None):
        UTILS_Dialogs.SaveSizePerso(self, __file__)
        if event != None:
            self.EndModal(wx.ID_OK)

    def GetReponse(self):
        return self.reponse
Exemple #5
0
class Dialog(wx.Dialog):
    def __init__(self, parent, track=None):
        if parent == None :
            dlgparent = None
        else :
            dlgparent = parent.parent
        wx.Dialog.__init__(self, dlgparent, -1, style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.MAXIMIZE_BOX|wx.MINIMIZE_BOX)
        self.parent = parent
        self.track = track
        self.reponse = ""

        # Bandeau
        intro = _(u"Vous pouvez gérer ici la demande de façon manuelle. Commencez par cliquer sur le bouton 'Appliquer la demande' pour voir apparaître les modifications demandées dans la grille des conso. Vous pouvez alors effectuer manuellement d'éventuelles modifications avant de valider.")
        titre = _(u"Traitement manuel des réservations")
        self.SetTitle(titre)
        self.ctrl_bandeau = CTRL_Bandeau.Bandeau(self, titre=titre, texte=intro, hauteurHtml=30, nomImage="Images/32x32/Calendrier_modifier.png")

        # Facturation
        self.box_facturation_staticbox = wx.StaticBox(self, wx.ID_ANY, _(u"Facturation"))
        self.ctrl_facturation = CTRL_Grille_facturation.CTRL(self)
        self.ctrl_facturation.SetMinSize((275, 100))

        # Détail demande
        self.box_demande_staticbox = wx.StaticBox(self, wx.ID_ANY, _(u"Détail de la demande"))
        self.ctrl_demande = CTRL_Html(self, couleurFond=self.GetBackgroundColour())
        self.ctrl_demande.SetMinSize((275, 100))

        # Grille
        self.box_grille_staticbox = wx.StaticBox(self, wx.ID_ANY, _(u"Grille des consommations"))
        self.ctrl_grille = DLG_Badgeage_grille.CTRL(self, panel_facturation=self.ctrl_facturation)

        # Journal
        self.box_journal_staticbox = wx.StaticBox(self, wx.ID_ANY, _(u"Journal d'évènements"))
        self.ctrl_log = CTRL_Log(self)
        self.ctrl_log.SetMinSize((100, 80))
        self.bouton_traiter = CTRL_Bouton_image.CTRL(self, texte=_(u"Appliquer la demande"), cheminImage="Images/32x32/Fleche_bas.png")
        self.bouton_reinit = CTRL_Bouton_image.CTRL(self, texte=_(u"Annuler les modifications"), cheminImage="Images/32x32/Actualiser.png")

        # Boutons
        self.bouton_aide = CTRL_Bouton_image.CTRL(self, texte=_(u"Aide"), cheminImage="Images/32x32/Aide.png")
        self.bouton_outils = CTRL_Bouton_image.CTRL(self, texte=_(u"Outils"), cheminImage="Images/32x32/Configuration.png")
        self.bouton_ok = CTRL_Bouton_image.CTRL(self, texte=_(u"Ok"), cheminImage="Images/32x32/Valider.png")
        self.bouton_fermer = CTRL_Bouton_image.CTRL(self, texte=_(u"Annuler"), cheminImage="Images/32x32/Annuler.png")

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.OnBoutonTraiter, self.bouton_traiter)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonReinit, self.bouton_reinit)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonAide, self.bouton_aide)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonOutils, self.bouton_outils)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonOk, self.bouton_ok)
        self.Bind(wx.EVT_BUTTON, self.OnBoutonFermer, self.bouton_fermer)
        self.Bind(wx.EVT_CLOSE, self.OnBoutonFermer)

        # Init
        if self.parent != None :
            self.parent.Init_grille(ctrl_grille=self.ctrl_grille)
            self.ctrl_demande.SetTexte(self.parent.parent.ctrl_description.GetTexte())

    def __set_properties(self):
        self.bouton_traiter.SetToolTip(wx.ToolTip(_(u"Cliquez ici pour appliquer la demande")))
        self.bouton_reinit.SetToolTip(wx.ToolTip(_(u"Cliquez ici pour annuler les modifications")))
        self.bouton_aide.SetToolTip(wx.ToolTip(_(u"Cliquez ici pour obtenir de l'aide")))
        self.bouton_outils.SetToolTip(wx.ToolTip(_(u"Cliquez ici pour accéder au menu des outils")))
        self.bouton_ok.SetToolTip(wx.ToolTip(_(u"Cliquez ici pour commencer le traitement des demandes")))
        self.bouton_fermer.SetToolTip(wx.ToolTip(_(u"Cliquez ici pour fermer")))
        self.SetMinSize((900, 700))

    def __do_layout(self):
        grid_sizer_base = wx.FlexGridSizer(4, 1, 10, 10)
        grid_sizer_base.Add(self.ctrl_bandeau, 1,wx.EXPAND, 0)

        grid_sizer_contenu = wx.FlexGridSizer(2, 1, 10, 10)

        grid_sizer_haut = wx.FlexGridSizer(1, 2, 10, 10)

        # Grille
        box_grille = wx.StaticBoxSizer(self.box_grille_staticbox, wx.VERTICAL)
        box_grille.Add(self.ctrl_grille, 1, wx.ALL | wx.EXPAND, 10)

        grid_sizer_haut.Add(box_grille, 1, wx.EXPAND, 10)

        grid_sizer_droit = wx.FlexGridSizer(2, 1, 10, 10)

        # Facturation
        box_facturation = wx.StaticBoxSizer(self.box_facturation_staticbox, wx.VERTICAL)
        box_facturation.Add(self.ctrl_facturation, 1, wx.ALL | wx.EXPAND, 10)
        grid_sizer_droit.Add(box_facturation, 1, wx.EXPAND, 10)

        # Demande
        box_demande = wx.StaticBoxSizer(self.box_demande_staticbox, wx.VERTICAL)
        box_demande.Add(self.ctrl_demande, 1, wx.ALL | wx.EXPAND, 10)
        grid_sizer_droit.Add(box_demande, 1, wx.EXPAND, 10)

        grid_sizer_droit.AddGrowableRow(0)
        grid_sizer_droit.AddGrowableRow(1)
        grid_sizer_droit.AddGrowableCol(0)

        grid_sizer_haut.Add(grid_sizer_droit, 1, wx.EXPAND, 10)
        grid_sizer_haut.AddGrowableRow(0)
        grid_sizer_haut.AddGrowableCol(0)

        grid_sizer_contenu.Add(grid_sizer_haut, 1, wx.EXPAND, 10)

        # Journal
        box_journal = wx.StaticBoxSizer(self.box_journal_staticbox, wx.VERTICAL)
        grid_sizer_journal = wx.FlexGridSizer(1, 2, 10, 10)
        grid_sizer_journal.Add(self.ctrl_log, 0, wx.EXPAND, 0)

        sizer_boutons = wx.BoxSizer(wx.VERTICAL)
        sizer_boutons.Add(self.bouton_traiter, 1, wx.EXPAND, 0)
        sizer_boutons.Add(self.bouton_reinit, 1, wx.EXPAND | wx.TOP, 5)
        grid_sizer_journal.Add(sizer_boutons, 1, wx.EXPAND, 0)
        
        grid_sizer_journal.AddGrowableRow(0)
        grid_sizer_journal.AddGrowableCol(0)
        box_journal.Add(grid_sizer_journal, 1, wx.ALL | wx.EXPAND, 10)

        grid_sizer_contenu.Add(box_journal, 1, wx.EXPAND, 10)

        grid_sizer_contenu.AddGrowableRow(0)
        grid_sizer_contenu.AddGrowableCol(0)
        grid_sizer_base.Add(grid_sizer_contenu, 1, wx.LEFT | wx.RIGHT | wx.EXPAND, 10)
        
        # Boutons
        grid_sizer_boutons = wx.FlexGridSizer(1, 5, 10, 10)
        grid_sizer_boutons.Add(self.bouton_aide, 0, 0, 0)
        grid_sizer_boutons.Add(self.bouton_outils, 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_fermer, 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(1)
        grid_sizer_base.AddGrowableCol(0)
        self.Layout()
        UTILS_Dialogs.AjusteSizePerso(self, __file__)
        self.CenterOnScreen()

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

    def OnBoutonFermer(self, event):
        UTILS_Dialogs.SaveSizePerso(self, __file__)
        self.EndModal(wx.ID_CANCEL)

    def OnBoutonOutils(self, event):
        # Création du menu Outils
        menuPop = UTILS_Adaptations.Menu()

        item = wx.MenuItem(menuPop, 10, _(u"Recalculer toutes les prestations"), _(u"Recalculer toutes les prestations"))
        item.SetBitmap(wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Euro.png"), wx.BITMAP_TYPE_PNG))
        menuPop.AppendItem(item)
        self.Bind(wx.EVT_MENU, self.ctrl_grille.RecalculerToutesPrestations, id=10)

        menuPop.AppendSeparator()

        item = wx.MenuItem(menuPop, 20, _(u"Imprimer la liste des réservations"), _(u"Imprimer la liste des réservations affichées"))
        item.SetBitmap(wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Imprimante.png"), wx.BITMAP_TYPE_PNG))
        menuPop.AppendItem(item)
        self.Bind(wx.EVT_MENU, self.ctrl_grille.grille.Imprimer, id=20)

        item = wx.MenuItem(menuPop, 30, _(u"Envoyer la liste des réservations par Email"), _(u"Envoyer la liste des réservations affichées par Email"))
        item.SetBitmap(wx.Bitmap(Chemins.GetStaticPath("Images/16x16/Emails_exp.png"), wx.BITMAP_TYPE_PNG))
        menuPop.AppendItem(item)
        self.Bind(wx.EVT_MENU, self.ctrl_grille.grille.EnvoyerEmail, id=30)

        self.PopupMenu(menuPop)
        menuPop.Destroy()

    def OnBoutonTraiter(self, event):
        self.reponse = self.parent.Appliquer_reservations(ctrl_grille=self.ctrl_grille, log_jumeau=self.ctrl_log)

    def OnBoutonReinit(self, event):
        self.parent.Init_grille(ctrl_grille=self.ctrl_grille)

    def OnBoutonOk(self, event):
        UTILS_Dialogs.SaveSizePerso(self, __file__)
        self.EndModal(wx.ID_OK)

    def GetReponse(self):
        return self.reponse