Viewing File: /home/cienp/public_html/portal/cron_agnd_pagm.php
<?php
require "includes/conecta.php";
function moeda($valor) {
$valor = str_replace(",", "", $valor);
$valor = number_format($valor, 2, ',', '.');
return $valor;
}
$dt_atua = date("d/m/Y");
$dt_pesq = date("Y-m-d");
$sql = "SELECT t.id_tipo_pagm, t.de_tipo_pagm, a.id_agnd_pagm, a.de_titl, a.vl_agnd, c.id_comp, c.nu_oc, f.nm_forn, ";
$sql .= "DATE_FORMAT(a.dt_agnd, '%d/%m/%Y') as dt_agn2 ";
$sql .= "FROM ".$pref_tabl."tipo_pagm t, ".$pref_tabl."agnd_pagm a, ".$pref_tabl."comp c, ".$pref_tabl."forn f ";
$sql .= "WHERE a.id_tipo_pagm = t.id_tipo_pagm ";
$sql .= "AND a.id_comp = c.id_comp ";
$sql .= "AND c.id_forn = f.id_forn ";
$sql .= "AND (a.dt_pagm IS NULL ";
$sql .= "OR a.dt_pagm = '0000-00-00') ";
$sql .= "AND a.dt_agnd = '$dt_pesq' ";
$sql .= "ORDER BY c.nu_oc ";
$res = mysqli_query($conn, $sql);
#echo $sql;
if (mysqli_num_rows($res) > 0) {
$mensagem = "
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"pt-BR\" lang=\"pt-BR\">
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
<style TYPE='text/css'>
A {text-decoration: none}
A:link {color:'#89211b';}
A:visited {color:'#89211b';}
A:hover {color:'#000000';}
</style>
</head>
<body>
<p align='left'><font color='#000000' size='2' face='Arial, Helvetica'>
Informamos que os pagamentos abaixo vencem no dia de hoje:<br><br>
<table cellspacing='0' cellpadding='0'>
<tr height='35' bgcolor='#b5b5b5'>
<td width='40' style='border: 1px solid #e7ecea; padding-left: 10px; padding-right: 10px; font-size: 16px; color: #FFF;'><b>OC/OS N°</b></td>
<td width='240' style='border: 1px solid #e7ecea; padding-left: 10px; padding-right: 10px; font-size: 16px; color: #FFF;'><b>Fornecedor</b></td>
<td width='240' style='border: 1px solid #e7ecea; padding-left: 10px; padding-right: 10px; font-size: 16px; color: #FFF;'><b>Título</b></td>
<td width='200' style='border: 1px solid #e7ecea; padding-left: 10px; padding-right: 10px; font-size: 16px; color: #FFF;'><b>Tipo de Pagamento</b></td>
<td width='90' style='border: 1px solid #e7ecea; padding-left: 10px; padding-right: 10px; font-size: 16px; color: #FFF;'><b>Valor</b></td>
</tr>
";
while ($linha = mysqli_fetch_array($res)) {
$linha['vl_agnd'] = moeda ($linha['vl_agnd']);
$mensagem .= "
<tr height='30' style='border: 1px solid #e7ecea;'>
<td style='border: 1px solid #e7ecea; padding-left: 10px; padding-right: 10px; font-size: 16px; color: #7f7f7f;'>$linha[nu_oc]</td>
<td style='border: 1px solid #e7ecea; padding-left: 10px; padding-right: 10px; font-size: 16px; color: #7f7f7f;'>$linha[nm_forn]</td>
<td style='border: 1px solid #e7ecea; padding-left: 10px; padding-right: 10px; font-size: 16px; color: #7f7f7f;'>$linha[de_titl]</td>
<td style='border: 1px solid #e7ecea; padding-left: 10px; padding-right: 10px; font-size: 16px; color: #7f7f7f;'>$linha[de_tipo_pagm]</td>
<td style='border: 1px solid #e7ecea; padding-left: 10px; padding-right: 10px; font-size: 16px; color: #7f7f7f;' align='right'>R$ $linha[vl_agnd]</td>
</tr>
";
}
$mensagem .= "
</table><br><br>
Atenciosamente,<br><br>
CIEnP<br>
Centro de Inovação e Ensaios Pré-Clínicos<br>
Setor de Compras
</font><br/></p>
</body>
</html>
";
$snap = "\n";
// $from = "atendimento@commix.com.br";
$from = "compras@cienp.org.br";
$boundary = "==Multipart_Boundary_x".md5(time())."x";
$body = stripslashes($mensagem);
// Criamos os cabeçalhos MIME utilizados para separar as partes da mensagem MIME
$html = "--".$boundary.$snap;
$html .= "Content-Transfer-Encoding: 8bits".$snap;
$html .= "Content-Type: text/html; charset=\"ISO-8859-1\"".$snap.$snap;
$html .= $body.$snap;
$html .= "--".$boundary."--";
// Adiciono os cabeçalhos de um arquivo anexado
$head = "MIME-Version: 1.0".$snap;
$head .= "From: $from".$snap;
$head .= "Return-Path: $from".$snap;
$head .= "Reply-to: $from".$snap;
$head .= "Bcc:gustavo.ciarallo@cienp.org.br,andre@commix.com.br".$snap;
$head .= "Content-type: multipart/alternative; boundary=\"{$boundary}\"".$snap;
$head .= $boundary.$snap;
// $to = 'andre@commix.com.br';
$to = 'financeiro@cienp.org.br';
$subject = "Agenda de Pagamentos - CIEnP";
$resmm = mail($to, $subject, $html, $head);
}
?>
Back to Directory
File Manager