Viewing file: dt_colaenvio.php (7.24 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php ini_set("memory_limit","256M"); class dt_colaenvio extends toba_datos_tabla { # Retorna solo los que no han sido enviados, a menos que se indique expresamente incluirlos en el parametro function get_listado($filtro=array()) { $where = array(); if (isset($filtro['fromemail'])) { $where[] = "t_c.fromemail ILIKE ".quote("%{$filtro['fromemail']}%"); } if (isset($filtro['subjet'])) { $where[] = "t_c.subjet ILIKE ".quote("%{$filtro['subjet']}%"); } if (isset($filtro['mail_address'])) { $where[] = "t_c.mail_address ILIKE ".quote("%{$filtro['mail_address']}%"); } if (isset($filtro['abierto'])) { $where[] = "t_c.abierto= ".quote($filtro['abierto']); } if (isset($filtro['incluir_enviados'])) { if ($filtro['incluir_enviados'] == true) { $where[] = "t_c.enviado = '1'"; }else{ $where[] = "t_c.enviado = '0'"; //aca se excluye a los enviados por defecto } #}else{ # $where[] = "t_c.enviado = '0'"; //aca se excluye a los enviados por defecto } if (isset($filtro['fecha_desde'])) { list($y,$m,$d)=explode("-",$filtro['fecha_desde']); //2011-03-31 $fecha_desde = $y."-".$m."-".$d; $where[] = "t_c.fecha_envio >= ".quote($fecha_desde); } if (isset($filtro['fecha_hasta'])) { list($y,$m,$d)=explode("-",$filtro['fecha_hasta']); //2011-03-31 $d=$d+1; $fecha_hasta = $y."-".$m."-".$d; $where[] = "t_c.fecha_envio < ".quote($fecha_hasta); } if (isset($filtro['envios_maximo'])) { $limit = " limit ".$filtro['envios_maximo']; }else{ $limit = ''; } $sql = "SELECT t_c.id_colaenvio, t_c.host, t_c.port, t_c.fromemail, t_c.fromname, t_c.timeout, t_c.mailer, t_c.username, t_c.pass, t_c.smtpauth, t_c.subjet, t_c.body, t_c.body_text, t_c.attached1, t_c.attached2, t_c.attached3, t_c.mail_address, t_c.fecha_alta, t_c.smtpsecure, t_c.fecha_envio, t_c.enviado, t_c.abierto, t_c.fecha_abierto, t_c.replyto, t_c.helo, t_con.usuario, t_con.nombre, t_con.telefono FROM colaenvio as t_c left outer join desarrollo.apex_usuario as t_con on (t_con.usuario = t_c.mail_address) ORDER BY id_colaenvio DESC $limit"; if (count($where)>0) { $sql = sql_concatenar_where($sql, $where); } return toba::db('tdfonline')->consultar($sql); } function get_mensaje_colaenvio($id_colaenvio) { $sql = "SELECT t_c.id_colaenvio, t_c.host, t_c.port, t_c.fromemail, t_c.fromname, t_c.timeout, t_c.mailer, t_c.username, t_c.pass, t_c.smtpauth, t_c.subjet, t_c.body, t_c.body_text, t_c.attached1, t_c.attached2, t_c.attached3, t_c.mail_address, t_c.fecha_alta, t_c.smtpsecure, t_c.fecha_envio, t_c.enviado, t_c.abierto, t_c.fecha_abierto, t_c.replyto, t_c.helo FROM colaenvio as t_c WHERE t_c.id_colaenvio = '$id_colaenvio'"; return toba::db('tdfonline')->consultar_fila($sql); }
function insertar_mensaje($mensaje,$contactos,$correo_envio) { $host = $correo_envio['host']; $port = $correo_envio['port']; $fromemail = $correo_envio['fromemail']; $replyto = $correo_envio['replyto']; $fromname = $correo_envio['fromname']; $timeout = $correo_envio['timeout']; $mailer = $correo_envio['mailer']; $username = $correo_envio['username']; $pass = $correo_envio['pass']; $smtpauth = $correo_envio['smtpauth']; $smtpsecure = $correo_envio['smtpsecure']; $helo = $correo_envio['helo']; $subjet = $correo_envio['subjet']; $body = $mensaje['body']; $body_text = $mensaje['bodytext']; #$attached1 = $mensaje['attached1']; #$attached2 = $mensaje['attached2']; #$attached3 = $mensaje['attached3']; //Seteo contador de correos a cola en cero $cont = 0; //Cargo correo por cada contacto NUEVO if(count($contactos)>0){ foreach ($contactos as $contacto){ $mail_address = $contacto['usuario']; //Reemplazo body con el nombre si es que hay bandera NOMBRE_CONTACTO /* $nombre = $contacto['nombre']; $trans = array("ID_CONTACTO" => $idcontacto, "NOMBRE_CONTACTO" => $nombre); $body_final = strtr($body, $trans); $body_text_final = strtr($body_text, $trans); */ //Inserto $sql="INSERT INTO colaenvio(host, port, fromemail, replyto, fromname, timeout, mailer, username, pass, smtpauth, smtpsecure, subjet, body, body_text, attached1, attached2, attached3, mail_address, fecha_alta, helo, enviado) VALUES ('$host','$port','$fromemail', '$replyto', '$fromname','$timeout','$mailer', '$username','$pass','$smtpauth','$smtpsecure','$subjet','$body','$body_text','$attached1','$attached2','$attached3','$mail_address','".date('Y-m-d H:i:s')."', '$helo', '0')"; toba::db('tdfonline')->ejecutar($sql); //Incremento contador $cont++; } } //Retorna candtidad de correos agregados a la cola de envio return $cont; }
function set_enviado($idcolaenvio){ //----- Obtengo datos necesarios ------------------------------------------------------------ $sql = "UPDATE colaenvio SET enviado = '1', fecha_envio = '".date("Y-m-d H:i:s")."' WHERE id_colaenvio = '".$idcolaenvio."'"; toba::db('tdfonline')->ejecutar($sql); } function set_abierto($idcolaenvio){ //----- Obtengo datos necesarios ------------------------------------------------------------ $sql = "UPDATE colaenvio SET abierto = '1', fecha_abierto = '".date("Y-m-d H:i:s")."' WHERE id_colaenvio = '".$idcolaenvio."'"; toba::db('tdfonline')->ejecutar($sql); } function eliminar_colaenvio($idcolaenvio){ $sql = "DELETE FROM colaenvio WHERE id_colaenvio = '".$id_colaenvio."'"; return toba::db('tdfonline')->ejecutar($sql); }
} ?>
|