def OnVerifiee(self, event):
        if self.commande:
            commande_verifiee = True

            for lc in self.liste_lignes_commande.GetObjects():
                if not lc.is_verifiee:
                    commande_verifiee = False

            if commande_verifiee:
                dlg = wx.MessageDialog(parent=None, message=u"La livraison a bien été vérifiée ?",
                                      caption=u"Vérification de la livraison", style=wx.YES_NO|wx.ICON_QUESTION)

                if dlg.ShowModal() == wx.ID_YES:
                    for lc in self.liste_lignes_commande.GetObjects():
                        lc.save()
                        
                    self.commande.statut = 3
                    self.commande.save()

                    self.liste_commandes.RefreshObject(self.commande)
                    self.OnSelectionCommande(None)

                    with DATABASE.transaction():
                        DATABASE.commit()

                dlg.Destroy()
            else:
                wx.MessageBox(u"La livraison n'a pas encoré été entièrement vérifiée", "Erreur", style=wx.ICON_ERROR)
 def OnClose(self, event):
     dlg = wx.MessageDialog(parent=None, message=u"Voulez vous sauvegarder cet achat ?",
                            caption=u"Sauvegarde de l'achat", style=wx.YES_NO|wx.ICON_QUESTION)
 
     if dlg.ShowModal() == wx.ID_YES:
         self.OnSauvegarder(event)
     else:
         DATABASE.rollback()
         self.EndModal(wx.ID_CANCEL)
Exemple #3
0
    def OnEnregistre(self, event):
        if self.Validate():
            self.panel_fournisseur.Enregistre()
            DATABASE.commit()

            event.Skip()
        else:
            control = wx.Window.FindFocus()
            self.notebook.ChangeSelection(0)
            control.SetFocus()
 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):
        dlg = wx.MessageDialog(parent=None,
                               message=u"Voulez vous sauvegarder cet achat ?",
                               caption=u"Sauvegarde de l'achat",
                               style=wx.YES_NO | wx.ICON_QUESTION)

        if dlg.ShowModal() == wx.ID_YES:
            self.OnSauvegarder(event)
        else:
            DATABASE.rollback()
            self.EndModal(wx.ID_CANCEL)
    def OnSauvegarder(self, event):
        try:
            date_commande = self.datepicker_date_commande.GetValue()
            print datetime(date_commande.GetYear(), date_commande.GetMonth()+1, date_commande.GetDay())

            self.commande.date_commande = datetime(date_commande.GetYear(), date_commande.GetMonth()+1, date_commande.GetDay())
            
            self.commande.save()
            DATABASE.commit()
            wx.MessageBox(u"La commande a été enregistrée", "Notification")
        except BaseException as ex:
            wx.MessageBox(u"Problème lors de l'enregistrement : %s" % ex, "Erreur")
    def OnDestroy(self, event):
        if self.commande.fournisseur != None:
            dlg = wx.MessageDialog(parent=None, message=u"Voulez vous sauvegarder la commande ?",
                                   caption=u"Sauvegarde de la commande", style=wx.YES_NO|wx.ICON_QUESTION)

            if dlg.ShowModal() == wx.ID_YES:
                self.OnSauvegarder(None)
            else:
                DATABASE.rollback()

            dlg.Destroy()

        event.Skip()
    def OnCommandee(self, event):
        if self.commande:
            dlg = wx.MessageDialog(parent=None, message=u"La commande a bien été commandée ?",
                                   caption=u"Commande de la commande", style=wx.YES_NO|wx.ICON_QUESTION)

            if dlg.ShowModal() == wx.ID_YES:
                self.commande.statut = 1
                self.commande.save()
                self.liste_commandes.RefreshObject(self.commande)
                self.OnSelectionCommande(None)
                DATABASE.commit()

            dlg.Destroy()
    def OnEmail(self, event):
        if self.commande:
            if self.commande.statut < 2:
                envoi_email = EnvoiEmailCommande(self, self.commande)
                envoi_email.ShowModal()
                envoi_email.Destroy()

                if envoi_email.ShowModal() == wx.ID_OK:
                    self.commande.statut(1)
                    self.commande.save()
                    self.liste_commandes.RefreshObject(self.commande)
                    self.OnSelectionCommande(None)

                    DATABASE.commit()
    def OnLivree(self, event):
        #TODO : ajouter la possibilité de choisir la date de livraison
        #Ajouter également une vérification sur les prix
        if self.commande:
            dlg = wx.MessageDialog(parent=None, message=u"La commande a bien été livrée ?",
                                   caption=u"Livraison de la commande", style=wx.YES_NO|wx.ICON_QUESTION)

            if dlg.ShowModal() == wx.ID_YES:
                self.commande.statut = 2
                self.commande.save()
                self.liste_commandes.RefreshObject(self.commande)
                self.OnSelectionCommande(None)
                DATABASE.commit()

            dlg.Destroy()
Exemple #11
0
    def OnDestroy(self, event):
        if not self.inventaire.is_valide:
            dlg = wx.MessageDialog(parent=None, message=u"Voulez vous sauvegarder l'inventaire ?",
                                   caption=u"Sauvegarde de l'inventaire", style=wx.YES_NO|wx.ICON_QUESTION)
    
            if dlg.ShowModal() == wx.ID_YES:
                self.inventaire.date = date.today()
                self.inventaire.save()
                DATABASE.commit()
            else:
                DATABASE.rollback()
    
            dlg.Destroy()

        event.Skip()
 def OnSauvegarder(self, event):
     if self.Validate():
         cotisation = self.achat.adherent.paye_cotisation_du_mois()
         cotisation.save()            
             
         self.achat.date = datetime.today()
         if self.text_cout_supplementaire.GetValue():
             self.achat.cout_supplementaire = float(self.text_cout_supplementaire.GetValue())
         else:
             self.achat.cout_supplementaire = 0
         self.achat.cout_supplementaire_commentaire = self.text_cout_supplementaire_commentaire.GetValue()
         self.achat.save()
         DATABASE.commit()
         wx.MessageBox(u"L'achat a été enregistré", "Notification")
         self.EndModal(wx.ID_SAVE)
    def OnEnregistre(self, event):
        if self.Validate():
            self.produit.nom = self.text_Nom.GetValue()
            self.produit.fournisseur = self.combo_box_Fournisseur.GetClientData(self.combo_box_Fournisseur.GetSelection())
            self.produit.ref_fournisseur = self.text_RefFournisseur.GetValue()
            self.produit.origine = self.text_Origine.GetValue()
            self.produit.vrac = self.radio_box_TypeVente.GetSelection()
            self.produit.liquide = self.radio_box_UniteMesure.GetSelection()
            if self.produit.vrac:
                self.produit.poids_volume = int(float(self.text_PoidsVolume.GetValue())*1000)
            else:
                self.produit.poids_volume = self.text_PoidsVolume.GetValue()
            self.produit.conditionnement = self.text_Conditionnement.GetValue()
            self.produit.tva = self.combo_box_TVA.GetClientData(self.combo_box_TVA.GetSelection())
            self.produit.prix_achat_HT = self.text_PrixAchat.GetValue()
            self.produit.retrait = self.checkbox_RetraitProduit.IsChecked()
            self.produit.motif_retrait = self.text_MotifRetrait.GetValue()
            if (self.produit.retrait == False):
                self.produit.a_etiquetter = True
            else:
                self.produit.a_etiquetter = False

            with DATABASE.transaction():
                self.produit.save()

            event.Skip()
    def __set_valeurs(self):
        try:
            #requete en brut pour pouvoir séelctionner les mois et les années des achats
            requete  = "SELECT strftime('%Y', date) as annee, "
            requete += "strftime('%m', date) as mois "
            requete += "FROM achats "
            requete += "WHERE adherent_id = %i " % self.adherent.id
            requete += "GROUP  BY annee, mois "
            requete += "ORDER  BY annee, mois DESC"
            
            # Liste des mois en français
            mois = ['Janvier',u'Février','Mars','Avril','Mai','Juin','Juillet',u'Août','Septembre','Octobre','Novembre',u'Décembre']
            
            mois_courant = (str(datetime.today().year), str(datetime.today().month))
    
            #on ajoute en premier le mois courant
            self.combobox_choix_mois.Append("%s %s" % (mois[int(mois_courant[1])-1], mois_courant[0]), mois_courant)
            self.combobox_choix_mois.SetSelection(0)
            
            #on ajoute tous les mois où il y a eu des achats
            for date in DATABASE.execute_sql(requete):
                if date != mois_courant:
                    self.combobox_choix_mois.Append("%s %s" % (mois[int(date[1])-1], date[0]), date)
            
            self.OnChoixMois(None)

            achats = Achat.select().where(Achat.adherent == self.adherent).order_by(Achat.date.desc())            
            self.liste_achats.SetObjects([a for a in achats])
            
            cotisations = Cotisation.select().where(Cotisation.adherent == self.adherent).order_by(Cotisation.date.desc())            
            self.liste_cotisations.SetObjects([c for c in cotisations])

        except BaseException as ex:
            print ex
    def OnValider(self, event):
        date_debut = self.datepicker_date_debut.GetValue()
        date_fin = self.datepicker_date_fin.GetValue()

        date_debut_dt = datetime.date(date_debut.GetYear(), date_debut.GetMonth()+1, date_debut.GetDay())
        date_fin_dt = datetime.date(date_fin.GetYear(), date_fin.GetMonth()+1, date_fin.GetDay())

        try:
            exercice = Exercice.select().where(((Exercice.date_debut <= date_fin_dt) & (Exercice.date_fin >= date_debut_dt))).get()
            if exercice == self.exercice:
                raise DoesNotExist

            wx.MessageBox(u"Les dates indiquées chevauchent l'exercice '%s'" % exercice.nom, "Erreur")
        except DoesNotExist:
            if self.Validate():
                self.exercice.nom = self.text_ctrl_nom.GetValue()
                self.exercice.date_debut = date_debut_dt
                self.exercice.date_fin = date_fin_dt

                with DATABASE.transaction():
                    self.exercice.save()

                EXERCICE_EN_COURS = Exercice.en_cours()

                event.Skip()
    def OnEnregistre(self, event):
        if self.Validate():
            self.produit.nom = self.text_Nom.GetValue()
            self.produit.fournisseur = self.combo_box_Fournisseur.GetClientData(
                self.combo_box_Fournisseur.GetSelection())
            self.produit.ref_fournisseur = self.text_RefFournisseur.GetValue()
            self.produit.origine = self.text_Origine.GetValue()
            self.produit.vrac = self.radio_box_TypeVente.GetSelection()
            self.produit.liquide = self.radio_box_UniteMesure.GetSelection()
            if self.produit.vrac:
                self.produit.poids_volume = int(
                    float(self.text_PoidsVolume.GetValue()) * 1000)
            else:
                self.produit.poids_volume = self.text_PoidsVolume.GetValue()
            self.produit.conditionnement = self.text_Conditionnement.GetValue()
            self.produit.tva = self.combo_box_TVA.GetClientData(
                self.combo_box_TVA.GetSelection())
            self.produit.prix_achat_HT = self.text_PrixAchat.GetValue()
            self.produit.retrait = self.checkbox_RetraitProduit.IsChecked()
            self.produit.motif_retrait = self.text_MotifRetrait.GetValue()
            if (self.produit.retrait == False):
                self.produit.a_etiquetter = True
            else:
                self.produit.a_etiquetter = False

            with DATABASE.transaction():
                self.produit.save()

            event.Skip()
Exemple #17
0
    def OnDestroy(self, event):
        if self.commande.fournisseur != None:
            dlg = wx.MessageDialog(
                parent=None,
                message=u"Voulez vous sauvegarder la commande ?",
                caption=u"Sauvegarde de la commande",
                style=wx.YES_NO | wx.ICON_QUESTION)

            if dlg.ShowModal() == wx.ID_YES:
                self.OnSauvegarder(None)
            else:
                DATABASE.rollback()

            dlg.Destroy()

        event.Skip()
Exemple #18
0
    def OnEnregistre(self, event):
        if self.Validate():
            self.tva.taux = self.text_TauxTVA.GetValue()

            with DATABASE.transaction():
                self.tva.save()

            event.Skip()
    def OnSupprimer(self, event):
        if self.commande:
            if self.commande.statut == 0:
                dlg = wx.MessageDialog(parent=None, message=u"Voulez vous vraiment supprimer la commande ?",
                                       caption=u"Suppression de la commande", style=wx.OK|wx.CANCEL|wx.ICON_QUESTION)

                if dlg.ShowModal() == wx.ID_OK:
                    self.liste_commandes.RemoveObject(self.commande)
                    self.liste_lignes_commande.SetObjects(None)

                    self.commande.delete_instance(recursive=True)

                    self.commande = None

                    self.OnSelectionCommande(None)

                    DATABASE.commit()
    def OnValider(self, event):
        if self.Validate():
            self.adhesion_type.nom = self.text_ctrl_Nom.GetValue()
            self.adhesion_type.prix = self.text_ctrl_Prix.GetValue()

            with DATABASE.transaction():
                self.adhesion_type.save()
            event.Skip()
Exemple #21
0
    def OnSauvegarder(self, event):
        try:
            date_commande = self.datepicker_date_commande.GetValue()
            print datetime(date_commande.GetYear(),
                           date_commande.GetMonth() + 1,
                           date_commande.GetDay())

            self.commande.date_commande = datetime(
                date_commande.GetYear(),
                date_commande.GetMonth() + 1, date_commande.GetDay())

            self.commande.save()
            DATABASE.commit()
            wx.MessageBox(u"La commande a été enregistrée", "Notification")
        except BaseException as ex:
            wx.MessageBox(u"Problème lors de l'enregistrement : %s" % ex,
                          "Erreur")
Exemple #22
0
    def OnSauvegarder(self, event):
        if self.Validate():
            cotisation = self.achat.adherent.paye_cotisation_du_mois()
            cotisation.save()

            self.achat.date = datetime.today()
            if self.text_cout_supplementaire.GetValue():
                self.achat.cout_supplementaire = float(
                    self.text_cout_supplementaire.GetValue())
            else:
                self.achat.cout_supplementaire = 0
            self.achat.cout_supplementaire_commentaire = self.text_cout_supplementaire_commentaire.GetValue(
            )
            self.achat.save()
            DATABASE.commit()
            wx.MessageBox(u"L'achat a été enregistré", "Notification")
            self.EndModal(wx.ID_SAVE)
    def OnEnregistre(self, event):
        if self.Validate():
            self.tva.taux = self.text_TauxTVA.GetValue()

            with DATABASE.transaction():
                self.tva.save()

            event.Skip()
    def OnSupprimeAdhesion(self, event):
        adhesion = self.liste_adhesions.GetSelectedObject()

        msgbox = wx.MessageBox(u"Supprimer l'adhésion du %s ?" % adhesion.date.strftime("%d/%m/%y"), "Suppression", wx.YES_NO | wx.ICON_QUESTION)

        if msgbox == wx.YES:
            with DATABASE.transaction():
                adhesion.delete_instance()

            self.liste_adhesions.RemoveObject(adhesion)
    def OnSuppressionInventaire(self, event):
        inventaire = self.liste_inventaires.GetSelectedObject()

        msgbox = wx.MessageBox(u"Supprimer l'inventaire du %s ?" % inventaire.date.strftime("%d/%m/%y"), "Suppression", wx.YES_NO | wx.ICON_QUESTION)

        if msgbox == wx.YES:
            with DATABASE.transaction():
                inventaire.delete_instance(recursive=True)

            self.liste_inventaires.RemoveObject(inventaire)
Exemple #26
0
    def OnSupprimeTypeCotisation(self, event):
        cotisation_type = self.liste_cotisation_types.GetSelectedObject()

        if cotisation_type.adherents.count() == 0:
            msgbox = wx.MessageBox(u"Supprimer le type de cotisation '%s'?" % cotisation_type.nom, "Suppression", wx.YES_NO | wx.ICON_QUESTION)

            if msgbox == wx.YES:
                with DATABASE.transaction():
                    cotisation_type.delete_instance()

                self.liste_cotisation_types.RemoveObject(cotisation_type)
    def OnEnregistre(self, event):
        if self.Validate():
            self.categorie.nom = self.text_NomCategorie.GetValue()

            with DATABASE.transaction():
                if not self.categorie.get_id():
                    self.categorie.set_id(int(self.combo_box_IDCategorie.GetValue()))
                    self.categorie.insert(**dict(self.categorie._data)).execute()
                else:
                    self.categorie.save()

            event.Skip()
Exemple #28
0
    def OnEnregistrer(self, event):
        if self.Validate():
            msgbox = wx.MessageBox(u"Sauvegarder l'inventaire ?", u"Confirmation", wx.YES_NO | wx.ICON_QUESTION)

            if msgbox == wx.YES:
                self.inventaire.date = date.today()
                self.inventaire.commentaire = self.text_commentaire.GetValue()

                with DATABASE.transaction():
                    self.inventaire.save()

                event.Skip()
    def OnSupprimeAdhesion(self, event):
        adhesion = self.liste_adhesions.GetSelectedObject()

        msgbox = wx.MessageBox(
            u"Supprimer l'adhésion du %s ?" %
            adhesion.date.strftime("%d/%m/%y"), "Suppression",
            wx.YES_NO | wx.ICON_QUESTION)

        if msgbox == wx.YES:
            with DATABASE.transaction():
                adhesion.delete_instance()

            self.liste_adhesions.RemoveObject(adhesion)
    def OnSuppressionInventaire(self, event):
        inventaire = self.liste_inventaires.GetSelectedObject()

        msgbox = wx.MessageBox(
            u"Supprimer l'inventaire du %s ?" %
            inventaire.date.strftime("%d/%m/%y"), "Suppression",
            wx.YES_NO | wx.ICON_QUESTION)

        if msgbox == wx.YES:
            with DATABASE.transaction():
                inventaire.delete_instance(recursive=True)

            self.liste_inventaires.RemoveObject(inventaire)
    def OnEnregistre(self, event):
        if self.Validate():
            self.categorie.nom = self.text_NomCategorie.GetValue()

            with DATABASE.transaction():
                if not self.categorie.get_id():
                    self.categorie.set_id(
                        int(self.combo_box_IDCategorie.GetValue()))
                    self.categorie.insert(
                        **dict(self.categorie._data)).execute()
                else:
                    self.categorie.save()

            event.Skip()
Exemple #32
0
    def OnValider(self, event):
        if self.Validate() and self.inventaire.pret_a_valider():
            msgbox = wx.MessageBox(u"Valider l'inventaire ? Il ne sera plus modifiable.", u"Confirmation", wx.YES_NO | wx.ICON_QUESTION)

            if msgbox == wx.YES:
                self.inventaire.is_valide = True
                self.inventaire.date = date.today()

                with DATABASE.transaction():
                    self.inventaire.validation()
                    self.inventaire.save()

                self.__set_properties()

                event.Skip()
    def Enregistre(self):
        if self.Validate():
            self.fournisseur.nom = self.text_Nom.GetValue()
            self.fournisseur.adresse = self.text_Adresse.GetValue()
            self.fournisseur.code_postal = self.text_CodePostal.GetValue()
            self.fournisseur.ville = self.text_Ville.GetValue()
            self.fournisseur.telephone_fixe = self.text_TelephoneFixe.GetValue()
            self.fournisseur.telephone_portable = self.text_TelephonePortable.GetValue()
            self.fournisseur.email = self.text_Email.GetValue()
            self.fournisseur.nom_contact = self.text_NomContact.GetValue()
            self.fournisseur.remarques = self.text_Remarques.GetValue()
            self.fournisseur.couleur = self.text_Couleur.GetValue()

            with DATABASE.transaction():
                self.fournisseur.save()
    def OnValider(self, event):
        if self.Validate():
            msgbox = wx.MessageBox(u"Sauvegarder l'adhésion ?", u"Confirmation", wx.YES_NO | wx.ICON_QUESTION)

            if msgbox == wx.YES:
                date_adhesion = self.datepicker_date_adhesion.GetValue()

                self.adhesion.date = datetime(date_adhesion.GetYear(), date_adhesion.GetMonth()+1, date_adhesion.GetDay())
                self.adhesion.adhesion_type = self.combo_box_adhesion_type.GetClientData(self.combo_box_adhesion_type.GetSelection())
                self.adhesion.montant = self.adhesion.adhesion_type.prix
                self.adhesion.cheque = self.text_ctrl_cheque.GetValue()
                
                with DATABASE.transaction():
                    self.adhesion.save()

                event.Skip()
Exemple #35
0
    def OnSauvegarde(self, event):

        with DATABASE.transaction():
            self.SMTP_serveur.value = self.tc_serveur.GetValue()
            self.SMTP_serveurport = self.tc_port.GetValue()
            self.SMTP_serveursecurite = self.cb_securite.GetSelection()
            self.SMTP_login = self.tc_login.GetValue()
            self.SMTP_motdepasse = self.tc_mdp.GetValue()
            
            self.SMTP_serveur.save()
            self.SMTP_serveurport.save()
            self.SMTP_serveursecurite.save()
            self.SMTP_login.save()
            self.SMTP_motdepasse.save()

        self.bouton_sauvegarder.Disable()
Exemple #36
0
    def Enregistre(self):
        if self.Validate():
            self.fournisseur.nom = self.text_Nom.GetValue()
            self.fournisseur.adresse = self.text_Adresse.GetValue()
            self.fournisseur.code_postal = self.text_CodePostal.GetValue()
            self.fournisseur.ville = self.text_Ville.GetValue()
            self.fournisseur.telephone_fixe = self.text_TelephoneFixe.GetValue(
            )
            self.fournisseur.telephone_portable = self.text_TelephonePortable.GetValue(
            )
            self.fournisseur.email = self.text_Email.GetValue()
            self.fournisseur.nom_contact = self.text_NomContact.GetValue()
            self.fournisseur.remarques = self.text_Remarques.GetValue()
            self.fournisseur.couleur = self.text_Couleur.GetValue()

            with DATABASE.transaction():
                self.fournisseur.save()
Exemple #37
0
    def OnModifInfos(self, event):
        self.ASSO_nom.valeur = self.text_ctrl_nom.GetValue()
        self.ASSO_adresse.valeur = self.text_ctrl_adresse.GetValue()
        self.ASSO_codepostal.valeur = self.text_ctrl_code_postal.GetValue()
        self.ASSO_ville.valeur = self.text_ctrl_ville.GetValue()
        self.ASSO_telephone.valeur = self.text_ctrl_telephone.GetValue()
        self.ASSO_email.valeur = self.text_ctrl_email.GetValue()
        self.ASSO_typeadhesion.valeur = str(self.radio_box_type_adhesion.GetSelection())

        with DATABASE.transaction():
            self.ASSO_nom.save()
            self.ASSO_adresse.save()
            self.ASSO_codepostal.save()
            self.ASSO_ville.save()
            self.ASSO_telephone.save()
            self.ASSO_email.save()
            self.ASSO_typeadhesion.save()
    def __set_valeurs(self):
        try:
            #requete en brut pour pouvoir séelctionner les mois et les années des achats
            requete = "SELECT strftime('%Y', date) as annee, "
            requete += "strftime('%m', date) as mois "
            requete += "FROM achats "
            requete += "WHERE adherent_id = %i " % self.adherent.id
            requete += "GROUP  BY annee, mois "
            requete += "ORDER  BY annee, mois DESC"

            # Liste des mois en français
            mois = [
                'Janvier', u'Février', 'Mars', 'Avril', 'Mai', 'Juin',
                'Juillet', u'Août', 'Septembre', 'Octobre', 'Novembre',
                u'Décembre'
            ]

            mois_courant = (str(datetime.today().year),
                            str(datetime.today().month))

            #on ajoute en premier le mois courant
            self.combobox_choix_mois.Append(
                "%s %s" % (mois[int(mois_courant[1]) - 1], mois_courant[0]),
                mois_courant)
            self.combobox_choix_mois.SetSelection(0)

            #on ajoute tous les mois où il y a eu des achats
            for date in DATABASE.execute_sql(requete):
                if date != mois_courant:
                    self.combobox_choix_mois.Append(
                        "%s %s" % (mois[int(date[1]) - 1], date[0]), date)

            self.OnChoixMois(None)

            achats = Achat.select().where(
                Achat.adherent == self.adherent).order_by(Achat.date.desc())
            self.liste_achats.SetObjects([a for a in achats])

            cotisations = Cotisation.select().where(
                Cotisation.adherent == self.adherent).order_by(
                    Cotisation.date.desc())
            self.liste_cotisations.SetObjects([c for c in cotisations])

        except BaseException as ex:
            print ex
Exemple #39
0
    def OnEnregistre(self, event):
        if self.Validate():
            self.adherent.nom = self.notebook_p1.text_Nom.GetValue()
            self.adherent.prenom = self.notebook_p1.text_Prenom.GetValue()
            self.adherent.adresse = self.notebook_p1.text_Adresse.GetValue()
            self.adherent.code_postal = self.notebook_p1.text_CodePostal.GetValue()
            self.adherent.ville = self.notebook_p1.text_Ville.GetValue()
            self.adherent.telephone_fixe = self.notebook_p1.text_TelephoneFixe.GetValue()
            self.adherent.telephone_portable = self.notebook_p1.text_TelephonePortable.GetValue()
            self.adherent.email = self.notebook_p1.text_Email.GetValue()
            self.adherent.cotisation_type = self.notebook_p1.combo_box_CotisationTypes.GetClientData(self.notebook_p1.combo_box_CotisationTypes.GetSelection())
            self.adherent.login = self.notebook_p1.text_Login.GetValue()

            if self.notebook_p1.text_Motdepasse.GetValue() != '':
                self.adherent.mot_de_passe = self.notebook_p1.text_Motdepasse.GetValue()

            with DATABASE.transaction():
                self.adherent.save()

            event.Skip()
    def OnValider(self, event):
        if self.Validate():
            msgbox = wx.MessageBox(u"Sauvegarder l'adhésion ?",
                                   u"Confirmation",
                                   wx.YES_NO | wx.ICON_QUESTION)

            if msgbox == wx.YES:
                date_adhesion = self.datepicker_date_adhesion.GetValue()

                self.adhesion.date = datetime(date_adhesion.GetYear(),
                                              date_adhesion.GetMonth() + 1,
                                              date_adhesion.GetDay())
                self.adhesion.adhesion_type = self.combo_box_adhesion_type.GetClientData(
                    self.combo_box_adhesion_type.GetSelection())
                self.adhesion.montant = self.adhesion.adhesion_type.prix
                self.adhesion.cheque = self.text_ctrl_cheque.GetValue()

                with DATABASE.transaction():
                    self.adhesion.save()

                event.Skip()
Exemple #41
0
    def OnImpressionEtiquettes(self, event):
        lst = []
        ligne_etiquettes = []
        tableau_etiquettes = []
        tableau_style = []
        hauteurs_lignes = []

        tableau_style.append(('VALIGN', (0, 0), (-1, -1), 'MIDDLE'))
        tableau_style.append(('TOPPADDING', (0, 0), (-1, -1), 0))
        tableau_style.append(('BOTTOMPADDING', (0, 0), (-1, -1), 0))
        tableau_style.append(('LEFTPADDING', (0, 0), (-1, -1), 2))
        tableau_style.append(('RIGHTPADDING', (0, 0), (-1, -1), 2))
        tableau_style.append(('BOX', (0, 0), (-1, -1), 2, colors.black))
        tableau_style.append(('INNERGRID', (0, 0), (-1, -1), 2, colors.black))

        n_produit = 0

        ref_style = ParagraphStyle('RefProduit', alignment=TA_CENTER, leading=16, fontName='Helvetica-Bold', fontSize=14)
        nom_style = ParagraphStyle('NomProduit', alignment=TA_CENTER, leading=16, fontName='Helvetica-Bold', fontSize=12)
        prix_style = ParagraphStyle('PrixProduit', alignment=TA_CENTER, leading=16, fontName='Helvetica-Bold', fontSize=14)

        liste_produits_etiquettes = []

        for produit in self.liste_produits.GetObjects():
            if produit.a_etiquetter:
                n_produit += 1

                if n_produit%2 == 0:
                    x = 3
                else:
                    x = 0

                y = (n_produit-1)/2

                ligne_etiquettes.append(Paragraph(produit.ref_GASE, ref_style))
                ligne_etiquettes.append(Paragraph(produit.nom, nom_style))

                ligne_etiquettes.append(Paragraph(produit.prix_vente_format, prix_style))

                tableau_style.append(('BACKGROUND',
                                      (x, y), (x+2, y),
                                      produit.fournisseur.couleur))

                if n_produit%2 == 0:
                    tableau_etiquettes.append(ligne_etiquettes)
                    hauteurs_lignes.append(2*cm)
                    ligne_etiquettes = []

                produit.a_etiquetter = False
                liste_produits_etiquettes.append(produit)

        #Si aucun produit n'est selectionnee on ne continue pas
        if n_produit > 0:
            if n_produit%2 != 0:
                ligne_etiquettes.append("")
                ligne_etiquettes.append("")
                ligne_etiquettes.append("")
                tableau_etiquettes.append(ligne_etiquettes)
                hauteurs_lignes.append(2*cm)

            table_etiquettes = Table(tableau_etiquettes,
                                     colWidths=[2*cm, 5.5*cm, 2*cm, 2*cm, 5.5*cm, 2*cm],
                                     rowHeights=hauteurs_lignes)
            table_etiquettes.setStyle(TableStyle(tableau_style))

            lst.append(table_etiquettes)

            #Création des répertoires si ils n'existent pas
            rep = os.path.dirname(os.getcwd() + "/Etiquettes/")

            if not os.path.exists(rep):
                os.makedirs(rep)

            date_jour = datetime.now()

            chemin_fichier = os.path.join(rep, "Etiquettes - " + date_jour.strftime("%d-%m-%Y %H-%M-%S") + ".pdf")

            doc = SimpleDocTemplate(chemin_fichier, title="Etiquettes - " + date_jour.strftime("%d-%m-%Y %H-%M-%S"), pagesize=A4, topMargin=2*cm, bottomMargin=2*cm, leftMargin=1.5*cm, rightMargin=1.5*cm)

            doc.build(lst)

            #session.commit()
            self.liste_produits.RefreshObjects(self.liste_produits.GetObjects())

            '''preview_pdf = PreviewPDF(chemin_fichier)
            preview_pdf.ShowModal()
            preview_pdf.Destroy()'''

            desktop.open(chemin_fichier)

            try:
                for p in liste_produits_etiquettes:
                    p.save()

                DATABASE.commit()
            except:
                DATABASE.rollback()
Exemple #42
0
 def OnClose(self, event):
     DATABASE.rollback()
     event.Skip()
 def OnClose(self, event):
     DATABASE.rollback()
     event.Skip()