diff --git a/IFPass.py b/IFPass.py index 90c65ac..73690a4 100644 --- a/IFPass.py +++ b/IFPass.py @@ -428,43 +428,7 @@ def memberdo(choix, member): os.system('cls') if choix == '1': # Edit member - while "the informations are incorrect": # Loop Filling informations - titre, firstname, surname, titrename = get_fullname(titre=titre, firstname=firstname, surname=surname) - - print("Titre : ", colored(titre, 'green')) - print("Prénom : ", colored(firstname, 'green')) - print("Nom : ", colored(surname, 'green')) - - correct = yes_or_no("Ces informations sont elles correctes ?") - os.system('cls') - - if correct: - wantnewpic = yes_or_no("Voulez-vous prendre une nouvelle photo ?") - os.system('cls') - if wantnewpic: - os.system('cls') - if version != 'devnocam': - picture = getpic() - else: - # We crop pic from the previous card - cartefilename = os.path.join(imgdir, clientID + '.pdf') - pdf = fitz.open(cartefilename) - page = pdf.loadPage(0) - mat = fitz.Matrix(4.165, 4.165) # To obtain good resolution - pix = page.getPixmap(matrix=mat) - - pageimg = Image.frombytes("RGBA", [pix.width, pix.height], pix.samples) - picture = pageimg.crop((47, 49, 343, 378)) - - barcode = barcode_gen(clientID) - fillcard(clientID, titrename, firstname, dateexp, barcode, picture) - cartefilename = mergepdf(clientID) - if version not in ('dev', 'devnocam'): - bkpdb() - printcard(cartefilename) - writeindb(titre, firstname, surname, clientID, dateinsc, dateexp, new=False) - os.system('cls') - break + titre, firstname, surname, dateexp = memberedit(titre, firstname, surname, clientID, dateinsc, dateexp) elif choix == '2': # Renew subscription dateexp = datetime.strptime(dateexp, '%d/%m/%Y').date() @@ -474,19 +438,87 @@ def memberdo(choix, member): elif diff < 0: dateexp = date.today() + timedelta(days=365) dateexp = dateexp.strftime('%d/%m/%Y') + + if titre == 'Dr.': + titrename = titre + ' ' + surname + else: + titrename = surname + + wantnewpic = yes_or_no("Voulez-vous prendre une nouvelle photo ?") + os.system('cls') + if wantnewpic: + os.system('cls') + if version != 'devnocam': + picture = getpic() + else: + # We crop pic from the previous card + cartefilename = os.path.join(imgdir, clientID + '.pdf') + pdf = fitz.open(cartefilename) + page = pdf.loadPage(0) + mat = fitz.Matrix(4.165, 4.165) # To obtain good resolution + pix = page.getPixmap(matrix=mat) + pageimg = Image.frombytes("RGBA", [pix.width, pix.height], pix.samples) + picture = pageimg.crop((47, 49, 343, 378)) + + barcode = barcode_gen(clientID) + fillcard(clientID, titrename, firstname, dateexp, barcode, picture) + cartefilename = mergepdf(clientID) + if version not in ('dev', 'devnocam'): bkpdb() printcard(cartefilename) writeindb(titre, firstname, surname, clientID, dateinsc, dateexp, new=False) + os.system('cls') print(colored("La date d'expiration a bien été mise à jour !\n", 'blue', attrs=['bold'])) elif choix == '3': # Print card - print('Print card') + printcard(cartefilename) else: print(colored('Choix incorrect !\n', 'red', attrs=['bold'])) return titre, firstname, surname, dateexp +def memberedit(titre, firstname, surname, clientID, dateinsc, dateexp): + while "the informations are incorrect": # Loop Filling informations + titre, firstname, surname, titrename = get_fullname(titre=titre, firstname=firstname, surname=surname) + + print("Titre : ", colored(titre, 'green')) + print("Prénom : ", colored(firstname, 'green')) + print("Nom : ", colored(surname, 'green')) + + correct = yes_or_no("Ces informations sont elles correctes ?") + os.system('cls') + + if correct: + wantnewpic = yes_or_no("Voulez-vous prendre une nouvelle photo ?") + os.system('cls') + if wantnewpic: + os.system('cls') + if version != 'devnocam': + picture = getpic() + else: + # We crop pic from the previous card + cartefilename = os.path.join(imgdir, clientID + '.pdf') + pdf = fitz.open(cartefilename) + page = pdf.loadPage(0) + mat = fitz.Matrix(4.165, 4.165) # To obtain good resolution + pix = page.getPixmap(matrix=mat) + + pageimg = Image.frombytes("RGBA", [pix.width, pix.height], pix.samples) + picture = pageimg.crop((47, 49, 343, 378)) + + barcode = barcode_gen(clientID) + fillcard(clientID, titrename, firstname, dateexp, barcode, picture) + cartefilename = mergepdf(clientID) + if version not in ('dev', 'devnocam'): + bkpdb() + printcard(cartefilename) + writeindb(titre, firstname, surname, clientID, dateinsc, dateexp, new=False) + os.system('cls') + break + return titre, firstname, surname, dateexp + + def main(): global IFPassDBdir, clientsfile, imgdir, clientsbkpfile, templatesdir, pngtemplate, fonttemplate, pdftemplate, printername, AcrobatReader while "The program is running":