Пример #1
0
 private function procesarListaPartidos($postJugadorApi, $postJugadorLocal, $postTorneo, &$listaPartidos)
 {
     $selectTorneos = Torneo::model()->selectTorneos();
     $peticionPartidos = ApiChallonge::getPartidoTorneo($postTorneo['idTorneo']);
     $lengthJugadores = count($postJugadorApi);
     for ($i = 0; $i < $lengthJugadores; $i++) {
         $jugadorApi = $postJugadorApi[$i];
         $jugadorLocal = $postJugadorLocal['jugadorId'][$i];
         $idTorneoLocal = $postJugadorLocal['idTorneoVzla'];
         $posicionJugadorLocal = $postJugadorLocal['posicionJugador'][$i];
         $peticionPartidos = str_replace($jugadorApi, $jugadorLocal, $peticionPartidos);
         $posicionJugador = new JugadorPosicionTorneo();
         $posicionJugador->id_jugador = $jugadorLocal;
         $posicionJugador->id_torneo = $idTorneoLocal;
         $posicionJugador->posicion = $posicionJugadorLocal;
         $posicionJugador->save();
     }
     $jsonPartidos = json_decode($peticionPartidos, true);
     $i = 0;
     foreach ($jsonPartidos as $key => $value) {
         $match = $value['match'];
         $player1Id = $match['player1_id'];
         $player2Id = $match['player2_id'];
         $winnerId = $match['winner_id'];
         $ronda = $match['identifier'];
         $numeroRonda = $match['round'];
         $jugadorVzla1 = Jugador::model()->findByPk($player1Id);
         $jugadorVzla2 = Jugador::model()->findByPk($player2Id);
         $ganadorVzla = Jugador::model()->findByPk($winnerId);
         $listaPartidos .= $this->renderPartial('_listaPartidos', array('jsonPartidos' => $jsonPartidos, 'player1Id' => $player1Id, 'player2Id' => $player2Id, 'winnerId' => $winnerId, 'ronda' => $ronda, 'numeroRonda' => $numeroRonda, 'jugadorVzla1' => $jugadorVzla1, 'jugadorVzla2' => $jugadorVzla2, 'ganadorVzla' => $ganadorVzla, 'i' => $i), true, false);
         $i++;
     }
     $listaPartidos .= Chtml::label('ID Torneo SSBMVZLA', 'ResultadoPvP_idTorneoVzla') . '<br/>' . CHtml::dropDownList('ResultadoPvP[idTorneoVzla]', '', $selectTorneos, array('empty' => '')) . '<br/>';
 }
Пример #2
0
 public static function crear($input)
 {
     $respuesta = [];
     $reglas = ['tipo' => array('required'), 'diainicio' => array('required')];
     $validador = Validator::make($input, $reglas);
     if ($validador->fails()) {
         $respuesta['mensaje'] = $validador;
         $respuesta['error'] = true;
     } else {
         $torneo = Torneo::where('nombre', '=', Input::get('tipo'))->where('codCampeonato', '=', Input::get('codcampeonato'))->first();
         if ($torneo == '') {
             //recuperamos la fecha ingresada y lo acomodamos para ingresar a la base de datos
             $fecha = Input::get('diainicio');
             $mes = substr($fecha, 0, 2);
             $dia = substr($fecha, 3, 2);
             $año = substr($fecha, 6, 4);
             $fecha = $año . '-' . $mes . '-' . $dia;
             //se crea un torneo
             $codCampeonato = Input::get('codcampeonato');
             $users = DB::table('trueda')->count();
             $users++;
             $users1 = (int) substr($codCampeonato, 3, strlen($codCampeonato));
             $codconclusion = "TORO" . $users1 . $users;
             $input = Input::all();
             $newtorneo = new Torneo();
             $newtorneo->codRueda = $codconclusion;
             $newtorneo->nombre = Input::get('tipo');
             $newtorneo->fechaCreacion = $fecha;
             $newtorneo->codCampeonato = $codCampeonato;
             $newtorneo->save();
             $respuesta['mensaje'] = 'Datos guardados correctamente';
             $respuesta['error'] = false;
         } else {
             $respuesta['mensaje'] = 'Este torneo ya existe';
             $respuesta['error'] = true;
         }
     }
     return $respuesta;
 }
Пример #3
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 actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $user = Yii::app()->user;
     $selectTorneos = Torneo::model()->selectTorneos();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['TorneoImagen'])) {
         $model->attributes = $_POST['TorneoImagen'];
         if ($model->save()) {
             $user->setFlash('success', "Datos han sido modificados <strong>satisfactoriamente</strong>.");
             $this->redirect(array('admin'));
         }
     }
     $this->render('update', array('model' => $model, 'selectTorneos' => $selectTorneos));
 }
Пример #4
0
 public function detail($codcampeonato, $idtorneo, $idfecha)
 {
     $torneo = Torneo::where('codRueda', '=', $idtorneo)->first();
     $fecha = Fechas::where('idFecha', '=', $idfecha)->first();
     $fixture = Fixture::where('nroFecha', '=', $fecha->nroFecha)->where('codRueda', '=', $idtorneo)->get();
     $fixturedeequipoqueescansa = Fixtureaux::where('nroFecha', '=', $fecha->nroFecha)->where('codRueda', '=', $idtorneo)->first();
     $equipoquedescansa = '';
     // $todoConclusion = Cambio::all();
     if ($fixturedeequipoqueescansa != '') {
         if ($fixturedeequipoqueescansa->codEquipo1 == '') {
             $equipoquedescansa = Equipo::where('codEquipo', '=', $fixturedeequipoqueescansa->codEquipo2)->first();
         } else {
             $equipoquedescansa = Equipo::where('codEquipo', '=', $fixturedeequipoqueescansa->codEquipo1)->first();
         }
     }
     return View::make('user_com_organizing.fecha.detail', compact('fecha'))->with('fixture', $fixture)->with('torneo', $torneo)->with('equipoquedescansa', $equipoquedescansa)->with('codcampeonato', $codcampeonato);
 }
Пример #5
0
 public function partido($codcampeonato, $codrueda, $idfecha, $codpartido)
 {
     //$todoConclusion = Cambio::all();
     //elementos
     $fecha = Fechas::find($idfecha);
     $partido = Partido::find($codpartido);
     $programacion = Programacion::find($partido->codProgramacion);
     $torneo = Torneo::where('codRueda', '=', $codrueda)->first();
     $arbitros = Arbitro::all();
     $arbixPart = ArbitroPorPartido::where('codPartido', '=', $codpartido)->count();
     $todosArbitros = ArbitroPorPartido::where('codPartido', '=', $codpartido)->get();
     //end elementos
     $nroPartido = $programacion->nroPartido;
     $fixture = Fixture::where('codRueda', '=', $torneo->codRueda)->where('nroFecha', '=', $fecha->nroFecha)->where('nroPartido', '=', $nroPartido)->first();
     //elementos
     $equipo1 = Equipo::find($fixture->codEquipo1);
     $equipo2 = Equipo::find($fixture->codEquipo2);
     $activarPlanilla = Planilla::where('codPartido', '=', $codpartido)->first();
     $fechaactual = DB::select("select curdate() as fecha");
     $fechasiguiente = DB::select("select  adddate(curdate(),1) as fecha");
     $fechaAnterior = DB::select("select  subdate(curdate(),1) as fecha");
     $hora = DB::select("select  curtime() as hora");
     $horaAsistencia = DB::select("select  subtime(?,3000) as fecha", array($partido->horaInicio));
     foreach ($fechaactual as $value) {
         $Factual = $value->fecha;
     }
     foreach ($fechasiguiente as $value) {
         $Fsiguiente = $value->fecha;
     }
     foreach ($hora as $value) {
         $horaA = $value->hora;
     }
     foreach ($fechaAnterior as $value) {
         $Fantes = $value->fecha;
     }
     foreach ($horaAsistencia as $value) {
         $HrAistencia = $value->fecha;
     }
     ///===== es la dia de programacion
     $HH = DB::select("select  if(?=?,1,0) as fecha", array($fecha->diaFecha, $Factual));
     foreach ($HH as $value) {
         $esdiaProgramacion = $value->fecha;
     }
     //end fechaf
     // mañena es dia de programacion
     $HH = DB::select("select  if(?<?,1,0) as fecha", array($fecha->diaFecha, $Fsiguiente));
     foreach ($HH as $value) {
         $manenaProgramacion = $value->fecha;
     }
     // ayer fue dia de programacion
     $HH = DB::select("select  if(?=?,1,0) as fecha", array($fecha->diaFecha, $Fantes));
     foreach ($HH as $value) {
         $ayerFProgramacion = $value->fecha;
     }
     // si la  hora es mayor 23:50
     $HH = DB::select("select  if(?=?,1,0) as fecha", array(substr($horaA, 0, 5), "23:50"));
     foreach ($HH as $value) {
         $esHora = $value->fecha;
     }
     // es hora de inicio
     $HH = DB::select("select  if(curtime()>=? and curtime()<?,1,0) as fecha", array($partido->horaInicio, "23:50:00"));
     foreach ($HH as $value) {
         $HoraI = $value->fecha;
     }
     //hora de tomo asistencia 30 min
     $HH = DB::select("select  if(curtime()>=? and curtime()<=?,1,0) as fecha", array($HrAistencia, $partido->horaInicio));
     foreach ($HH as $value) {
         $AH = $value->fecha;
     }
     $jugadoresequipo1 = "";
     $jugadoresequipo2 = "";
     $activarPlanilla = Planilla::where('codPartido', '=', $codpartido)->first();
     if ($activarPlanilla != "") {
         $Planilla1 = Planilla::where('codPartido', '=', $codpartido)->where('nroPlantilla', '=', 1)->first();
         $Planilla2 = Planilla::where('codPartido', '=', $codpartido)->where('nroPlantilla', '=', 2)->first();
         //$fixture->codEquipo1
         //$Jequipo1 = Jugador::where('codequipo', '=', $fixture->equipo1)->get();
         //$Jequipo2 = Jugador::where('codequipo', '=', $fixture->equipo2)->get();
         //$arbitros = Arbitro::all();
         //todos los jugadores de este partido  $torneo $idtorneo,$idfecha,$idfixture)
     }
     /*
          $Delanteros1 = '';
          $Mediocampistas1 = '';
          $Defensas1 = '';
          $Guardameta1 = '';
          $suplentes1 = '';
          $jugadoresdeunpartido2 = '';
          //recuperamos los arbitros del partido
          $arbitrosdelpartido = '';
          //verificamos si el partido ya se jugó
              //recuperar los datos del partido jugado
              $arbitrosdelpartido = ArbitroPorPartido::where('codPartido','=',$partido->codPartido)->first();
     
              //resuperamos todos los jugadores de este partido  ... un rato
     /*
              $Delanteros1 = DB::table('tjugadorenjuego')
                  ->join('tjugador','tjugadorenjuego.idjugador','=','tjugador.idjugador')
                  ->join('tdocente','tdocente.coddocente','=','tjugador.coddocente')
                  ->join('tequipo','tequipo.codequipo','=','tjugador.codequipo')
                  ->where('tjugadorenjuego.codpartido','=',$partido->codpartido)
                  ->where('tjugador.codequipo','=',$fixture->equipo1)
                  ->where('tjugadorenjuego.condicionenpartido','=','delantero')
                  ->get();
              $Mediocampistas1 = DB::table('tjugadorenjuego')
                  ->join('tjugador','tjugadorenjuego.idjugador','=','tjugador.idjugador')
                  ->join('tdocente','tdocente.coddocente','=','tjugador.coddocente')
                  ->join('tequipo','tequipo.codequipo','=','tjugador.codequipo')
                  ->where('tjugadorenjuego.codpartido','=',$partido->codpartido)
                  ->where('tjugador.codequipo','=',$fixture->equipo1)
                  ->where('tjugadorenjuego.condicionenpartido','=','mediocampista')
                  ->get();
              $Defensas1 = DB::table('tjugadorenjuego')
                  ->join('tjugador','tjugadorenjuego.idjugador','=','tjugador.idjugador')
                  ->join('tdocente','tdocente.coddocente','=','tjugador.coddocente')
                  ->join('tequipo','tequipo.codequipo','=','tjugador.codequipo')
                  ->where('tjugadorenjuego.codpartido','=',$partido->codpartido)
                  ->where('tjugador.codequipo','=',$fixture->equipo1)
                  ->where('tjugadorenjuego.condicionenpartido','=','defensa')
                  ->get();
              $Guardameta1 = DB::table('tjugadorenjuego')
              ->join('tjugador','tjugadorenjuego.idjugador','=','tjugador.idjugador')
              ->join('tdocente','tdocente.coddocente','=','tjugador.coddocente')
              ->join('tequipo','tequipo.codequipo','=','tjugador.codequipo')
              ->where('tjugadorenjuego.codpartido','=',$partido->codpartido)
              ->where('tjugador.codequipo','=',$fixture->equipo1)
              ->where('tjugadorenjuego.condicionenpartido','=','guardameta')
              ->get();
              $suplentes1 = DB::table('tjugadorenjuego')
                  ->join('tjugador','tjugadorenjuego.idjugador','=','tjugador.idjugador')
                  ->join('tdocente','tdocente.coddocente','=','tjugador.coddocente')
                  ->join('tequipo','tequipo.codequipo','=','tjugador.codequipo')
                  ->where('tjugadorenjuego.codpartido','=',$partido->codpartido)
                  ->where('tjugador.codequipo','=',$fixture->equipo1)
                  ->where('tjugadorenjuego.condicionenpartido','=','suplente')
                  ->get();
              $jugadoresdeunpartido2 = DB::table('tjugadorenjuego')
                  ->join('tjugador','tjugadorenjuego.idjugador','=','tjugador.idjugador')
                  ->where('tjugadorenjuego.codpartido','=',$partido->codpartido)
                  ->where('tjugador.codequipo','=',$fixture->equipo2)
                  ->get();
     */
     $activarPlanilla = Planilla::where('codPartido', '=', $codpartido)->first();
     return View::make('user_com_organizing.fecha.partido.index', compact('fixture'))->with('idfecha', $idfecha)->with('torneo', $torneo)->with('programacion', $programacion)->with('codcampeonato', $codcampeonato)->with('arbitros', $arbitros)->with('partido', $partido)->with('arbixPart', $arbixPart)->with('todosArbitros', $todosArbitros)->with('equipo1', $equipo1)->with('equipo2', $equipo2)->with('activarPlanilla', $activarPlanilla)->with('esdiaProgramacion', $esdiaProgramacion)->with('manenaProgramacion', $manenaProgramacion)->with('ayerFProgramacion', $ayerFProgramacion)->with('esHora', $esHora)->with('HoraI', $HoraI)->with('AH', $AH);
     //->with('todoConclusion', $todoConclusion);
 }
Пример #6
0
 /**
 * Returns the data model based on the primary key given in the GET variable.
 * If the data model is not found, an HTTP exception will be raised.
 * @param integer the ID of the model to be loaded
 */
 public function loadModel($id)
 {
     $model = Torneo::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #7
0
 public function detail($codcampeonato, $idtorneo)
 {
     //$tabla = DB::select('call TABLAPOSICIONES');
     $fixture = Fixture::where('codRueda', '=', $idtorneo)->get();
     $fechas = Fechas::where('codRueda', '=', $idtorneo)->get();
     //$equipos = Equipoxtorneo::where('codRueda', '=', $idtorneo)->get();
     $fechasdeltorneo = Fechas::where('codRueda', '=', $idtorneo)->get();
     $campeonato = Campeonato::where('codCampeonato', '=', $codcampeonato)->first();
     $torneo = Torneo::where('codRueda', '=', $idtorneo)->first();
     $nroequipos = $this->nroequipos($codcampeonato);
     return View::make('user_com_organizing.torneo.detail', compact('fechasdeltorneo'))->with('codcampeonato', $codcampeonato)->with('torneo', $torneo)->with('nroequipos', $nroequipos);
 }
Пример #8
0
 public function selectTorneos()
 {
     $model = Torneo::model()->findAll(array('select' => 'nombre, id', 'order' => 'nombre'));
     $lista = CHtml::listdata($model, 'id', 'nombre');
     return $lista;
 }
Пример #9
0
 public function getIndex()
 {
     $data['torneos'] = Torneo::all();
     return View::make('torneos.index', $data);
 }