Exemplo n.º 1
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)
Exemplo n.º 2
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.º 3
0
    def markAsPaid(self):

        downloadFile(FILENAME)

        markAsPaidPageInstance = self.controller.returnInstance(MarkAsPaidPage)
        MarkAsPaidPage.spawnGridnet(markAsPaidPageInstance, self.lUnpaid)

        self.controller.show_frame(MarkAsPaidPage)
Exemplo n.º 4
0
    def checkApartmentNumber(self):

        downloadFile(FILENAME)

        info = self.entry1.get()

        parsedInfo = parseInfo(info)

        if parsedInfo:

            InfoPageInstance = self.controller.returnInstance(InfoPage)
            InfoPage.generateFirstPage(InfoPageInstance, self.entry1.get(), parsedInfo['paid'], parsedInfo['unpaid'], parsedInfo['email'])

            self.controller.show_frame(InfoPage)

        else:
            tk.messagebox.showinfo('Fel', 'Felaktigt lägenhetsnummer!')
Exemplo n.º 5
0
def updateFile_Email(apartmentNumber, lEmail):

    ret = downloadFile(FILENAME)
    while ret == False:
        ret = downloadFile(FILENAME)

    with open(FILENAME) as data_file:
        data = json.load(data_file)

    if apartmentNumber.upper() in data.keys():
        data[apartmentNumber.upper()]['email'] = lEmail

        with open(FILENAME, 'w') as outfile:
            json.dump(data, outfile)

        ret = uploadFile(FILENAME)
        while ret == False:
            ret = uploadFile(FILENAME)
Exemplo n.º 6
0
def updateFile_PaidUnpaid(apartmentNumber, dPaid_Date, lUnpaid):

    ret = downloadFile(FILENAME)
    while ret == False:
        ret = downloadFile(FILENAME)

    with open(FILENAME) as data_file:
        data = json.load(data_file)

    if apartmentNumber.upper() in data.keys():
        data[apartmentNumber.upper()]['paid'] = dPaid_Date
        data[apartmentNumber.upper()]['unpaid'] = lUnpaid

        with open(FILENAME, 'w') as outfile:
            json.dump(data, outfile, indent=4)

        ret = uploadFile(FILENAME)
        while ret == False:
            ret = uploadFile(FILENAME)
Exemplo n.º 7
0
    def updateEmail(self, idx):

        downloadFile(FILENAME)

        updatedEmail = simpledialog.askstring('Email', 'Email')

        if updatedEmail:

            try:
                self.lEmail[idx] = updatedEmail
            except:
                self.lEmail.append(updatedEmail)

            if idx == 0:
                self.email1.config(text=self.lEmail[idx])

            if idx == 1:
                self.email2.config(text=self.lEmail[idx])

            updateFile_Email(self.apartmentNumber, self.lEmail)
Exemplo n.º 8
0
    def appendToClipboard(self):

        downloadFile(FILENAME)

        sCSVEmail = ''

        if self.checkButtonValA.get() and self.checkButtonValB.get():
            sCSVEmail = returnCSVEmail()

        elif self.checkButtonValA.get():
            sCSVEmail = returnCSVEmail(specificHouse='A')

        elif self.checkButtonValB.get():
            sCSVEmail = returnCSVEmail(specificHouse='B')

        r = tk.Tk()
        r.withdraw()
        r.clipboard_clear()
        r.clipboard_append(sCSVEmail)

        self.toplevel.destroy()
Exemplo n.º 9
0
def backup():
    downloadFile(FILENAME)
    uploadFile(FILENAME, 'parkingBackup', time.strftime('%Y%m%d_%X'))