<?php 
    
       require_once("../datos/mysqlticket.php");  
       $t = new mysqlticket();
       $ar = $t->GetReporteTransparencia();

       $profesionales ="<span>El Equipo  postventa al momento de la visita es :<span><br>";
       $prof = $t->getProfesional(trim($id_persona_responsable));
       for($i =0;$i<count($prof);$i++){
           $profesionales = $profesionales." ".$prof[$i]['NOMBRE']." ".$prof[$i]['APE_PATERNO']." ".$prof[$i]['APE_PATERNO']."</br>"; 
       }

    $tbody="";
        for($i =0;$i<count($ar);$i++){
            $tbody = $tbody."<tr><td><".$ar[$i]['Usuario']."<td>";
            $tbody = $tbody."<td><".$ar[$i]['PROYECTO']."<td>";
            $tbody = $tbody."<td><".$ar[$i]['0-7 pend']."<td>";
            $tbody = $tbody."<td><".$ar[$i]['7-14 pend']."<td>";
            $tbody = $tbody."<td><".$ar[$i]['15-30 pend']."<td>";
            $tbody = $tbody."<td><".$ar[$i]['30+ pend']."<td>";
            $tbody = $tbody."<td><".$ar[$i]['0-7 cat']."<td>";
            $tbody = $tbody."<td><".$ar[$i]['7-14 cat']."<td>";
            $tbody = $tbody."<td><".$ar[$i]['15-30 cat']."<td>";
            $tbody = $tbody."<td><".$ar[$i]['30+ cat']."<td>";
            $tbody = $tbody."<td><".$ar[$i]['0-7 días']."<td>";
            $tbody = $tbody."<td><".$ar[$i]['07-14 Días']."<td>";
            $tbody = $tbody."<td><".$ar[$i]['15-30 Días']."<td>";
            $tbody = $tbody."<td><".$ar[$i]['30+']."<td></tr>";
        }




        $cuerpo ="<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
        <html xmlns='http://www.w3.org/1999/xhtml'>
            <head>
                <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
                <meta name='viewport' content='width=device-width'/>
                <title>Modular Template Patterns</title>
                <style type='text/css'>
              body, #bodyTable, #bodyCell{height:100% !important; margin:0; padding:0; width:100% !important;}
              table{border-collapse:collapse;}
              img, a img{border:0; outline:none; text-decoration:none;}
              h1, h2, h3, h4, h5, h6{margin:0; padding:0;}
              p{margin: 1em 0;}
              .ReadMsgBody{width:100%;} .ExternalClass{width:100%;}
              table, td{mso-table-lspace:0pt; mso-table-rspace:0pt;}
              img{-ms-interpolation-mode: bicubic;} 
              body, table, td, p, a, li, blockquote{-ms-text-size-adjust:100%; -webkit-text-size-adjust:100%;} 
              .flexibleContainerCell{padding-top:20px; padding-Right:20px; padding-Left:20px;}
              .flexibleImage{height:auto;}
              .bottomShim{padding-bottom:20px;}
              .imageContent, .imageContentLast{padding-bottom:20px;}
              .nestedContainerCell{padding-top:20px; padding-Right:20px; padding-Left:20px;}
              body, #bodyTable{background-color:#F5F5F5;}
              #bodyCell{padding-top:40px; padding-bottom:40px;}
              #emailBody{background-color:#FFFFFF; border:1px solid #DDDDDD; border-collapse:separate; border-radius:4px;}
              h1, h2, h3, h4, h5, h6{color:#202020; font-family:Helvetica; font-size:20px; line-height:125%; text-align:Left;}
              .textContent, .textContentLast{color:#404040; font-family:Helvetica; font-size:16px; line-height:125%; text-align:Left; padding-bottom:20px;}
              .textContent a, .textContentLast a{color:#2C9AB7; text-decoration:underline;}
              .nestedContainer{background-color:#E5E5E5; border:1px solid #CCCCCC;}
                    .emailButton{background-color:#2C9AB7; border-collapse:separate; border-radius:4px;}
                  .buttonContent{color:#FFFFFF; font-family:Helvetica; font-size:18px; font-weight:bold; line-height:100%; padding:15px; text-align:center;}
              .buttonContent a{color:#FFFFFF; display:block; text-decoration:none;}
              .emailCalendar{background-color:#FFFFFF; border:1px solid #CCCCCC;}
              .emailCalendarMonth{background-color:#2C9AB7; color:#FFFFFF; font-family:Helvetica, Arial, sans-serif; font-size:16px; font-weight:bold; padding-top:10px; padding-bottom:10px; text-align:center;}
              .emailCalendarDay{color:#2C9AB7; font-family:Helvetica, Arial, sans-serif; font-size:60px; font-weight:bold; line-height:100%; padding-top:20px; padding-bottom:20px; text-align:center;}
              @media only screen and (max-width: 480px){      
                body{width:100% !important; min-width:100% !important;} /
                table[id='emailBody'], table[class='flexibleContainer']{width:100% !important;}
                img[class='flexibleImage']{height:auto !important; width:100% !important;}
                table[class='emailButton']{width:100% !important;}
                td[class='buttonContent']{padding:0 !important;}
                td[class='buttonContent'] a{padding:15px !important;}
                td[class='textContentLast'], td[class='imageContentLast']{padding-top:20px !important;}
                td[id='bodyCell']{padding-top:10px !important; padding-Right:10px !important; padding-Left:10px !important;}
              }
            </style>
            </head>
            <body>
              <center>
                 <div class='row'>
                    <div class='col-md-12'>
                    <table id='tablaReporte'  class='table  table-bordered responsive'>
                        <thead class="">
                        <tr>
                            <th class='text-center' colspan='2' >Datos</th>
                            <th class='text-center' colspan='4'>Atenciones pendientes por resolver</th>
                            <th class='text-center' colspan='4'>Por Categorizar</th>
                            <th class='text-center' colspan='4'>Horas Disponibles</th>
                        </tr>
                            <tr>
                                <th>Usuario</th>
                                <th>Proyecto</th>
                                <th>0-7</th>
                                <th>7-14</th>
                                <th>15-30</th>
                                <th>30+</th>
                                <th>0-7</th>
                                <th>7-14</th>
                                <th>15-30</th>
                                <th>30+</th>
                                <th>0-7</th>
                                <th>7-14</th>
                                <th>15-30</th>
                                <th>30+</th>
                            </tr>
                        </thead>
                        <tbody>".$tbody."
                    </tbody>
                    </table>
                    </div>
                </center>
            </body>
        </html>";

        include_once("class.phpmailer.php");
        include_once("class.smtp.php");
        $mail = new PHPMailer();
        $mail->IsSMTP();
        $mail->SMTPAuth = true;
           // if($host == "smtp.gmail.com"){
             // $mail->SMTPSecure = 'ssl';
           //}
        $mail->Host = "mail.itodoslossantos.cl";//$host; // SMTP a utilizar. Por ej. smtp.elserver.com
        $mail->Username = "postventa@itodoslossantos.cl";//strtolower($usuario); // Correo completo a utilizar
        $mail->Password ="VaiN3908";//$contrasena; // Contraseña
        $mail->Port = 26;//$puerto; // Puerto a utilizar
        $mail->From = "postventa@itodoslossantos.cl";//$remitente; // Desde donde enviamos (Para mostrar)
         if(trim($id_proyecto) == 19){
         $mail->FromName  = "Inmobiliaria CISS";
         }else{
    
            $mail->FromName  = "Inmobiliaria Todos los Santos";
        }
    
        $mail->AddAddress("postventa@vain-arm.cl");
        $mail->Subject ="Postventa";//'Titulo'; // Este es el titulo del email.
        foreach($list as $bccer){
            $mail->AddBCC($bccer);
        }
    
        $hu = $t->ListarCorreosGlobal();
        for($i =0;$i<count($hu);$i++){
            $mail->addCC($hu[$i]['CORREO']);
        }
    
        $mail->SMTPAutoTLS = true;
        $mail->SMTPOptions = array(
            'ssl' => array(
            'verify_peer' => false,
            'verify_peer_name' => false,
            'allow_self_signed' => true
        )
         );
        $mail->SMTPDebug = 2;
        $mail->Debugoutput = 'html';
        $mail->IsHTML(true); // El correo se envía como HTML
        $mail->Body = $cuerpo;//$contenido; // Mensaje a enviar
        if(!$mail->Send())
        {
           exit;
        }
?>