def get_template_bory_email_horizontal():
    bory_horizontal = """
    <!DOCTYPE html>
    <html>

    <head>
        <style>
            body {
                margin: 0;
                padding: 50px;
            }

            table {
                font-family: arial, sans-serif;
                border-collapse: collapse;
                padding: 10px 15px;
                width: 100%;

            }

            td,
            th {
                border: 1px solid #dddddd;
                padding: 6px 6px 6px 0px;
                background-color: rgb(169, 169, 169);
                font-weight: bold;
            }

            /*@media screen and (min-width: 600px) {
                table{
                        width: 50% !important; 
                        height:auto !important;
                        min-width: 200px !important;  
                }
            }*/
    
        </style>
    </head>

    <body>
        <a href="http://www.trabin.com.br/">
            <img src="https://res.cloudinary.com/quotation-now/image/upload/v1570189494/trabin/TrabinLogo_edovf4.gif" alt="HTML tutorial" style="width:auto;height:auto;border:0;">
        </a>

        <h2>""" + get_date_auditit().strftime(
        "%d/%m/%Y") + """ - """ + get_weekday(
        ) + """<br>""" + get_config_company_name() + """
        </h2>

    <!--Tabela com as informações de monitoramento-->
        <table width=100%;> 
            <tr>

    """

    break_company = ''
    # Add primeira célula superior esquerda em branco
    bory_horizontal = bory_horizontal + '<th style="font-size: 16px; text-align: center;"><b>Empresas(TI)</b></th>'

    # GET online dos dados de monitoramento
    db_monitor = get_database_data_online(
        'Select * From monitora order by company,key')

    # Loop para montar o cabeçalho da tabela

    # Conta as colunas para expandir via tag=colspan a última célula destinada ao footer
    count_col = 1
    # Conta as empresas para impressão no footer
    count_col_company = 0
    for item in db_monitor:
        count_col = count_col + 1
        # split, transforma um string separada por vígula em uma lista
        # sptrip, retira os espaços em branco de ambos os lados
        s = item.split(',')
        company = s[1].strip()

        # Demais células referente aos títulos das colunas com os nomes das empresas
        if not break_company:
            bory_horizontal = bory_horizontal + '<td style="font-size: 16px; text-align: center;"><b>' + company + '</b></td>'
            count_col_company = count_col_company + 1
        elif break_company != company:
            bory_horizontal = bory_horizontal + '<td style="font-size: 16px; text-align: center;"><b>' + company + '</b></td>'
            count_col_company = count_col_company + 1
        break_company = company

    # GET online dos dados de monitoramento
    db_monitor = get_database_data_online(
        'Select * From monitora order by key,company')

    bory_horizontal = bory_horizontal + '</tr>'
    bory_horizontal = bory_horizontal + '<tr>'

    # Loop para montar o corpo da tabela
    color_step_key = 2
    color_step_value = 2
    break_info = ''
    for item in db_monitor:
        s = item.split(',')
        key = s[2].strip()
        value = s[3].strip()
        date = s[4].strip()
        if not break_info:
            bory_horizontal = bory_horizontal + '<td style="font-size: 16px; text-align: center; background-color: rgb(128, 128, 128);">' + key + '</td>'
        elif break_info != key:
            bory_horizontal = bory_horizontal + '</tr>'
            bory_horizontal = bory_horizontal + '<tr>'
            if color_step_key == 1:
                bory_horizontal = bory_horizontal + '<td style="font-size: 16px; text-align: center; background-color: rgb(128, 128, 128);">' + key + '</td>'
                color_step_key = 2
                color_step_value = 2
            else:
                bory_horizontal = bory_horizontal + '<td style="font-size: 16px; text-align: center; background-color: rgb(169, 169, 169);">' + key + '</td>'
                color_step_key = 1
                color_step_value = 1
        break_info = key

        if color_step_value == 1:
            bory_horizontal = bory_horizontal + str(
                alert_cell_diff(
                    origin='get_horizontal',
                    tag_html_atual=
                    '<td style="font-size: 16px; text-align: right; background-color: rgb(169, 169, 169);">',
                    date_data=value,
                    key_data=key)) + value + '</td>'
        else:
            bory_horizontal = bory_horizontal + str(
                alert_cell_diff(
                    origin='get_horizontal',
                    tag_html_atual=
                    '<td style="font-size: 16px; text-align: right; background-color: rgb(128, 128, 128);">',
                    date_data=value,
                    key_data=key)) + value + '</td>'

    bory_horizontal = bory_horizontal + """

    </tr>
        <tr style="text-align: center;">
        <td colspan=""" + str(
        count_col) + """ style="background-color: rgb(169, 169, 169);">
            <small>
                <div style="font-size: 18px;">Total de """ + str(
            count_col_company) + """ Empresas 
                </div>
            </small>
        </td>
    </tr>      

    </tr>
        <tr style="text-align: center;">
        <td colspan=""" + str(
                count_col) + """ style="background-color: rgb(128, 128, 128);">
            <small>
                <div>© 2019 Copyright:
                    <a href=""" + get_config_company_home(
                ) + """ style="color: rgb(46, 45, 45)">
                        """ + get_config_company_copyright() + """
                    </a>
                </div>

                <div>Tecnologias:
                    <a href="https://www.python.org/" style="color: rgb(46, 45, 45)">
                        Language Python -
                    </a>
                
                    <a href="https://www.elephantsql.com" style="color: rgb(46, 45, 45)">
                        PostgreSQL-ElephantSQL(AWS) - 
                    </a>

                    <a href="https://cloudinary.com/" style="color: rgb(46, 45, 45)">
                        Cloudnay-Picture Platform(CLOUD) - 
                    </a>
                    
                </div>
            </small>
        </td>
    </tr>      


    </table>

    </body>

    </html>
    """
    return bory_horizontal
示例#2
0
                      get_config_email_to, get_config_email_cc,
                      get_config_email_passwd, get_config_email_smtp,
                      get_config_email_port)
from py_email_bory import get_template_bory_email_horizontal, get_template_bory_email_vertical

# Envio do e-mail
contador = 0
while (contador < 2):
    contador = contador + 1
    if contador == 1:
        Subject_send = '(Dados)'
    else:
        Subject_send = '(Servidor)'

    msg = email.message.Message()
    msg['Subject'] = get_config_company_name() + Subject_send
    msg['From'] = get_config_email_from()
    msg['To'] = get_config_email_to()
    cc = get_config_email_cc()
    if cc:
        msg['Cc'] = cc
    password = get_config_email_passwd()
    msg.add_header('Content-Type', 'text/html')

    # Renderiza corpo do email em formato HORIZONTAL por empresa, ou seja, a empresa na linha
    #msg.set_payload(get_template_bory_email_horizontal())

    # Renderiza corpo do email em formato VERTICAL por empresa, ou seja, as empresas na coluna
    #msg.set_payload(get_template_bory_email_vertical(int(contador)))

    # Renderiza corpo do email em dois formatos, vertical e horinzontal por empresa