def _rows_to_table_buttons(self, row, permission): """ This function returns the group a user belongs to and shows it as a link to a page which allows users to change it. """ from os_gui import OsGui os_gui = OsGui() T = current.T db = current.db if not permission: return '' delete_onclick = "return confirm('" + \ T('Remove from teachers list? - This person will still be a customer.') + "');" delete = os_gui.get_button('delete_notext', URL('teachers', 'delete', vars={'uID': row.id}), onclick=delete_onclick, _class='pull-right') links = [] # Check Update teachers payment attendance classes links.append( A(os_gui.get_fa_icon('fa-usd'), T('Fixed rate payments'), _href=URL('teachers', 'payment_fixed_rate', vars={'teID': row.id}))) links.append( A(os_gui.get_fa_icon('fa-subway'), T('Travel allowance'), _href=URL('teachers', 'payment_travel', vars={'teID': row.id}))) links.append('divider') links.append( A(os_gui.get_fa_icon('fa-check-square-o'), T('Assign classtypes'), _href=URL('teachers', 'edit_classtypes', vars={'uID': row.id}))) links.append( A(os_gui.get_fa_icon('fa-pencil'), T('Edit'), _href=URL('customers', 'edit', args=row.id))) actions = os_gui.get_dropdown_menu(links=links, btn_text=T('Actions'), btn_size='btn-sm', btn_icon='actions', menu_class='btn-group pull-right') return DIV(delete, actions, _class='pull-right')
def _get_payment_info_mandates_format(self, rows): """ :param rows: gluon.dal.rows object of db.customers_payment_info_mandates :return: """ from os_gui import OsGui T = current.T auth = current.auth os_gui = OsGui() request = current.request delete_permission = ( auth.has_membership(group_id='Admins') or auth.has_permission('delete', 'customers_payments_info_mandates') ) edit_permission = ( auth.has_membership(group_id='Admins') or auth.has_permission('update', 'customers_payments_info_mandates') ) onclick = "return confirm('" + \ T('Do you really want to remove this mandate?') + "');" mandates = DIV() for row in rows.render(): btn_delete = '' box_tools = DIV(_class='box-tools') if delete_permission and request.controller == 'customers': box_tools.append( A(os_gui.get_fa_icon('fa-times'), _href=URL('customers', 'bankaccount_mandate_delete', vars={'cuID':self.cuID, 'cpimID': row.id}), _onclick=onclick, _class='btn-box-tool text-red') ) mandates.append(DIV( DIV(H3(T("Direct debit mandate"), _class="box-title"), box_tools, _class="box-header" ), DIV(LABEL(T("Reference")), DIV(row.MandateReference), LABEL(T("Signed on")), DIV(row.MandateSignatureDate), LABEL(T("Mandate content")) if row.MandateText else '', DIV(XML(row.MandateText) ), _class="box-body" ), _class="box box-solid" )) return mandates
def rows_to_table(self, rows, status, items_per_page, page): """ turn rows object into an html table :param rows: gluon.dal.rows with all fields of db.teachers_payment_classes and db.classes :return: html table """ from os_gui import OsGui T = current.T auth = current.auth os_gui = OsGui() header = THEAD( TR( TH(), TH(T("Date")), TH(T("Time")), TH(T("Location")), TH(T("Class type")), TH(T("Teacher")), TH(T("Type")), TH(T("Attendance")), TH(T("Payment")), TH(os_gui.get_fa_icon('fa-subway')), TH() # Actions )) table = TABLE(header, _class="table table-striped table-hover small_font") permissions = self._rows_to_table_button_permissions() for i, row in enumerate(rows): repr_row = list(rows[i:i + 1].render())[0] if status == 'not_verified': buttons = self._rows_to_table_get_not_verified_buttons( row, os_gui, permissions) elif status == 'verified': buttons = self._rows_to_table_get_verified_buttons( row, os_gui, permissions) else: buttons = '' tr = TR( TD(repr_row.teachers_payment_classes.Status), TD(repr_row.teachers_payment_classes.ClassDate), TD(repr_row.classes.Starttime), TD(repr_row.classes.school_locations_id), TD(repr_row.classes.school_classtypes_id), TD(repr_row.teachers_payment_classes.auth_teacher_id, BR(), repr_row.teachers_payment_classes.auth_teacher_id2), TD( repr_row.teachers_payment_classes.RateType, BR(), SPAN(repr_row.teachers_payment_classes. teachers_payment_attendance_list_id or '', _class='grey')), TD(repr_row.teachers_payment_classes.AttendanceCount), TD( repr_row.teachers_payment_classes.ClassRate, BR(), SPAN(repr_row.teachers_payment_classes.tax_rates_id, _class='grey')), TD( repr_row.teachers_payment_classes.TravelAllowance, BR(), SPAN(repr_row.teachers_payment_classes. tax_rates_id_travel_allowance or '', _class='grey')), TD(buttons)) table.append(tr) pager = self._rows_to_table_get_navigation(rows, items_per_page, page) return DIV(table, pager)
def get_notes_formatted(self, note_type, permission_edit=False, permission_delete=False): """ :param note_type: ['backoffice', 'teachers'] :return: HTML formatted notes using AdminLTE chat layout """ from openstudio.os_gui import OsGui os_gui = OsGui() T = current.T delete_onclick = "return confirm('" + T( 'Are you sure you want to delete this note?') + "');" rows = self.get_notes(note_type=note_type) notes = DIV(_class='direct-chat-messages direct-chat-messages-high') for i, row in enumerate(rows): repr_row = list(rows[i:i + 1].render())[0] edit = '' delete = '' if permission_delete: delete = A(T('Delete'), _href=URL('customers', 'note_delete', vars={ 'cnID': row.id, 'cuID': self.cuID }), _onclick=delete_onclick, _class='text-red') if permission_edit: edit = A( T('Edit'), _href=URL('customers', 'notes', vars={ 'cnID': row.id, 'cuID': self.cuID, 'note_type': note_type }), ) status = "" if row.Processed: status = SPAN(os_gui.get_fa_icon('fa-check'), ' ', T("Processed"), _class="direct-chat-scope pull-right text-green") note = DIV(DIV(SPAN(repr_row.auth_user_id, _class="direct-chat-name pull-left"), SPAN(delete, _class="direct-chat-scope pull-right"), SPAN(edit, _class="direct-chat-scope pull-right"), status, SPAN(repr_row.NoteDate, ' ', repr_row.NoteTime, ' ', _class="direct-chat-timestamp pull-right"), _class="direct-chat-info clearfix"), IMG(_src=URL('static', 'images/person_inverted_small.png'), _class="direct-chat-img"), DIV(XML(repr_row.Note.replace('\n', '<br>')), _class="direct-chat-text"), _class="direct-chat-msg") notes.append(note) return notes