class PaymentFlowHistoryDialog(BasicDialog): title = _(u'Payment Flow History Dialog') desc = _("Select a date or a range to be visualised in the report:") size = (-1, -1) model_type = PaymentFlowDay def __init__(self, store): """A dialog to print the PaymentFlowHistoryReport report. :param store: a store """ self.store = store BasicDialog.__init__(self, header_text='<b>%s</b>' % self.desc, title=self.title) self._setup_widgets() # # BasicDialog # def confirm(self): state = self._date_filter.get_state() from kiwi.db.query import DateQueryState if isinstance(state, DateQueryState): start, end = state.date, state.date else: start, end = state.start, state.end results = PaymentFlowDay.get_flow_history(self.store, start, end) if not results: info(_('No payment history found.')) return False print_report(PaymentFlowHistoryReport, payment_histories=results) return True # # Private # def _setup_widgets(self): self.ok_button.set_label(gtk.STOCK_PRINT) self._date_filter = DateSearchFilter(_(u'Date:')) #FIXME: add a remove_option method in DateSearchFilter. self._date_filter.clear_options() self._date_filter.add_custom_options() for option in [Today, Yesterday, LastWeek, LastMonth]: self._date_filter.add_option(option) self._date_filter.select(position=0) self.vbox.pack_start(self._date_filter, False, False) self._date_filter.show_all()