Beispiel #1
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);
 }