Exemplo n.º 1
0
    def generatePDF(self):
        try:
            i = max(self.lPaid + self.lUnpaid)
        except:
            i = 0

        downloadFile(FILENAME)

        numberOfPermissions = simpledialog.askinteger('Antal', 'Hur många tillstånd?')

        while numberOfPermissions != None and numberOfPermissions % 3 != 0:
            tk.messagebox.showinfo('Fel', 'Måste vara jämt delbart med tre!')
            numberOfPermissions = simpledialog.askinteger('Antal', 'Hur många tillstånd?')

        if numberOfPermissions:
            self.updateListOfUnpaid(i, numberOfPermissions)
            fileName = creatPermissionPDF(self.apartmentNumber, i+1, numberOfPermissions)

            updateFile_PaidUnpaid(self.apartmentNumber, self.dPaid_dates, self.lUnpaid)

            if self.checkButtonVal.get():
                sendEmail(fileName, self.lEmail, 'Parkeringstillstånd', 'Här kommer dina parkeringstillstånd!')

            else:
                webbrowser.open_new(r'%s' % fileName)
Exemplo n.º 2
0
    def generateCompilationMonthlyPDF(self):

        year = self.entry_year.get()
        month = self.box_value_month.get()

        if not (year).isdigit():
            tk.messagebox.showinfo('Fel', 'Året måste vara ett nummer!')
            self.generateCompilation()
            return

        year_month = "%d_%s" % (int(year), lMonths.index(month)+1)

        self.toplevel.destroy()

        downloadFile(FILENAME)
        data = returnData()

        d = {}

        for apartmentNumber in data.keys():
            for paidPermission in data[apartmentNumber]['paid']:
                if data[apartmentNumber]['paid'][paidPermission] == year_month:
                    l = d.setdefault(apartmentNumber, [])
                    l.append(int(paidPermission))

        fileName = creatPermissionCompilation(d, year_month, year, month)

        if self.checkButton_SendToMediator.get():
            subject = 'BRF Bällstabacken 4 Parkeringstillstånd sammanställning %s %s' % (month, year)
            sendEmail(fileName, EMAIL['MEDIATOR'], subject, '')
        else:
            webbrowser.open_new(r'%s' % fileName)