/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     //read the post input (use this technique if you have no post variable name):
     $post = file_get_contents("php://input");
     //decode json post input as php array:
     $data = CJSON::decode($post, true);
     //Event is a Yii model:
     $evento = new Evento();
     //load json data into model:
     $evento->attributes = $data;
     //this is for responding to the client:
     $response = array();
     //save model, if that fails, get its validation errors:
     if ($evento->save() == false) {
         $response['success'] = false;
         $response['errors'] = $evento->errors;
     } else {
         $response['success'] = true;
         //respond with the saved contact in case the model/db changed any values
         //$response['evento'] = $evento;
     }
     //respond with json content type:
     header('Content-type:application/json');
     //encode the response as json:
     echo CJSON::encode($response);
     exit;
 }
Exemple #2
0
 public function handleCreate()
 {
     try {
         if (Request::ajax()) {
             $error = false;
             $idEvento = Input::get('idevento');
             $eventoUpdated = Evento::find($idEvento);
             if ($eventoUpdated) {
                 $eventoUpdated->idconfiguraciontrampa = Input::get('idctrampa');
                 $eventoUpdated->fechaevento = Input::get('fechaevento');
                 $eventoUpdated->idclasificaiontrampa = Input::get('idclasificacion');
                 $eventoUpdated->semana = Input::get('semana');
                 $eventoUpdated->observaciones = Input::get('observaciones');
                 $eventoUpdated->save();
             } else {
                 $evento = new Evento();
                 $evento->idconfiguraciontrampa = Input::get('idctrampa');
                 $evento->fechaevento = Input::get('fechaevento');
                 $evento->idclasificaiontrampa = Input::get('idclasificacion');
                 $evento->semana = Input::get('semana');
                 $evento->observaciones = Input::get('observaciones');
                 $evento->save();
             }
             $resultado = array('error' => false, 'msg' => 'created successfully');
             return Response::json($resultado);
         }
     } catch (Exception $ex) {
         $resultado = array('error' => true, 'msg' => 'Error saving data');
         return Response::json($resultado);
     }
 }
 public function postMensajero()
 {
     $id = Input::get('recibo_id');
     $recibo = Recibo::find($id);
     $evento = new Evento();
     $client_id = '830870432482-po6o126nspi5d3iukgkn7ni6m0qpg5mq.apps.googleusercontent.com';
     $email_address = '*****@*****.**';
     $key_file_location = app_path('key/Bifrost-7c8d70841343.p12');
     $client = new Google_Client();
     $client->setApplicationName('Bifrost');
     $key = file_get_contents($key_file_location);
     $scopes = implode(' ', array(Google_Service_Calendar::CALENDAR));
     $cred = new Google_Auth_AssertionCredentials($email_address, array($scopes), $key);
     $client->setAssertionCredentials($cred);
     if ($client->getAuth()->isAccessTokenExpired()) {
         $client->getAuth()->refreshTokenWithAssertion($cred);
     }
     $service = new Google_Service_Calendar($client);
     $event = new Google_Service_Calendar_Event(array('summary' => 'Cobranza Programada', 'location' => 'Domicilio del cliente', 'description' => Input::get('detalles'), 'start' => array('date' => Input::get('fecha')), 'end' => array('date' => Input::get('fecha'))));
     $createdEvent = $service->events->insert('*****@*****.**', $event);
     $evento->recibo_id = $id;
     $evento->evento = $createdEvent->getId();
     $recibo->mensajero = 1;
     $evento->save();
     $recibo->save();
     return Response::json(array('status', 'ok'));
 }
 /**
 * Store a newly created resource in storage.
 *
 * @return Response
 */
 public function store()
 {
     $user = Auth::user();
     $club = $user->clubs()->FirstOrFail();
     $validator = Validator::make(Input::all(), Evento::$rules);
     if ($validator->passes()) {
         $event = new Evento();
         $event->name = Input::get('name');
         $event->type_id = Input::get('type');
         $event->location = Input::get('location');
         $event->date = Input::get('date');
         $event->end = Input::get('end');
         $event->fee = Input::get('fee');
         $event->early_fee = Input::get('early_fee');
         $event->early_deadline = Input::get('early_deadline');
         $event->open = Input::get('open');
         $event->close = Input::get('close');
         $event->notes = Input::get('notes');
         $event->status = Input::get('status');
         $event->max = Input::get('max');
         $event->user_id = $user->id;
         $event->club_id = $club->id;
         $event->save();
         if ($event->id) {
             return Redirect::action('EventoController@index')->with('messages', 'Event created successfully');
         }
     }
     $error = $validator->errors()->all(':message');
     return Redirect::action('EventoController@create')->withErrors($validator)->withInput();
 }
Exemple #5
0
 public function crear()
 {
     $req = $this->request;
     $vdt = $this->validarEvento($req->post());
     $autor = $this->session->getUser();
     $evento = new Evento();
     $evento->cuerpo = $vdt->getData('cuerpo');
     $evento->lugar = $vdt->getData('lugar');
     $evento->fecha = Carbon\Carbon::parse($vdt->getData('fecha'));
     $evento->save();
     $contenido = new Contenido();
     $contenido->titulo = $vdt->getData('titulo');
     $contenido->puntos = 0;
     $contenido->categoria_id = $vdt->getData('categoria');
     $contenido->autor()->associate($autor);
     $contenido->contenible()->associate($evento);
     $partido = $autor->partido;
     if (isset($partido) && $vdt->getData('asociar')) {
         $contenido->impulsor()->associate($partido);
     }
     $contenido->save();
     TagCtrl::updateTags($contenido, TagCtrl::getTagIds($vdt->getData('tags')));
     $log = UserlogCtrl::createLog('newEventoo', $autor->id, $evento);
     if ($contenido->impulsor) {
         NotificacionCtrl::createNotif($partido->afiliados()->lists('id'), $log);
     }
     $this->flash('success', 'Su evento fue creado exitosamente.');
     $this->redirectTo('shwEvento', array('idEve' => $evento->id));
 }
Exemple #6
0
 public function creaNuovoEvento($data, $conn = null, $use_swift = true)
 {
     $evento = new Evento();
     $evento->fromArray($data);
     $evento->save($conn);
     $this->sendMail($evento, $use_swift);
 }
 public function storeEventos()
 {
     $dados = new Evento();
     $dados->nome = Input::get('nome');
     $dados->local = Input::get('local');
     $dados->data_evento = Input::get('ano') . '/' . Input::get('mes') . '/' . Input::get('dia') . ' ' . Input::get('hr') . ':' . Input::get('min');
     $dados->valor_ingresso = Input::get('valor');
     $dados->artista_principal = Input::get('artista');
     $dados->artista_secundario = Input::get('musicos');
     $dados->descricao = Input::get('descricao');
     $dados->endereco = Input::get('endereco');
     $dados->numero = Input::get('numero');
     $dados->complemento = Input::get('complemento');
     $dados->bairro = Input::get('bairro');
     $dados->cidade = Input::get('cidade');
     $dados->estado = Input::get('estado');
     $dados->coordenadas = Input::get('coord');
     $dados->cronograma = Input::get('resp');
     $dados->ativo = 1;
     $dados->album = 0;
     $dados->save();
     $destino = str_replace(' ', '_', strtolower(public_path() . "/images/eventos/{$dados->nome}"));
     if (Input::hasFile('img')) {
         $nome = "evento_" . str_replace(' ', '_', strtolower($dados->nome)) . "." . Input::file('img')->getClientOriginalExtension();
         $img = Input::file('img');
         $img->move($destino, $nome);
     }
     return View::make('/admin/cadastros/eventos', array('ok' => true));
 }
Exemple #8
0
 public function testSave()
 {
     $data = array('titolo' => 'phpday2010!!!', 'descrizione' => 'questo è il talk per il phpday 2010!', 'data_inizio' => '2010-05-14', 'data_fine' => '2010-05-15');
     $evento = new Evento();
     $evento->fromArray($data);
     $evento->save($this->pdo);
     $xml_dataset = $this->createFlatXMLDataSet(dirname(__FILE__) . '/../fixtures/evento.xml');
     $this->assertDataSetsEqual($xml_dataset, $this->getConnection()->createDataSet(array('evento')));
 }
Exemple #9
0
 public function postGravar()
 {
     $evento = new Evento();
     $evento->titulo = Input::get('titulo');
     $evento->sinopse = Input::get('sinopse');
     $evento->categoria = Input::get('categoria');
     $evento->protagonista = Input::get('protagonista');
     $evento->autor = Input::get('autor');
     $evento->save();
     $eventos = Evento::all();
     return View::make('Evento.eventoVisu')->with('eventos', $eventos);
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Evento();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Evento'])) {
         $model->attributes = $_POST['Evento'];
         $model->estatus_did = 1;
         if ($model->save()) {
             $this->redirect(array('index'));
         }
     } else {
         if (isset($_POST["title"])) {
             $model->nombre = $_POST['title'];
             $model->fechaInicio_ft = $_POST['start'];
             $model->fechaFin_ft = $_POST['end'];
             $model->estatus_did = 1;
             if ($model->save()) {
                 $this->redirect(array('index'));
             }
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function testPostEventoCorrecto()
 {
     $destino = Enhance::getCodeCoverageWrapper('EventosControllerClass');
     $destino->postEvento();
     $eventos = new Evento();
     $eventos->nombre = 'Concierto Dani Martin';
     $eventos->fecha = '2014-08-01';
     $eventos->hora = '23:30';
     $eventos->tipo = 'musica';
     $eventos->aforo = '1000';
     $eventos->descripcion = 'concierto del ex-cantante de ECDL en Berja';
     $eventos->save();
     $this->call('POST', 'eventos');
     $this->assertRedirectedToRoute('eventos');
 }
 public function testPostEventoCorrecto()
 {
     $destino = Enhance::getCodeCoverageWrapper('EventosControllerClass');
     $destino->postEvento();
     $eventos = new Evento();
     $eventos->nombre = 'Concirto David Bisbal';
     $eventos->fecha = '2014-08-14';
     $eventos->hora = '23:00';
     $eventos->tipo = 'B';
     $eventos->aforo = '1000';
     $eventos->descripcion = 'Concierto del famoso almeriense David Bisbal en Vera (Almeria)';
     $eventos->save();
     $this->call('POST', 'eventos');
     $this->assertRedirectedToRoute('eventos');
 }
Exemple #13
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Evento();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Evento'])) {
         $model->attributes = $_POST['Evento'];
         echo '<pre>';
         print_r($model->attributes);
         echo "</pre>";
         exit;
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
 public function postEvento()
 {
     $reglas = array('nombre' => array('required', 'min:8', 'unique:eventos'), 'fecha' => 'required', 'hora' => 'required', 'tipo' => 'required', 'aforo' => 'required', 'descripcion' => 'required');
     $validator = Validator::make(Input::all(), $reglas);
     if ($validator->fails()) {
         return Redirect::to('/eventos')->withErrors($validator)->withInput();
     } else {
         $eventos = new Evento();
         $eventos->nombre = Input::get('nombre');
         $eventos->fecha = Input::get('fecha');
         $eventos->hora = Input::get('hora');
         $eventos->tipo = Input::get('tipo');
         $eventos->aforo = Input::get('aforo');
         $eventos->descripcion = Input::get('descripcion');
         $eventos->save();
         return Redirect::to('eventos');
     }
 }
	/**
	 * Creates a new model.
	 * If creation is successful, the browser will be redirected to the 'view' page.
	 */
	public function actionCreate()
	{
		$model=new Evento;

		// Uncomment the following line if AJAX validation is needed
		// $this->performAjaxValidation($model);

		if(isset($_POST['Evento']))
		{
			$model->attributes=$_POST['Evento'];
                        $model->utilizador_oid = Utilizador::getIdByUsername(
                                                        Yii::app()->user->name
                                                 );
			if($model->save())
				$this->redirect(array('//pagevento/index','id'=>$model->idevento));
		}

		$this->render('create',array(
			'model'=>$model,
		));
	}
Exemple #16
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     if (Request::ajax()) {
         $response = array();
         $evento = new Evento();
         $evento->start = Input::get('fecha_hora');
         $evento->nombre = Input::get('nombre');
         $evento->descripcion = Input::get('descripcion');
         $evento->ambito_evento = Input::get('ambito_evento');
         $evento->profesores_id = Auth::user()->id;
         if ($evento->validate()) {
             if (empty(Input::get('asunto'))) {
                 $evento->save();
                 return Response::json(array('success' => true));
             } else {
                 $reunion = new Reunion();
                 $reunion->asunto = Input::get('asunto');
                 $reunion->descripcion = Input::get('descripcion_reunion');
                 if (empty(Input::get('ordinaria'))) {
                     $reunion->ordinaria = 0;
                 } else {
                     $reunion->ordinaria = 1;
                 }
                 if ($reunion->validate()) {
                     $evento->save();
                     $reunion->eventos_id = $evento->id;
                     $reunion->save();
                     return Response::json(array('success' => true));
                 } else {
                     return Response::json(array('success' => false, 'errores' => $reunion->errors()->toArray()));
                 }
             }
         } else {
             return Response::json(array('success' => false, 'errores' => $evento->errors()->toArray()));
         }
     } else {
         return Response::json(array('success' => false));
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //$proveedores_galeria = new Proveedor_galeria;
     //$proveedores_galeria->id=0;
     //$proveedores_galeria->proveedores_idproveedor=Input::get('idproveedor');
     //$fecha=''
     //$titulo=Input::get('titulo');
     //$idproveedor=Input::get('idproveedor');
     $authuser = Auth::user();
     if (!File::exists('images/eventos/')) {
         $result = File::makeDirectory('images/eventos/', 0777);
     }
     $rules = array('titulo' => 'required', 'contenido' => 'required', 'fecha_evento' => 'required|date', 'imagen' => 'required|mimes:png,gif,jpeg|max:200000000');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('administracion/eventos/create')->withErrors($validator)->withInput();
     } else {
         $file = Input::file('imagen');
         $evento = new Evento();
         $id = Str::random(4);
         $date_now = new DateTime();
         $destinationPath = 'images/eventos/';
         $filename = $date_now->format('YmdHis') . $id;
         $mime_type = $file->getMimeType();
         $extension = $file->getClientOriginalExtension();
         $upload_success = $file->move($destinationPath, $filename . '.' . $extension);
         $evento->fecha = $date_now;
         $evento->usuario = $authuser->id;
         $evento->titulo = Input::get('titulo');
         $evento->fecha_evento = Input::get('fecha_evento');
         $evento->imagen = $filename . '.' . $extension;
         $evento->contenido = Input::get('contenido');
         $evento->save();
     }
     return Redirect::to("administracion/eventos")->with(array('usuarioimg' => $authuser->imagen, 'usuarionombre' => $authuser->nombre, 'usuarioid' => $authuser->id));
     //
 }
 public function submit_create_evento()
 {
     if (Auth::check()) {
         $data["inside_url"] = Config::get('app.inside_url');
         $data["user"] = Session::get('user');
         $data["permisos"] = Session::get('permisos');
         if (in_array('side_nuevo_evento', $data["permisos"])) {
             // Validate the info, create rules for the inputs
             $attributes = array('nombre' => 'Título del Evento', 'fecha_evento' => 'Fecha del Evento', 'idcolegios' => 'Colegio', 'direccion' => 'Dirección Exacta', 'voluntarios' => 'Voluntarios', 'latitud' => 'Punto en el Mapa');
             $messages = array();
             $rules = array('nombre' => 'required|alpha_spaces|min:2|max:100', 'fecha_evento' => 'required', 'idcolegios' => 'required', 'direccion' => 'required|max:100', 'voluntarios' => 'required', 'latitud' => 'required');
             // Run the validation rules on the inputs from the form
             $validator = Validator::make(Input::all(), $rules, $messages, $attributes);
             // If the validator fails, redirect back to the form
             if ($validator->fails()) {
                 return Redirect::to('eventos/create_evento')->withErrors($validator)->withInput(Input::all());
             } else {
                 /* Primero creo el evento */
                 $evento = new Evento();
                 $evento->nombre = Input::get('nombre');
                 $evento->fecha_evento = date('Y-m-d H:i:s', strtotime(Input::get('fecha_evento')));
                 //$evento->idtipo_eventos = Input::get('idtipo_eventos');
                 $evento->direccion = Input::get('direccion');
                 $evento->latitud = Input::get('latitud');
                 $evento->longitud = Input::get('longitud');
                 $evento->idperiodos = Input::get('idperiodos');
                 $evento->save();
                 /* Creo los puntos de reunion */
                 if (!empty(Input::get('puntos_reunion'))) {
                     foreach (Input::get('puntos_reunion') as $punto_reunion) {
                         $punto_reunion_evento = new PuntoEvento();
                         $punto_reunion_evento->idpuntos_reunion = $punto_reunion;
                         $punto_reunion_evento->ideventos = $evento->ideventos;
                         $punto_reunion_evento->save();
                     }
                 }
                 /* Creo las asistencias de los usuarios */
                 foreach (Input::get('voluntarios') as $voluntario) {
                     $asistencia = new Asistencia();
                     $asistencia->asistio = 0;
                     $asistencia->idusers = $voluntario;
                     $asistencia->ideventos = $evento->ideventos;
                     $asistencia->save();
                 }
                 /* Creo las asistencias de los niños */
                 $ninhos = Ninho::getNinhosPorColegio(Input::get('idcolegios'))->get();
                 foreach ($ninhos as $ninho) {
                     $asistencia_ninho = new AsistenciaNinho();
                     $asistencia_ninho->idninhos = $ninho->idninhos;
                     $asistencia_ninho->ideventos = $evento->ideventos;
                     $asistencia_ninho->save();
                 }
                 /* Envio las notificaciones via e-mail a los voluntarios */
                 $emails_voluntarios = Asistencia::getUsersPorEvento($evento->ideventos)->get();
                 $emails = array();
                 foreach ($emails_voluntarios as $email_voluntario) {
                     $emails[] = $email_voluntario->email;
                 }
                 Mail::send('emails.eventRegistration', array('evento' => $evento), function ($message) use($emails, $evento) {
                     $message->to($emails)->subject('Tienes un nuevo evento de AFI Perú.');
                 });
                 // Llamo a la función para registrar el log de auditoria
                 $descripcion_log = "Se creó el evento con id {{$evento->ideventos}}";
                 Helpers::registrarLog(3, $descripcion_log);
                 Session::flash('message', 'Se registró correctamente el evento.');
                 return Redirect::to('eventos/create_evento');
             }
         } else {
             // Llamo a la función para registrar el log de auditoria
             $descripcion_log = "Se intentó acceder a la ruta '" . Request::path() . "' por el método '" . Request::method() . "'";
             Helpers::registrarLog(10, $descripcion_log);
             Session::flash('error', 'Usted no tiene permisos para realizar dicha acción.');
             return Redirect::to('/dashboard');
         }
     } else {
         return View::make('error/error');
     }
 }
Exemple #19
0
 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     $model = new Evento();
     if (isset($_POST["Evento"])) {
         $model->attributes = $_POST["Evento"];
         $model->estatus_did = 1;
         if ($model->save()) {
             Yii::app()->user->setFlash("info", "Se agregó el evento: " . $model->nombre . ".");
             $this->redirect(array("index"));
         }
     } else {
         $dataProvider = new CActiveDataProvider('Evento');
         $this->render('index', array('dataProvider' => $dataProvider, 'model' => $model));
     }
 }
Exemple #20
0
 function _agregar_editar_form($eventoId = null)
 {
     $respuesta = new stdClass();
     $respuesta->validacion = FALSE;
     $mensaje = '';
     $this->form_validation->set_rules('titulo', 'Título', 'required|trim');
     $this->form_validation->set_rules('url', 'Enlace', 'required|trim|callback__check_url');
     $this->form_validation->set_rules('informacion', 'Información', 'trim|max_length[150]');
     $this->form_validation->set_rules('permanente', 'Periodo', 'callback__check_fecha');
     $this->form_validation->set_rules('region_sel', 'Regiones', 'callback__check_region');
     $this->form_validation->set_rules('servicio_codigo', 'Servicio', 'required|callback__check_servicio');
     $this->form_validation->set_rules('tipo', 'Público objetivo', 'required');
     if ($this->form_validation->run() == TRUE) {
         if ($eventoId) {
             $evento = Doctrine::getTable('Evento')->find($eventoId);
         } else {
             $evento = new Evento();
             $evento->maestro = 1;
             $evento->publicado = 0;
             $evento->estado = NULL;
         }
         if ($this->input->post('region_sel') == 1) {
             $Regiones = Doctrine::getTable('Region')->findAll();
             $regionesArr = array();
             foreach ($Regiones as $r) {
                 $regionesArr[] = $r->id;
             }
         } else {
             $regionesArr = $this->input->post('region');
         }
         // INFO: las fechas en el formulario vienen con otro formato, por lo que es necesario normalizarlas
         $_postulacion_start = $this->input->post('postulacion_start');
         if (preg_match("/^(\\d{2})[-\\/](\\d{2})[-\\/](\\d{4})\$/", $_postulacion_start)) {
             $_aDate = explode('-', $_postulacion_start);
             $_postulacion_start = $_aDate[2] . '-' . $_aDate[1] . '-' . $_aDate[0];
         }
         $_postulacion_end = $this->input->post('postulacion_end');
         if (preg_match("/^(\\d{2})[-\\/](\\d{2})[-\\/](\\d{4})\$/", $_postulacion_end)) {
             $_aDate = explode('-', $_postulacion_end);
             $_postulacion_end = $_aDate[2] . '-' . $_aDate[1] . '-' . $_aDate[0];
         }
         if ($this->input->post('permanente') == 1) {
             $evento->postulacion_start = NULL;
             $evento->postulacion_end = NULL;
             $evento->permanente = 1;
         } else {
             $evento->postulacion_start = $_postulacion_start;
             $evento->postulacion_end = $_postulacion_end;
             $evento->permanente = 0;
         }
         $evento->informacion = $this->input->post('informacion');
         $evento->titulo = $this->input->post('titulo');
         $evento->url = $this->input->post('url');
         $evento->servicio_codigo = $this->input->post('servicio_codigo');
         $evento->tipo = $this->input->post('tipo');
         $evento->destacado = $this->input->post('destacado') ? $this->input->post('destacado') : 0;
         $evento->setRegionesFromArray($regionesArr);
         $evento->save();
         $evento->generarVersion();
         $respuesta->validacion = TRUE;
         $siteUrl = 'backend/eventos' . (!$this->user->tieneRol(array('cal-publicador', 'cal-aprobador')) ? '' : '/ver/' . $evento->id);
         $respuesta->redirect = site_url($siteUrl);
         $this->session->set_flashdata('message', 'Evento actualizado exitosamente.');
     } else {
         $respuesta->validacion = FALSE;
         $respuesta->errores = validation_errors('<p class="error">', '</p>');
     }
     echo json_encode($respuesta);
 }
Exemple #21
0
$docParr = new ParrafoDocumento();
$docParr->cuerpo = 'Documento creado para hacer pruebas.';
$docParr->ubicacion = 0;
$docParr->version()->associate($docVers);
$docParr->save();
$conteni = new Contenido();
$conteni->titulo = 'Primer Documento';
$conteni->categoria_id = 1;
$conteni->autor()->associate($usuario);
$conteni->contenible()->associate($documen);
$conteni->save();
$eventoo = new Evento();
$eventoo->cuerpo = 'Evento creada para hacer pruebas.';
$eventoo->lugar = 'Calle Test 123';
$eventoo->fecha = Carbon\Carbon::parse('2035-07-25 12:00:00');
$eventoo->save();
$conteni = new Contenido();
$conteni->titulo = 'Primer Evento';
$conteni->categoria_id = 1;
$conteni->autor()->associate($usuario);
$conteni->contenible()->associate($eventoo);
$conteni->save();
$novedad = new Novedad();
$novedad->cuerpo = 'Novedad creada para hacer pruebas.';
$novedad->save();
$conteni = new Contenido();
$conteni->titulo = 'Primer Novedad';
$conteni->categoria_id = 1;
$conteni->autor()->associate($usuario);
$conteni->contenible()->associate($novedad);
$conteni->save();
Exemple #22
0
    $validacion = Validator::make(Input::all(), $reglas, $mensajes);
    $validacion->setAttributeNames($friendly_names);
    if ($validacion->fails()) {
        return Redirect::to('admin/eventos/add')->withErrors($validacion)->withInput();
    } else {
        $evento = new Evento();
        $evento->tituloEvento = $datos['txtTitulo'];
        $evento->fechaInicio = $datos['txtFechaInicio'] . " " . $datos['txtHoraInicio'] . ":00";
        $evento->fechaFinal = $datos['txtFechaFinal'] . " " . $datos['txtHoraFinal'] . ":00";
        $evento->textoEvento = $datos['txtTextoEvento'];
        $evento->lugarEventoInicio = $datos['txtLugarInicio'];
        $evento->lugarEventoFinal = $datos['txtLugarFinal'];
        $evento->fkidUsuario = Session::get('idUsuario');
        $evento->fechaPublicacion = date("Y-m-d H:i:s");
        //$n->imagenUrl = "/img/hola.png";
        if ($evento->save()) {
            $evento->imagenUrl = 'imgseventos/' . $evento->id . "." . $imagen->getClientOriginalExtension();
            //guardamos la imagen en public/imgs con el nombre original
            $imagen->move("imgseventos", $evento->id . "." . $imagen->getClientOriginalExtension());
            $evento->save();
            //redirigimos con un mensaje flash
            return Redirect::to('admin/eventos')->with(array('confirm' => 'Evento publicado correctamente.'));
        } else {
            return Redirect::to('admin/eventos')->with(array('error' => 'Error. No se pudo publicar el evento.'));
        }
    }
}));
Route::get("noticias", function () {
    $noticias = Noticia::all();
    return View::make("noticias.index")->with("noticias", $noticias);
});
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate()
 {
     $id = $_POST['id'];
     $model = $this->loadModel($id);
     if ($_POST['type'] == 0) {
         $model->fechaInicio = $_POST['data'][0];
         $model->fechaFin = $_POST['data'][1];
         $model->descripcion = $_POST['data'][2];
         $model->save();
     } elseif ($_POST['type'] == 1) {
         $model_cita = new Cita();
         $model_evento = new Evento();
         $model_evento->fechaInicio = $_POST['data'][0];
         $model_evento->fechaFin = $_POST['data'][1];
         $model_evento->descripcion = $_POST['data'][3];
         $model_evento->save();
         $model_cita->calendario_id = $model_evento->id;
         $model_cita->paciente_id = $_POST['data'][2];
         $model_cita->save();
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     //		if(isset($_POST['Evento']))
     //		{
     //			$model->attributes=$_POST['Evento'];
     //			if($model->save())
     //				$this->redirect(array('view','id'=>$model->id));
     //		}
     //
     //		$this->render('update',array(
     //			'model'=>$model,
     //		));
 }
Exemple #24
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionCrear($id)
 {
     $evento = new Evento();
     if (isset($_POST['Evento'])) {
         $evento->attributes = $_POST['Evento'];
         date_default_timezone_set('America/Bogota');
         setlocale(LC_ALL, 'es_ES.UTF-8');
         $evento->fecha = strtotime($evento->fecha);
         $evento->hora = strtotime($evento->hora);
         if ($evento->save()) {
             Yii::app()->user->setFlash('success', 'Evento ' . $evento->nombre . ' guardado con éxito');
             $this->redirect($_POST['returnUrl'] ? $_POST['returnUrl'] : bu('administrador/pagina/view/' . $evento->pgEventos->pagina_id));
         }
     }
     //if(isset($_POST['Evento']))
     $pgEventos = $id ? PgEventos::model()->with('pagina')->findByPk($id)->id : 0;
     $evento->pg_eventos_id = $pgEventos;
     $this->render('crear', array('model' => $evento));
 }
Exemple #25
0
 private function save($data, $numFila, $recurso, $evento_id)
 {
     $result = true;
     $fechaDesde = sgrDate::dateCSVtoSpanish($data['F_DESDE_HORARIO1']);
     $fechaHasta = sgrDate::dateCSVtoSpanish($data['F_HASTA_HORARIO1']);
     $nRepeticiones = sgrDate::numRepeticiones($fechaDesde, $fechaHasta, $data['COD_DIA_SEMANA']);
     for ($j = 0; $j < $nRepeticiones; $j++) {
         //foreach
         $evento = new Evento();
         //evento periodico o puntual??
         if ($nRepeticiones == 1) {
             $evento->repeticion = 0;
         } else {
             $evento->repeticion = 1;
         }
         $evento->evento_id = $evento_id;
         //fechas de inicio y fin
         $evento->fechaFin = sgrDate::parsedatetime(sgrDate::dateCSVtoSpanish($data['F_HASTA_HORARIO1']), 'd-m-Y', 'Y-m-d');
         //¿por que, no es $fechaDesde ya calculado??
         $evento->fechaInicio = sgrDate::parsedatetime(sgrDate::dateCSVtoSpanish($data['F_DESDE_HORARIO1']), 'd-m-Y', 'Y-m-d');
         //fecha Evento
         $startDate = sgrDate::timeStamp_fristDayNextToDate(sgrDate::dateCSVtoSpanish($data['F_DESDE_HORARIO1']), $data['COD_DIA_SEMANA'], 'Y-m-d');
         $currentfecha = sgrDate::fechaEnesimoDia($startDate, $j);
         $evento->fechaEvento = sgrDate::parsedatetime($currentfecha, 'd-m-Y', 'Y-m-d');
         //horario
         $evento->horaInicio = $data['INI'];
         $evento->horaFin = $data['FIN'];
         //obtner identificador de recurso (espacio o medio)
         //$evento->recurso_id = $this->getRecursoByIdLugar($data['ID_LUGAR']);
         $evento->recurso_id = $recurso->id;
         $evento->estado = 'aprobada';
         //código día de la semana
         $evento->diasRepeticion = json_encode($data['COD_DIA_SEMANA']);
         $evento->dia = $data['COD_DIA_SEMANA'];
         $evento->titulo = $data['ASIGNATURA'] . ' - ' . $data['NOMCOM'];
         $evento->asignatura = $data['ASIGNATURA'];
         $evento->profesor = $data['NOMCOM'];
         $evento->actividad = 'Docencia Reglada P.O.D';
         $evento->dia = $data['COD_DIA_SEMANA'];
         //Asignamos a usuario que carga el pod
         $userPOD = User::where('username', '=', 'pod')->first();
         //$evento->user_id = Auth::user()->id;
         $evento->user_id = $userPOD->id;
         $evento->save();
     }
     //fin foreach
     return $result;
 }