예제 #1
0
 public function notificarAction()
 {
     //Conectamos a BBDD
     $sid = new Container('base');
     $db_name = $sid->offsetGet('dbNombre');
     $remitente = "Comit�";
     $this->dbAdapter = $this->getServiceLocator()->get($db_name);
     //Obtenemos datos POST
     $post = $this->request->getPost();
     if (isset($post['destino'])) {
         //Validamos si es mensaje directo a Dpto
         if (isset($post['dpto'])) {
             //Consultamos datos del dpto
             $dptoMail = new UnidadTable($this->dbAdapter);
             $lista = $dptoMail->getVerResidentesActivos($this->dbAdapter, $post['id_unidad']);
             $htmlMarkup = \HtmlCorreo::htmlMensajeDirecto($lista[0]['nombre'], $remitente, $post['textbody']);
             $html = new MimePart($htmlMarkup);
             $html->type = "text/html";
             $body = new MimeMessage();
             $body->setParts(array($html));
             $message = new Message();
             $message->addTo($lista[0]['correo'])->addFrom('*****@*****.**', 'Notificacion becheck')->setSubject($post['asunto'])->setBody($body);
             $transport = new SendmailTransport();
             $transport->send($message);
             //Retornamos a la vista
             $result = new JsonModel(array('status' => 'ok', 'descripcion' => 'Se ha enviado correctamente un correo'));
             //$result->setTerminal(true);
             return $result;
         }
         $result = new JsonModel(array('status' => 'ok', 'descripcion' => $post));
         $result->setTerminal(true);
         return $result;
     }
     //Instancias
     $dpto = new UnidadTable($this->dbAdapter);
     $form = new NotificacionForm("form");
     //Obtenemos combo dptos
     $dptos = $dpto->getDatosActivos();
     //Cargamos dptos en formulario
     $form->get('id_unidad')->setAttribute('options', $dptos);
     $this->layout('layout/comite');
     return new ViewModel(array('form' => $form));
 }
예제 #2
0
 public function sendmailcircularAction()
 {
     //CORREOOOOOO
     $sid = new Container('base');
     $id_usuario = $sid->offsetGet('id_usuario');
     $id_db = $sid->offsetGet('id_db');
     $status = "ok";
     $mensaje = "";
     if (isset($id_usuario)) {
         //por seguridad, se aplica consulta de la peticion. Debe existir y con estado Proceso
         $db_name = $sid->offsetGet('dbNombre');
         $this->dbAdapter = $this->getServiceLocator()->get($db_name);
         $circularTable = new CircularTable($this->dbAdapter);
         //recuperamos nro de peticion de circular
         $lc = $this->request->getPost();
         $filtros = array('id' => $lc['id_circular'], 'estado' => 'Proceso');
         $lstCircular = $circularTable->getCircularByDatos($filtros);
         if (count($lstCircular) > 0) {
             // seteamos el link
             $link_circular = 'http://becheck.cl/files/db/' . $id_db . '/circulares/' . $lstCircular[0]['nombre_file'];
             //actualizamos la peticion de Proceso a Enviando
             $filtros = array('id' => $lc['id_circular'], 'estado' => 'Enviando', 'user_update' => $id_usuario, 'date_update' => SysFnc::FechaActualYmdHms());
             $circularTable->actualizarCircular($filtros);
             //obtenemos todos los correos de la comunidad
             $correos = $circularTable->getListadoCorreoActivos($this->dbAdapter);
             //enviando a la gentita...
             $tamanio = count($correos);
             if ($tamanio > 0) {
                 //seteamos el link del descarga
                 //seteamos para que no expire la trasaccion
                 set_time_limit(90);
                 //enviamos correo masivas
                 $transport = new SmtpTransport();
                 $options = new SmtpOptions(array('name' => 'smtp.gmail.com', 'host' => 'smtp.gmail.com', 'port' => '587', 'connection_class' => 'login', 'connection_config' => array('username' => '*****@*****.**', 'password' => 'xofita123', 'ssl' => 'tls')));
                 for ($i = 0; $i < $tamanio; $i++) {
                     if (isset($correos[$i]['correo'])) {
                         $pos = strpos($correos[$i]['correo'], "@");
                         if ($pos == false) {
                         } else {
                             //si utilizas temporalmente Encomienda
                             $htmlMarkup = \HtmlCorreo::htmlcircular($correos[$i]['nombre'], $link_circular);
                             $html = new MimePart($htmlMarkup);
                             $html->type = "text/html";
                             $body = new MimeMessage();
                             $body->setParts(array($html));
                             $message = new Message();
                             $message->addTo($correos[$i]['correo'])->addFrom('*****@*****.**', 'Sistema be check')->setSubject('AVISO: Nuevo Circular del Condominio')->setBody($body);
                             $transport->setOptions($options);
                             $transport->send($message);
                             sleep(0.5);
                         }
                     }
                 }
                 //actualizamos si fue enviado
                 $filtros = array('id' => $lc['id_circular'], 'estado' => 'Enviado OK', 'user_update' => $id_usuario, 'date_update' => SysFnc::FechaActualYmdHms());
                 $circularTable->actualizarCircular($filtros);
             } else {
                 $mensaje = "No hay datos para enviar correo masivo a la comunidad";
             }
             $mensaje = "Envio masivo de correo - OK";
         } else {
             $mensaje = "No se envia correos por que no cumple la regla de negocio";
         }
     } else {
         $status = "nok";
         $mensaje = "sesion time out";
     }
     return new JsonModel(array('status' => $status, 'mensaje' => $mensaje));
 }
예제 #3
0
 public function registrarAction()
 {
     $sid = new Container('base');
     $id_usuario = $sid->offsetGet('id_usuario');
     $id_db = $sid->offsetGet('id_db');
     $status = "";
     $error = "";
     if (isset($id_usuario)) {
         $fechaCompleta = SysFnc::FechaActualYmdHms();
         $v = $this->request->getPost();
         if (isset($v['id_persona_remite']) && (int) $v['id_persona_remite'] > 0) {
             $db_name = $sid->offsetGet('dbNombre');
             $this->dbAdapter = $this->getServiceLocator()->get($db_name);
             $encomienda = new EncomiendaTable($this->dbAdapter);
             $File = $this->params()->fromFiles('fileData');
             $adapterFile = new \Zend\File\Transfer\Adapter\Http();
             $adapterFile->setDestination($_SERVER['DOCUMENT_ROOT'] . '/files/db/' . $id_db . '/conserje/encomienda');
             $adapterFile->receive($File['name']);
             $nombreArchivoEnc = isset($File['name']) ? $File['name'] : "";
             $datos = array('id_unidad' => $v['id_unidad'], 'id_persona_remite' => $v['id_persona_remite'], 'detalle' => $v['detalle'], 'fecha_ingreso' => $fechaCompleta, 'date_update' => $fechaCompleta, 'user_create' => $id_usuario, 'foto' => $nombreArchivoEnc);
             $idEnc = $encomienda->nuevaEncomienda($datos);
             //Enviar Correo
             $dptoMail = new UnidadTable($this->dbAdapter);
             $lista = $dptoMail->getVerResidentesActivos($this->dbAdapter, $v['id_unidad']);
             for ($i = 0; $i < count($lista); $i++) {
                 if (isset($lista[$i]['correo'])) {
                     $pos = strpos($lista[$i]['correo'], "@");
                     if ($pos == false) {
                     } else {
                         $nombre = $lista[$i]['nombre'];
                         $remitente = $v['remitente'];
                         $descp = "";
                         if ($nombreArchivoEnc == "") {
                             $descp = "No presenta fotografia";
                             $filepath = "";
                         } else {
                             $filepath = 'http://becheck.cl/files/db/' . $id_db . '/conserje/encomienda/' . $nombreArchivoEnc;
                         }
                         //  $htmlMarkup=\HtmlCorreo::htmlEncomienda($nombre,$remitente,$filepath);
                         $htmlMarkup = \HtmlCorreo::htmlconfreserva();
                         $html = new MimePart($htmlMarkup);
                         $html->type = "text/html";
                         $body = new MimeMessage();
                         $body->setParts(array($html));
                         $message = new Message();
                         $message->addTo($lista[$i]['correo'])->addFrom('*****@*****.**', 'Sistema be check')->setSubject('Aviso de Encomienda Recepcionada')->setBody($body);
                         $transport = new SendmailTransport();
                         $transport->send($message);
                         sleep(2);
                         //enviamos correo
                     }
                 }
             }
             //Fin Enviar Correo
             $status = "ok";
         } else {
             $status = "nok";
             $error = "el identificador del remitente no encontrado";
         }
     } else {
         $status = "nok";
         $error = "usuario no encontrado";
     }
     return new JsonModel(array('status' => $status, 'error' => $error));
 }
예제 #4
0
 public function enviarAction()
 {
     //Obtenemos datos POST
     $post = $this->request->getPost();
     //Conectamos a BBDD
     $sid = new Container('base');
     $remitente = "Conserje";
     $db_name = $sid->offsetGet('dbNombre');
     $this->dbAdapter = $this->getServiceLocator()->get($db_name);
     //Tablas
     $dptoMail = new UnidadTable($this->dbAdapter);
     //Validamos destinatario
     if (isset($post['dpto'])) {
         //Consultamos datos del dpto
         $lista = $dptoMail->getVerResidentesActivos($this->dbAdapter, $post['id_unidad']);
     } else {
         //Consultamos datos del dpto
         $lista = $dptoMail->getVerResidentesActivos($this->dbAdapter, $post['id_unidad']);
     }
     //Armamos EMAIL
     $htmlMarkup = \HtmlCorreo::htmlMensajeDirecto($lista[0]['nombre'], $remitente, $post['textbody']);
     $html = new MimePart($htmlMarkup);
     $html->type = "text/html";
     $body = new MimeMessage();
     $body->setParts(array($html));
     $message = new Message();
     $message->addTo($lista[0]['correo'])->addFrom('*****@*****.**', 'Notificación becheck')->setSubject($post['asunto'])->setBody($body);
     $transport = new SmtpTransport();
     $options = new SmtpOptions(array('name' => 'smtp.gmail.com', 'host' => 'smtp.gmail.com', 'port' => '587', 'connection_class' => 'login', 'connection_config' => array('username' => '*****@*****.**', 'password' => 'xofita123', 'ssl' => 'tls')));
     $transport->setOptions($options);
     $transport->send($message);
     //Retornamos a la vista
     $result = new JsonModel(array('status' => 'ok', 'descripcion' => 'Se ha enviado correctamente un correo'));
     //$result->setTerminal(true);
     return $result;
 }
예제 #5
0
 private function sendMailConfirmacion($id_unidad, $id_uth, $dia, $estado)
 {
     $sid = new Container('base');
     $db_name = $sid->offsetGet('dbNombre');
     $this->dbAdapter = $this->getServiceLocator()->get($db_name);
     $dptoMail = new UnidadTable($this->dbAdapter);
     $lista = $dptoMail->getVerResidentesActivos($this->dbAdapter, $id_unidad);
     $rsvQuincho = new RsvQuinchoTable($this->dbAdapter);
     $valoresRsv = $rsvQuincho->mostrarHorarioNombreQuincho($this->dbAdapter, $id_uth);
     for ($i = 0; $i < count($lista); $i++) {
         if (isset($lista[$i]['correo'])) {
             $pos = strpos($lista[$i]['correo'], "@");
             if ($pos == false) {
             } else {
                 $nombre = $lista[$i]['nombre'];
                 $dpto = $lista[$i]['dpto'];
                 //  $htmlMarkup=\HtmlCorreo::htmlEncomienda($nombre,$remitente,$filepath);
                 $htmlMarkup = \HtmlCorreo::htmlconfreserva($nombre, $dpto, $valoresRsv[0]['nombre'], $dia, $valoresRsv[0]['inicio'] . ' a ' . $valoresRsv[0]['fin'], $estado);
                 $html = new MimePart($htmlMarkup);
                 $html->type = "text/html";
                 $body = new MimeMessage();
                 $body->setParts(array($html));
                 $message = new Message();
                 $message->addTo($lista[$i]['correo'])->addFrom('*****@*****.**', 'Sistema be check')->setSubject('Aviso de Reserva de Quincho')->setBody($body);
                 $transport = new SendmailTransport();
                 $transport->send($message);
                 sleep(2);
                 //enviamos correo
             }
         }
     }
 }
예제 #6
0
 public function emailclaveAction()
 {
     $mail = $_POST['mail'];
     $this->dbAdapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter');
     $usu = new PersonaTable($this->dbAdapter);
     $existe = $usu->getDatosMail($mail);
     if (count($existe) > 0) {
         $str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
         $cad = "";
         for ($i = 0; $i < 8; $i++) {
             $cad .= substr($str, rand(0, 62), 1);
         }
         $token = md5($cad);
         //$nuevaclave = substr($nuevaclave,3,11);
         $nuevotoken = array('token' => $token, 'mail' => $mail);
         $tok = new TokenTable($this->dbAdapter);
         $tok->nuevoToken($nuevotoken);
         $url = "www.becheck.cl/pmv/public/application/recuperar/index/" . $token;
         $htmlMarkup = \HtmlCorreo::htmlPassword($existe[0]['nombre'] . " " . $existe[0]['apellido'], $url);
         /*   $text = new MimePart($textContent);
              $text->type = "text/plain";*/
         $html = new MimePart($htmlMarkup);
         $html->type = "text/html";
         /* $image = new MimePart(fopen($pathToImage, 'r'));
            $image->type = "image/jpeg";*/
         $body = new MimeMessage();
         $body->setParts(array($html));
         $message = new Message();
         $message->addTo($mail)->addFrom('*****@*****.**', 'Sistema be check')->setSubject('Recuperar Contraseña')->setBody($body);
         $transport = new SendmailTransport();
         $transport->send($message);
         $descripcion = "Se ha enviado un correo a :  " . $mail;
         $result = new JsonModel(array('descripcion' => $descripcion, 'status' => 'ok'));
         return $result;
     } else {
         $descripcion = "Lo siento, el correo no existe en nuestros registros...";
         $result = new JsonModel(array('descripcion' => $descripcion));
         return $result;
     }
 }