PageRenderTime 25ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/scripts/send.mails.php

https://bitbucket.org/elulice/gestionar
PHP | 429 lines | 338 code | 80 blank | 11 comment | 51 complexity | 5a77228902ce290a184452d0e30db547 MD5 | raw file
  1. <?php
  2. header('Content-type: text/html; charset=utf-8');
  3. include("class.phpmailer.php");
  4. include("../clases/framework-1.0/class.bd.php");
  5. include("../includes/funciones.php");
  6. // DATOS GG
  7. //
  8. // $mail->Host = "192.168.10.27"; // SMTP a utilizar. Por ej. smtp.elserver.com
  9. // $mail->Username = "gestionresponde"; // Correo completo a utilizar
  10. // $mail->Password = "Arwebs2020"; // Contraseña
  11. $case = $_GET['case'];
  12. function sendClientResp()
  13. {
  14. $email = htmlentities($_GET['email'], ENT_NOQUOTES, 'UTF-8');
  15. $ccT = htmlentities($_GET['cc'], ENT_NOQUOTES, 'UTF-8');
  16. $cc = htmlentities($_GET['cco'], ENT_NOQUOTES, 'UTF-8');
  17. $contenido = $_GET['contenido'];
  18. $content = replaceSpecialChar($contenido);
  19. $idTk = $_GET['id'];
  20. $type = "respuesta_cliente";
  21. $fecha = date('Y-m-d');
  22. $hora = date("H:i:s");
  23. $mail = new PHPMailer();
  24. $mail->IsSMTP();
  25. $mail->SMTPAuth = true;
  26. $mail->SMTPSecure = "TSL";
  27. $mail->Host = "192.168.10.27"; // SMTP a utilizar. Por ej. smtp.elserver.com
  28. $mail->Username = "gestionresponde"; // Correo completo a utilizar
  29. $mail->Password = "Arwebs2020"; // Contraseña
  30. $mail->Port = 25; // Puerto a utilizar
  31. $mail->From = "gestionresponde@grupo-gestion.com.ar"; // Desde donde enviamos (Para mostrar)
  32. $mail->FromName = "Grupo Gestion";
  33. if (!empty($email)) {
  34. $mail->AddAddress($email); // Esta es la dirección a donde enviamos
  35. }
  36. if (!empty($ccT)) {
  37. $mail->AddAddress($ccT); // Esta es la dirección a donde enviamos
  38. }
  39. if (!empty($cc)) {
  40. $mail->AddBCC($cc); // Copia
  41. }
  42. require_once("html.format.new.ticket.php");
  43. $mail->IsHTML(true); // El correo se envía como HTML
  44. $mail->Subject = "Grupo Gestion | Soporte | Respuesta"; // Este es el titulo del email.
  45. $mail->Body = html_entity_decode($body); // Mensaje a enviar
  46. $exito = $mail->Send(); // Envía el correo.
  47. $queryC = "UPDATE all_tickets SET response_sended_to_client = 'S' WHERE id = $idTk";
  48. $cBD = new BD();
  49. if ($cBD->Ejecutar($queryC)) {
  50. echo "success UPDATE";
  51. }
  52. $queryB = "UPDATE all_tickets SET estado_id = '3' WHERE id = $idTk";
  53. $cBD = new BD();
  54. if ($cBD->Ejecutar($queryB)) {
  55. echo "success UPDATE State";
  56. }
  57. $queryA = "INSERT INTO responded_to_client (rtc_fecha, rtc_hora, rtc_id_ticket) VALUES (\"$fecha\",'$hora','$idTk')";
  58. $cBD = new BD();
  59. if ($cBD->Ejecutar($queryA)) {
  60. echo "Se actualizo fecha y hora de respuesta al cliente";
  61. }
  62. if ($exito) {
  63. $aviso = "1|Email Enviado!.";
  64. } else {
  65. $aviso = "0|Error de envio.";
  66. }
  67. echo ($aviso);
  68. }
  69. function newTicket()
  70. {
  71. $email = htmlentities($email, ENT_NOQUOTES, 'UTF-8');
  72. $nombreSol = $_GET['nomsolic'];
  73. $nroTicket = $_GET['id'];
  74. $status = $_GET["status"];
  75. $contenido = $_GET['contenido'];
  76. $type = "new_ticket";
  77. $content = "&iexcl;Su reclamo ha sido registrado con &eacute;xito! <br/><br/>
  78. A partir de este momento nos encontramos trabajando para darle una respuesta.<br/><br/>
  79. En caso de no recibirla, en el plazo de 24 horas, o que la misma no sea de su conformidad,<br/>
  80. comunicarse al 0810 - 666 - GESTION (4378466) con su n&uacute;mero de reclamo.</br></br></br>
  81. &iexcl;Muchas gracias!";
  82. $mail = new PHPMailer();
  83. $mail->IsSMTP();
  84. $mail->SMTPAuth = true;
  85. $mail->SMTPSecure = "TSL";
  86. $mail->Host = "192.168.10.27"; // SMTP a utilizar. Por ej. smtp.elserver.com
  87. $mail->Username = "gestionresponde"; // Correo completo a utilizar
  88. $mail->Password = "Arwebs2020"; // Contraseña
  89. $mail->Port = 25; // Puerto a utilizar
  90. $mail->From = "gestionresponde@grupo-gestion.com.ar"; // Desde donde enviamos (Para mostrar)
  91. $mail->FromName = "Grupo Gestion";
  92. $mail->AddAddress($email); // Esta es la dirección a donde enviamos
  93. include("html.format.new.ticket.php");
  94. $mail->IsHTML(true); // El correo se envía como HTML
  95. $mail->Subject = "[Ticket #" . $nroTicket . "] Gestion Laboral"; // Este es el titulo del email.
  96. // $body = "Su reclamo ha sido procesado. Recibir&aacute; una respuesta a la brevedad.<br/><br/> Muchas gracias por contactarse con Grupo Gesti&oacute;n.<br/><br/>";
  97. $mail->Body = html_entity_decode($body); // Mensaje a enviar
  98. $exito = $mail->Send(); // Envía el correo.
  99. if ($exito) {
  100. $aviso = "1|Email Enviado!.";
  101. } else {
  102. $aviso = "0|Error de envio.";
  103. }
  104. newTicketSucResp();
  105. }
  106. function newTicketSucResp()
  107. {
  108. $cc = htmlentities($_GET['cc'], ENT_NOQUOTES, 'UTF-8');
  109. $cco = htmlentities($_GET['cco'], ENT_NOQUOTES, 'UTF-8');
  110. $eSucursal = htmlentities($_GET['eSucursal'], ENT_NOQUOTES, 'UTF-8');
  111. // $eResponsable = htmlentities($_GET['eResponsable'], ENT_NOQUOTES, 'UTF-8');
  112. $eResponsable = str_replace("ñ", "n", $_GET['eResponsable']);
  113. $eResponsable = str_replace("Ñ", "N", $eResponsable);
  114. $nroTicket = $_GET['id'];
  115. $contenido = $_GET['contenido'];
  116. $nombreSol = $_GET['nomsolic'];
  117. // var_dump($contenido);
  118. $tipo_usuario = $_GET['tipo_usuario'];
  119. switch ($tipo_usuario) {
  120. case 1:
  121. $tipo_usuario = "Postulante";
  122. break;
  123. case 2:
  124. $tipo_usuario = "Usuaria";
  125. break;
  126. case 3: $tipo_usuario = "Colaborador";
  127. $dni = $_GET["dniColab"];
  128. break;
  129. default : $tipo_usuario = "tipo_usuario";
  130. }
  131. $created_by = $_SESSION["usuario"];
  132. $mail = new PHPMailer();
  133. $mail->IsSMTP();
  134. $mail->SMTPAuth = true;
  135. $mail->SMTPSecure = "TSL";
  136. $mail->Host = "192.168.10.27"; // SMTP a utilizar. Por ej. smtp.elserver.com
  137. $mail->Username = "gestionresponde"; // Correo completo a utilizar
  138. $mail->Password = "Arwebs2020"; // Contraseña
  139. $mail->Port = 25; // Puerto a utilizar
  140. $mail->From = "gestionresponde@grupo-gestion.com.ar"; // Desde donde enviamos (Para mostrar)
  141. $mail->FromName = "Grupo Gestion";
  142. if ($eSucursal != "") {
  143. $mail->AddAddress($eSucursal); // Esta es la dirección a donde enviamos
  144. }
  145. if ($eResponsable != "") {
  146. $mail->AddCC($eResponsable);
  147. }
  148. if ($cc != "") {
  149. $mail->AddCC($cc); // Copia
  150. }
  151. if ($cco != "") {
  152. $mail->AddBCC($cco); // Copia
  153. }
  154. $mail->IsHTML(true); // El correo se envía como HTML
  155. $mail->Subject = "[Ticket #" . $nroTicket . "] | $nombreSol | " . date('d-m-Y H:i:s'); // Este es el titulo del email.
  156. $type = "sucresp";
  157. include("html.format.new.ticket.php");
  158. $mail->Body = html_entity_decode($body); // Mensaje a enviar
  159. $mail->CharSet = 'UTF-8';
  160. $exito = $mail->Send(); // Envía el correo.
  161. if ($exito) {
  162. $aviso = "1|Email Enviado!.";
  163. } else {
  164. $aviso = "0|Error de envio.";
  165. }
  166. echo ($aviso);
  167. }
  168. function editTicket()
  169. {
  170. $cc = htmlentities($_GET['cc'], ENT_NOQUOTES, 'UTF-8');
  171. $cco = htmlentities($_GET['cco'], ENT_NOQUOTES, 'UTF-8');
  172. $eSucursal = htmlentities($_GET['eSucursal'], ENT_NOQUOTES, 'UTF-8');
  173. $eResponsable = htmlentities($_GET['eResponsable'], ENT_NOQUOTES, 'UTF-8');
  174. $nroTicket = $_GET['id'];
  175. $contenido = $_GET['contenido'];
  176. $tipo_usuario = $_GET['tipo_usuario'];
  177. switch ($tipo_usuario) {
  178. case 1:
  179. $tipo_usuario = "Postulante";
  180. break;
  181. case 2:
  182. $tipo_usuario = "Usuaria";
  183. break;
  184. case 3: $tipo_usuario = "Colaborador";
  185. break;
  186. default : $tipo_usuario = "tipo_usuario";
  187. }
  188. $created_by = $_SESSION["usuario"];
  189. $mail = new PHPMailer();
  190. $mail->IsSMTP();
  191. $mail->SMTPAuth = true;
  192. $mail->SMTPSecure = "TSL";
  193. $mail->Host = "192.168.10.27"; // SMTP a utilizar. Por ej. smtp.elserver.com
  194. $mail->Username = "gestionresponde"; // Correo completo a utilizar
  195. $mail->Password = "Arwebs2020"; // Contraseña
  196. $mail->Port = 25; // Puerto a utilizar
  197. $mail->From = "gestionresponde@grupo-gestion.com.ar"; // Desde donde enviamos (Para mostrar)
  198. $mail->FromName = "Grupo Gestion";
  199. $mail->AddAddress($eSucursal); // Esta es la dirección a donde enviamos
  200. $mail->AddCC($eResponsable);
  201. if ($cc != "") {
  202. $mail->AddCC($cc); // Copia
  203. }
  204. if ($cco != "") {
  205. $mail->AddBCC($cco); // Copia
  206. }
  207. $mail->IsHTML(true); // El correo se envía como HTML
  208. $mail->Subject = "Gestion.Ar | Ticket Cargado"; // Este es el titulo del email.
  209. $body = "El usuario $created_by ha cargado un nuevo Ticket para " . strtoupper($tipo_usuario) . " con el Nro $nroTicket <br/><br/>";
  210. $body .= "Contenido del Ticket: $contenido <br/><br/>";
  211. $body .= "Enlace al Ticket: http://www.grupo-gestion.com.ar/gestion.ar/?redirect=tickets.edit.php?id=$nroTicket<br/><br/>";
  212. $mail->Body = html_entity_decode($body); // Mensaje a enviar
  213. $exito = $mail->Send(); // Envía el correo.
  214. if ($exito) {
  215. $aviso = "1|Email Enviado!.";
  216. } else {
  217. $aviso = "0|Error de envio.";
  218. }
  219. exit($aviso);
  220. }
  221. function sendMailRecoverPass()
  222. {
  223. $email = $_GET['email'];
  224. $queryCheck = "SELECT MEmpEmail, passwords.password as MEmpClave FROM miembroempresa
  225. LEFT JOIN passwords ON miembroempresa.PerNro = passwords.user_id
  226. WHERE MEmpEmail = '$email'";
  227. $cBD = new BD();
  228. $oRegistro = $cBD->Seleccionar($queryCheck);
  229. while ($aRegistro = $cBD->RetornarFila($oRegistro)) {
  230. $email_sql = $aRegistro['MEmpEmail'];
  231. $clave_sql = $aRegistro['MEmpClave'];
  232. }
  233. if ($email_sql == $email) {
  234. $mail = new PHPMailer();
  235. $mail->IsSMTP();
  236. $mail->SMTPAuth = true;
  237. $mail->SMTPSecure = "TSL";
  238. $mail->Host = "192.168.10.27"; // SMTP a utilizar. Por ej. smtp.elserver.com
  239. $mail->Username = "gestionresponde"; // Correo completo a utilizar
  240. $mail->Password = "Arwebs2020"; // Contraseña
  241. $mail->Port = 25; // Puerto a utilizar
  242. $mail->From = "gestionresponde@grupo-gestion.com.ar"; // Desde donde enviamos (Para mostrar)
  243. $mail->FromName = "Grupo Gestion";
  244. $mail->AddAddress($email_sql); // Esta es la dirección a donde enviamos
  245. $mail->IsHTML(true); // El correo se envía como HTML
  246. $mail->Subject = "Grupo Gestion | Soporte | Recuperar Clave"; // Este es el titulo del email.
  247. $body = "Su clave es:<br/>" . $clave_sql . "<br/><br/>";
  248. $mail->Body = html_entity_decode($body); // Mensaje a enviar
  249. $exito = $mail->Send(); // Envía el correo.
  250. if ($exito) {
  251. $aviso = "Se ha enviado un Mensaje a su casilla de correo.";
  252. } else {
  253. $aviso = "Hubo un inconveniente en el envio del Correo. Vuelva a intentar nuevamente m&aacute;s tarde. Disculpe las molestias.";
  254. }
  255. } else {
  256. $aviso = "El Correo no se encuentra registrado en nuestro sistema.";
  257. }
  258. exit($aviso);
  259. }
  260. function sendMailsupervisor()
  261. {
  262. $nombreSol = utf8_decode($_GET["nomsolic"]);
  263. $nroTicket = $_GET["id"];
  264. $forWho = $_GET["status"];
  265. $respuesta = $_GET["contenido"];
  266. $mail = new PHPMailer();
  267. $mail->IsSMTP();
  268. $mail->SMTPAuth = true;
  269. $mail->SMTPSecure = "TSL";
  270. $mail->Host = "192.168.10.27"; // SMTP a utilizar. Por ej. smtp.elserver.com
  271. $mail->Username = "gestionresponde"; // Correo completo a utilizar
  272. $mail->Password = "Arwebs2020"; // Contraseña
  273. $mail->Port = 25; // Puerto a utilizar
  274. $mail->From = "gestionresponde@grupo-gestion.com.ar"; // Desde donde enviamos (Para mostrar)
  275. $mail->FromName = "Grupo Gestion";
  276. $mail->AddAddress('administracioncomercial@grupo-gestion.com.ar');
  277. // $mail->AddAddress('ulopez@arwebs.net');
  278. if ($forWho != "admin") {
  279. $sql = "SELECT MEmpEmail FROM miembroempresa me ";
  280. $sql.= " LEFT JOIN user_type ON me.PerNro = user_type.idusuario ";
  281. $sql.= " LEFT JOIN tipomiembro ON user_type.tipo_id = TMiembNro ";
  282. $sql.= " WHERE user_type.tipo_id = 7";
  283. $cBD = new BD();
  284. $oRegistro = $cBD->Seleccionar($sql);
  285. while ($aRegistro = $cBD->RetornarFila($oRegistro)) {
  286. if (!empty($aRegistro["MEmpEmail"])) {
  287. $mail->AddBCC($aRegistro["MEmpEmail"]); // Esta es la dirección a donde enviamos
  288. }
  289. }
  290. $type = "supervisor";
  291. } else {
  292. $type = "supervisoradmin";
  293. }
  294. include("html.format.new.ticket.php");
  295. $mail->IsHTML(true); // El correo se envía como HTML
  296. $mail->Subject = "Grupo Gestion | Respuesta a Ticket Nro #$nroTicket | Generada por $nombreSol"; // Este es el titulo del email.
  297. $mail->Body = html_entity_decode($body); // Mensaje a enviar
  298. $exito = $mail->Send(); // Envía el correo.
  299. if ($exito) {
  300. $aviso = "Se ha enviado un correo a todos los supervisores para que autoricen la respuesta.";
  301. } else {
  302. $aviso = "Hubo un inconveniente en el envio del Correo. ";
  303. }
  304. // sendMailsupervisorAdmin($nombreSol, $nroTicket, $respuesta);
  305. exit($aviso);
  306. }
  307. function sendMailsupervisorAdmin($nmSol, $nTick, $resp)
  308. {
  309. $nombreSol = $nmSol;
  310. $nroTicket = $nTick;
  311. $respuesta = $resp;
  312. $mail = new PHPMailer();
  313. $mail->IsSMTP();
  314. $mail->SMTPAuth = true;
  315. $mail->SMTPSecure = "TSL";
  316. $mail->Host = "192.168.10.27"; // SMTP a utilizar. Por ej. smtp.elserver.com
  317. $mail->Username = "gestionresponde"; // Correo completo a utilizar
  318. $mail->Password = "Arwebs2020"; // Contraseña
  319. $mail->Port = 25; // Puerto a utilizar
  320. $mail->From = "gestionresponde@grupo-gestion.com.ar"; // Desde donde enviamos (Para mostrar)
  321. $mail->FromName = "Grupo Gestion";
  322. $mail->AddAddress('administracioncomercial@grupo-gestion.com.ar');
  323. // $mail->AddAddress('ulopez@arwebs.net');
  324. $type = "supervisoradmin";
  325. include("html.format.new.ticket.php");
  326. $mail->IsHTML(true); // El correo se envía como HTML
  327. $mail->Subject = "Grupo Gestion | Respuesta a Ticket Nro #$nroTicket | Generada por $nombreSol"; // Este es el titulo del email.
  328. $mail->Body = html_entity_decode($body); // Mensaje a enviar
  329. $exito = $mail->Send(); // Envía el correo.
  330. if ($exito) {
  331. $aviso = "Se ha enviado un correo a todos los supervisores para que autoricen la respuesta.";
  332. } else {
  333. $aviso = "Hubo un inconveniente en el envio del Correo. ";
  334. }
  335. exit($aviso);
  336. }
  337. if ($case == "sendClientResp") {
  338. sendClientResp();
  339. }
  340. if ($case == "newTicket") {
  341. newTicket();
  342. }
  343. if ($case == "recoverpass") {
  344. sendMailRecoverPass();
  345. }
  346. if ($case == "sendsupervisor") {
  347. sendMailsupervisor();
  348. }
  349. ?>