Ejemplo n.º 1
0
def generate_email_body(template, loan_id, ill=0):
    """
    Generate the body of an email for loan recalls.

    @param template: email template
    @type template: string

    @param loan_id: identify the loan. Primary key of crcLOAN.
    @type loan_id: int

    @return email(body)
    """

    if ill:
        # Inter library loan.
        out = template
    else:
        recid = db.get_loan_recid(loan_id)
        (book_title, book_year, book_author, book_isbn,
         book_editor) = book_information_from_MARC(int(recid))
        due_date = db.get_due_date(loan_id)

        lib_id = db.get_library_for_loan(loan_id)
        library_details = db.get_library_details(lib_id)
        (library_id, name, address, email, phone, lib_type,
         notes) = library_details

        out = template % (book_title, book_year, book_author, book_isbn,
                          book_editor, due_date, name, name, phone, email)

    return out
Ejemplo n.º 2
0
def generate_email_body(template, loan_id, ill=0):
    """
    Generate the body of an email for loan recalls.

    @param template: email template
    @type template: string

    @param loan_id: identify the loan. Primary key of crcLOAN.
    @type loan_id: int

    @return email(body)
    """

    if ill:
        # Inter library loan.
        out = template
    else:
        recid = db.get_loan_recid(loan_id)
        (book_title, book_year, book_author,
        book_isbn, book_editor) = book_information_from_MARC(int(recid))
        due_date = db.get_due_date(loan_id)

        lib_id = db.get_library_for_loan(loan_id)
        library_details = db.get_library_details(lib_id)
        (library_id, name, address, email, phone,
            lib_type, notes) = library_details

        out = template % (book_title, book_year, book_author,
                      book_isbn, book_editor, due_date, name, name, phone, email)

    return out
Ejemplo n.º 3
0
def print_actual_due_date(loan_id=None, barcode=None, borrower_id=None):
    if not loan_id and barcode:
        loan_id = db.get_current_loan_id(barcode)
    elif not barcode and loan_id:
        loan_infos = db.get_loan_infos(loan_id)
        if loan_infos:
            barcode = loan_infos[1]

    if loan_id and barcode:
        due_date = db.get_due_date(loan_id)

        if not (borrower_id):
            borrower_id = db.get_borrower_id_from_loan(loan_id)

        loan_period = db.get_loan_period_from_loan_rule(barcode, user_id=borrower_id, patrontype_id=None)
        if loan_period and loan_period['type'] == 'hours':
            return due_date
        else:
            return due_date.split(" ")[0]

    return None
Ejemplo n.º 4
0
def print_actual_due_date(loan_id=None, barcode=None, borrower_id=None):
    if not loan_id and barcode:
        loan_id = db.get_current_loan_id(barcode)
    elif not barcode and loan_id:
        loan_infos = db.get_loan_infos(loan_id)
        if loan_infos:
            barcode = loan_infos[1]

    if loan_id and barcode:
        due_date = db.get_due_date(loan_id)

        if not (borrower_id):
            borrower_id = db.get_borrower_id_from_loan(loan_id)

        loan_period = db.get_loan_period_from_loan_rule(barcode,
                                                        user_id=borrower_id,
                                                        patrontype_id=None)
        if loan_period and loan_period['type'] == 'hours':
            return due_date
        else:
            return due_date.split(" ")[0]

    return None