예제 #1
0
파일: Liga.php 프로젝트: jortiz-el/PhP
 public function generaLiga($liga)
 {
     $interval = new DateInterval("P7D");
     $fecha = new DateTime("2014-11-2");
     $format = "Y-m-d";
     foreach ($liga as $num => $partidos) {
         $fechaPartido = $fecha->format($format);
         $jornada = new Jornadas($this->id, $fechaPartido);
         $jornada->persit();
         $fecha->add($interval);
         foreach ($partidos as $jugado) {
             $partido = new Partidos($jornada->getId(), $jugado['local'], $jugado['visitante']);
             $partido->persit();
         }
     }
 }
예제 #2
0
 /** deploy a contest->journeys->series->rounds tree */
 function publicweb_deploy()
 {
     $result = array();
     // retrieve contest data
     $result['Prueba'] = $this->prueba;
     // retrieve journeys for this contest
     $result['Jornadas'] = $this->myDBObject->__select("*", "Jornadas", "(Prueba={$this->prueba['ID']}) AND (Nombre != '-- Sin asignar --') ", "", "")['rows'];
     foreach ($result['Jornadas'] as &$jornada) {
         // retrieve rounds for each series
         $jornada['Mangas'] = Jornadas::enumerateMangasByJornada($jornada['ID'])['rows'];
         // retrieve series for each journey
         $tnd = new Tandas("publicweb_deploy", $this->prueba['ID'], $jornada['ID']);
         $jornada['Tandas'] = $tnd->getTandas(0)['rows'];
         // incluye user defined rounds ( to display timetable )
         // retrieve final results index for each series
         $jornada['Series'] = Jornadas::enumerateRondasByJornada($jornada['ID'])['rows'];
     }
     return $result;
 }
예제 #3
0
 /**
  * @param {mixed} $jobj JornadaID or JornadaObject as returned by _getObject() / _getArray()
  * @return bool true or false
  */
 static function hasGrades($jobj)
 {
     if (is_numeric($jobj)) {
         $obj = new Jornadas("hasGrades", 0);
         // dummy prueba id
         $jobj = $obj->selectByID($jobj);
     }
     $flag = true;
     if (is_object($jobj)) {
         if (intval($jobj->Open) != 0) {
             $flag = false;
         }
         if (intval($jobj->Equipos3) != 0) {
             $flag = false;
         }
         if (intval($jobj->Equipos4) != 0) {
             $flag = false;
         }
         if (intval($jobj->KO) != 0) {
             $flag = false;
         }
     }
     if (is_array($jobj)) {
         if (intval($jobj['Open']) != 0) {
             $flag = false;
         }
         if (intval($jobj['Equipos3']) != 0) {
             $flag = false;
         }
         if (intval($jobj['Equipos4']) != 0) {
             $flag = false;
         }
         if (intval($jobj['KO']) != 0) {
             $flag = false;
         }
     }
     return $flag;
 }
 function composeTable()
 {
     $this->myLogger->enter();
     $this->ac_SetDrawColor($this->config->getEnv('pdf_linecolor'));
     $this->SetLineWidth(0.3);
     if ($this->federation->get('WideLicense')) {
         $this->pos[1] += 5;
         $this->pos[2] = 0;
         $this->pos[3] += 5;
         $this->pos[4] += 5;
     }
     // Datos
     $rowcount = 0;
     $numrows = $this->PageNo() == 1 ? 30 : 33;
     $this->myLogger->trace("before foreach");
     foreach ($this->resultados['rows'] as $row) {
         // REMINDER: $this->cell( width, height, data, borders, where, align, fill)
         if ($rowcount % $numrows == 0) {
             // assume $numrows rows per page ( rowWidth = 7mmts )
             if ($rowcount > 0) {
                 $this->Cell(array_sum($this->pos), 0, '', 'T');
             }
             // linea de cierre
             $this->addPage();
             $this->writeTableHeader();
         }
         // properly format special fields
         $puesto = $row['Penalizacion'] >= 200 ? "-" : "{$row['Puesto']}";
         $veloc = $row['Penalizacion'] >= 200 ? "-" : number_format($row['Velocidad'], 1);
         $tiempo = $row['Penalizacion'] >= 200 ? "-" : number_format($row['Tiempo'], $this->timeResolution);
         $penal = number_format($row['Penalizacion'], $this->timeResolution);
         $this->ac_row($rowcount, 8);
         // print row data
         $this->SetFont($this->getFontName(), '', 8);
         // set data font size
         $this->Cell($this->pos[0], 6, $row['Dorsal'], 'LR', 0, $this->align[0], true);
         $this->SetFont($this->getFontName(), 'B', 8);
         // mark Nombre as bold
         $this->Cell($this->pos[1], 6, $row['Nombre'], 'LR', 0, $this->align[1], true);
         $this->SetFont($this->getFontName(), '', 8);
         // set data font size
         if ($this->pos[2] != 0) {
             $this->Cell($this->pos[2], 6, $row['Licencia'], 'LR', 0, $this->align[2], true);
         }
         $this->Cell($this->pos[3], 6, $row['NombreGuia'], 'LR', 0, $this->align[3], true);
         $this->Cell($this->pos[4], 6, $row['NombreClub'], 'LR', 0, $this->align[4], true);
         if (Jornadas::hasGrades($this->jornada->ID)) {
             $this->Cell($this->pos[5], 6, $row['Categoria'] . ' - ' . $row['Grado'], 'LR', 0, $this->align[5], true);
         } else {
             // $catstr=$row['Categoria'];
             $catstr = $this->federation->getCategory($row['Categoria']);
             $this->Cell($this->pos[5], 6, $catstr, 'LR', 0, $this->align[5], true);
         }
         $this->Cell($this->pos[6], 6, $row['Faltas'], 'LR', 0, $this->align[6], true);
         $this->Cell($this->pos[7], 6, $row['Tocados'], 'LR', 0, $this->align[7], true);
         $this->Cell($this->pos[8], 6, $row['Rehuses'], 'LR', 0, $this->align[8], true);
         $this->Cell($this->pos[9], 6, $tiempo, 'LR', 0, $this->align[9], true);
         $this->Cell($this->pos[10], 6, $veloc, 'LR', 0, $this->align[10], true);
         $this->Cell($this->pos[11], 6, $penal, 'LR', 0, $this->align[11], true);
         $this->Cell($this->pos[12], 6, $row['Calificacion'], 'LR', 0, $this->align[12], true);
         $this->SetFont($this->getFontName(), 'B', 11);
         // bold 11px
         $this->Cell($this->pos[13], 6, $puesto, 'LR', 0, $this->align[13], true);
         $this->Ln();
         $rowcount++;
     }
     // Línea de cierre
     $this->Cell(array_sum($this->pos), 0, '', 'T');
     $this->myLogger->leave();
 }
예제 #5
0
 /**
  * Pagina de resultados de la jornada ordenados por grado/categoría/puesto
  * @param {array} $jornada datos de la jornada
  * @param {object} $insc objeto de tipo Inscripcion con las inscripciones de la prueba
  */
 function createJornadaDataPage($jornada, $insc)
 {
     // create Excel sheet
     $jdatapage = $this->myWriter->addNewSheetAndMakeItCurrent();
     $name = $this->normalizeSheetName("Data " . $jornada['Nombre']);
     $jdatapage->setName($name);
     // write table header
     $this->writeTableHeader();
     $rondas = Jornadas::enumerateRondasByJornada($jornada['ID'])['rows'];
     // obtenemos los datos "personales" de los perros de la jornada
     $lista = $insc->inscritosByJornada($jornada['ID'], false)['rows'];
     $eq = new Equipos("excel_printInscripciones", $this->prueba['ID'], $jornada['ID']);
     $inscritos = array();
     foreach ($lista as $perro) {
         // add team information
         $perro['Equipo'] = $eq->getTeamByPerro($perro['Perro'])['Nombre'];
         // reindexamos las inscripciones por el PerroID
         $inscritos[$perro['Perro']] = $perro;
     }
     // obtenemos todas las clasificaciones de la jornada
     $clas = new Clasificaciones("excel_Clasificaciones", $this->prueba['ID'], $jornada['ID']);
     $results = array();
     foreach ($rondas as $ronda) {
         $mangas = array($ronda['Manga1'], $ronda['Manga2']);
         $clasifRonda = $clas->clasificacionFinal($ronda['Rondas'], $mangas, $ronda['Mode']);
         $results = array_merge($results, $clasifRonda['rows']);
     }
     // OK ya tenemos los datos de toda la jornada; ahora a ordenar por grado,categoría y puesto
     usort($results, function ($a, $b) {
         $res = strcmp($a['Grado'], $b['Grado']);
         if ($res != 0) {
             return $res;
         }
         $res = strcmp($a['Categoria'], $b['Categoria']);
         if ($res != 0) {
             return $res;
         }
         return $a['Puesto'] > $b['Puesto'] ? 1 : -1;
     });
     // componemos la fila Excel anyiadiendo datos personales
     //
     // 'Dorsal',
     // 'Nombre','NombreLargo','Genero','Raza','Licencia','LOE_RRC','Categoria','Grado','NombreGuia','NombreClub','Pais', // datos del perro
     // 'Equipo','Celo','Observaciones', // datos de la inscripcion en la jornada
     // 'F1','R1','E1','N1','Tiempo1','Penal1', // datos de la manga 1
     // 'F2','R2','E2','N2','Tiempo2','Penal2', // datos de la manga 2
     //  // TODO: handle series with more than 2 rounds
     // 'Tiempo','Penalizacion','Calificacion'
     foreach ($results as $perro) {
         $row = array();
         // si el perro no esta en la lista de inscritos, marca error e ignora entrada
         if (!array_key_exists($perro['Perro'], $inscritos)) {
             $this->myLogger->error("Encontrada Clasificacion para perro no inscrito:" . $perro['Perro']);
             continue;
         }
         $pdata =& $inscritos[$perro['Perro']];
         $pdata['Done'] = 1;
         // mark perro inscrito _and_ with clasification
         // datos personales
         $row[] = $perro['Dorsal'];
         $row[] = $pdata['Nombre'];
         $row[] = $pdata['NombreLargo'];
         $row[] = $pdata['Genero'];
         $row[] = $pdata['Raza'];
         $row[] = $pdata['Licencia'];
         $row[] = $pdata['LOE_RRC'];
         $row[] = $pdata['Categoria'];
         $row[] = $pdata['Grado'];
         $row[] = $pdata['NombreGuia'];
         $row[] = $pdata['NombreClub'];
         $row[] = $pdata['Pais'];
         // Datos de la inscripcion
         $row[] = $pdata['Equipo'];
         $row[] = $pdata['Celo'];
         $row[] = $pdata['Observaciones'];
         // resultados manga 1
         $row[] = $perro['F1'];
         // Manga 1: faltas + tocados
         $row[] = $perro['R1'];
         // Manga 1: rehuses
         $row[] = $perro['E1'];
         // Manga 1: eliminado
         $row[] = $perro['N1'];
         // manga 1: no presentado
         $row[] = $perro['T1'];
         // manga 1: tiempo
         $row[] = $perro['P1'];
         // manga 1: penalizacion
         // resultados manga 2
         $row[] = $perro['F2'];
         // Manga 2: faltas + tocados
         $row[] = $perro['R2'];
         // Manga 2: rehuses
         $row[] = $perro['E2'];
         // Manga 2: eliminado
         $row[] = $perro['N2'];
         // manga 2: no presentado
         $row[] = $perro['T2'];
         // manga 2: tiempo
         $row[] = $perro['P2'];
         // manga 2: penalizacion
         // datos globales de clasificacion
         $row[] = $perro['Tiempo'];
         $row[] = $perro['Penalizacion'];
         $row[] = $perro['Calificacion'];
         // !!finaly!! add perro to excel table
         $this->myWriter->addRow($row);
     }
     // por ultimo metemos las inscripciones que no tienen resultado asociado
     foreach ($inscritos as $pdata) {
         if (array_key_exists('Done', $pdata)) {
             continue;
         }
         // already done
         $row = array();
         // datos personales
         $row[] = $pdata['Dorsal'];
         $row[] = $pdata['Nombre'];
         $row[] = $pdata['NombreLargo'];
         $row[] = $pdata['Genero'];
         $row[] = $pdata['Raza'];
         $row[] = $pdata['Licencia'];
         $row[] = $pdata['LOE_RRC'];
         $row[] = $pdata['Categoria'];
         $row[] = $pdata['Grado'];
         $row[] = $pdata['NombreGuia'];
         $row[] = $pdata['NombreClub'];
         $row[] = $pdata['Pais'];
         // add perro without results to excel table
         $this->myWriter->addRow($row);
     }
 }
예제 #6
0
 function __construct($sessionid, $pruebaid = 0, $jornadaid = 0, $mangaid = 0, $tandatype = 0, $mode = 0)
 {
     $this->config = Config::getInstance();
     $this->myLogger = new Logger("VideoWall.php", $this->config->getEnv("debug_level"));
     $this->myDBObject = new DBObject("Videowall");
     $this->manga = null;
     $this->tanda = null;
     $this->ronda = null;
     $this->mangaid = $mangaid;
     $this->tandatype = $tandatype;
     $tandaid = 0;
     if ($sessionid != 0) {
         // obtenemos los datos desde la sesion abierta en el tablet
         $this->session = $this->myDBObject->__getArray("Sesiones", $sessionid);
         $this->sessionid = $sessionid;
         $pruebaid = $this->session['Prueba'];
         $jornadaid = $this->session['Jornada'];
         $mangaid = $this->session['Manga'];
         $tandaid = $this->session['Tanda'];
         $this->mode = -1;
     } else {
         // obtenemos los datos desde las variables recibidas por http
         $this->session = null;
         $this->sessionid = 0;
         $this->mode = $mode;
     }
     $this->prueba = $this->myDBObject->__getArray("Pruebas", $pruebaid);
     $this->jornada = $this->myDBObject->__getArray("Jornadas", $jornadaid);
     if ($mangaid != 0) {
         $this->manga = $this->myDBObject->__getArray("Mangas", $mangaid);
         $this->manga['Manga'] = $mangaid;
         // manga['ID'] contains extra info and should not be used
         $this->mangaid = $mangaid;
     }
     if ($tandaid != 0) {
         $this->tanda = $this->myDBObject->__getArray("Tandas", $tandaid);
         $this->tandatype = $this->tanda['Tipo'];
     }
     // retrieve rounds for this journey
     if ($mangaid != 0) {
         $rondas = Jornadas::enumerateRondasByJornada($jornadaid)['rows'];
         foreach ($rondas as $ronda) {
             $cat = Tandas::$tipo_tanda[$this->tandatype]['Categoria'];
             $this->myLogger->trace("MangaID {$this->mangaid} Cat: {$cat} Ronda: " . json_encode($ronda));
             if ($ronda['Manga1'] == $this->mangaid) {
                 foreach (str_split($cat) as $c) {
                     if (strpos($ronda['Categoria'], $c) === false) {
                         continue;
                     }
                     $this->ronda = $ronda;
                     break;
                 }
             }
             if ($ronda['Manga2'] == $this->mangaid) {
                 foreach (str_split($cat) as $c) {
                     if (strpos($ronda['Categoria'], $c) === false) {
                         continue;
                     }
                     $this->ronda = $ronda;
                     break;
                 }
             }
         }
     }
     $this->club = $this->myDBObject->__getArray("Clubes", $this->prueba['Club']);
     if ($this->manga != null) {
         // elimina parentesis del nombre
         $str = Mangas::$tipo_manga[$this->manga['Tipo']][1];
         $a = strpos($str, "(");
         if ($a !== FALSE) {
             $str = substr($str, 0, $a);
         }
         $this->manga['Nombre'] = $str;
     }
     $this->myLogger->info("sesion:{$sessionid} prueba:{$this->prueba['ID']} jornada:{$this->jornada['ID']} manga:{$this->mangaid} tanda:{$this->tandatype} mode:{$mode}");
 }
예제 #7
0
 function getResultadosEquipos($mode)
 {
     // obtenemos resultados individuales
     $resultados = $this->getResultados($mode);
     // obtenemos los equipos de la jornada cuya categoria coincide con la buscada
     $teams = array();
     foreach ($this->getDatosEquipos() as $equipo) {
         if ($equipo['Nombre'] === "-- Sin asignar --") {
             continue;
         }
         // comprobamos la categoria. si no coincide tiramos el equipo
         $modes = array("L", "M", "S", "MS", "LMS", "T", "LM", "ST", "LMST");
         if (!category_match($equipo['Categorias'], $modes[$mode])) {
             continue;
         }
         $r = array_merge($equipo, array('Count' => 0, 'Tiempo' => 0, 'Penalizacion' => 0));
         $teams[$equipo['ID']] = $r;
     }
     // procesamos manga Se asume que los resultados ya vienen ordenados por puesto,
     $mindogs = Jornadas::getTeamDogs($this->getDatosJornada())[0];
     // get mindogs
     // de manera que se contabilizan solo los mindogs primeros perros de cada equipo
     foreach ($resultados['rows'] as $resultado) {
         $eq = $resultado['Equipo'];
         if (!array_key_exists($eq, $teams)) {
             $this->myLogger->notice("evalFinalEquipos(): Prueba:{$this->IDPrueba} Jornada:{$this->IDJornada} Manga:1 Equipo:{$eq} no existe");
             continue;
         }
         if ($teams[$eq]['Count'] >= $mindogs) {
             continue;
         }
         $teams[$eq]['Count']++;
         $teams[$eq]['Tiempo'] += $resultado['Tiempo'];
         $teams[$eq]['Penalizacion'] += $resultado['Penalizacion'];
     }
     // rellenamos huecos hasta completar mindogs
     foreach ($teams as &$team) {
         // 100:Eliminado 200:NoPresentado 400:Pendiente
         for ($n = $team['Count']; $n < $mindogs; $n++) {
             $team['Penalizacion'] += 400;
         }
     }
     // eliminamos el indice del array
     $equipos = array_values($teams);
     // re-ordenamos los datos en base a la puntuacion
     usort($equipos, function ($a, $b) {
         if ($a['Penalizacion'] == $b['Penalizacion']) {
             return $a['Tiempo'] > $b['Tiempo'] ? 1 : -1;
         }
         return $a['Penalizacion'] > $b['Penalizacion'] ? 1 : -1;
     });
     // retornamos resultado
     $resultados['individual'] = $resultados['rows'];
     $resultados['equipos'] = $equipos;
     return $resultados;
 }
 /**
  * Constructor
  * @param {integer} $prueba Prueba ID
  * @param {array} $inscritos Lista de inscritos en formato jquery array[count,rows[]]
  * @throws Exception
  */
 function __construct($prueba, $inscritos, $jornadas, $jornadaid)
 {
     parent::__construct('Portrait', 'print_inscritosByJornada', $prueba, 0);
     if ($prueba == 0 || $inscritos === null) {
         $this->errormsg = "printInscritosByPrueba: either prueba or inscription data are invalid";
         throw new Exception($this->errormsg);
     }
     usort($inscritos['rows'], function ($a, $b) {
         return $a['Dorsal'] > $b['Dorsal'] ? 1 : -1;
     });
     $this->inscritos = $inscritos['rows'];
     $this->jornadas = $jornadas['rows'];
     $this->setPageName("inscritosByJornada.pdf");
     $this->cellHeader = array(_('Dorsal'), _('Name'), _('Lic'), _('Handler'), $this->strClub, _('Cat'), _('Grado'), _('Heat'), _('Comments'));
     $this->JName = "";
     foreach ($jornadas['rows'] as $j) {
         if ($j['ID'] == $jornadaid) {
             $this->jornada = $j;
             $this->JName = "J{$j['Numero']}";
             // remove "Grade" from cell array if jornada is open/team/KO
             if (!Jornadas::hasGrades($j)) {
                 $this->pos[5] = 16;
                 // increase category size
                 $this->pos[6] = 0;
                 // set grade size to zero
             }
             break;
         }
     }
     if ($this->JName === "") {
         $this->errormsg = "printInscritosByJornada: Invalid Jornada ID:{$jornadaid} for provided prueba";
         throw new Exception($this->errormsg);
     }
 }
예제 #9
0
 function writeCell($idx, $row)
 {
     $wide = $this->federation->get('WideLicense');
     // use extra space for wide license id
     // REMINDER: $this->cell( width, height, data, borders, where, align, fill)
     $offset = $this->PageNo() == 1 ? 80 : 55;
     $this->SetXY(10, $offset + 6 * $idx);
     // first page has 3 extra header lines
     $fill = $idx % 2 != 0 ? true : false;
     // fomateamos datos
     $puesto = $row['Penalizacion'] >= 200 ? "-" : "{$row['Puesto']}º";
     $penal = number_format($row['Penalizacion'], $this->timeResolution);
     $tiempo = number_format($row['Tiempo'], $this->timeResolution);
     $v1 = $row['P1'] >= 200 ? "-" : number_format($row['V1'], 1);
     $t1 = $row['P1'] >= 200 ? "-" : number_format($row['T1'], $this->timeResolution);
     $p1 = number_format($row['P1'], $this->timeResolution);
     $v2 = $row['P2'] >= 200 ? "-" : number_format($row['V2'], 1);
     $t2 = $row['P2'] >= 200 ? "-" : number_format($row['T2'], $this->timeResolution);
     $p2 = number_format($row['P2'], $this->timeResolution);
     // REMINDER: $this->cell( width, height, data, borders, where, align, fill)
     $this->SetFont($this->getFontName(), '', 8);
     // default font
     // datos del participante
     $this->Cell(10, 6, $row['Dorsal'], 0, 0, 'L', $fill);
     // dorsal
     $this->SetFont($this->getFontName(), 'B', 8);
     // Display Nombre in bold typeface
     $this->Cell($wide ? 20 : 25, 6, $row['Nombre'], 0, 0, 'L', $fill);
     // nombre (20,y
     $this->SetFont($this->getFontName(), '', $wide ? 6 : 8);
     // default font
     $this->Cell($wide ? 30 : 15, 6, $row['Licencia'], 0, 0, 'C', $fill);
     // licencia
     $this->SetFont($this->getFontName(), '', 8);
     // default font
     if (Jornadas::hasGrades($this->jornada)) {
         $this->Cell(10, 6, "{$row['Categoria']} {$row['Grado']}", 0, 0, 'C', $fill);
         // categoria/grado
     } else {
         $this->Cell(10, 6, "{$row['Categoria']}", 0, 0, 'C', $fill);
         // categoria/grado
     }
     $this->Cell($wide ? 30 : 35, 6, $row['NombreGuia'], 0, 0, 'R', $fill);
     // nombreGuia
     $this->Cell($wide ? 15 : 20, 6, $row['NombreClub'], 0, 0, 'R', $fill);
     // nombreClub
     // manga 1
     $this->Cell(7, 6, $row['F1'], 0, 0, 'C', $fill);
     // 1- Faltas+Tocados
     $this->Cell(7, 6, $row['R1'], 0, 0, 'C', $fill);
     // 1- Rehuses
     $this->Cell(12, 6, $t1, 0, 0, 'C', $fill);
     // 1- Tiempo
     $this->Cell(9, 6, $v1, 0, 0, 'C', $fill);
     // 1- Velocidad
     $this->Cell(12, 6, $p1, 0, 0, 'C', $fill);
     // 1- Penalizacion
     $this->Cell(10, 6, $row['C1'], 0, 0, 'C', $fill);
     // 1- calificacion
     // manga 2
     if ($this->manga2 != null) {
         $this->Cell(7, 6, $row['F2'], 0, 0, 'C', $fill);
         // 2- Faltas+Tocados
         $this->Cell(7, 6, $row['R2'], 0, 0, 'C', $fill);
         // 2- Rehuses
         $this->Cell(12, 6, $t2, 0, 0, 'C', $fill);
         // 2- Tiempo
         $this->Cell(9, 6, $v2, 0, 0, 'C', $fill);
         // 2- Velocidad
         $this->Cell(12, 6, $p2, 0, 0, 'C', $fill);
         // 2- Penalizacion
         $this->Cell(10, 6, $row['C2'], 0, 0, 'C', $fill);
         // 2- calificacion
     } else {
         $this->Cell(57, 6, '', 0, 0, 'C', $fill);
         // espacio en blanco
     }
     // global
     $this->Cell(12, 6, $tiempo, 0, 0, 'C', $fill);
     // Tiempo
     $this->Cell(12, 6, $penal, 0, 0, 'C', $fill);
     // Penalizacion
     $this->Cell(14, 6, $row['Calificacion'], 0, 0, 'C', $fill);
     // Calificacion
     $this->SetFont($this->getFontName(), 'B', 10);
     // default font
     $this->Cell(8, 6, $puesto, 0, 0, 'C', $fill);
     // Puesto
     // lineas rojas
     $this->ac_SetDrawColor($this->config->getEnv('pdf_linecolor'));
     $this->Line(10, $offset + 6 * $idx, 10, $offset + 6 * ($idx + 1));
     $this->Line(10 + 115, $offset + 6 * $idx, 10 + 115, $offset + 6 * ($idx + 1));
     $this->Line(10 + 172, $offset + 6 * $idx, 10 + 172, $offset + 6 * ($idx + 1));
     $this->Line(10 + 229, $offset + 6 * $idx, 10 + 229, $offset + 6 * ($idx + 1));
     $this->Line(10 + 275, $offset + 6 * $idx, 10 + 275, $offset + 6 * ($idx + 1));
     $this->Ln();
 }
예제 #10
0
 /**
  * Borra una prueba
  * @param {integer} $id ID de la prueba
  * @return string
  */
 function delete($id)
 {
     $this->myLogger->enter();
     // pruebaID==1 is default prueba, so avoid deletion
     if ($id <= 1) {
         return $this->error("pruebas::delete() Invalid Prueba ID:{$id}");
     }
     // Borramos resultados asociados a esta prueba
     $res = $this->query("DELETE FROM Resultados WHERE ( Prueba={$id})");
     if (!$res) {
         return $this->error($this->conn->error);
     }
     // Borramos inscripciones de esta prueba
     $res = $this->query("DELETE FROM Inscripciones WHERE ( Prueba={$id})");
     if (!$res) {
         return $this->error($this->conn->error);
     }
     // Borramos las jornadas (y mangas) de esta prueba
     $j = new Jornadas("Pruebas.php", $id);
     $j->deleteByPrueba();
     // Borramos tambien las tandas de las jornadas de esta prueba
     $res = $this->query("DELETE FROM Tandas WHERE ( Prueba={$id})");
     if (!$res) {
         return $this->error($this->conn->error);
     }
     // finalmente intentamos eliminar la prueba
     $res = $this->query("DELETE FROM Pruebas WHERE (ID={$id})");
     if (!$res) {
         return $this->error($this->conn->error);
     }
     $this->myLogger->leave();
     return "";
 }
예제 #11
0
 function writeCell($idx, $row)
 {
     // REMINDER: $this->cell( width, height, data, borders, where, align, fill)
     $y = $this->getY();
     $this->SetX(10);
     // first page has 3 extra header lines
     $this->ac_row($idx, 9);
     // fomateamos datos
     $puesto = $row['Penalizacion'] >= 200 ? "-" : "{$row['Puesto']}º";
     $penal = number_format($row['Penalizacion'], $this->timeResolution);
     $tiempo = number_format($row['Tiempo'], $this->timeResolution);
     $v1 = $row['P1'] >= 200 ? "-" : number_format($row['V1'], 1);
     $t1 = $row['P1'] >= 200 ? "-" : number_format($row['T1'], $this->timeResolution);
     $p1 = number_format($row['P1'], $this->timeResolution);
     $v2 = $row['P2'] >= 200 ? "-" : number_format($row['V2'], 1);
     $t2 = $row['P2'] >= 200 ? "-" : number_format($row['T2'], $this->timeResolution);
     $p2 = number_format($row['P2'], $this->timeResolution);
     // REMINDER: $this->cell( width, height, data, borders, where, align, fill)
     // datos del participante
     $this->Cell(10, 6, $row['Dorsal'], 0, 0, 'R', true);
     // dorsal
     $this->SetFont($this->getFontName(), 'B', 9);
     // bold font
     $this->Cell(25, 6, $row['Nombre'], 0, 0, 'L', true);
     // nombre (20,y
     $this->SetFont($this->getFontName(), '', 9);
     // default font
     $this->Cell(15, 6, $row['Licencia'], 0, 0, 'C', true);
     // licencia
     if (Jornadas::hasGrades($this->jornada)) {
         $this->Cell(10, 6, "{$row['Categoria']} {$row['Grado']}", 0, 0, 'C', true);
         // categoria/grado
     } else {
         $this->Cell(10, 6, "{$row['Categoria']}", 0, 0, 'C', true);
         // solo categoria (Open/Teams/KO)
     }
     $this->Cell(35, 6, $row['NombreGuia'], 0, 0, 'R', true);
     // nombreGuia
     $this->Cell(20, 6, $row['NombreClub'], 0, 0, 'R', true);
     // nombreClub
     // manga 1
     $this->Cell(7, 6, $row['F1'], 0, 0, 'C', true);
     // 1- Faltas+Tocados
     $this->Cell(7, 6, $row['R1'], 0, 0, 'C', true);
     // 1- Rehuses
     $this->Cell(12, 6, $t1, 0, 0, 'C', true);
     // 1- Tiempo
     $this->Cell(9, 6, $v1, 0, 0, 'C', true);
     // 1- Velocidad
     $this->Cell(12, 6, $p1, 0, 0, 'C', true);
     // 1- Penalizacion
     $this->Cell(12, 6, $row['C1'], 0, 0, 'C', true);
     // 1- calificacion
     // manga 2
     if ($this->manga2 != null) {
         $this->Cell(7, 6, $row['F2'], 0, 0, 'C', true);
         // 2- Faltas+Tocados
         $this->Cell(7, 6, $row['R2'], 0, 0, 'C', true);
         // 2- Rehuses
         $this->Cell(12, 6, $t2, 0, 0, 'C', true);
         // 2- Tiempo
         $this->Cell(9, 6, $v2, 0, 0, 'C', true);
         // 2- Velocidad
         $this->Cell(12, 6, $p2, 0, 0, 'C', true);
         // 2- Penalizacion
         $this->Cell(12, 6, $row['C2'], 0, 0, 'C', true);
         // 2- calificacion
     } else {
         $this->Cell(59, 6, '', 0, 0, 'C', true);
         // espacio en blanco
     }
     // global
     $this->Cell(12, 6, $tiempo, 0, 0, 'C', true);
     // Tiempo
     $this->Cell(12, 6, $penal, 0, 0, 'C', true);
     // Penalizacion
     $this->Cell(10, 6, $row['Calificacion'], 0, 0, 'C', true);
     // Calificacion
     $this->SetFont($this->getFontName(), 'B', 9);
     // default font
     $this->Cell(8, 6, $puesto, 0, 0, 'R', true);
     // Puesto
     $this->SetFont($this->getFontName(), '', 9);
     // default font
     // lineas rojas
     $this->ac_SetDrawColor($this->config->getEnv('pdf_linecolor'));
     $this->Line(10, $y, 10, $y + 6);
     $this->Line(10 + 115, $y, 10 + 115, $y + 6);
     $this->Line(10 + 174, $y, 10 + 174, $y + 6);
     $this->Line(10 + 233, $y, 10 + 233, $y + 6);
     $this->Line(10 + 275, $y, 10 + 275, $y + 6);
     $this->Ln(6);
 }
예제 #12
0
 /**
  * retrieve all inscriptions of stored prueba and jornada
  * @param {int} $jornadaID ID de jornada
  * @param {boolean} $pagination: use http_request to retrieve page and rows (true) or disable it(false)
  */
 function inscritosByJornada($jornadaID, $pagination = true)
 {
     $this->myLogger->enter();
     $pruebaid = $this->pruebaID;
     // Cogemos la lista de jornadas abiertas de esta prueba
     $j = new Jornadas("inscripciones::inscritosByJornada()", $this->pruebaID);
     $jornadas = $j->searchByPrueba(1, 1);
     // allowClosed=1, hideUnassigned=1
     if ($jornadas === null || $jornadas === "") {
         return $this->error("{$this->file}::updateOrdenSalida() cannot get list of open Jornadas for prueba:" . $this->pruebaID);
     }
     // por cada jornada abierta, miramos a ver si la ID coincide con la que buscamos
     $mask = 0;
     foreach ($jornadas["rows"] as $jornada) {
         if ($jornada['ID'] == $jornadaID) {
             $mask = 1 << $jornada['Numero'] - 1;
         }
         // 1..8
     }
     if ($mask == 0) {
         return $this->error("{$this->file}::inscritosByJornada() cannot find open Jornada ID: {$jornadaID} in prueba:" . $this->pruebaID);
     }
     $limit = "";
     if ($pagination) {
         $page = http_request("page", "i", 1);
         $rows = http_request("rows", "i", 50);
         if ($page != 0 && $rows != 0) {
             $offset = ($page - 1) * $rows;
             $limit = $offset . "," . $rows;
         }
     }
     // obtenemos la lista de perros inscritos con sus datos
     $result = $this->__select("Inscripciones.ID AS ID, Inscripciones.Prueba AS Prueba, Inscripciones.Perro AS Perro, Raza,\n\t\t\t\tDorsal, PerroGuiaClub.Nombre AS Nombre, PerroGuiaClub.NombreLargo AS NombreLargo,  Genero, Raza, Licencia, LOE_RRC, Categoria, Grado, Celo, Guia, Club, Pais, LogoClub,\n\t\t\t\tNombreGuia, NombreClub,\tInscripciones.Observaciones AS Observaciones, Jornadas, Pagado", "Inscripciones,PerroGuiaClub", "( Inscripciones.Perro = PerroGuiaClub.ID) AND\n\t\t\t\t( Inscripciones.Prueba={$pruebaid} ) AND ( ( Inscripciones.Jornadas&{$mask} ) != 0 ) ", "NombreClub ASC, Categoria ASC , Grado ASC, Nombre ASC, Celo ASC", $limit);
     $this->myLogger->leave();
     return $result;
 }
예제 #13
0
/**
 * Funcion de procesado de inscripciones
 * revisa la inscripcion
 * ajusta orden de salida
 * crea entradas en tabla de resultados
 * @param {integer} $p ID de prueba
 * @param {integer} $i ID de inscripcion
 */
function procesaInscripcion($p, $i)
{
    $myConfig = Config::getInstance();
    $myLogger = new Logger("procesaInscripcion", $myConfig->getEnv("debug_level"));
    $am = new AuthManager("procesaInscripcion");
    // si la prueba o la inscripcion son nulas genera error
    try {
        if ($p <= 0) {
            throw new Exception("ID de prueba invalida: {$p}");
        }
        if ($i <= 0) {
            throw new Exception("ID de inscripcion invalida");
        }
        $am->access(PERMS_OPERATOR);
        // grant access or throw exception
        // buscamos las jornadas de que consta la Prueba
        $jobject = new Jornadas("procesaInscripcion", $p);
        $jp = $jobject->searchByPrueba();
        if (!$jp) {
            throw new Exception("No encuentro jornadas para la prueba: {$p}");
        }
        // buscamos las jornadas en las que esta inscrito
        $iobject = new Inscripciones("procesaInscripcion", $p);
        $inscripcion = $iobject->selectByID($i);
        if (!$inscripcion) {
            throw new Exception("No encuentro la inscripcion con ID: {$i}");
        }
        $idp = $inscripcion['Perro'];
        // obtenemos los datos del perro
        $pobj = new Dogs("procesaInscripcion()");
        $perro = $pobj->selectByID($idp);
        if (!$perro) {
            throw new Exception("No hay datos para el perro a inscribir con id: {$idp}");
        }
        // TODO: check Dog Federation against Prueba Federation
        // contrastamos la lista de jornadas de la prueba con la lista de jornadas en las que esta inscrito
        foreach ($jp['rows'] as $jornada) {
            $numj = $jornada['Numero'] - 1;
            // obtenemos el numero de jornada
            $idj = $jornada['ID'];
            if ($jornada['Cerrada'] == 1) {
                $myLogger->info("La jornada {$idj} de la prueba {$p} esta cerrada");
                continue;
                // no tocamos las jornadas cerradas
            }
            if (($inscripcion['Jornadas'] & 1 << $numj) != 0) {
                $myLogger->info("El perro {$idp} esta inscrito en la jornada {$idj} de la prueba {$p}");
                inscribePerroEnJornada($inscripcion, $jornada, $perro);
            } else {
                $myLogger->info("El perro {$idp} NO esta inscrito en la jornada {$idj} de la prueba {$p}");
                borraPerroDeJornada($inscripcion, $jornada, $perro);
            }
        }
    } catch (Exception $e) {
        do_log($e->getMessage());
        echo json_encode(array('errorMsg' => $e->getMessage()));
    }
}
예제 #14
0
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; 
if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
require_once __DIR__ . "/../logging.php";
require_once __DIR__ . "/../tools.php";
require_once __DIR__ . "/../auth/AuthManager.php";
require_once __DIR__ . "/classes/Jornadas.php";
/***************** programa principal **************/
try {
    $result = null;
    $jornadas = new Jornadas("jornadaFunctions", http_request("Prueba", "i", 0));
    $am = new AuthManager("jornadaFunctions");
    $operation = http_request("Operation", "s", null);
    $jornadaid = http_request("ID", "i", 0);
    $perms = http_request("Perms", "i", 0);
    $allowClosed = http_request("AllowClosed", "i", 0);
    $hideUnassigned = http_request("HideUnassigned", "i", 0);
    if ($operation === null) {
        throw new Exception("Call to jornadaFunctions without 'Operation' requested");
    }
    switch ($operation) {
        // there is no need of "insert" method: every prueba has 8 "hard-linked" jornadas
        case "delete":
            $am->access(PERMS_OPERATOR);
            $result = $jornadas->delete($jornadaid);
            break;