diff --git a/IFPass.py b/IFPass.py index 8fd442e..4d79dd7 100644 --- a/IFPass.py +++ b/IFPass.py @@ -85,14 +85,20 @@ def initialisation(): return IFPassDBdir, printername, AcrobatReader, clientsfile, clientsbkpfile, imgdir, templatesdir, pdftemplate, pngtemplate, fonttemplate -def get_fullname(): - while "Empty firstname": - firstname = input("Prénom : ").strip() - if len(firstname) == 0: - os.system('cls') - print(colored("\nLe Prénom ne peut pas être vide.", 'red')) - else: - break +def get_fullname(**kwargs): # **kwargs => Optionnal arguments + if 'firstname' in kwargs: + firstname = kwargs['firstname'] + newfirstname = input("Prénom (" + firstname + "): ").strip() + if len(newfirstname) != 0: + firstname = newfirstname + else: + while "Empty firstname": + firstname = input("Prénom : ").strip() + if len(firstname) == 0: + os.system('cls') + print(colored("\nLe Prénom ne peut pas être vide.", 'red')) + else: + break firstname = firstname[0].upper() + firstname[1:].lower() if '-' in firstname: pos = firstname.find("-") @@ -102,13 +108,20 @@ def get_fullname(): pos = firstname.find(" ") firstname = firstname[:pos + 1] + firstname[pos + 1].upper() + \ firstname[pos + 2:] # Check if compound name - while "Empty surname": - surname = input("Nom : ").upper().strip() - if len(surname) == 0: - os.system('cls') - print(colored("\nLe Nom ne peut pas être vide.", 'red')) - else: - break + + if 'surname' in kwargs: + surname = kwargs['surname'] + newsurname = input("Prénom (" + surname + "): ").strip() + if len(newsurname) != 0: + surname = newsurname + else: + while "Empty surname": + surname = input("Nom : ").upper().strip() + if len(surname) == 0: + os.system('cls') + print(colored("\nLe Nom ne peut pas être vide.", 'red')) + else: + break docteur = yes_or_no('Est-ce un Docteur ?') if docteur: titre = 'Dr.' @@ -213,7 +226,7 @@ def bkpdb(): copyfile(clientsfile, clientsbkpfile) -def fillcard(clientID, titrename, firstname, dateexp, barcode): +def fillcard(clientID, titrename, firstname, dateexp, barcode, picture): print("Création de la carte avec les informations...", end='') try: im = Image.open(pngtemplate) @@ -307,11 +320,10 @@ def newmember(): if correct: os.system('cls') if version != 'devnocam': - global picture picture = getpic() clientID = getclientID() barcode = barcode_gen(clientID) - fillcard(clientID, titrename, firstname, dateexp, barcode) + fillcard(clientID, titrename, firstname, dateexp, barcode, picture) cartefilename = mergepdf(clientID) if version not in ('dev', 'devnocam'): bkpdb() @@ -382,10 +394,14 @@ def membersearch(): def memberdo(choix, member): titre = member[0] firstname = member[1] + surname = member[2] + clientID = member[3] + dateinsc = member[4] + dateexp = member[5] os.system('cls') if choix == '1': # Edit member while "the informations are incorrect": # Loop Filling informations - titre, firstname, surname, titrename = get_fullname() + titre, firstname, surname, titrename = get_fullname(titre=titre, firstname=firstname, surname=surname) os.system('cls') print("Titre : ", colored(titre, 'green')) @@ -395,20 +411,23 @@ def memberdo(choix, member): correct = yes_or_no("Ces informations sont elles correctes ?") if correct: - newpic = yes_or_no("Voulez-vous prendre une nouvelle photo ?") - if newpic: + wantnewpic = yes_or_no("Voulez-vous prendre une nouvelle photo ?") + if wantnewpic: os.system('cls') if version != 'devnocam': - global picture picture = getpic() clientID = member[3] barcode = barcode_gen(clientID) - fillcard(barcode) + fillcard(clientID, titrename, firstname, dateexp, barcode, picture) cartefilename = mergepdf() if version not in ('dev', 'devnocam'): bkpdb() printcard(cartefilename) + writeindb(titre, firstname, surname, clientID, dateinsc, dateexp) break + else: + # We crop pic from the previous card + pass elif choix == '2': # Renew subscription print(2) @@ -422,7 +441,6 @@ def memberdo(choix, member): def main(): - # global titre, firstname, surname, titrename, dateinsc, dateexp, clientID, clientsfile, IFPassDBdir, clientsfile, imgdir, clientsbkpfile, templatesdir, pngtemplate, fonttemplate, picture, pdftemplate, printername, AcrobatReader global IFPassDBdir, clientsfile, imgdir, clientsbkpfile, templatesdir, pngtemplate, fonttemplate, pdftemplate, printername, AcrobatReader while "The program is running": init() # Initialisation of colorama