public function editarInvitado() { /**EDITAR SERVICIO*****/ if (!Sesion::isAdmin()) { return Redirect::to('administracion/logout'); } $token = Input::get('token'); if (isset($token)) { $data = array('n' => Input::get('n'), 'c' => Input::get('c'), 'activo' => Input::get('activo'), 'i' => Input::get('i'), 'co' => Input::get('co')); $validaciones = array('n' => array('required', 'regex:/^([0-9a-zA-ñÑZáéíóúñÁÉÍÓÚ\\-\\s\\,\\.\\?\\¿\\¡\\!])+$/'), 'activo' => array('required', 'boolean')); $validator = Validator::make($data, $validaciones); if ($validator->fails()) { $respuesta; $mensajes = $validator->messages(); foreach ($mensajes->all() as $mensaje) { $respuesta = $mensaje; } $response = array('status' => 'ERROR', 'message' => $respuesta); } else { $editar = Invitados::where('invId', $data['i'])->update(array('invNombre' => $data['n'], 'invCorreo' => $data['c'], 'invActivo' => $data['activo'], 'invPass' => $data['co'])); if ($editar) { $response = array('status' => 'OK', 'message' => 'Invitado actualizado'); } else { $response = array('status' => 'ERROR', 'message' => 'No se puede actualizar el invitado, intente de nuevo'); } } } else { $response = array('status' => 'ERROR', 'message' => 'Vuelva a intentar en un momento'); } return Response::json($response); }
public function enviarAhora() { $format = "Y-m-d"; $timestamp = time(); $fecha = date($format, $timestamp); $fechaInicio = $fecha . " 00:00:00"; $fechaFin = $fecha . " 23:59:59"; $formatEnv = "Y-m-d"; $fechaEnv = date($formatEnv, $timestamp); $body = ""; $diaSemForm = "N"; $mesForm = "n"; $diaForm = "j"; $anioForm = "Y"; $diaSemEnvio = date($diaSemForm, $timestamp); $mesEnvio = date($mesForm, $timestamp); $diaEnvio = date($diaForm, $timestamp); $anioEnvio = date($anioForm, $timestamp); $diaSemana = CorreoController::getDia($diaSemEnvio); $mes = CorreoController::getMes($mesEnvio); $seleccionar = NoticiasController::consultaNoticiasEnvio($fechaInicio, $fechaFin); $fueNombreAnterior = ""; foreach ($seleccionar as $valor) { $fueNombre = $valor['fueNombre']; $notTitulo = $valor['notTitulo']; $notContenido = $valor['notContenido']; $notAutor = $valor['notAutor']; $notEnlace = $valor['notEnlace']; $fuenteIgual = strcmp($fueNombre, $fueNombreAnterior); if ($fuenteIgual == 0) { $mostrarFuente = ""; } else { $mostrarFuente = $fueNombre; } $fueNombreAnterior = $fueNombre; $body = $body . '<br>'; $body = $body . '<div>'; $body = $body . '<h2 style="text-align: center; color:#1565c0;"> <u>' . $mostrarFuente . '</u></h2>'; $body = $body . '<h4 style="text-align: left; color:#1565c0;">' . $notTitulo . '</h4>'; $body = $body . '<p style="text-align: justify;" >' . $notContenido . '</p>'; $body = $body . '<br><p style="text-align: justify;" ><small>' . $notAutor . '</small></p>'; $body = $body . '<p style="text-align: justify;" ><small> <a href="' . $notEnlace . '">' . $notEnlace . '</a></small></p>'; $body = $body . '</div>'; } $dataCorreo = array('fechaEnv' => $fechaEnv, 'body' => $body, 'diaSem' => $diaSemana, 'dia' => $diaEnvio, 'mes' => $mes, 'anio' => $anioEnvio); $correoInt = Integrantes::where('intActivo', TRUE)->get(array('intCorreo'))->toArray(); $correoRes = Responsables::where('resActivo', TRUE)->get(array('resCorreo'))->toArray(); $correoInv = Invitados::where('invActivo', TRUE)->get(array('invCorreo'))->toArray(); foreach ($correoInt as $valor) { $toEmail[] = $valor['intCorreo']; } foreach ($correoRes as $valor) { $toEmail[] = $valor['resCorreo']; } foreach ($correoInv as $valor) { $toEmail[] = $valor['invCorreo']; } $asunto = 'noticias-' . $fechaEnv; // $toEmail = "*****@*****.**"; /* Mail::send('emails.envioNoticiasMail', $dataCorreo, function($message) use($toEmail, $asunto){ $message->to($toEmail); $message->subject($asunto); }); */ if (count($seleccionar) > 0) { $response = array('status' => 'OK', 'data' => $toEmail, 'message' => 'Se enviaron correos correctamente.'); } else { $response = array('status' => 'ERROR', 'message' => 'No se pudo enviar correo.'); } return Response::json($response); }