Example #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionSolicita()
 {
     $model = new Noticias();
     $model->setscenario('solicita');
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Noticias'])) {
         $model->attributes = $_POST['Noticias'];
         if ($model->save()) {
             Yii::app()->user->setFlash('success', 'La noticia se ha grabado correctamente, Tiene que esperar a que el administrador apruebe su solicitud, un correo ha sido enviado a su buzon');
             Yii::app()->crugemailer->mail_general(Confignoticias::getMailAdminTablon(), 'Nueva solicitud de Noticia', $model->mensaje, $model, array('fecha', 'expira', 'fechapublicacion'));
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('solicita', array('model' => $model));
 }
 public function post_add()
 {
     //echo "hola desde post";
     $inputs = Input::All();
     //print_r($inputs);
     $reglas = array('titulo' => 'required|min:5', 'contenido' => 'required|min:5');
     $mensajes = array("required" => "este campo es obligatorio", "min" => "debe tener como mínimo 5 caracteres");
     $validar = Validator::make($inputs, $reglas, $mensajes);
     if ($validar->fails()) {
         return Redirect::back()->withErrors($validar);
     } else {
         $n = new Noticias();
         $n->titulo = $inputs["titulo"];
         $n->contenido = $inputs["contenido"];
         $n->seo_slug = Helper::con_guion($inputs["titulo"]);
         $n->fecha = date("Y-m-d");
         $n->save();
         Session::flash('mensaje', 'El registro ha sido ingresado exitosamente');
         return Redirect::to('test/add');
     }
 }
Example #3
0
 public static function InsertaCumple()
 {
     $matr = Trabajadores::model()->findall("cumple=:dato", array(":dato" => date("Y-m-d")));
     //solo puede haber un mensaje de onomastico por dia
     //
     //
     //
     /*echo "<br><br><br><br><br>".count($matr)."<br>";
     	 echo date("Y-m-d").'';*/
     $esto = Noticias::model()->find("tiponoticia='02' and aprobado='1' and fecha>=:fechita", array(":fechita" => date("Y-m-d")));
     /*var_dump($esto);
       yii::app()->end();*/
     //print_r($matr);
     //echo gettype($esto);
     if (count($matr) > 0 and $esto == null) {
         $cadena = "Feliz cumpleaños , el dia de hoy  :  ";
         for ($i = 0; $i < count($matr); ++$i) {
             $cadena = $cadena . $matr[$i]['nombres'] . " " . $matr[$i]['ap'] . " " . $matr[$i]['am'] . "   ";
         }
         $cadena = $cadena . "\n";
         $cadena = $cadena . "Muchas felicidades en este dia ....!";
         $mensaje = new Noticias();
         $mensaje->txtnoticia = $cadena;
         $mensaje->iduser = Confignoticias::model()->findBypK(1)->iduseradm;
         $mensaje->autor = Yii::app()->user->um->loadUserById($mensaje->iduser)->username;
         $mensaje->tiponoticia = '02';
         $mensaje->aprobado = 1;
         $mensaje->fechapropuesta = date('Y-m-d');
         $mensaje->fexpira = date('Y-m-d');
         if (!$mensaje->save()) {
             throw new CHttpException(500, 'NO s peudo grabra el noticin del cumple.');
         }
     }
     return 1;
 }