Viewing file: processaNewsletter.php (14.9 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
//set_time_limit(360);
/*ini_set('display_errors',1);
ini_set('display_startup_erros',1);
error_reporting(E_ALL);*/
//ini_set('memory_limit', '256M');
require_once("../core/config.php");
require_once(APP_PATH . "/cms/restritoIPanel.php");
require_once(APP_PATH . "/cms/IPanelForm.php");
require_once(APP_PATH . "/cms/IPanelApp.php");
require_once(APP_PATH . "/cms/IPanelConfig.php");
require_once(APP_PATH . "/cms/IPanelMenu.php");
require_once(APP_PATH . "/system/FileUpload.php");
require_once(APP_PATH . "/controller/GenericCtrl.php");
require_once(APP_PATH . "/model/Foto.php");
require_once(APP_PATH . "/model/Contato.php");
require_once(APP_PATH . "/util/Util.php");
require_once(APP_PATH . "/util/Data.php");
require_once(APP_PATH . "/system/email/Email.php");
$util = new Util();
$data = new Data();
if ($_GET['action'] != "Logoff") {
$config = new IPanelConfig($_GET['lc']);
$form = new IPanelForm();
$form->setArea($_GET['lc']);
$form->setConfig($config);
$ipanel = new IPanelApp();
$ipanel->setArea($_GET['lc']);
$ipanel->setConfig();
$menu = new IPanelMenu();
$control = new GenericCtrl($_GET['lc']);
if ($_POST['action'] == "Form") {
$object = $form->saveFormDataToObject($_POST, $_FILES);
if ($_POST['id'] != "") {
if ($object->replace()) {
$objectId = $object->id;
} else {
$object->save();
$objectId = $control->getLastId();
}
} else {
$object->save();
$objectId = $control->getLastId();
}
$hasrecorte = false;
$fileUpload = new FileUpload();
$uploadFolder = $ipanel->getConfig()->getParameter("uploads.folder");
if ($ipanel->getConfig()->getParameter("images") != null) {
$hasRecorte = true;
}
if ($uploadFolder != null && $uploadFolder != "") {
foreach ($ipanel->getConfig()->getFields() as $fields) {
foreach ($fields as $field => $value) {
if ($value['type'] == "image" || $value['type'] == "file") {
if (!empty($_FILES[$field]['name'])) {
$fileUpload->width = 2500;
$fileUpload->height = 2500;
$fileUpload->resize = true;
$fileUpload->upload($_FILES[$field]['tmp_name'], $uploadFolder, $objectId, $object[$field]);
if ($value['type'] == "image" && $hasRecorte) {
$showLayerRecorte = true;
}
}
}
}
}
}
$caminhoAnexo = "http://www.arpenpr.org.br/site/ipanel/uploads/newsletter/".$objectId."/";
$msg = '';
$msg.= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
$msg.= '<html xmlns="http://www.w3.org/1999/xhtml">';
$msg.= '<head>';
$msg.= '<meta name="viewport" content="width=device-width" />';
$msg.= '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
$msg.= '<title>IRPEN | Instituto de Registro Civil de Pessoas Naturais do Paraná</title>';
$msg.= '<link rel="stylesheet" type="text/css" href="http://arpenpr.org.br/site/assets/css/email.css" />';
$msg.= '</head>';
$msg.= '<body bgcolor="#FFFFFF">';
$msg.= '<table class="head-wrap" bgcolor="#094162">';
$msg.= '<tr>';
$msg.= '<td></td>';
$msg.= '<td class="header container">';
$msg.= '<div class="content">';
$msg.= '<table bgcolor="#094162">';
$msg.= '<tr>';
$msg.= '<td><img src="http://www.arpenpr.org.br/site/images/logo.jpg" /></td>';
$msg.= '<td align="right"><h6 class="collapse" style="color:#fff">IRPEN | </h6></td>';
$msg.= '</tr>';
$msg.= '</table>';
$msg.= '</div>';
$msg.= '</td>';
$msg.= '<td></td>';
$msg.= '</tr>';
$msg.= '</table>';
$msg.= '<table class="body-wrap">';
$msg.= '<tr>';
$msg.= '<td></td>';
$msg.= '<td class="container" bgcolor="#FFFFFF">';
$msg.= '<div class="content">';
$msg.= '<table>';
$msg.= '<tr>';
$msg.= '<td>';
$msg.= '<h3>'. $object['titulo'] .'</h3>';
$msg.= '<p class="lead">'. $object['conteudo'] .'</p>';
if ($object['anexo01'] != "" || $object['anexo02'] != "" || $object['anexo03'] != "") {
$msg.= '<p class="callout">';
$msg.= 'Esta mensagem possui anexos: <br/><br/>';
if ($object['anexo01'] != "") {
$msg.= '<a href="'. $caminhoAnexo."/". $object['anexo01'] .'">Baixar Anexo 01 »</a><br/>';
}
if ($object['anexo02'] != "") {
$msg.= '<a href="'. $caminhoAnexo."/". $object['anexo02'] .'">Baixar Anexo 02 »</a><br/>';
}
if ($object['anexo03'] != "") {
$msg.= '<a href="'. $caminhoAnexo."/". $object['anexo03'] .'">Baixar Anexo 03 »</a><br/>';
}
$msg.= '</p>';
}
$msg.= '<br/><br/> ';
$msg.= '<table class="social" width="100%">';
$msg.= '<tr>';
$msg.= '<td>';
$msg.= '<table align="left" class="column">';
$msg.= '<tr>';
$msg.= '<td> ';
$msg.= '<h5 class="">Contatos Sociais:</h5>';
$msg.= '<p class="">';
$msg.= '<a href="https://www.facebook.com/irpenpr" class="soc-btn fb">Facebook</a> ';
$msg.= '<a href="https://twitter.com/irpenpr" class="soc-btn tw">Twitter</a> ';
$msg.= '</p>';
$msg.= '</td>';
$msg.= '</tr>';
$msg.= '</table> ';
$msg.= '<table align="left" class="column">';
$msg.= '<tr>';
$msg.= '<td> ';
$msg.= '<h5 class="">Contato:</h5> ';
$msg.= '<p>';
$msg.= 'Fone: <strong>(41) 3232-9811</strong><br/>';
$msg.= 'E-mail: <strong><a href="emailto:comunicacao@arpenpr.org.br">comunicacao@arpenpr.org.br</a></strong>';
$msg.= '</p>';
$msg.= '</td>';
$msg.= '</tr>';
$msg.= '</table>';
$msg.= '<span class="clear"></span> ';
$msg.= '</td>';
$msg.= '</tr>';
$msg.= '</table>';
$msg.= '</td>';
$msg.= '</tr>';
$msg.= '</table>';
$msg.= '</div>';
$msg.= '</td>';
$msg.= '<td></td>';
$msg.= '</tr>';
$msg.= '</table>';
$msg.= '</body>';
$msg.= '</html>';
$headers = "From: IRPEN | Instituto de Registro Civil de Pessoas Naturais do Parana<contato@arpenpr.org.br>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1\n";
// buscas dos cartorios os quais devem receber o e-mail
if ($object['tipoEnvio'] == "T") {
$contatoCtrl = new GenericCtrl("Contato");
$contatos = $contatoCtrl->getAllObjects();
foreach ($contatos as $contato) {
if ($contato['tabeliao'] == "S" &&
$contato['descricao'] != "DESATIVADO" &&
$contato['ativoSn'] == "S" &&
$contato['email'] != "email@anoregpr.org.br") {
//echo $contato['email']."<br/>";
if ($contato['email'] != "") {
mail($contato['email'], $object['titulo'], $msg, $headers);
}
if ($contato['email2'] != "") {
mail($contato['email2'], $object['titulo'], $msg, $headers);
}
}
}
}
if ($object['tipoEnvio'] == "A") {
$ids = "";
$oficioCtrl = new GenericCtrl("Oficio");
$oficios = $oficioCtrl->getAllObjects();
foreach ($oficios as $oficio) {
if ($oficio['ativoSn'] == "S" &&
$oficio['contato']['ativoSn'] == "S" &&
$oficio['contato']['associadoSn'] == "S" &&
$oficio['contato']['descricao'] != "DESATIVADO") {
$ids.= $oficio['id']."|";
if ($oficio['contato']['email'] != "") {
mail($oficio['contato']['email'], $object['titulo'], $msg, $headers);
}
if ($oficio['contato']['email2'] != "") {
mail($oficio['contato']['email2'], $object['titulo'], $msg, $headers);
}
}
}
$newsCtrl = new GenericCtrl("Newsletter");
$news = $newsCtrl->getObject($objectId);
$news['destinatarios'] = $ids;
$news->save();
}
if ($object['tipoEnvio'] == "N") {
$ids = "";
$oficioCtrl = new GenericCtrl("Oficio");
$oficios = $oficioCtrl->getAllObjects();
foreach ($oficios as $oficio) {
if ($oficio['ativoSn'] == "S" &&
$oficio['contato']['ativoSn'] == "S" &&
$oficio['contato']['associadoSn'] == "N" &&
$oficio['contato']['descricao'] != "DESATIVADO") {
$ids.= $oficio['id']."|";
if ($oficio['contato']['email'] != "") {
mail($oficio['contato']['email'], $object['titulo'], $msg, $headers);
}
if ($oficio['contato']['email2'] != "") {
mail($oficio['contato']['email2'], $object['titulo'], $msg, $headers);
}
}
}
$newsCtrl = new GenericCtrl("Newsletter");
$news = $newsCtrl->getObject($objectId);
$news['destinatarios'] = $ids;
$news->save();
}
if ($object['tipoEnvio'] == "E") {
$ids = "";
$oficioCtrl = new GenericCtrl("Oficio");
foreach ($_POST['cboDestinatarios'] as $selecionado) {
$oficio = $oficioCtrl->getObject($selecionado);
$ids.= $oficio['id']."|";
if ($oficio['contato']['email'] != "") {
mail($oficio['contato']['email'], $object['titulo'], $msg, $headers);
}
if ($oficio['contato']['email2'] != "") {
mail($oficio['contato']['email2'], $object['titulo'], $msg, $headers);
}
}
$newsCtrl = new GenericCtrl("Newsletter");
$news = $newsCtrl->getObject($objectId);
$news['destinatarios'] = $ids;
$news->save();
}
if ($object['tipoEnvio'] == "RC" || empty($object['tipoEnvio'])) {
mail("joao.santos@mirasistemas.com.br", $object['titulo'], $msg, $headers);
mail("irpen@mirasistemas.com.br",$object['titulo'], $msg, $headers);
mail("contato@arpenpr.org.br",$object['titulo'], $msg, $headers);
mail("atendimento2@arpenpr.org.br",$object['titulo'], $msg, $headers);
mail("eventos@arpenpr.org.br",$object['titulo'], $msg, $headers);
mail("joao.santos@mirasistemas.com.br",$object['titulo'], $msg, $headers);
$contatoCtrl = new GenericCtrl("Contato");
$contatos = $contatoCtrl->getAllRCPNS();
foreach ($contatos as $contato) {
if ($contato['email'] != "") {
mail($contato['email'], $object['titulo'], $msg, $headers);
}
if ($contato['email2'] != "") {
mail($contato['email2'], $object['titulo'], $msg, $headers);
}
}
}
$url = "../../view/?lc=" . $_GET['lc'];
header("Location:" . $url . "&md=Lista&stp=" . time());
}
}
?>
|