<?php
class RifasControlador extends Controladores {
function inicio() {
Vistas::mostrarApps("rifas", "panel-inicio",array());
}
function sorteosActivos(){
$Sorteos = SorteosRifas::activos();
Vistas::mostrarApps("rifas", "sorteos-activos",array( "Sorteos" => $Sorteos ));
}
function verFormularioAsistencia(){
$Sorteo = SorteosRifas::datos($this->sorteo);
Vistas::mostrarApps("rifas", "form-asistencia",array( "Sorteo" => $Sorteo ));
}
function verConfiguracion() {
Vistas::mostrarApps("rifas", "form-config",
array()
);
}
function verRuleta() {
$Sorteo = SorteosRifas::datosCompletos($this->sorteo);
Vistas::mostrarApps("rifas", "juego-ruleta",array("Sorteo" => $Sorteo));
}
function cargarRuleta() {
$Sorteo = SorteosRifas::datosCompletos($this->sorteo);
Vistas::mostrarApps("rifas", "ruleta",array("Sorteo" => $Sorteo));
}
function todos() {
$colaboradores = Colaboradores::todos();
echo RespuestasSistema::exito(array("Colaboradores" => $colaboradores));
}
function asistentes() {
$Premio = null;
if( isset($this->premio) and !is_null($this->premio) ){
$Premio = SorteosRifas::datosPremio($this->premio);
}
$Asistentes = SorteosRifas::asistentes($this->sorteo);
//print_r($Asistentes);
if(count($Asistentes)){
echo RespuestasSistema::exito("", array("Asistentes" => $Asistentes, "Premio" => $Premio));
}else{
echo RespuestasSistema::alerta("Todavia no ha llegado nadie.");
}
}
function asistentesSinGanar() {
$Premio = null;
if( isset($this->premio) and !is_null($this->premio) ){
$Premio = SorteosRifas::datosPremio($this->premio);
}
$Asistentes = SorteosRifas::asistentesSinGanar($this->sorteo);
//print_r($Asistentes);
if(count($Asistentes)){
echo RespuestasSistema::exito("", array("Asistentes" => $Asistentes, "Premio" => $Premio));
}else{
echo RespuestasSistema::alerta("Todavia no ha llegado nadie.");
}
}
function todosAsistentes() {
$Asistentes = SorteosRifas::asistentes($this->sorteo);
Vistas::mostrarApps(
'rifas','tbl-asistentes',
array('Asistentes' => $Asistentes)
);
}
function todosPremios() {
$Premios = SorteosRifas::premios($this->sorteo);
Vistas::mostrarApps("rifas", "todos-premios",
array('Premios' => $Premios)
);
}
function todosParticipantes() {
$Asistentes = SorteosRifas::asistentes($this->sorteo);
Vistas::mostrarApps("rifas", "todos-participantes",
array('Asistentes' => $Asistentes)
);
}
function datosColaborador() {
$Persona = Colaboradores::porCedula($this->identificacion);
if (!is_null($Persona)) {
echo RespuestasSistema::exito("",array("Persona" => $Persona));
} else {
echo RespuestasSistema::fallo("No se encontró una persona con identificación [" . $this->identificacion . " ], verifique el tipo y el número e intente nuevamente!");
}
}
function registrarAsistente() {
$Persona = Colaboradores::porIdentificacion( TiposIdentificacion::CEDULA, $this->identificacion);
if( SorteosRifas::estaInscrito($this->sorteo, $Persona->personaID) ){
echo RespuestasSistema::alerta("Ya está inscrito en el sorteo!");
}else{
$Registrado = SorteosRifas::registrarAsistente($this->sorteo , $Persona->personaID , $Persona->colaboradorID);
if (!is_null($Registrado)) {
echo RespuestasSistema::exito("REGISTRADO en el Sorteo!");
} else {
echo RespuestasSistema::fallo("Falló el registro de la persona con identificación [" . $this->identificacion . " ], verifique el tipo y el número e intente nuevamente!");
}
}
}
function registrarGanador(){
$actualizado = SorteosRifas::registrarGanadorPremio($this->premio, $this->participante);
if( $actualizado > 0 ){
echo RespuestasSistema::exito("", array());
}else{
echo RespuestasSistema::fallo("No se pudo registrar el ganador del premio");
}
}
}