/scripts/send.mails.php
PHP | 429 lines | 338 code | 80 blank | 11 comment | 51 complexity | 5a77228902ce290a184452d0e30db547 MD5 | raw file
- <?php
- header('Content-type: text/html; charset=utf-8');
- include("class.phpmailer.php");
- include("../clases/framework-1.0/class.bd.php");
- include("../includes/funciones.php");
- // DATOS GG
- //
- // $mail->Host = "192.168.10.27"; // SMTP a utilizar. Por ej. smtp.elserver.com
- // $mail->Username = "gestionresponde"; // Correo completo a utilizar
- // $mail->Password = "Arwebs2020"; // Contraseña
- $case = $_GET['case'];
- function sendClientResp()
- {
- $email = htmlentities($_GET['email'], ENT_NOQUOTES, 'UTF-8');
- $ccT = htmlentities($_GET['cc'], ENT_NOQUOTES, 'UTF-8');
- $cc = htmlentities($_GET['cco'], ENT_NOQUOTES, 'UTF-8');
- $contenido = $_GET['contenido'];
- $content = replaceSpecialChar($contenido);
- $idTk = $_GET['id'];
- $type = "respuesta_cliente";
- $fecha = date('Y-m-d');
- $hora = date("H:i:s");
- $mail = new PHPMailer();
- $mail->IsSMTP();
- $mail->SMTPAuth = true;
- $mail->SMTPSecure = "TSL";
- $mail->Host = "192.168.10.27"; // SMTP a utilizar. Por ej. smtp.elserver.com
- $mail->Username = "gestionresponde"; // Correo completo a utilizar
- $mail->Password = "Arwebs2020"; // Contraseña
- $mail->Port = 25; // Puerto a utilizar
- $mail->From = "gestionresponde@grupo-gestion.com.ar"; // Desde donde enviamos (Para mostrar)
- $mail->FromName = "Grupo Gestion";
- if (!empty($email)) {
- $mail->AddAddress($email); // Esta es la dirección a donde enviamos
- }
- if (!empty($ccT)) {
- $mail->AddAddress($ccT); // Esta es la dirección a donde enviamos
- }
- if (!empty($cc)) {
- $mail->AddBCC($cc); // Copia
- }
- require_once("html.format.new.ticket.php");
- $mail->IsHTML(true); // El correo se envÃa como HTML
- $mail->Subject = "Grupo Gestion | Soporte | Respuesta"; // Este es el titulo del email.
- $mail->Body = html_entity_decode($body); // Mensaje a enviar
- $exito = $mail->Send(); // EnvÃa el correo.
- $queryC = "UPDATE all_tickets SET response_sended_to_client = 'S' WHERE id = $idTk";
- $cBD = new BD();
- if ($cBD->Ejecutar($queryC)) {
- echo "success UPDATE";
- }
- $queryB = "UPDATE all_tickets SET estado_id = '3' WHERE id = $idTk";
- $cBD = new BD();
- if ($cBD->Ejecutar($queryB)) {
- echo "success UPDATE State";
- }
- $queryA = "INSERT INTO responded_to_client (rtc_fecha, rtc_hora, rtc_id_ticket) VALUES (\"$fecha\",'$hora','$idTk')";
- $cBD = new BD();
- if ($cBD->Ejecutar($queryA)) {
- echo "Se actualizo fecha y hora de respuesta al cliente";
- }
- if ($exito) {
- $aviso = "1|Email Enviado!.";
- } else {
- $aviso = "0|Error de envio.";
- }
- echo ($aviso);
- }
- function newTicket()
- {
- $email = htmlentities($email, ENT_NOQUOTES, 'UTF-8');
- $nombreSol = $_GET['nomsolic'];
- $nroTicket = $_GET['id'];
- $status = $_GET["status"];
- $contenido = $_GET['contenido'];
- $type = "new_ticket";
- $content = "¡Su reclamo ha sido registrado con éxito! <br/><br/>
- A partir de este momento nos encontramos trabajando para darle una respuesta.<br/><br/>
- En caso de no recibirla, en el plazo de 24 horas, o que la misma no sea de su conformidad,<br/>
- comunicarse al 0810 - 666 - GESTION (4378466) con su número de reclamo.</br></br></br>
- ¡Muchas gracias!";
- $mail = new PHPMailer();
- $mail->IsSMTP();
- $mail->SMTPAuth = true;
- $mail->SMTPSecure = "TSL";
- $mail->Host = "192.168.10.27"; // SMTP a utilizar. Por ej. smtp.elserver.com
- $mail->Username = "gestionresponde"; // Correo completo a utilizar
- $mail->Password = "Arwebs2020"; // Contraseña
- $mail->Port = 25; // Puerto a utilizar
- $mail->From = "gestionresponde@grupo-gestion.com.ar"; // Desde donde enviamos (Para mostrar)
- $mail->FromName = "Grupo Gestion";
- $mail->AddAddress($email); // Esta es la dirección a donde enviamos
- include("html.format.new.ticket.php");
- $mail->IsHTML(true); // El correo se envÃa como HTML
- $mail->Subject = "[Ticket #" . $nroTicket . "] Gestion Laboral"; // Este es el titulo del email.
- // $body = "Su reclamo ha sido procesado. Recibirá una respuesta a la brevedad.<br/><br/> Muchas gracias por contactarse con Grupo Gestión.<br/><br/>";
- $mail->Body = html_entity_decode($body); // Mensaje a enviar
- $exito = $mail->Send(); // EnvÃa el correo.
- if ($exito) {
- $aviso = "1|Email Enviado!.";
- } else {
- $aviso = "0|Error de envio.";
- }
- newTicketSucResp();
- }
- function newTicketSucResp()
- {
- $cc = htmlentities($_GET['cc'], ENT_NOQUOTES, 'UTF-8');
- $cco = htmlentities($_GET['cco'], ENT_NOQUOTES, 'UTF-8');
- $eSucursal = htmlentities($_GET['eSucursal'], ENT_NOQUOTES, 'UTF-8');
- // $eResponsable = htmlentities($_GET['eResponsable'], ENT_NOQUOTES, 'UTF-8');
- $eResponsable = str_replace("ñ", "n", $_GET['eResponsable']);
- $eResponsable = str_replace("Ñ", "N", $eResponsable);
- $nroTicket = $_GET['id'];
- $contenido = $_GET['contenido'];
- $nombreSol = $_GET['nomsolic'];
- // var_dump($contenido);
- $tipo_usuario = $_GET['tipo_usuario'];
- switch ($tipo_usuario) {
- case 1:
- $tipo_usuario = "Postulante";
- break;
- case 2:
- $tipo_usuario = "Usuaria";
- break;
- case 3: $tipo_usuario = "Colaborador";
- $dni = $_GET["dniColab"];
- break;
- default : $tipo_usuario = "tipo_usuario";
- }
- $created_by = $_SESSION["usuario"];
- $mail = new PHPMailer();
- $mail->IsSMTP();
- $mail->SMTPAuth = true;
- $mail->SMTPSecure = "TSL";
- $mail->Host = "192.168.10.27"; // SMTP a utilizar. Por ej. smtp.elserver.com
- $mail->Username = "gestionresponde"; // Correo completo a utilizar
- $mail->Password = "Arwebs2020"; // Contraseña
- $mail->Port = 25; // Puerto a utilizar
- $mail->From = "gestionresponde@grupo-gestion.com.ar"; // Desde donde enviamos (Para mostrar)
- $mail->FromName = "Grupo Gestion";
- if ($eSucursal != "") {
- $mail->AddAddress($eSucursal); // Esta es la dirección a donde enviamos
- }
- if ($eResponsable != "") {
- $mail->AddCC($eResponsable);
- }
- if ($cc != "") {
- $mail->AddCC($cc); // Copia
- }
- if ($cco != "") {
- $mail->AddBCC($cco); // Copia
- }
- $mail->IsHTML(true); // El correo se envÃa como HTML
- $mail->Subject = "[Ticket #" . $nroTicket . "] | $nombreSol | " . date('d-m-Y H:i:s'); // Este es el titulo del email.
- $type = "sucresp";
- include("html.format.new.ticket.php");
- $mail->Body = html_entity_decode($body); // Mensaje a enviar
- $mail->CharSet = 'UTF-8';
- $exito = $mail->Send(); // EnvÃa el correo.
- if ($exito) {
- $aviso = "1|Email Enviado!.";
- } else {
- $aviso = "0|Error de envio.";
- }
- echo ($aviso);
- }
- function editTicket()
- {
- $cc = htmlentities($_GET['cc'], ENT_NOQUOTES, 'UTF-8');
- $cco = htmlentities($_GET['cco'], ENT_NOQUOTES, 'UTF-8');
- $eSucursal = htmlentities($_GET['eSucursal'], ENT_NOQUOTES, 'UTF-8');
- $eResponsable = htmlentities($_GET['eResponsable'], ENT_NOQUOTES, 'UTF-8');
- $nroTicket = $_GET['id'];
- $contenido = $_GET['contenido'];
- $tipo_usuario = $_GET['tipo_usuario'];
- switch ($tipo_usuario) {
- case 1:
- $tipo_usuario = "Postulante";
- break;
- case 2:
- $tipo_usuario = "Usuaria";
- break;
- case 3: $tipo_usuario = "Colaborador";
- break;
- default : $tipo_usuario = "tipo_usuario";
- }
- $created_by = $_SESSION["usuario"];
- $mail = new PHPMailer();
- $mail->IsSMTP();
- $mail->SMTPAuth = true;
- $mail->SMTPSecure = "TSL";
- $mail->Host = "192.168.10.27"; // SMTP a utilizar. Por ej. smtp.elserver.com
- $mail->Username = "gestionresponde"; // Correo completo a utilizar
- $mail->Password = "Arwebs2020"; // Contraseña
- $mail->Port = 25; // Puerto a utilizar
- $mail->From = "gestionresponde@grupo-gestion.com.ar"; // Desde donde enviamos (Para mostrar)
- $mail->FromName = "Grupo Gestion";
- $mail->AddAddress($eSucursal); // Esta es la dirección a donde enviamos
- $mail->AddCC($eResponsable);
- if ($cc != "") {
- $mail->AddCC($cc); // Copia
- }
- if ($cco != "") {
- $mail->AddBCC($cco); // Copia
- }
- $mail->IsHTML(true); // El correo se envÃa como HTML
- $mail->Subject = "Gestion.Ar | Ticket Cargado"; // Este es el titulo del email.
- $body = "El usuario $created_by ha cargado un nuevo Ticket para " . strtoupper($tipo_usuario) . " con el Nro $nroTicket <br/><br/>";
- $body .= "Contenido del Ticket: $contenido <br/><br/>";
- $body .= "Enlace al Ticket: http://www.grupo-gestion.com.ar/gestion.ar/?redirect=tickets.edit.php?id=$nroTicket<br/><br/>";
- $mail->Body = html_entity_decode($body); // Mensaje a enviar
- $exito = $mail->Send(); // EnvÃa el correo.
- if ($exito) {
- $aviso = "1|Email Enviado!.";
- } else {
- $aviso = "0|Error de envio.";
- }
- exit($aviso);
- }
- function sendMailRecoverPass()
- {
- $email = $_GET['email'];
- $queryCheck = "SELECT MEmpEmail, passwords.password as MEmpClave FROM miembroempresa
- LEFT JOIN passwords ON miembroempresa.PerNro = passwords.user_id
- WHERE MEmpEmail = '$email'";
- $cBD = new BD();
- $oRegistro = $cBD->Seleccionar($queryCheck);
- while ($aRegistro = $cBD->RetornarFila($oRegistro)) {
- $email_sql = $aRegistro['MEmpEmail'];
- $clave_sql = $aRegistro['MEmpClave'];
- }
- if ($email_sql == $email) {
- $mail = new PHPMailer();
- $mail->IsSMTP();
- $mail->SMTPAuth = true;
- $mail->SMTPSecure = "TSL";
- $mail->Host = "192.168.10.27"; // SMTP a utilizar. Por ej. smtp.elserver.com
- $mail->Username = "gestionresponde"; // Correo completo a utilizar
- $mail->Password = "Arwebs2020"; // Contraseña
- $mail->Port = 25; // Puerto a utilizar
- $mail->From = "gestionresponde@grupo-gestion.com.ar"; // Desde donde enviamos (Para mostrar)
- $mail->FromName = "Grupo Gestion";
- $mail->AddAddress($email_sql); // Esta es la dirección a donde enviamos
- $mail->IsHTML(true); // El correo se envÃa como HTML
- $mail->Subject = "Grupo Gestion | Soporte | Recuperar Clave"; // Este es el titulo del email.
- $body = "Su clave es:<br/>" . $clave_sql . "<br/><br/>";
- $mail->Body = html_entity_decode($body); // Mensaje a enviar
- $exito = $mail->Send(); // EnvÃa el correo.
- if ($exito) {
- $aviso = "Se ha enviado un Mensaje a su casilla de correo.";
- } else {
- $aviso = "Hubo un inconveniente en el envio del Correo. Vuelva a intentar nuevamente más tarde. Disculpe las molestias.";
- }
- } else {
- $aviso = "El Correo no se encuentra registrado en nuestro sistema.";
- }
- exit($aviso);
- }
- function sendMailsupervisor()
- {
- $nombreSol = utf8_decode($_GET["nomsolic"]);
- $nroTicket = $_GET["id"];
- $forWho = $_GET["status"];
- $respuesta = $_GET["contenido"];
- $mail = new PHPMailer();
- $mail->IsSMTP();
- $mail->SMTPAuth = true;
- $mail->SMTPSecure = "TSL";
- $mail->Host = "192.168.10.27"; // SMTP a utilizar. Por ej. smtp.elserver.com
- $mail->Username = "gestionresponde"; // Correo completo a utilizar
- $mail->Password = "Arwebs2020"; // Contraseña
- $mail->Port = 25; // Puerto a utilizar
- $mail->From = "gestionresponde@grupo-gestion.com.ar"; // Desde donde enviamos (Para mostrar)
- $mail->FromName = "Grupo Gestion";
- $mail->AddAddress('administracioncomercial@grupo-gestion.com.ar');
- // $mail->AddAddress('ulopez@arwebs.net');
- if ($forWho != "admin") {
- $sql = "SELECT MEmpEmail FROM miembroempresa me ";
- $sql.= " LEFT JOIN user_type ON me.PerNro = user_type.idusuario ";
- $sql.= " LEFT JOIN tipomiembro ON user_type.tipo_id = TMiembNro ";
- $sql.= " WHERE user_type.tipo_id = 7";
- $cBD = new BD();
- $oRegistro = $cBD->Seleccionar($sql);
- while ($aRegistro = $cBD->RetornarFila($oRegistro)) {
- if (!empty($aRegistro["MEmpEmail"])) {
- $mail->AddBCC($aRegistro["MEmpEmail"]); // Esta es la dirección a donde enviamos
- }
- }
- $type = "supervisor";
- } else {
- $type = "supervisoradmin";
- }
- include("html.format.new.ticket.php");
- $mail->IsHTML(true); // El correo se envÃa como HTML
- $mail->Subject = "Grupo Gestion | Respuesta a Ticket Nro #$nroTicket | Generada por $nombreSol"; // Este es el titulo del email.
- $mail->Body = html_entity_decode($body); // Mensaje a enviar
- $exito = $mail->Send(); // EnvÃa el correo.
- if ($exito) {
- $aviso = "Se ha enviado un correo a todos los supervisores para que autoricen la respuesta.";
- } else {
- $aviso = "Hubo un inconveniente en el envio del Correo. ";
- }
- // sendMailsupervisorAdmin($nombreSol, $nroTicket, $respuesta);
- exit($aviso);
- }
- function sendMailsupervisorAdmin($nmSol, $nTick, $resp)
- {
- $nombreSol = $nmSol;
- $nroTicket = $nTick;
- $respuesta = $resp;
- $mail = new PHPMailer();
- $mail->IsSMTP();
- $mail->SMTPAuth = true;
- $mail->SMTPSecure = "TSL";
- $mail->Host = "192.168.10.27"; // SMTP a utilizar. Por ej. smtp.elserver.com
- $mail->Username = "gestionresponde"; // Correo completo a utilizar
- $mail->Password = "Arwebs2020"; // Contraseña
- $mail->Port = 25; // Puerto a utilizar
- $mail->From = "gestionresponde@grupo-gestion.com.ar"; // Desde donde enviamos (Para mostrar)
- $mail->FromName = "Grupo Gestion";
- $mail->AddAddress('administracioncomercial@grupo-gestion.com.ar');
- // $mail->AddAddress('ulopez@arwebs.net');
- $type = "supervisoradmin";
- include("html.format.new.ticket.php");
- $mail->IsHTML(true); // El correo se envÃa como HTML
- $mail->Subject = "Grupo Gestion | Respuesta a Ticket Nro #$nroTicket | Generada por $nombreSol"; // Este es el titulo del email.
- $mail->Body = html_entity_decode($body); // Mensaje a enviar
- $exito = $mail->Send(); // EnvÃa el correo.
- if ($exito) {
- $aviso = "Se ha enviado un correo a todos los supervisores para que autoricen la respuesta.";
- } else {
- $aviso = "Hubo un inconveniente en el envio del Correo. ";
- }
- exit($aviso);
- }
- if ($case == "sendClientResp") {
- sendClientResp();
- }
- if ($case == "newTicket") {
- newTicket();
- }
- if ($case == "recoverpass") {
- sendMailRecoverPass();
- }
- if ($case == "sendsupervisor") {
- sendMailsupervisor();
- }
- ?>