Ejemplo n.º 1
0
    def __init__(self, parent, adherent=None):
        wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, style=wx.TAB_TRAVERSAL)

        #permet de faire un validate sur tout les panels
        self.SetExtraStyle(wx.WS_EX_VALIDATE_RECURSIVELY)

        if adherent:
            self.adherent = adherent
        else:
            self.adherent = Adherent()

        self.notebook = wx.Notebook(self, -1, style=0)
        self.notebook_p1 = wx.Panel(self.notebook, -1)
        self.notebook_p2 = wx.Panel(self.notebook, -1)
        self.notebook_p3 = wx.Panel(self.notebook, -1)

        #self.sizer_adhesions_staticbox = wx.StaticBox(self.notebook_p4, -1, u"Types d'adhésion")
        #self.label_description_adhesions = wx.StaticText(self.notebook_p4, -1, u"Ce sont les différentes formules disponibles pour adhérer à l'association.")

        self.panel_adherent = FicheAdherentBase(self.notebook_p1, self.adherent)
        self.panel_gestion_adhesions = GestionAdhesions(self.notebook_p2, self.adherent)
        self.panel_gestion_fournisseurs = GestionFournisseurs(self.notebook_p3, self.adherent)
        
        self.bouton_ok = wx.Button(self, wx.ID_OK, "")
        self.bouton_annuler = wx.Button(self, wx.ID_CANCEL, "Annuler")
        
        self.bouton_ok.Bind(wx.EVT_BUTTON, self.OnEnregistre)
        self.Bind(wx.EVT_WINDOW_DESTROY, self.OnClose)

        self.__set_properties()
        self.__do_layout()
Ejemplo n.º 2
0
    def __init__(self, parent, adherent=None):
        wx.Panel.__init__(self,
                          parent,
                          id=wx.ID_ANY,
                          pos=wx.DefaultPosition,
                          style=wx.TAB_TRAVERSAL)

        #permet de faire un validate sur tout les panels
        self.SetExtraStyle(wx.WS_EX_VALIDATE_RECURSIVELY)

        if adherent:
            self.adherent = adherent
        else:
            self.adherent = Adherent()

        self.notebook = wx.Notebook(self, -1, style=0)
        self.notebook_p1 = wx.Panel(self.notebook, -1)
        self.notebook_p2 = wx.Panel(self.notebook, -1)
        self.notebook_p3 = wx.Panel(self.notebook, -1)

        #self.sizer_adhesions_staticbox = wx.StaticBox(self.notebook_p4, -1, u"Types d'adhésion")
        #self.label_description_adhesions = wx.StaticText(self.notebook_p4, -1, u"Ce sont les différentes formules disponibles pour adhérer à l'association.")

        self.panel_adherent = FicheAdherentBase(self.notebook_p1,
                                                self.adherent)
        self.panel_gestion_adhesions = GestionAdhesions(
            self.notebook_p2, self.adherent)
        self.panel_gestion_fournisseurs = GestionFournisseurs(
            self.notebook_p3, self.adherent)

        self.bouton_ok = wx.Button(self, wx.ID_OK, "")
        self.bouton_annuler = wx.Button(self, wx.ID_CANCEL, "Annuler")

        self.bouton_ok.Bind(wx.EVT_BUTTON, self.OnEnregistre)
        self.Bind(wx.EVT_WINDOW_DESTROY, self.OnClose)

        self.__set_properties()
        self.__do_layout()
 def __remplissage_liste(self):
     try:
         requete = Adherent.select().where(~(Adherent.id << self.fournisseur.referents))
         self.liste_referents.SetObjects([a for a in requete])
         
         #On dimentionne le dialog selon la largeur des colonnes
         largeur = 0
         for num_colonne in range(2) :
             largeur += self.liste_referents.GetColumnWidth(num_colonne)
          
         self.liste_referents.SetMinSize((largeur+20,300))
         
     except BaseException as ex:
         print ex
Ejemplo n.º 4
0
    def __remplissage_liste(self):
        try:
            requete = Adherent.select().where(
                ~(Adherent.id << self.fournisseur.referents))
            self.liste_referents.SetObjects([a for a in requete])

            #On dimentionne le dialog selon la largeur des colonnes
            largeur = 0
            for num_colonne in range(2):
                largeur += self.liste_referents.GetColumnWidth(num_colonne)

            self.liste_referents.SetMinSize((largeur + 20, 300))

        except BaseException as ex:
            print ex
Ejemplo n.º 5
0
    def __init__(self, parent, adherent=None):
        wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL)

        if adherent:
            self.adherent = adherent
        else:
            self.adherent = Adherent()

        self.label_Nom = wx.StaticText(self, -1, "Nom :")
        self.text_Nom = wx.TextCtrl(self, -1, "", validator=GenericTextValidator())
        self.label_Prenom = wx.StaticText(self, -1, u"Prénom :")
        self.text_Prenom = wx.TextCtrl(self, -1, "", validator=GenericTextValidator())
        self.label_Adresse = wx.StaticText(self, -1, "Adresse :")
        self.text_Adresse = wx.TextCtrl(self, -1, "", validator=GenericTextValidator())
        self.label_CodePostal = wx.StaticText(self, -1, "Code Postal :")
        self.text_CodePostal = wx.TextCtrl(self, -1, "", validator=GenericTextValidator(flag=VALIDATE_INT))
        self.label_Ville = wx.StaticText(self, -1, "Ville :")
        self.text_Ville = wx.TextCtrl(self, -1, "", validator=GenericTextValidator())
        self.label_TelephoneFixe = wx.StaticText(self, -1, u"Tel fixe:")
        self.text_TelephoneFixe = wx.TextCtrl(self, -1, "", validator=GenericTextValidator(obligatoire=False))
        self.label_TelephonePortable = wx.StaticText(self, -1, u"Tel portable :")
        self.text_TelephonePortable = wx.TextCtrl(self, -1, "", validator=GenericTextValidator(obligatoire=False))
        self.label_Email = wx.StaticText(self, -1, "Email :")
        self.text_Email = wx.TextCtrl(self, -1, "", validator=EmailValidator(obligatoire=False))
        self.label_Cotisation = wx.StaticText(self, -1, "Cotisation :")
        self.combo_box_CotisationTypes = wx.ComboBox(self, -1, choices=[], style=wx.CB_DROPDOWN|wx.CB_READONLY)
        self.label_Login = wx.StaticText(self, -1, "Login :"******"")
        self.label_ConfirmMotdepasse = wx.StaticText(self, -1, "Confirmation :")
        self.text_ConfirmMotdepasse = wx.TextCtrl(self, -1, "", style=wx.TE_PASSWORD)
        self.label_Motdepasse = wx.StaticText(self, -1, "Mot de passe :")
        self.text_Motdepasse = wx.TextCtrl(self, -1, "", style=wx.TE_PASSWORD, validator=MotDePasseValidator(self.text_ConfirmMotdepasse))
        
        self.__set_properties()
        self.__do_layout()
        self.__set_combobox_cotisations()
        self.__set_valeurs()
Ejemplo n.º 6
0
    def __init__(self, parent, adherent=None):
        wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL)

        if adherent:
            self.adherent = adherent
        else:
            self.adherent = Adherent.select().where(Adherent.id == 1).get()

        self.label_total_achats = wx.StaticText(
            self, -1, "Total des achats du mois en cours :")
        self.label_total_achats_v = wx.StaticText(self, -1, u"XX.XX €")
        self.label_solde = wx.StaticText(self, -1, u"Solde :")
        self.label_solde_v = wx.StaticText(self, -1, u"XX.XX €")
        self.static_line = wx.StaticLine(self, -1)
        self.bouton_ajout_achat = wx.Button(self, -1, "Nouvel achat")
        self.bouton_ajout_credit = wx.Button(self, -1, "Nouveau paiement")
        self.label_info = wx.StaticText(
            self, -1,
            u"Note : Le dernier achat et le dernier paiement sont modifiable le jour même."
        )

        self.notebook_achats = wx.Notebook(self, -1, style=0)

        #Page "Dernieres produits achetés"
        self.panel_page_achat_mois = wx.Panel(self.notebook_achats, -1)
        self.label_mois_recherche = wx.StaticText(self.panel_page_achat_mois,
                                                  -1, u"Achats du mois de ")
        self.combobox_choix_mois = wx.ComboBox(self.panel_page_achat_mois, -1)
        self.label_total_mois = wx.StaticText(
            self.panel_page_achat_mois, -1,
            u"Total des achats du mois : XX.XX €")
        self.liste_achats_mois = ObjectListView(
            self.panel_page_achat_mois,
            -1,
            style=wx.LC_REPORT | wx.SUNKEN_BORDER | wx.LC_SINGLE_SEL)
        """def date_achat(ligne_achat):
            return ligne_achat.achat.date.strftime("%d-%m-%y")

        def ref_GASE_nom(ligne_achat):
            return "%s - %s" % (ligne_achat.produit.ref_GASE, ligne_achat.produit.nom)
        
        self.liste_achats_mois.SetColumns([
            ColumnDefn("Ref GASE - Nom", "left", -1, ref_GASE_nom, minimumWidth=250, groupKeyGetter=date_achat),
            ColumnDefn("Prix", "left", -1, "produit.prix_vente_format", minimumWidth=100),
            ColumnDefn(u"Quantité", "left", -1, "quantite_format", minimumWidth=70),
            ColumnDefn(u"Total", "right", -1, "prix_total", stringConverter=u"%.2f €", minimumWidth=70, isSpaceFilling=True)
        ])"""

        self.liste_achats_mois.SetColumns([
            ColumnDefn("Date",
                       "center",
                       -1,
                       "achat.date",
                       stringConverter="%d-%m-%y",
                       minimumWidth=70),
            ColumnDefn("Ref GASE",
                       "center",
                       -1,
                       "produit.ref_GASE",
                       minimumWidth=70),
            ColumnDefn("Nom", "left", -1, "produit.nom", minimumWidth=100),
            ColumnDefn("Prix",
                       "left",
                       -1,
                       "produit.prix_vente_format",
                       minimumWidth=100),
            ColumnDefn(u"Quantité",
                       "left",
                       -1,
                       "quantite_format",
                       minimumWidth=70),
            ColumnDefn(u"Total",
                       "right",
                       -1,
                       "prix_total",
                       stringConverter=u"%.2f €",
                       minimumWidth=70,
                       isSpaceFilling=True)
        ])

        self.liste_achats_mois.SetEmptyListMsg("Aucuns achat pour ce mois")
        self.liste_achats_mois.AutoSizeColumns()

        self.notebook_achats.AddPage(self.panel_page_achat_mois,
                                     u"Achats du mois")

        #Page "Achats"
        self.panel_page_achats = wx.Panel(self.notebook_achats, -1)

        self.liste_achats = ObjectListView(
            self.panel_page_achats,
            -1,
            style=wx.LC_REPORT | wx.SUNKEN_BORDER | wx.LC_SINGLE_SEL,
            sortable=False)

        self.liste_achats.SetColumns([
            ColumnDefn("Date",
                       "left",
                       -1,
                       "date",
                       stringConverter="Achat du %d-%m-%y",
                       minimumWidth=100),
            ColumnDefn(u"Total",
                       "right",
                       -1,
                       "total",
                       stringConverter=u"%.2f €",
                       minimumWidth=100,
                       isSpaceFilling=True)
        ])

        def rowFormatterAchats(listItem, achat):
            if achat.is_achat_du_jour() and (
                    achat == self.liste_achats.GetObjectAt(0)):
                listItem.SetBackgroundColour("#CCFFCC")

        self.liste_achats.rowFormatter = rowFormatterAchats
        self.liste_achats.AutoSizeColumns()

        self.liste_lignes_achat = ObjectListView(
            self.panel_page_achats,
            -1,
            style=wx.LC_REPORT | wx.SUNKEN_BORDER | wx.LC_SINGLE_SEL)

        self.liste_lignes_achat.SetColumns([
            ColumnDefn("Ref GASE",
                       "left",
                       -1,
                       "produit.ref_GASE",
                       minimumWidth=70),
            ColumnDefn("Nom", "left", -1, "produit.nom", minimumWidth=100),
            ColumnDefn("Prix",
                       "left",
                       -1,
                       "produit.prix_vente_format",
                       minimumWidth=100),
            ColumnDefn(u"Quantité",
                       "left",
                       -1,
                       "quantite_format",
                       minimumWidth=70),
            ColumnDefn(u"Total",
                       "right",
                       -1,
                       "prix_total",
                       stringConverter=u"%.2f €",
                       minimumWidth=70,
                       isSpaceFilling=True)
        ])

        self.liste_lignes_achat.AutoSizeColumns()
        self.liste_lignes_achat.SortBy(1)

        self.notebook_achats.AddPage(self.panel_page_achats, "Achats")

        #Page "Cotisations"
        self.panel_page_cotisations = wx.Panel(self.notebook_achats, -1)
        self.liste_cotisations = ObjectListView(
            self.panel_page_cotisations,
            -1,
            style=wx.LC_REPORT | wx.SUNKEN_BORDER | wx.LC_SINGLE_SEL)

        def cotisation_mois_annee(cotisation):
            mois = [
                'Janvier', u'Février', 'Mars', 'Avril', 'Mai', 'Juin',
                'Juillet', u'Août', 'Septembre', 'Octobre', 'Novembre',
                u'Décembre'
            ]

            return "%s %i" % (mois[cotisation.date.month - 1],
                              cotisation.date.year)

        self.liste_cotisations.SetColumns([
            ColumnDefn("Cotisation de",
                       "left",
                       -1,
                       cotisation_mois_annee,
                       minimumWidth=100),
            ColumnDefn(u"Réglée le", "left", -1, "date", minimumWidth=100),
            ColumnDefn(u"Montant",
                       "left",
                       -1,
                       "montant",
                       stringConverter=u"%.2f €",
                       minimumWidth=70,
                       isSpaceFilling=True)
        ])

        self.notebook_achats.AddPage(self.panel_page_cotisations,
                                     "Cotisations")

        #Page "Paiements"
        self.panel_page_credits = wx.Panel(self.notebook_achats, -1)
        self.liste_credits = wx.ListCtrl(self.panel_page_credits,
                                         -1,
                                         style=wx.LC_REPORT | wx.SUNKEN_BORDER)

        self.notebook_achats.AddPage(self.panel_page_credits, "Paiements")

        self.__set_properties()
        self.__set_valeurs()
        self.__do_layout()

        self.combobox_choix_mois.Bind(wx.EVT_COMBOBOX, self.OnChoixMois)
        self.bouton_ajout_achat.Bind(wx.EVT_BUTTON, self.OnAjoutAchat)
        self.liste_achats.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnDetailsAchat)
        self.liste_achats.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnModifAchat)
        #self.liste_achats_mois.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnDetailsAchat)
        self.liste_achats_mois.Disable()
Ejemplo n.º 7
0
class FicheAdherent(wx.Panel):
    def __init__(self, parent, adherent=None):
        wx.Panel.__init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, style=wx.TAB_TRAVERSAL)

        #permet de faire un validate sur tout les panels
        self.SetExtraStyle(wx.WS_EX_VALIDATE_RECURSIVELY)

        if adherent:
            self.adherent = adherent
        else:
            self.adherent = Adherent()

        self.notebook = wx.Notebook(self, -1, style=0)
        self.notebook_p1 = wx.Panel(self.notebook, -1)
        self.notebook_p2 = wx.Panel(self.notebook, -1)
        self.notebook_p3 = wx.Panel(self.notebook, -1)

        #self.sizer_adhesions_staticbox = wx.StaticBox(self.notebook_p4, -1, u"Types d'adhésion")
        #self.label_description_adhesions = wx.StaticText(self.notebook_p4, -1, u"Ce sont les différentes formules disponibles pour adhérer à l'association.")

        self.panel_adherent = FicheAdherentBase(self.notebook_p1, self.adherent)
        self.panel_gestion_adhesions = GestionAdhesions(self.notebook_p2, self.adherent)
        self.panel_gestion_fournisseurs = GestionFournisseurs(self.notebook_p3, self.adherent)
        
        self.bouton_ok = wx.Button(self, wx.ID_OK, "")
        self.bouton_annuler = wx.Button(self, wx.ID_CANCEL, "Annuler")
        
        self.bouton_ok.Bind(wx.EVT_BUTTON, self.OnEnregistre)
        self.Bind(wx.EVT_WINDOW_DESTROY, self.OnClose)

        self.__set_properties()
        self.__do_layout()
        # end wxGlade

    def __set_properties(self):
        #On affiche pas les panneaux secondaires pour un nouvel adhérent
        if not self.adherent.get_id():
            self.notebook_p2.Hide()
            self.notebook_p3.Hide()

    def __do_layout(self):
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer_p1 = wx.BoxSizer(wx.VERTICAL)
        sizer_p2 = wx.BoxSizer(wx.VERTICAL)
        sizer_p3 = wx.BoxSizer(wx.VERTICAL)

        sizer_p1.Add(self.panel_adherent, 1, wx.ALL|wx.EXPAND, 5)
        self.notebook_p1.SetSizer(sizer_p1)

        sizer_p2.Add(self.panel_gestion_adhesions, 1, wx.ALL|wx.EXPAND, 5)
        self.notebook_p2.SetSizer(sizer_p2)

        sizer_p3.Add(self.panel_gestion_fournisseurs, 1, wx.ALL|wx.EXPAND, 5)
        self.notebook_p3.SetSizer(sizer_p3)

        self.notebook.AddPage(self.notebook_p1, u"Adhérent")
        self.notebook.AddPage(self.notebook_p2, u"Adhésions")
        self.notebook.AddPage(self.notebook_p3, u"Fournisseurs")

        sizer_boutons = wx.BoxSizer(wx.HORIZONTAL)

        sizer_boutons.Add((20, 20), 1, 0, 0)
        sizer_boutons.Add(self.bouton_ok, 0, 0, 0)
        sizer_boutons.Add((20, 20), 1, 0, 0)
        sizer_boutons.Add(self.bouton_annuler, 0, 0, 0)
        sizer_boutons.Add((20, 20), 1, 0, 0)

        sizer.Add(self.notebook, 1, wx.ALL|wx.EXPAND, 5)
        sizer.Add(sizer_boutons, 0, wx.TOP|wx.BOTTOM|wx.EXPAND, 10)
        self.SetSizer(sizer)
        sizer.Fit(self)
        
    def GetAdherent(self):
        return self.adherent

    def OnEnregistre(self, event):
        if self.Validate():
            self.panel_adherent.Enregistre()
            DATABASE.commit()
            
            event.Skip()
        else:
            control = wx.Window.FindFocus()
            self.notebook.ChangeSelection(0)
            control.SetFocus()

    def OnClose(self, event):
        DATABASE.rollback()
        event.Skip()
Ejemplo n.º 8
0
class FicheAdherentBase(wx.Panel):
    def __init__(self, parent, adherent=None):
        wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL)

        if adherent:
            self.adherent = adherent
        else:
            self.adherent = Adherent()

        self.label_Nom = wx.StaticText(self, -1, "Nom :")
        self.text_Nom = wx.TextCtrl(self, -1, "", validator=GenericTextValidator())
        self.label_Prenom = wx.StaticText(self, -1, u"Prénom :")
        self.text_Prenom = wx.TextCtrl(self, -1, "", validator=GenericTextValidator())
        self.label_Adresse = wx.StaticText(self, -1, "Adresse :")
        self.text_Adresse = wx.TextCtrl(self, -1, "", validator=GenericTextValidator())
        self.label_CodePostal = wx.StaticText(self, -1, "Code Postal :")
        self.text_CodePostal = wx.TextCtrl(self, -1, "", validator=GenericTextValidator(flag=VALIDATE_INT))
        self.label_Ville = wx.StaticText(self, -1, "Ville :")
        self.text_Ville = wx.TextCtrl(self, -1, "", validator=GenericTextValidator())
        self.label_TelephoneFixe = wx.StaticText(self, -1, u"Tel fixe:")
        self.text_TelephoneFixe = wx.TextCtrl(self, -1, "", validator=GenericTextValidator(obligatoire=False))
        self.label_TelephonePortable = wx.StaticText(self, -1, u"Tel portable :")
        self.text_TelephonePortable = wx.TextCtrl(self, -1, "", validator=GenericTextValidator(obligatoire=False))
        self.label_Email = wx.StaticText(self, -1, "Email :")
        self.text_Email = wx.TextCtrl(self, -1, "", validator=EmailValidator(obligatoire=False))
        self.label_Cotisation = wx.StaticText(self, -1, "Cotisation :")
        self.combo_box_CotisationTypes = wx.ComboBox(self, -1, choices=[], style=wx.CB_DROPDOWN|wx.CB_READONLY)
        self.label_Login = wx.StaticText(self, -1, "Login :"******"")
        self.label_ConfirmMotdepasse = wx.StaticText(self, -1, "Confirmation :")
        self.text_ConfirmMotdepasse = wx.TextCtrl(self, -1, "", style=wx.TE_PASSWORD)
        self.label_Motdepasse = wx.StaticText(self, -1, "Mot de passe :")
        self.text_Motdepasse = wx.TextCtrl(self, -1, "", style=wx.TE_PASSWORD, validator=MotDePasseValidator(self.text_ConfirmMotdepasse))
        
        self.__set_properties()
        self.__do_layout()
        self.__set_combobox_cotisations()
        self.__set_valeurs()

    def __set_properties(self):
        self.text_Nom.SetMinSize((250, -1))
        self.text_CodePostal.SetMinSize((80, -1))
        self.text_TelephoneFixe.SetMinSize((150, -1))
        self.text_TelephonePortable.SetMinSize((150, -1))
        # end wxGlade

    def __do_layout(self):
        grid_sizer = wx.FlexGridSizer(10, 2, 6, 6)

        grid_sizer.Add(self.label_Nom, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer.Add(self.text_Nom, 0, wx.EXPAND, 0)
        grid_sizer.Add(self.label_Prenom, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer.Add(self.text_Prenom, 0, wx.EXPAND, 0)
        grid_sizer.Add(self.label_Adresse, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer.Add(self.text_Adresse, 0, wx.EXPAND, 0)
        grid_sizer.Add(self.label_CodePostal, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer.Add(self.text_CodePostal, 0, 0, 0)
        grid_sizer.Add(self.label_Ville, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer.Add(self.text_Ville, 0, wx.EXPAND, 0)
        grid_sizer.Add(self.label_TelephoneFixe, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer.Add(self.text_TelephoneFixe, 0, 0, 0)
        grid_sizer.Add(self.label_TelephonePortable, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer.Add(self.text_TelephonePortable, 0, 0, 0)
        grid_sizer.Add(self.label_Email, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer.Add(self.text_Email, 0, wx.EXPAND, 0)
        grid_sizer.Add(self.label_Cotisation, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer.Add(self.combo_box_CotisationTypes, 0, wx.EXPAND, 0)
        grid_sizer.Add(self.label_Login, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer.Add(self.text_Login, 0, wx.EXPAND, 0)
        grid_sizer.Add(self.label_Motdepasse, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer.Add(self.text_Motdepasse, 0, wx.EXPAND, 0)
        grid_sizer.Add(self.label_ConfirmMotdepasse, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer.Add(self.text_ConfirmMotdepasse, 0, wx.EXPAND, 0)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(grid_sizer, 0, wx.ALL|wx.EXPAND, 10)

        self.SetSizer(sizer)
        self.Fit()
        self.Layout()

    def __set_combobox_cotisations(self):
        try:
            cotisation_types = [c for c in CotisationType.select().order_by(CotisationType.prix.asc())]
            for c in cotisation_types:
                self.combo_box_CotisationTypes.Append(c.nom + u" - %s ¤" % c.prix, c)

            self.combo_box_CotisationTypes.Select(0)

        except BaseException as ex:
            print ex

    def __set_valeurs(self):
        if self.adherent.get_id():
            self.text_Nom.SetValue(self.adherent.nom)
            self.text_Prenom.SetValue(self.adherent.prenom)
            self.text_Adresse.SetValue(self.adherent.adresse)
            self.text_CodePostal.SetValue(self.adherent.code_postal)
            self.text_Ville.SetValue(self.adherent.ville)
            self.text_TelephoneFixe.SetValue(self.adherent.telephone_fixe)
            self.text_TelephonePortable.SetValue(self.adherent.telephone_portable)
            self.text_Email.SetValue(self.adherent.email)
            self.text_Login.SetValue(self.adherent.login)
            #self.text_Login.SetValidator(LoginValidator(self.adherent.GetLogins()))

            for i in range(len(self.combo_box_CotisationTypes.GetItems())):
                if self.adherent.cotisation_type == self.combo_box_CotisationTypes.GetClientData(i):
                    self.combo_box_CotisationTypes.Select(i)
                    break

        #TODO: On ajoute le validator de logins
        #self.text_Login.SetValidator(LoginValidator(self.adherent.GetLogins()))

    def GetAdherent(self):
        return self.adherent

    def Enregistre(self):
        if self.Validate():
            self.adherent.nom = self.text_Nom.GetValue()
            self.adherent.prenom = self.text_Prenom.GetValue()
            self.adherent.adresse = self.text_Adresse.GetValue()
            self.adherent.code_postal = self.text_CodePostal.GetValue()
            self.adherent.ville = self.text_Ville.GetValue()
            self.adherent.telephone_fixe = self.text_TelephoneFixe.GetValue()
            self.adherent.telephone_portable = self.text_TelephonePortable.GetValue()
            self.adherent.email = self.text_Email.GetValue()
            self.adherent.cotisation_type = self.combo_box_CotisationTypes.GetClientData(self.combo_box_CotisationTypes.GetSelection())
            self.adherent.login = self.text_Login.GetValue()

            #TODO: à revoir
            if self.text_Motdepasse.GetValue() != '':
                self.adherent.mot_de_passe = self.text_Motdepasse.GetValue()

            self.adherent.save()
Ejemplo n.º 9
0
    def __init__(self, parent, adherent=None):
        wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL)

        if adherent == None:
            adherent = Adherent()

        self.adherent = adherent
        
        self.notebook = wx.Notebook(self, -1, style=0)

        self.notebook_p1 = wx.Panel(self.notebook, -1)

        self.notebook_p1.label_Nom = wx.StaticText(self, -1, "Nom :")
        self.notebook_p1.text_Nom = wx.TextCtrl(self, -1, "", validator=GenericTextValidator())
        self.notebook_p1.label_Prenom = wx.StaticText(self, -1, u"Pr�nom :")
        self.notebook_p1.text_Prenom = wx.TextCtrl(self, -1, "", validator=GenericTextValidator())
        self.notebook_p1.label_Adresse = wx.StaticText(self, -1, "Adresse :")
        self.notebook_p1.text_Adresse = wx.TextCtrl(self, -1, "", validator=GenericTextValidator())
        self.notebook_p1.label_CodePostal = wx.StaticText(self, -1, "Code Postal :")
        self.notebook_p1.text_CodePostal = wx.TextCtrl(self, -1, "", validator=GenericTextValidator(flag=VALIDATE_INT))
        self.notebook_p1.label_Ville = wx.StaticText(self, -1, "Ville :")
        self.notebook_p1.text_Ville = wx.TextCtrl(self, -1, "", validator=GenericTextValidator())
        self.notebook_p1.label_TelephoneFixe = wx.StaticText(self, -1, u"Tel fixe:")
        self.notebook_p1.text_TelephoneFixe = wx.TextCtrl(self, -1, "", validator=GenericTextValidator(obligatoire=False))
        self.notebook_p1.label_TelephonePortable = wx.StaticText(self, -1, u"Tel portable :")
        self.notebook_p1.text_TelephonePortable = wx.TextCtrl(self, -1, "", validator=GenericTextValidator(obligatoire=False))
        self.notebook_p1.label_Email = wx.StaticText(self, -1, "Email :")
        self.notebook_p1.text_Email = wx.TextCtrl(self, -1, "", validator=EmailValidator(obligatoire=False))
        self.notebook_p1.label_Cotisation = wx.StaticText(self, -1, "Cotisation :")
        self.notebook_p1.combo_box_CotisationTypes = wx.ComboBox(self, -1, choices=[], style=wx.CB_DROPDOWN|wx.CB_READONLY)
        self.notebook_p1.label_Login = wx.StaticText(self, -1, "Login :"******"")
        self.notebook_p1.label_ConfirmMotdepasse = wx.StaticText(self, -1, "Confirmation :")
        self.notebook_p1.text_ConfirmMotdepasse = wx.TextCtrl(self, -1, "", style=wx.TE_PASSWORD)
        self.notebook_p1.label_Motdepasse = wx.StaticText(self, -1, "Mot de passe :")
        self.notebook_p1.text_Motdepasse = wx.TextCtrl(self, -1, "", style=wx.TE_PASSWORD, validator=MotDePasseValidator(self.notebook_p1.text_ConfirmMotdepasse))

        self.notebook_p1.button_ok = wx.Button(self, wx.ID_OK, "")
        self.notebook_p1.button_annuler = wx.Button(self, wx.ID_CANCEL, "Annuler")

        '''self.notebook_p2 = wx.Panel(self.notebook, -1)
        
        self.notebook_p2.bouton_ajout_adhesion = wx.BitmapButton(self, -1, wx.Bitmap("../icons/16x16/ajouter.ico"))
        self.notebook_p2.bouton_supprime_adhesion = wx.BitmapButton(self, -1, wx.Bitmap("../icons/16x16/enlever.ico"))
        self.notebook_p2.liste_categories = ObjectListView(self, -1, style=wx.LC_REPORT | wx.SUNKEN_BORDER | wx.LC_SINGLE_SEL)

        self.notebook_p2.liste_categories.SetColumns([
            ColumnDefn(u"Adh�sion", "left", -1, "adhesion_type.nom"),
            ColumnDefn("Date", "left", -1, "date"),
            ColumnDefn("Montant", "left", 100,
                       "montant",
                       stringConverter="%f �",
                       isSpaceFilling=True)
        ])'''
        

        self.__set_properties()
        self.__do_layout()
        self.__set_combobox_cotisations()
        self.__set_valeurs()

        self.notebook_p1.button_ok.Bind(wx.EVT_BUTTON, self.OnEnregistre)

        self.notebook_p1.Bind(wx.EVT_CLOSE, self.OnClose, self)
        self.notebook_p1.Bind(wx.EVT_BUTTON, self.OnClose, self.notebook_p1.button_annuler)
Ejemplo n.º 10
0
    def __init__(self, parent, achat=None, adherent=None):
        wx.Dialog.__init__(self, parent,  style=wx.DEFAULT_DIALOG_STYLE)

        if achat == None:
            if adherent == None:
                #TODO : à modifier quand le système d'identification sera en place
                adherent = Adherent.select().where(Adherent.id == 1).get()

            achat = Achat.create(adherent=adherent)

        self.achat = achat

        self.sizer_infos_staticbox = wx.StaticBox(self, -1, "Informations")

        self.label_credit_restant = wx.StaticText(self, -1, u"Crédit restant")
        self.label_cotisation = wx.StaticText(self, -1, u"Cotisation du mois")
        self.label_cotisation_payee = wx.StaticText(self, -1, u"- Payée le xx-xx-xx")
        self.label_total_achats = wx.StaticText(self, -1, "Total des achats")
        self.label_solde = wx.StaticText(self, -1, u"Solde après achat")
        self.label_credit_restant_valeur = wx.StaticText(self, -1, u"0.00 ¤")
        self.label_cotisation_valeur = wx.StaticText(self, -1, u"0.00 ¤")
        self.label_total_achats_valeur = wx.StaticText(self, -1, u"0.00 ¤", style=wx.ALIGN_RIGHT)
        self.label_cout_supplementaire = wx.StaticText(self, -1, u"Coût supplémentaire")
        self.text_cout_supplementaire = wx.TextCtrl(self, -1, validator=GenericTextValidator(VALIDATE_FLOAT, obligatoire=False))
        self.text_cout_supplementaire_commentaire = TextCtrlDescriptive(self, -1, style=wx.TE_MULTILINE)
        self.label_solde_valeur = wx.StaticText(self, -1, u"0.00 ¤")

        self.sizer_liste_produits_staticbox = wx.StaticBox(self, -1, "Liste des produits")
        self.label_titre_achat = wx.StaticText(self, -1, "Achat pour ")
        self.search_nom = wx.SearchCtrl(self, -1, "")
        self.liste_produits = ObjectListView(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)

        self.liste_produits.SetColumns([
            ColumnDefn("Ref GASE", "left", -1, "ref_GASE", minimumWidth=70),
            ColumnDefn("Nom", "left", -1, "nom", minimumWidth=100),
            ColumnDefn("Prix", "right", -1, "prix_vente_format", minimumWidth=100, isSpaceFilling=True)
        ])
        self.liste_produits.SetEmptyListMsg("Aucun produits")
        self.liste_produits.AutoSizeColumns()

        self.sizer_achat_staticbox = wx.StaticBox(self, -1, "Achat")
        self.liste_lignes_achat = ObjectListView(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)

        self.liste_lignes_achat.SetColumns([
            ColumnDefn("Ref GASE", "left", -1, "produit.ref_GASE", minimumWidth=70),
            ColumnDefn("Nom", "left", -1, "produit.nom", minimumWidth=100),
            ColumnDefn("Prix", "left", -1, "produit.prix_vente_format", minimumWidth=100),
            ColumnDefn(u"Quantité", "left", -1, "quantite_format", minimumWidth=70),
            ColumnDefn("Total TTC", "right", -1, "prix_total", stringConverter=u"%.2f ¤", minimumWidth=70, isSpaceFilling=True)
        ])
        self.liste_lignes_achat.AutoSizeColumns()

        self.liste_lignes_achat.SetEmptyListMsg(u"Produits achetés")
        
        self.bouton_sauvegarder = wx.Button(self, wx.ID_SAVE)
        self.bouton_annuler = wx.Button(self, wx.ID_CANCEL)

        self.__set_properties()
        self.__set_tooltips()
        self.__set_values()
        self.__do_layout()

        self.bouton_sauvegarder.Bind(wx.EVT_BUTTON, self.OnSauvegarder)
        self.bouton_annuler.Bind(wx.EVT_BUTTON, self.OnClose)
        self.text_cout_supplementaire.Bind(wx.EVT_TEXT, self.OnChangeCoutSupp)
        self.search_nom.Bind(wx.EVT_TEXT, self.OnFilter)
        self.liste_produits.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnAjoutProduit)
        self.liste_lignes_achat.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnModifProduit)
        self.Bind(wx.EVT_CLOSE, self.OnClose)
Ejemplo n.º 11
0
    def __init__(self, parent, achat=None, adherent=None):
        wx.Dialog.__init__(self, parent, style=wx.DEFAULT_DIALOG_STYLE)

        if achat == None:
            if adherent == None:
                #TODO : à modifier quand le système d'identification sera en place
                adherent = Adherent.select().where(Adherent.id == 1).get()

            achat = Achat.create(adherent=adherent)

        self.achat = achat

        self.sizer_infos_staticbox = wx.StaticBox(self, -1, "Informations")

        self.label_credit_restant = wx.StaticText(self, -1, u"Crédit restant")
        self.label_cotisation = wx.StaticText(self, -1, u"Cotisation du mois")
        self.label_cotisation_payee = wx.StaticText(self, -1,
                                                    u"- Payée le xx-xx-xx")
        self.label_total_achats = wx.StaticText(self, -1, "Total des achats")
        self.label_solde = wx.StaticText(self, -1, u"Solde après achat")
        self.label_credit_restant_valeur = wx.StaticText(self, -1, u"0.00 ¤")
        self.label_cotisation_valeur = wx.StaticText(self, -1, u"0.00 ¤")
        self.label_total_achats_valeur = wx.StaticText(self,
                                                       -1,
                                                       u"0.00 ¤",
                                                       style=wx.ALIGN_RIGHT)
        self.label_cout_supplementaire = wx.StaticText(
            self, -1, u"Coût supplémentaire")
        self.text_cout_supplementaire = wx.TextCtrl(
            self,
            -1,
            validator=GenericTextValidator(VALIDATE_FLOAT, obligatoire=False))
        self.text_cout_supplementaire_commentaire = TextCtrlDescriptive(
            self, -1, style=wx.TE_MULTILINE)
        self.label_solde_valeur = wx.StaticText(self, -1, u"0.00 ¤")

        self.sizer_liste_produits_staticbox = wx.StaticBox(
            self, -1, "Liste des produits")
        self.label_titre_achat = wx.StaticText(self, -1, "Achat pour ")
        self.search_nom = wx.SearchCtrl(self, -1, "")
        self.liste_produits = ObjectListView(self,
                                             -1,
                                             style=wx.LC_REPORT
                                             | wx.SUNKEN_BORDER)

        self.liste_produits.SetColumns([
            ColumnDefn("Ref GASE", "left", -1, "ref_GASE", minimumWidth=70),
            ColumnDefn("Nom", "left", -1, "nom", minimumWidth=100),
            ColumnDefn("Prix",
                       "right",
                       -1,
                       "prix_vente_format",
                       minimumWidth=100,
                       isSpaceFilling=True)
        ])
        self.liste_produits.SetEmptyListMsg("Aucun produits")
        self.liste_produits.AutoSizeColumns()

        self.sizer_achat_staticbox = wx.StaticBox(self, -1, "Achat")
        self.liste_lignes_achat = ObjectListView(self,
                                                 -1,
                                                 style=wx.LC_REPORT
                                                 | wx.SUNKEN_BORDER)

        self.liste_lignes_achat.SetColumns([
            ColumnDefn("Ref GASE",
                       "left",
                       -1,
                       "produit.ref_GASE",
                       minimumWidth=70),
            ColumnDefn("Nom", "left", -1, "produit.nom", minimumWidth=100),
            ColumnDefn("Prix",
                       "left",
                       -1,
                       "produit.prix_vente_format",
                       minimumWidth=100),
            ColumnDefn(u"Quantité",
                       "left",
                       -1,
                       "quantite_format",
                       minimumWidth=70),
            ColumnDefn("Total TTC",
                       "right",
                       -1,
                       "prix_total",
                       stringConverter=u"%.2f ¤",
                       minimumWidth=70,
                       isSpaceFilling=True)
        ])
        self.liste_lignes_achat.AutoSizeColumns()

        self.liste_lignes_achat.SetEmptyListMsg(u"Produits achetés")

        self.bouton_sauvegarder = wx.Button(self, wx.ID_SAVE)
        self.bouton_annuler = wx.Button(self, wx.ID_CANCEL)

        self.__set_properties()
        self.__set_tooltips()
        self.__set_values()
        self.__do_layout()

        self.bouton_sauvegarder.Bind(wx.EVT_BUTTON, self.OnSauvegarder)
        self.bouton_annuler.Bind(wx.EVT_BUTTON, self.OnClose)
        self.text_cout_supplementaire.Bind(wx.EVT_TEXT, self.OnChangeCoutSupp)
        self.search_nom.Bind(wx.EVT_TEXT, self.OnFilter)
        self.liste_produits.Bind(wx.EVT_LIST_ITEM_ACTIVATED,
                                 self.OnAjoutProduit)
        self.liste_lignes_achat.Bind(wx.EVT_LIST_ITEM_ACTIVATED,
                                     self.OnModifProduit)
        self.Bind(wx.EVT_CLOSE, self.OnClose)
Ejemplo n.º 12
0
    def __init__(self, parent, adherent=None):
        wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL)
        
        if adherent:
            self.adherent = adherent
        else:
            self.adherent = Adherent.select().where(Adherent.id == 1).get()

        self.label_total_achats = wx.StaticText(self, -1, "Total des achats du mois en cours :")
        self.label_total_achats_v = wx.StaticText(self, -1, u"XX.XX €")
        self.label_solde = wx.StaticText(self, -1, u"Solde :")
        self.label_solde_v = wx.StaticText(self, -1, u"XX.XX €")
        self.static_line = wx.StaticLine(self, -1)
        self.bouton_ajout_achat = wx.Button(self, -1, "Nouvel achat")
        self.bouton_ajout_credit = wx.Button(self, -1, "Nouveau paiement")
        self.label_info = wx.StaticText(self, -1, u"Note : Le dernier achat et le dernier paiement sont modifiable le jour même.")

        self.notebook_achats = wx.Notebook(self, -1, style=0)

        #Page "Dernieres produits achetés"
        self.panel_page_achat_mois = wx.Panel(self.notebook_achats, -1)
        self.label_mois_recherche = wx.StaticText(self.panel_page_achat_mois, -1, u"Achats du mois de ")
        self.combobox_choix_mois = wx.ComboBox(self.panel_page_achat_mois, -1)
        self.label_total_mois = wx.StaticText(self.panel_page_achat_mois, -1, u"Total des achats du mois : XX.XX €")
        self.liste_achats_mois = ObjectListView(self.panel_page_achat_mois, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER|wx.LC_SINGLE_SEL)

        """def date_achat(ligne_achat):
            return ligne_achat.achat.date.strftime("%d-%m-%y")

        def ref_GASE_nom(ligne_achat):
            return "%s - %s" % (ligne_achat.produit.ref_GASE, ligne_achat.produit.nom)
        
        self.liste_achats_mois.SetColumns([
            ColumnDefn("Ref GASE - Nom", "left", -1, ref_GASE_nom, minimumWidth=250, groupKeyGetter=date_achat),
            ColumnDefn("Prix", "left", -1, "produit.prix_vente_format", minimumWidth=100),
            ColumnDefn(u"Quantité", "left", -1, "quantite_format", minimumWidth=70),
            ColumnDefn(u"Total", "right", -1, "prix_total", stringConverter=u"%.2f €", minimumWidth=70, isSpaceFilling=True)
        ])"""
        
        self.liste_achats_mois.SetColumns([
            ColumnDefn("Date", "center", -1, "achat.date", stringConverter="%d-%m-%y", minimumWidth=70),
            ColumnDefn("Ref GASE", "center", -1, "produit.ref_GASE", minimumWidth=70),
            ColumnDefn("Nom", "left", -1, "produit.nom", minimumWidth=100),
            ColumnDefn("Prix", "left", -1, "produit.prix_vente_format", minimumWidth=100),
            ColumnDefn(u"Quantité", "left", -1, "quantite_format", minimumWidth=70),
            ColumnDefn(u"Total", "right", -1, "prix_total", stringConverter=u"%.2f €", minimumWidth=70, isSpaceFilling=True)
        ])
        
        self.liste_achats_mois.SetEmptyListMsg("Aucuns achat pour ce mois")
        self.liste_achats_mois.AutoSizeColumns()

        self.notebook_achats.AddPage(self.panel_page_achat_mois, u"Achats du mois")

        #Page "Achats"
        self.panel_page_achats = wx.Panel(self.notebook_achats, -1)

        self.liste_achats =  ObjectListView(self.panel_page_achats, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER|wx.LC_SINGLE_SEL, sortable=False)
        
        self.liste_achats.SetColumns([
            ColumnDefn("Date", "left", -1, "date", stringConverter="Achat du %d-%m-%y", minimumWidth=100),
            ColumnDefn(u"Total", "right", -1, "total", stringConverter=u"%.2f €", minimumWidth=100, isSpaceFilling=True)
        ])
        
        def rowFormatterAchats(listItem, achat):
            if achat.is_achat_du_jour() and (achat == self.liste_achats.GetObjectAt(0)):
                listItem.SetBackgroundColour("#CCFFCC")

        self.liste_achats.rowFormatter = rowFormatterAchats
        self.liste_achats.AutoSizeColumns()

        self.liste_lignes_achat = ObjectListView(self.panel_page_achats, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER|wx.LC_SINGLE_SEL)

        self.liste_lignes_achat.SetColumns([
            ColumnDefn("Ref GASE", "left", -1, "produit.ref_GASE", minimumWidth=70),
            ColumnDefn("Nom", "left", -1, "produit.nom", minimumWidth=100),
            ColumnDefn("Prix", "left", -1, "produit.prix_vente_format", minimumWidth=100),
            ColumnDefn(u"Quantité", "left", -1, "quantite_format", minimumWidth=70),
            ColumnDefn(u"Total", "right", -1, "prix_total", stringConverter=u"%.2f €", minimumWidth=70, isSpaceFilling=True)
        ])

        self.liste_lignes_achat.AutoSizeColumns()
        self.liste_lignes_achat.SortBy(1)

        self.notebook_achats.AddPage(self.panel_page_achats, "Achats")

        #Page "Cotisations"
        self.panel_page_cotisations = wx.Panel(self.notebook_achats, -1)
        self.liste_cotisations = ObjectListView(self.panel_page_cotisations, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER|wx.LC_SINGLE_SEL)
        
        def cotisation_mois_annee(cotisation):
            mois = ['Janvier',u'Février','Mars','Avril','Mai','Juin','Juillet',u'Août','Septembre','Octobre','Novembre',u'Décembre']
            
            return "%s %i" % (mois[cotisation.date.month-1], cotisation.date.year)
        
        self.liste_cotisations.SetColumns([
            ColumnDefn("Cotisation de", "left", -1, cotisation_mois_annee, minimumWidth=100),
            ColumnDefn(u"Réglée le", "left", -1, "date", minimumWidth=100),
            ColumnDefn(u"Montant", "left", -1, "montant", stringConverter=u"%.2f €", minimumWidth=70, isSpaceFilling=True)
        ])
        
        self.notebook_achats.AddPage(self.panel_page_cotisations, "Cotisations")
        
        #Page "Paiements"
        self.panel_page_credits = wx.Panel(self.notebook_achats, -1)
        self.liste_credits = wx.ListCtrl(self.panel_page_credits, -1, style=wx.LC_REPORT | wx.SUNKEN_BORDER)
        
        self.notebook_achats.AddPage(self.panel_page_credits, "Paiements")


        self.__set_properties()
        self.__set_valeurs()
        self.__do_layout()

        self.combobox_choix_mois.Bind(wx.EVT_COMBOBOX, self.OnChoixMois)
        self.bouton_ajout_achat.Bind(wx.EVT_BUTTON, self.OnAjoutAchat)
        self.liste_achats.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnDetailsAchat)
        self.liste_achats.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnModifAchat)
        #self.liste_achats_mois.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnDetailsAchat)
        self.liste_achats_mois.Disable()
Ejemplo n.º 13
0
 def __remplissage_liste(self):
     try:
         self.liste_adherents.SetObjects([a for a in Adherent.select()])
         self.liste_adherents.AutoSizeColumns()
     except BaseException as ex:
         print ex
Ejemplo n.º 14
0
class FicheAdherent(wx.Panel):
    def __init__(self, parent, adherent=None):
        wx.Panel.__init__(self,
                          parent,
                          id=wx.ID_ANY,
                          pos=wx.DefaultPosition,
                          style=wx.TAB_TRAVERSAL)

        #permet de faire un validate sur tout les panels
        self.SetExtraStyle(wx.WS_EX_VALIDATE_RECURSIVELY)

        if adherent:
            self.adherent = adherent
        else:
            self.adherent = Adherent()

        self.notebook = wx.Notebook(self, -1, style=0)
        self.notebook_p1 = wx.Panel(self.notebook, -1)
        self.notebook_p2 = wx.Panel(self.notebook, -1)
        self.notebook_p3 = wx.Panel(self.notebook, -1)

        #self.sizer_adhesions_staticbox = wx.StaticBox(self.notebook_p4, -1, u"Types d'adhésion")
        #self.label_description_adhesions = wx.StaticText(self.notebook_p4, -1, u"Ce sont les différentes formules disponibles pour adhérer à l'association.")

        self.panel_adherent = FicheAdherentBase(self.notebook_p1,
                                                self.adherent)
        self.panel_gestion_adhesions = GestionAdhesions(
            self.notebook_p2, self.adherent)
        self.panel_gestion_fournisseurs = GestionFournisseurs(
            self.notebook_p3, self.adherent)

        self.bouton_ok = wx.Button(self, wx.ID_OK, "")
        self.bouton_annuler = wx.Button(self, wx.ID_CANCEL, "Annuler")

        self.bouton_ok.Bind(wx.EVT_BUTTON, self.OnEnregistre)
        self.Bind(wx.EVT_WINDOW_DESTROY, self.OnClose)

        self.__set_properties()
        self.__do_layout()
        # end wxGlade

    def __set_properties(self):
        #On affiche pas les panneaux secondaires pour un nouvel adhérent
        if not self.adherent.get_id():
            self.notebook_p2.Hide()
            self.notebook_p3.Hide()

    def __do_layout(self):
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer_p1 = wx.BoxSizer(wx.VERTICAL)
        sizer_p2 = wx.BoxSizer(wx.VERTICAL)
        sizer_p3 = wx.BoxSizer(wx.VERTICAL)

        sizer_p1.Add(self.panel_adherent, 1, wx.ALL | wx.EXPAND, 5)
        self.notebook_p1.SetSizer(sizer_p1)

        sizer_p2.Add(self.panel_gestion_adhesions, 1, wx.ALL | wx.EXPAND, 5)
        self.notebook_p2.SetSizer(sizer_p2)

        sizer_p3.Add(self.panel_gestion_fournisseurs, 1, wx.ALL | wx.EXPAND, 5)
        self.notebook_p3.SetSizer(sizer_p3)

        self.notebook.AddPage(self.notebook_p1, u"Adhérent")
        self.notebook.AddPage(self.notebook_p2, u"Adhésions")
        self.notebook.AddPage(self.notebook_p3, u"Fournisseurs")

        sizer_boutons = wx.BoxSizer(wx.HORIZONTAL)

        sizer_boutons.Add((20, 20), 1, 0, 0)
        sizer_boutons.Add(self.bouton_ok, 0, 0, 0)
        sizer_boutons.Add((20, 20), 1, 0, 0)
        sizer_boutons.Add(self.bouton_annuler, 0, 0, 0)
        sizer_boutons.Add((20, 20), 1, 0, 0)

        sizer.Add(self.notebook, 1, wx.ALL | wx.EXPAND, 5)
        sizer.Add(sizer_boutons, 0, wx.TOP | wx.BOTTOM | wx.EXPAND, 10)
        self.SetSizer(sizer)
        sizer.Fit(self)

    def GetAdherent(self):
        return self.adherent

    def OnEnregistre(self, event):
        if self.Validate():
            self.panel_adherent.Enregistre()
            DATABASE.commit()

            event.Skip()
        else:
            control = wx.Window.FindFocus()
            self.notebook.ChangeSelection(0)
            control.SetFocus()

    def OnClose(self, event):
        DATABASE.rollback()
        event.Skip()
Ejemplo n.º 15
0
    def __init__(self, parent, adherent=None):
        wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL)

        if adherent:
            self.adherent = adherent
        else:
            self.adherent = Adherent()

        self.label_Nom = wx.StaticText(self, -1, "Nom :")
        self.text_Nom = wx.TextCtrl(self,
                                    -1,
                                    "",
                                    validator=GenericTextValidator())
        self.label_Prenom = wx.StaticText(self, -1, u"Prénom :")
        self.text_Prenom = wx.TextCtrl(self,
                                       -1,
                                       "",
                                       validator=GenericTextValidator())
        self.label_Adresse = wx.StaticText(self, -1, "Adresse :")
        self.text_Adresse = wx.TextCtrl(self,
                                        -1,
                                        "",
                                        validator=GenericTextValidator())
        self.label_CodePostal = wx.StaticText(self, -1, "Code Postal :")
        self.text_CodePostal = wx.TextCtrl(
            self, -1, "", validator=GenericTextValidator(flag=VALIDATE_INT))
        self.label_Ville = wx.StaticText(self, -1, "Ville :")
        self.text_Ville = wx.TextCtrl(self,
                                      -1,
                                      "",
                                      validator=GenericTextValidator())
        self.label_TelephoneFixe = wx.StaticText(self, -1, u"Tel fixe:")
        self.text_TelephoneFixe = wx.TextCtrl(
            self, -1, "", validator=GenericTextValidator(obligatoire=False))
        self.label_TelephonePortable = wx.StaticText(self, -1,
                                                     u"Tel portable :")
        self.text_TelephonePortable = wx.TextCtrl(
            self, -1, "", validator=GenericTextValidator(obligatoire=False))
        self.label_Email = wx.StaticText(self, -1, "Email :")
        self.text_Email = wx.TextCtrl(
            self, -1, "", validator=EmailValidator(obligatoire=False))
        self.label_Cotisation = wx.StaticText(self, -1, "Cotisation :")
        self.combo_box_CotisationTypes = wx.ComboBox(self,
                                                     -1,
                                                     choices=[],
                                                     style=wx.CB_DROPDOWN
                                                     | wx.CB_READONLY)
        self.label_Login = wx.StaticText(self, -1, "Login :"******"")
        self.label_ConfirmMotdepasse = wx.StaticText(self, -1,
                                                     "Confirmation :")
        self.text_ConfirmMotdepasse = wx.TextCtrl(self,
                                                  -1,
                                                  "",
                                                  style=wx.TE_PASSWORD)
        self.label_Motdepasse = wx.StaticText(self, -1, "Mot de passe :")
        self.text_Motdepasse = wx.TextCtrl(self,
                                           -1,
                                           "",
                                           style=wx.TE_PASSWORD,
                                           validator=MotDePasseValidator(
                                               self.text_ConfirmMotdepasse))

        self.__set_properties()
        self.__do_layout()
        self.__set_combobox_cotisations()
        self.__set_valeurs()
Ejemplo n.º 16
0
class FicheAdherentBase(wx.Panel):
    def __init__(self, parent, adherent=None):
        wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL)

        if adherent:
            self.adherent = adherent
        else:
            self.adherent = Adherent()

        self.label_Nom = wx.StaticText(self, -1, "Nom :")
        self.text_Nom = wx.TextCtrl(self,
                                    -1,
                                    "",
                                    validator=GenericTextValidator())
        self.label_Prenom = wx.StaticText(self, -1, u"Prénom :")
        self.text_Prenom = wx.TextCtrl(self,
                                       -1,
                                       "",
                                       validator=GenericTextValidator())
        self.label_Adresse = wx.StaticText(self, -1, "Adresse :")
        self.text_Adresse = wx.TextCtrl(self,
                                        -1,
                                        "",
                                        validator=GenericTextValidator())
        self.label_CodePostal = wx.StaticText(self, -1, "Code Postal :")
        self.text_CodePostal = wx.TextCtrl(
            self, -1, "", validator=GenericTextValidator(flag=VALIDATE_INT))
        self.label_Ville = wx.StaticText(self, -1, "Ville :")
        self.text_Ville = wx.TextCtrl(self,
                                      -1,
                                      "",
                                      validator=GenericTextValidator())
        self.label_TelephoneFixe = wx.StaticText(self, -1, u"Tel fixe:")
        self.text_TelephoneFixe = wx.TextCtrl(
            self, -1, "", validator=GenericTextValidator(obligatoire=False))
        self.label_TelephonePortable = wx.StaticText(self, -1,
                                                     u"Tel portable :")
        self.text_TelephonePortable = wx.TextCtrl(
            self, -1, "", validator=GenericTextValidator(obligatoire=False))
        self.label_Email = wx.StaticText(self, -1, "Email :")
        self.text_Email = wx.TextCtrl(
            self, -1, "", validator=EmailValidator(obligatoire=False))
        self.label_Cotisation = wx.StaticText(self, -1, "Cotisation :")
        self.combo_box_CotisationTypes = wx.ComboBox(self,
                                                     -1,
                                                     choices=[],
                                                     style=wx.CB_DROPDOWN
                                                     | wx.CB_READONLY)
        self.label_Login = wx.StaticText(self, -1, "Login :"******"")
        self.label_ConfirmMotdepasse = wx.StaticText(self, -1,
                                                     "Confirmation :")
        self.text_ConfirmMotdepasse = wx.TextCtrl(self,
                                                  -1,
                                                  "",
                                                  style=wx.TE_PASSWORD)
        self.label_Motdepasse = wx.StaticText(self, -1, "Mot de passe :")
        self.text_Motdepasse = wx.TextCtrl(self,
                                           -1,
                                           "",
                                           style=wx.TE_PASSWORD,
                                           validator=MotDePasseValidator(
                                               self.text_ConfirmMotdepasse))

        self.__set_properties()
        self.__do_layout()
        self.__set_combobox_cotisations()
        self.__set_valeurs()

    def __set_properties(self):
        self.text_Nom.SetMinSize((250, -1))
        self.text_CodePostal.SetMinSize((80, -1))
        self.text_TelephoneFixe.SetMinSize((150, -1))
        self.text_TelephonePortable.SetMinSize((150, -1))
        # end wxGlade

    def __do_layout(self):
        grid_sizer = wx.FlexGridSizer(10, 2, 6, 6)

        grid_sizer.Add(self.label_Nom, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer.Add(self.text_Nom, 0, wx.EXPAND, 0)
        grid_sizer.Add(self.label_Prenom, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer.Add(self.text_Prenom, 0, wx.EXPAND, 0)
        grid_sizer.Add(self.label_Adresse, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer.Add(self.text_Adresse, 0, wx.EXPAND, 0)
        grid_sizer.Add(self.label_CodePostal, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer.Add(self.text_CodePostal, 0, 0, 0)
        grid_sizer.Add(self.label_Ville, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer.Add(self.text_Ville, 0, wx.EXPAND, 0)
        grid_sizer.Add(self.label_TelephoneFixe, 0, wx.ALIGN_CENTER_VERTICAL,
                       0)
        grid_sizer.Add(self.text_TelephoneFixe, 0, 0, 0)
        grid_sizer.Add(self.label_TelephonePortable, 0,
                       wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer.Add(self.text_TelephonePortable, 0, 0, 0)
        grid_sizer.Add(self.label_Email, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer.Add(self.text_Email, 0, wx.EXPAND, 0)
        grid_sizer.Add(self.label_Cotisation, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer.Add(self.combo_box_CotisationTypes, 0, wx.EXPAND, 0)
        grid_sizer.Add(self.label_Login, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer.Add(self.text_Login, 0, wx.EXPAND, 0)
        grid_sizer.Add(self.label_Motdepasse, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer.Add(self.text_Motdepasse, 0, wx.EXPAND, 0)
        grid_sizer.Add(self.label_ConfirmMotdepasse, 0,
                       wx.ALIGN_CENTER_VERTICAL, 0)
        grid_sizer.Add(self.text_ConfirmMotdepasse, 0, wx.EXPAND, 0)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(grid_sizer, 0, wx.ALL | wx.EXPAND, 10)

        self.SetSizer(sizer)
        self.Fit()
        self.Layout()

    def __set_combobox_cotisations(self):
        try:
            cotisation_types = [
                c for c in CotisationType.select().order_by(
                    CotisationType.prix.asc())
            ]
            for c in cotisation_types:
                self.combo_box_CotisationTypes.Append(
                    c.nom + u" - %s ¤" % c.prix, c)

            self.combo_box_CotisationTypes.Select(0)

        except BaseException as ex:
            print ex

    def __set_valeurs(self):
        if self.adherent.get_id():
            self.text_Nom.SetValue(self.adherent.nom)
            self.text_Prenom.SetValue(self.adherent.prenom)
            self.text_Adresse.SetValue(self.adherent.adresse)
            self.text_CodePostal.SetValue(self.adherent.code_postal)
            self.text_Ville.SetValue(self.adherent.ville)
            self.text_TelephoneFixe.SetValue(self.adherent.telephone_fixe)
            self.text_TelephonePortable.SetValue(
                self.adherent.telephone_portable)
            self.text_Email.SetValue(self.adherent.email)
            self.text_Login.SetValue(self.adherent.login)
            #self.text_Login.SetValidator(LoginValidator(self.adherent.GetLogins()))

            for i in range(len(self.combo_box_CotisationTypes.GetItems())):
                if self.adherent.cotisation_type == self.combo_box_CotisationTypes.GetClientData(
                        i):
                    self.combo_box_CotisationTypes.Select(i)
                    break

        #TODO: On ajoute le validator de logins
        #self.text_Login.SetValidator(LoginValidator(self.adherent.GetLogins()))

    def GetAdherent(self):
        return self.adherent

    def Enregistre(self):
        if self.Validate():
            self.adherent.nom = self.text_Nom.GetValue()
            self.adherent.prenom = self.text_Prenom.GetValue()
            self.adherent.adresse = self.text_Adresse.GetValue()
            self.adherent.code_postal = self.text_CodePostal.GetValue()
            self.adherent.ville = self.text_Ville.GetValue()
            self.adherent.telephone_fixe = self.text_TelephoneFixe.GetValue()
            self.adherent.telephone_portable = self.text_TelephonePortable.GetValue(
            )
            self.adherent.email = self.text_Email.GetValue()
            self.adherent.cotisation_type = self.combo_box_CotisationTypes.GetClientData(
                self.combo_box_CotisationTypes.GetSelection())
            self.adherent.login = self.text_Login.GetValue()

            #TODO: à revoir
            if self.text_Motdepasse.GetValue() != '':
                self.adherent.mot_de_passe = self.text_Motdepasse.GetValue()

            self.adherent.save()