예제 #1
0
    def _list_formatted_get_buttons(self, row, permission_edit,
                                    permission_delete):
        """
        :param row:
        :param permission_edit:
        :return:
        """
        from os_gui import OsGui

        T = current.T
        os_gui = OsGui()
        buttons = DIV(_class='pull-right')

        if permission_edit:
            edit = os_gui.get_button(
                'edit',
                URL('finance_cashbook',
                    'additional_item_edit',
                    vars={'acaiID': row.id}))
            buttons.append(edit)
        if permission_delete:
            onclick_delete = \
                "return confirm('" + \
                T('m_openstudio_os_accounting_cashbooks_additional_items_delete_confirm') + \
                "');"

            delete = os_gui.get_button('delete_notext',
                                       URL('finance_cashbook',
                                           'additional_item_delete',
                                           vars={'acaiID': row.id}),
                                       onclick=onclick_delete)
            buttons.append(delete)

        return buttons
예제 #2
0
    def _classes_reservation_add_get_button(self, clsID):
        """
            Returns add button for a customer to add a reservation
        """
        from os_customer import Customer
        from os_gui import OsGui
        os_gui = OsGui()

        session = current.session
        DATE_FORMAT = current.DATE_FORMAT

        date = session.customers_classes_reservation_add_vars['date']
        date_formatted = date.strftime(DATE_FORMAT)
        cuID = session.customers_classes_reservation_add_vars['cuID']
        customer = Customer(cuID)

        add = os_gui.get_button('add',
                                URL('classes',
                                    'reservation_add_choose',
                                    vars={
                                        'cuID': cuID,
                                        'clsID': clsID,
                                        'date': date_formatted
                                    }),
                                btn_size='btn-sm',
                                _class="pull-right")

        return add
예제 #3
0
    def get_payment_fixed_rate_default_display(self):
        """
        :return: HTML display of default rate for teacher
        """
        from os_gui import OsGui

        T = current.T
        os_gui = OsGui()

        display = DIV(H3(T("Default rate")), )

        edit_url = URL('payment_fixed_rate_default', vars={'teID': self.id})
        rows = self.get_payment_fixed_rate_default(render=True)
        if not rows:
            display.append(A(T('Set default rate'), _href=edit_url))
            return display

        row = list(rows)[0]

        display.append(
            DIV(
                os_gui.get_button('edit',
                                  edit_url,
                                  _class='pull-right',
                                  title=T('Edit'),
                                  tooltip=T('Edit the default rate')),
                H4(row.ClassRate),
                ' ',
                row.tax_rates_id,
                BR(),
            ))

        return display
    def _list_formatted_get_buttons(self, row, permission_edit):
        """
        :param row:
        :param permission_edit:
        :return:
        """
        from os_gui import OsGui

        os_gui = OsGui()
        buttons = DIV(_class='pull-right')

        if permission_edit:
            edit = os_gui.get_button(
                'edit',
                URL('settings',
                    'financial_glaccount_edit',
                    vars={'agID': row.id}))
            buttons.append(edit)
            archive = os_gui.get_button(
                'archive',
                URL('settings',
                    'financial_glaccount_archive',
                    vars={'agID': row.id}))
            buttons.append(archive)

        return buttons
    def _list_formatted_get_buttons(self, row, permission_edit,
                                    permission_delete):
        """
        :param row:
        :param permission_edit:
        :return:
        """
        from os_gui import OsGui

        T = current.T
        os_gui = OsGui()
        buttons = DIV(_class='pull-right')

        if permission_edit:
            edit = os_gui.get_button(
                'edit', URL('finance_expenses', 'edit', vars={'aeID': row.id}))
            buttons.append(edit)
        if permission_delete:
            onclick_delete = \
                "return confirm('" + \
                T('Are you sure you want to delete this expense?') + \
                "');"

            delete = os_gui.get_button('delete_notext',
                                       URL('finance_expenses',
                                           'delete',
                                           vars={'aeID': row.id}),
                                       onclick=onclick_delete)
            buttons.append(delete)

        return buttons
    def _rows_to_table_get_navigation(self, rows, items_per_page, page):
        from os_gui import OsGui

        os_gui = OsGui()
        request = current.request

        # Navigation
        previous = ''
        url_previous = None
        if page:
            url_previous = URL(args=[page - 1], vars=request.vars)
            previous = A(SPAN(_class='glyphicon glyphicon-chevron-left'),
                         _href=url_previous)

        nxt = ''
        url_next = None
        if len(rows) > items_per_page:
            url_next = URL(args=[page + 1], vars=request.vars)
            nxt = A(SPAN(_class='glyphicon glyphicon-chevron-right'),
                    _href=url_next)

        navigation = os_gui.get_page_navigation_simple(url_previous, url_next,
                                                       page + 1)

        if previous or nxt:
            pass
        else:
            navigation = ''

        return DIV(navigation)
예제 #7
0
    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
예제 #8
0
    def get_add(self, button_text=None, btn_size='btn-sm', redirect_vars={}):
        """
        :return: Returns an html add button for an account
        """
        from openstudio.os_gui import OsGui

        os_gui = OsGui()

        add = os_gui.get_button('add',
                                URL('customers', 'add', vars=redirect_vars),
                                _class='pull-right',
                                btn_size=btn_size,
                                title=button_text)

        return add
예제 #9
0
    def _rows_to_table_link_events(self, row):
        """
            Returns 'yes' if a teacher teaches workshops and no if otherwise
        """
        from os_gui import OsGui

        os_gui = OsGui()
        T = current.T

        if row.teaches_workshops:
            label = os_gui.get_label('success', T('Yes'))
        else:
            label = os_gui.get_label('default', T('No'))

        return A(label, _href=URL('teaches_events', vars={'uID':row.id}))
예제 #10
0
    def _list_formatted_link_view(self, row):
        """
        Returns the 'view' button for a receipt
        """
        from os_gui import OsGui

        T = current.T
        os_gui = OsGui()

        return os_gui.get_button(
            'noicon',
            URL('finance', 'receipt', vars={'rID': row.id}),
            title=T("View"),
            _target="_blank"
        )
    def list_formatted(self):
        """

        :return: HTML table of reminders
        """
        from os_gui import OsGui

        T = current.T
        auth = current.auth
        os_gui = OsGui()

        rows = self.list()

        if not len(rows):
            return T("No reminders configured")

        permission = auth.has_membership(group_id='Admins') or \
                     auth.has_permission('delete', 'sys_email_reminders')

        header = THEAD(TR(TH('Reminder'), TH()))
        table = TABLE(header, _class='table table-striped table-hover')

        for row in rows:
            table.append(
                TR(
                    TD(
                        T("%s Day(s) before class date, email reminder about open class to teacher."
                          % row.Days)),
                    TD(
                        self._list_formatted_get_delete_button(
                            row.id, permission, os_gui))))

        return table
    def _list_sqlform_grid_link_edit(self, row):
        """
        :param row:
        :return:
        """
        from os_gui import OsGui
        auth = current.auth
        os_gui = OsGui()
        edit = ''

        permission = auth.has_membership(group_id='Admins') or \
                     auth.has_permission('update', 'accounting_expenses')
        if permission:
            edit = os_gui.get_button(
                'edit', URL('finance_expenses', 'edit', vars={'aeID': row.id}))

        return edit
예제 #13
0
    def _rows_to_table_link_group(self, row):
        """
            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

        no_group = A(os_gui.get_label('default', T('No group')),
                     _href=URL('school_properties',
                               'account_group_add',
                               args=[row.id]))

        if row.id == 1:
            ret_val = os_gui.get_label('info', "Admins")
        else:  # check if the user had a group
            if db(db.auth_membership.user_id ==
                  row.id).count() > 0:  # change group
                query = (db.auth_membership.user_id == row.id)
                left = [
                    db.auth_group.on(
                        db.auth_group.id == db.auth_membership.group_id)
                ]
                rows = db(query).select(db.auth_group.ALL,
                                        db.auth_membership.ALL,
                                        left=left)
                for query_row in rows:
                    role = query_row.auth_group.role
                    if 'user' not in role:
                        ret_val = A(os_gui.get_label('info', role),
                                    _href=URL(
                                        'school_properties',
                                        "account_group_edit",
                                        args=[query_row.auth_membership.id]))
                    else:  # no group added yet
                        ret_val = no_group
            else:  # no group added yet
                ret_val = no_group

        return ret_val
예제 #14
0
    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')
예제 #15
0
    def list_formatted(self):
        """
            :return: HTML table with mailing lists
        """
        from os_gui import OsGui

        T = current.T
        os_gui = OsGui()
        auth = current.auth

        header = THEAD(TR(TH(T('Name')),
                          TH(T('Description')),
                          TH(T('Frequency')),
                          TH(T('MailChimp ListID')),
                          TH()))
        table = TABLE(header, _class='table table-striped table-hover')

        permission_edit = (auth.has_membership(group_id='Admins') or
                           auth.has_permission('update', 'mailing_lists'))
        permission_delete = (auth.has_membership(group_id='Admins') or
                             auth.has_permission('delete', 'mailing_lists'))

        onclick_delete = "return confirm('" \
            + T('Do you really want to delete this list?') + ' ' \
            + "');"

        rows = self.list()
        for row in rows:
            buttons = ''
            edit = ''
            delete = ''
            vars = {'mlID':row.id}

            if permission_edit:
                edit = os_gui.get_button('edit',
                    URL('settings_mail', 'mailing_list_edit', vars=vars))

            if permission_delete:
                delete = os_gui.get_button('delete_notext',
                    URL('settings_mail', 'mailing_list_delete', vars=vars),
                    onclick=onclick_delete,
                )
            buttons = DIV(edit, delete, _class='pull-right')

            tr = TR(
                TD(os_gui.max_string_length(row.Name, 20)),
                TD(os_gui.max_string_length(row.Description, 30)),
                TD(os_gui.max_string_length(row.Frequency, 20)),
                TD(row.MailChimpListID),
                TD(buttons)
            )

            table.append(tr)

        return table
예제 #16
0
    def get_mailing_lists_customer_display(self, cuID):
        """
        :param cuID: db.auth_user.id
        :return:
        """
        from os_gui import OsGui
        T = current.T
        os_gui = OsGui()

        mailchimp = self.get_client()
        if not mailchimp:
            return T("Unable to load mailing lists, please contact your studio.")

        rows = self.get_mailing_lists()

        header = THEAD(TR(
            TH(T('List')),
            TH(T('Description')),
            TH(T('Frequency')),
            TH(T('Status')),
            TH()
        ))

        table = TABLE(header, _class='table table-striped table-hover')
        for row in rows:
            list_id = row.MailChimpListID
            status = self.get_mailing_list_customer_subscription_status(
                mailchimp,
                list_id,
                cuID
            )

            tr = TR(
                TD(row.Name),
                TD(XML(row.Description)),
                TD(row.Frequency),
                TD(self.get_mailing_list_customer_display_status(
                    status,
                    os_gui
                )),
                TD(self.get_mailing_list_customer_display_buttons(
                    status,
                    list_id,
                    os_gui
                ))
            )
            table.append(tr)

        return table
    def list_sqlform_grid(self, date_from=None, date_until=None):
        """
        SQLFORM.grid for accounting_expenses
        :param date_from:
        :param date_until:
        :return:
        """
        db = current.db
        auth = current.auth
        session = current.session
        grid_ui = current.globalenv['grid_ui']
        DATE_FORMAT = current.DATE_FORMAT
        from general_helpers import datestr_to_python
        from openstudio.os_gui import OsGui
        os_gui = OsGui()
        T = current.T

        query = (db.accounting_expenses.id > 0)
        links = [
            self._list_sqlform_grid_link_edit,
        ]

        delete_permission = auth.has_membership(group_id='Admins') or \
                            auth.has_permission('delete', 'accounting_expenses')

        grid = SQLFORM.grid(
            query,
            links=links,
            # left=left,
            field_id=db.accounting_expenses.id,
            # fields=fields,
            create=False,
            editable=False,
            details=False,
            searchable=False,
            deletable=delete_permission,
            csv=False,
            # maxtextlengths=maxtextlengths,
            orderby=~db.accounting_expenses.id,
            ui=grid_ui)
        grid.element('.web2py_counter', replace=None)  # remove the counter
        grid.elements('span[title=Delete]',
                      replace=None)  # remove text from delete button

        return grid
예제 #18
0
    def get_upcoming_classes_formatted(self, days=3):
        """
            Returns upcoming classes for teacher
        """
        from os_gui import OsGui
        from os_class_schedule import ClassSchedule

        T = current.T
        db = current.db
        auth = current.auth
        os_gui = OsGui()
        DATE_FORMAT = current.DATE_FORMAT
        TODAY_LOCAL = current.globalenv['TODAY_LOCAL']

        attendance_permission = (auth.has_membership(group_id='Admins')
                                 or auth.has_permission(
                                     'update', 'classes_attendance'))

        date = TODAY_LOCAL
        delta = datetime.timedelta(days=1)

        header = THEAD(
            TR(
                TH(T('Class date')),
                TH(T('Time')),
                TH(T('Location')),
                TH(T('Class type')),
                TH(T('Teacher')),
                TH(T('Teacher2')),
                TH(),
            ))

        table = TABLE(header, _class='table table-hover')

        for day in range(0, days):
            cs = ClassSchedule(date, filter_id_teacher=self.id)

            rows = cs.get_day_rows()
            for i, row in enumerate(rows):
                if row.classes_otc.Status == 'cancelled' or row.school_holidays.id:
                    continue

                repr_row = list(rows[i:i + 1].render())[0]

                result = cs._get_day_row_teacher_roles(row, repr_row)

                teacher = result['teacher_role']
                teacher2 = result['teacher_role2']

                attendance = ''
                if attendance_permission:
                    attendance = os_gui.get_button(
                        'noicon',
                        URL('classes',
                            'attendance',
                            vars={
                                'clsID': row.classes.id,
                                'date': date.strftime(DATE_FORMAT)
                            }),
                        title=T('Attendance'),
                        _class=T('pull-right'))

                tr = TR(
                    TD(date.strftime(DATE_FORMAT),
                       _class='bold green' if day == 0 else ''),
                    TD(repr_row.classes.Starttime, ' - ',
                       repr_row.classes.Endtime),
                    TD(repr_row.classes.school_locations_id),
                    TD(repr_row.classes.school_classtypes_id), TD(teacher),
                    TD(teacher2), TD(attendance))

                table.append(tr)

            date += delta

        upcoming_classes = DIV(
            DIV(H3(T('My upcoming classes'), _class="box-title"),
                DIV(A(I(_class='fa fa-minus'),
                      _href='#',
                      _class='btn btn-box-tool',
                      _title=T("Collapse"),
                      **{'_data-widget': 'collapse'}),
                    _class='box-tools pull-right'),
                _class='box-header with-border'),
            DIV(table, _class='box-body'),
            self._get_teacher_upcoming_classes_formatted_footer(),
            _class='box box-primary')

        return upcoming_classes
    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)
예제 #20
0
    def list_formatted(self, status, limitby):
        """

        :return: HTML table of available sub teachers
        """
        from os_gui import OsGui

        T = current.T
        db = current.db
        os_gui = OsGui()

        table = TABLE(_class='table table-hover')

        table.append(
            THEAD(
                TR(
                    # TH(),
                    TH(T('Date')),
                    TH(T('Start')),
                    TH(T('Location')),
                    TH(T('Class Type')),
                    TH(T('Sub teacher')),
                    TH(),  # actions))
                )))

        left = [
            db.classes_otc.on(
                db.classes_otc_sub_avail.classes_otc_id == db.classes_otc.id),
            db.classes.on(db.classes_otc.classes_id == db.classes.id)
        ]

        if status == 'pending':
            query = (db.classes_otc_sub_avail.Accepted == None)
        else:
            query = ((db.classes_otc_sub_avail.Accepted == True) |
                     (db.classes_otc_sub_avail.Accepted == False))

        rows = db(query).select(db.classes_otc_sub_avail.ALL,
                                db.classes_otc.ALL,
                                db.classes.ALL,
                                left=left,
                                limitby=limitby,
                                orderby=db.classes_otc.ClassDate
                                | db.classes_otc.Starttime)

        for i, row in enumerate(rows):
            repr_row = list(rows[i:i + 1].render())[0]

            if row.classes_otc_sub_avail.Accepted == True:
                status = os_gui.get_label('success', T("Accepted"))
            elif row.classes_otc_sub_avail.Accepted == False:
                status = os_gui.get_label('danger', T("Declined"))
            else:
                status = os_gui.get_label('primary', T("Pending"))
            button = os_gui.get_button(
                'ok_notext',
                URL('sub_avail_accept',
                    vars={'cotcsaID': row.classes_otc_sub_avail.id}),
                title='Accept',
                _class='pull-right',
                btn_class='btn-success')

            button += os_gui.get_button(
                'cancel_notext',
                URL('sub_avail_decline',
                    vars={'cotcsaID': row.classes_otc_sub_avail.id}),
                title='Decline',
                _class='pull-right',
                btn_class='btn-danger')

            tr = TR(TD(repr_row.classes_otc.ClassDate),
                    TD(repr_row.classes.Starttime),
                    TD(repr_row.classes.school_locations_id),
                    TD(repr_row.classes.school_classtypes_id),
                    TD(repr_row.classes_otc_sub_avail.auth_teacher_id),
                    TD(status), TD(button))

            table.append(tr)

        return dict(table=table, rows=rows)
예제 #21
0
    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
        """
        import uuid
        from os_gui import OsGui

        T = current.T
        auth = current.auth
        os_gui = OsGui()

        header = THEAD(
            TR(
                TH('Expense #'),
                TH(T("Employee")),
                TH(T("Date")),
                TH(T("Description")),
                TH(T("Amount")),
                TH(T("Quantity")),
                TH(T("Attachment")),
                TH(T("Invoice")),
                TH()  # Actions
            ))

        table = TABLE(header,
                      _class="table table-striped table-hover small_font")

        permissions = auth.has_membership(group_id='Admins') or \
               auth.has_permission('update', 'employee_claims')

        for i, row in enumerate(rows):
            repr_row = list(rows[i:i + 1].render())[0]
            buttons = ''
            if permissions:

                if status == 'pending':
                    buttons = self._rows_to_table_get_pending_buttons(
                        row, os_gui)
                elif status == 'accepted':
                    buttons = self._rows_to_table_get_accepted_buttons(
                        row, os_gui)
                elif status == 'rejected':
                    buttons = self._rows_to_table_get_rejected_buttons(
                        row, os_gui)
            tr = TR(TD(row.employee_claims.id),
                    TD(repr_row.employee_claims.auth_user_id),
                    TD(repr_row.employee_claims.ClaimDate),
                    TD(repr_row.employee_claims.Description),
                    TD(repr_row.employee_claims.Amount),
                    TD(repr_row.employee_claims.Quantity),
                    TD(self._rows_to_table_get_attachment(row, os_gui, uuid)),
                    TD(self._rows_to_table_get_invoice_link(row, os_gui)),
                    TD(buttons))

            table.append(tr)

        pager = self._rows_to_table_get_navigation(rows, items_per_page, page)

        return DIV(table, pager)
예제 #22
0
    def classes_add_get_list(self, date, list_type, cuID=None, teID=None):
        """
            Get list of classes for a date
            list_type is expected to be in
            [ 'attendance', 'reservations', 'tp_fixed_rate' ]
        """
        from os_attendance_helper import AttendanceHelper
        from os_class_schedule import ClassSchedule
        from os_gui import OsGui

        T = current.T
        db = current.db
        os_gui = OsGui()
        DATE_FORMAT = current.DATE_FORMAT
        session = current.session

        if list_type == 'attendance':
            session.classes_attendance_signin_back = 'cu_classes_attendance'
            ah = AttendanceHelper()
            # links = [ lambda row: ah.get_signin_buttons(row.classes.id, date, cuID) ]

        if session.classes_schedule_sort == 'location':
            orderby = db.school_locations.Name | db.classes.Starttime
        elif session.classes_schedule_sort == 'starttime':
            orderby = db.classes.Starttime | db.school_locations.Name
        else:
            orderby = db.school_locations.Name | db.classes.Starttime

        filter_id_teacher = None
        if list_type == 'tp_fixed_rate':
            filter_id_teacher = cuID
        cs = ClassSchedule(date,
                           sorting=orderby,
                           filter_id_teacher=filter_id_teacher)
        classes = cs.get_day_list()

        header = THEAD(TR(TH(T('Time')),
                          TH(T('Location')),
                          TH(T('Class')),
                          TH(),
                          TH()  # buttons
                          ))
        table = TABLE(header, _class='table table-striped table-hover')
        for c in classes:
            status = self._classes_add_get_list_get_cancelled_holiday(c)
            buttons = ''

            if list_type == 'reservations':
                buttons = self._classes_reservation_add_get_button(c['ClassesID'])
            elif list_type == 'attendance' and status == '':
                buttons = os_gui.get_button('noicon',
                                            URL('customers', 'classes_attendance_add_booking_options',
                                                vars={'cuID': cuID,
                                                      'clsID': c['ClassesID'],
                                                      'date': date.strftime(DATE_FORMAT)}),
                                            title='Check in',
                                            _class='pull-right')
            elif list_type == 'tp_fixed_rate':
                buttons = os_gui.get_button(
                    'noicon',
                    URL('teachers',
                        'payment_fixed_rate_class',
                        vars={'teID': teID,
                              'clsID': c['ClassesID']}),
                    title=T('Set rate'),
                    _class='pull-right'
                )

            tr = TR(
                TD(c['Starttime'], ' - ', c['Endtime']),
                TD(c['Location']),
                TD(c['ClassType']),
                TD(status),
                TD(buttons)
            )

            table.append(tr)

        return table
예제 #23
0
    def get_payment_travel_display(self):
        """
        :return: gluon.dal.row object of db.teachers_payment_travel
        """
        from openstudio.os_gui import OsGui

        T = current.T
        auth = current.auth
        os_gui = OsGui()
        rows = self.get_payment_travel_allowances()

        display = DIV()

        if not rows:
            return display

        edit_permission = auth.has_membership(group_id='Admins') or \
                          auth.has_permission('update', 'teachers_payment_travel')
        delete_permission = auth.has_membership(group_id='Admins') or \
                          auth.has_permission('delete', 'teachers_payment_travel')
        delete_onclick = "return confirm('" + \
            T('Do you really want to delete the travel allowance for this location?') \
            + "');"

        table = TABLE(self._get_payment_travel_display_get_table_header(),
                      _class='table table-hover table-striped')

        for i, row in enumerate(rows):
            repr_row = list(rows[i:i + 1].render())[0]

            buttons = DIV(_class='pull-right')
            if edit_permission:
                edit_url = URL('payment_travel_edit',
                               vars={
                                   'teID': self.id,
                                   'tpfrtID': row.teachers_payment_travel.id
                               })
                buttons.append(os_gui.get_button('edit', edit_url))

            if delete_permission:
                delete_url = URL('payment_travel_delete',
                                 vars={
                                     'tpfrtID': row.teachers_payment_travel.id,
                                     'teID': self.id
                                 })
                buttons.append(
                    os_gui.get_button(
                        'delete_notext',
                        delete_url,
                        onclick=delete_onclick,
                    ))

            table.append(
                TR(TD(row.school_locations.Name),
                   TD(repr_row.teachers_payment_travel.TravelAllowance),
                   TD(repr_row.teachers_payment_travel.tax_rates_id),
                   TD(buttons)))

        display.append(table)

        return display
예제 #24
0
    def get_payment_fixed_rate_classes_display(self):
        """
        :return: gluon.dal.row object of db.teachers_payment_fixed_rate_class
        """
        from openstudio.os_gui import OsGui

        T = current.T
        auth = current.auth
        os_gui = OsGui()
        rows = self.get_payment_fixed_rate_classes_rows()

        display = DIV(
            os_gui.get_button('add',
                              URL('teachers',
                                  'payment_fixed_rate_class_add',
                                  vars={'teID': self.id}),
                              _class='pull-right'),
            H3(T("Class rates")),
        )

        if not rows:
            return display

        edit_permission = auth.has_membership(group_id='Admins') or \
                          auth.has_permission('update', 'teachers_payment_fixed_rate_class')
        delete_permission = auth.has_membership(group_id='Admins') or \
                          auth.has_permission('delete', 'teachers_payment_fixed_rate_class')
        delete_onclick = "return confirm('" + \
            T('Do you really want to delete this class rate?') \
            + "');"

        table = TABLE(
            self._get_payment_fixed_rate_classes_display_get_table_header(),
            _class='table table-hover table-striped')

        for i, row in enumerate(rows):
            repr_row = list(rows[i:i + 1].render())[0]

            buttons = DIV(_class='pull-right')
            if edit_permission:
                edit_url = URL(
                    'payment_fixed_rate_class',
                    vars={
                        'teID': self.id,
                        'clsID':
                        row.teachers_payment_fixed_rate_class.classes_id
                    })
                buttons.append(os_gui.get_button('edit', edit_url))

            if delete_permission:
                delete_url = URL('payment_fixed_rate_class_delete',
                                 vars={
                                     'tpfrcID':
                                     row.teachers_payment_fixed_rate_class.id,
                                     'teID':
                                     self.id
                                 })
                buttons.append(
                    os_gui.get_button(
                        'delete_notext',
                        delete_url,
                        onclick=delete_onclick,
                    ))

            time = SPAN(repr_row.classes.Starttime, ' - ',
                        repr_row.classes.Endtime)

            table.append(
                TR(TD(repr_row.classes.Week_day), TD(time),
                   TD(repr_row.classes.school_classtypes_id),
                   TD(repr_row.classes.school_locations_id),
                   TD(repr_row.teachers_payment_fixed_rate_class.ClassRate),
                   TD(repr_row.teachers_payment_fixed_rate_class.tax_rates_id),
                   TD(buttons)))

        display.append(table)

        return display
예제 #25
0
    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
예제 #26
0
    def get_subrequests_formatted(self):
        """
        :return: HTML table holding subrequests this teacher can apply for
        """
        from os_gui import OsGui

        os_gui = OsGui()

        T = current.T
        db = current.db
        auth = current.auth
        TODAY_LOCAL = current.TODAY_LOCAL

        header = THEAD(
            TR(TH(T('Class date')), TH(T('Time')), TH(T('Location')),
               TH(T('Class type')), TH()))

        table = TABLE(header, _class='table table-hover')

        # Get classtypes for currently logged on teacher
        query = (db.teachers_classtypes.auth_user_id == self.id)
        rows = db(query).select(db.teachers_classtypes.school_classtypes_id)
        ctIDs = [row.school_classtypes_id for row in rows]

        left = [
            db.classes.on(db.classes_otc.classes_id == db.classes.id, ),
            db.classes_teachers.on(
                db.classes_teachers.classes_id == db.classes.id)
        ]

        query = ((db.classes_otc.Status == 'open') &
                 ((db.classes.school_classtypes_id.belongs(ctIDs)) |
                  (db.classes_otc.school_classtypes_id.belongs(ctIDs))) &
                 (db.classes_teachers.Startdate <= db.classes_otc.ClassDate) &
                 ((db.classes_teachers.Enddate >= db.classes_otc.ClassDate) |
                  (db.classes_teachers.Enddate == None)) &
                 (db.classes_otc.ClassDate >= TODAY_LOCAL))

        rows = db(query).select(db.classes_otc.ALL,
                                db.classes.ALL,
                                left=left,
                                orderby=db.classes.id)

        for i, row in enumerate(rows):
            repr_row = list(rows[i:i + 1].render())[0]
            row_avail = db.classes_otc_sub_avail(
                classes_otc_id=row.classes_otc.id,
                auth_teacher_id=auth.user.id)

            if not row_avail:
                button = os_gui.get_button(
                    'noicon',
                    URL('ep',
                        'available_for_sub',
                        vars={'cotcID': row.classes_otc.id}),
                    title=T("I'm available to sub"),
                    _class='pull-right',
                    btn_class='btn-success')
            else:
                button = os_gui.get_button('noicon',
                                           URL('ep',
                                               'cancel_available_for_sub',
                                               vars={'cotcsaID':
                                                     row_avail.id}),
                                           title=T("I'm no longer available"),
                                           _class='pull-right',
                                           btn_class='btn-warning')
            tr = TR(
                TD(repr_row.classes_otc.ClassDate),
                TD(repr_row.classes.Starttime, ' - ',
                   repr_row.classes.Endtime),
                TD(repr_row.classes.school_locations_id),
                TD(repr_row.classes.school_classtypes_id), TD(button))
            table.append(tr)

        if not len(rows):
            table = T("No one is looking for a sub at the moment...")

        sub_requests = DIV(DIV(H3(T('Can you sub a class?'),
                                  _class="box-title"),
                               DIV(A(I(_class='fa fa-minus'),
                                     _href='#',
                                     _class='btn btn-box-tool',
                                     _title=T("Collapse"),
                                     **{'_data-widget': 'collapse'}),
                                   _class='box-tools pull-right'),
                               _class='box-header with-border'),
                           DIV(table, _class='box-body'),
                           _class='box box-success')

        ## disable for now
        return ''