Esempio n. 1
0
    def on_generate(self, event):
        today = datetime.date.today()
        bills = []
        item = -1
        while True:
            item = self.reminders.GetNextSelected(item)
            if item == -1:
                break
            id_bill = self.data[item][0]
            self.cursor.execute(
                """INSERT INTO reminders (id_bill, amount_cts, reminder_date) VALUES (%s, %s, %s)""",
                [id_bill, custo.MONTANT_RAPPEL_CTS, today])

            bills.append(Bill.load(self.cursor, id_bill))
        consults = [b for b in bills if b.type == BILL_TYPE_CONSULTATION]
        if consults:
            filename = normalize_filename(datetime.datetime.now().strftime(
                'rappels_consultations_%F_%Hh%Mm%Ss.pdf'))
            pdf_bills.consultations(filename, consults)
            cmd, cap = mailcap.findmatch(mailcap.getcaps(), 'application/pdf',
                                         'view', filename)
            os.system(cmd)
        manuals = [b for b in bills if b.type == BILL_TYPE_MANUAL]
        if manuals:
            filename = normalize_filename(datetime.datetime.now().strftime(
                'rappels_factures_manuelles_%F_%Hh%Mm%Ss.pdf'))
            pdf_bills.manuals(filename, manuals)
            cmd, cap = mailcap.findmatch(mailcap.getcaps(), 'application/pdf',
                                         'view', filename)
            os.system(cmd)
        self.Close()
Esempio n. 2
0
 def on_print_again(self, event):
     bill_ids = [
         id for i, id in enumerate(self.data) if self.payments.IsSelected(i)
     ]
     if bill_ids:
         bills = [Bill.load(self.cursor, id_bill) for id_bill in bill_ids]
         consults = [b for b in bills if b.type == BILL_TYPE_CONSULTATION]
         if consults:
             filename_consult = normalize_filename(
                 datetime.datetime.now().strftime(
                     'consultations_%F_%Hh%Mm%Ss.pdf'))
             pdf_bills.consultations(filename_consult, consults)
             cmd, cap = mailcap.findmatch(mailcap.getcaps(),
                                          'application/pdf', 'view',
                                          filename_consult)
             os.system(cmd + '&')
         manuals = [b for b in bills if b.type == BILL_TYPE_MANUAL]
         if manuals:
             filename_manual = normalize_filename(
                 datetime.datetime.now().strftime(
                     'fact_manuelles_%F_%Hh%Mm%Ss.pdf'))
             pdf_bills.manuals(filename_manual, manuals)
             cmd, cap = mailcap.findmatch(mailcap.getcaps(),
                                          'application/pdf', 'view',
                                          filename_manual)
             os.system(cmd + '&')