def print_new_loan_information(req, ln): """ Create a printable format with the information of the last loan who has been registered on the table crcLOAN. """ _ = gettext_set_language(ln) # get the last loan from crcLOAN (recid, borrower_id, due_date) = db.get_last_loan() # get book's information (book_title, book_year, book_author, book_isbn, book_editor) = book_information_from_MARC(recid) # get borrower's data/information (name, address, email) (borrower_name, borrower_address, borrower_email) = db.get_borrower_data(borrower_id) # Generate printable format req.content_type = "text/html" req.send_http_header() out = """<table style='width:95%; margin:auto; max-width: 600px;'>""" out += """ <tr> <td><img src="%s/img/CERN_CDS_logo.png"></td> </tr> </table><br />""" % (CFG_SITE_URL) out += """<table style='color: #79d; font-size: 82%; width:95%; margin:auto; max-width: 400px;'>""" out += """ <tr><td align="center"><h2><strong>%s</strong></h2></td></tr>""" % (_("Loan information")) out += """ <tr><td align="center"><strong>%s</strong></td></tr>""" % (_("This book is sent to you ...")) out += """</table><br />""" out += """<table style='color: #79d; font-size: 82%; width:95%; margin:auto; max-width: 400px;'>""" out += """<tr> <td width="70"><strong>%s</strong></td><td style='color: black;'>%s</td> </tr> <tr> <td width="70"><strong>%s</strong></td><td style='color: black;'>%s</td> </tr> <tr> <td width="70"><strong>%s</strong></td><td style='color: black;'>%s</td> </tr> <tr> <td width="70"><strong>%s</strong></td><td style='color: black;'>%s</td> </tr> <tr> <td width="70"><strong>%s</strong></td><td style='color: black;'>%s</td> </tr> """ % (_("Title"), book_title, _("Author"), book_author, _("Editor"), book_editor, _("ISBN"), book_isbn, _("Year"), book_year) out += """</table><br />""" out += """<table style='color: #79d; font-size: 82%; width:95%; margin:auto; max-width: 400px;'>""" out += """<tr> <td width="70"><strong>%s</strong></td><td style='color: black;'>%s</td> </tr> <tr> <td width="70"><strong>%s</strong></td><td style='color: black;'>%s</td> </tr> <tr> <td width="70"><strong>%s</strong></td><td style='color: black;'>%s</td> </tr> <tr> <td width="70"><strong>%s</strong></td><td style='color: black;'>%s</td> </tr> """ % (_("Id"), borrower_id, _("Name"), borrower_name, _("Address"), borrower_address, _("Email"), borrower_email) out += """</table> <br />""" out += """<table style='color: #79d; font-size: 82%; width:95%; margin:auto; max-width: 400px;'>""" out += """ <tr><td align="center"><h2><strong>%s: %s</strong></h2></td></tr>""" % (_("Due date"), due_date) out += """</table>""" out += """<table style='color: #79d; font-size: 82%; width:95%; margin:auto; max-width: 800px;'> <tr><td><input type="button" onClick='window.print()' value='Print' style='color: #fff; background: #36c; font-weight: bold;'></td></tr> </table>""" req.write("<html>") req.write(out) req.write("</html>") return "\n"
def print_new_loan_information(req, ln=CFG_SITE_LANG): """ Create a printable format with the information of the last loan who has been registered on the table crcLOAN. """ _ = gettext_set_language(ln) # get the last loan from crcLOAN (recid, borrower_id, due_date) = db.get_last_loan() # get book's information (book_title, book_year, book_author, book_isbn, book_editor) = book_information_from_MARC(recid) # get borrower's data/information (name, address, email) (borrower_name, borrower_address, borrower_mailbox, borrower_email) = db.get_borrower_data(borrower_id) # Generate printable format req.content_type = "text/html" req.send_http_header() out = """<table style='width:95%; margin:auto; max-width: 600px;'>""" out += """ <tr> <td><img src="%s/img/CERN_CDS_logo.png"></td> </tr> </table><br />""" % (CFG_SITE_URL) out += """<table style='color: #79d; font-size: 82%; width:95%; margin:auto; max-width: 400px;'>""" out += """ <tr> <td align="center"> <h2><strong>%s</strong></h2> </td> </tr>""" % (_("Loan information")) out += """ <tr> <td align="center"><strong>%s</strong></td> </tr>""" % (_("This book has been sent to you:")) out += """</table><br />""" out += """<table style='color: #79d; font-size: 82%; width:95%; margin:auto; max-width: 400px;'>""" out += """ <tr> <td width="70"><strong>%s</strong></td> <td style='color: black;'>%s</td> </tr> <tr> <td width="70"><strong>%s</strong></td> <td style='color: black;'>%s</td> </tr> <tr> <td width="70"><strong>%s</strong></td> <td style='color: black;'>%s</td> </tr> <tr> <td width="70"><strong>%s</strong></td> <td style='color: black;'>%s</td> </tr> <tr> <td width="70"><strong>%s</strong></td> <td style='color: black;'>%s</td> </tr> """ % (_("Title"), book_title, _("Author"), book_author, _("Editor"), book_editor, _("ISBN"), book_isbn, _("Year"), book_year) out += """</table><br />""" out += """<table style='color: #79d; font-size: 82%; width:95%; margin:auto; max-width: 400px;'>""" out += """ <tr> <td width="70"><strong>%s</strong></td> <td style='color: black;'>%s</td> </tr> <tr> <td width="70"><strong>%s</strong></td> <td style='color: black;'>%s</td> </tr> <tr> <td width="70"><strong>%s</strong></td> <td style='color: black;'>%s</td> </tr> <tr> <td width="70"><strong>%s</strong></td> <td style='color: black;'>%s</td> </tr> """ % (_("Name"), borrower_name, _("Mailbox"), borrower_mailbox, _("Address"), borrower_address, _("Email"), borrower_email) out += """</table> <br />""" out += """<table style='color: #79d; font-size: 82%; width:95%; margin:auto; max-width: 400px;'>""" out += """ <tr> <td align="center"><h2><strong>%s: %s</strong></h2></td> </tr>""" % (_("Due date"), due_date) out += """</table>""" out += """<table style='color: #79d; font-size: 82%; width:95%; margin:auto; max-width: 800px;'> <tr> <td> <input type="button" onClick='window.print()' value='Print' style='color: #fff; background: #36c; font-weight: bold;'> </td> </tr> </table> """ req.write("<html>") req.write(out) req.write("</html>") return "\n"