/**
  * Constructor
  * @throws Exception
  */
 function __construct($federation)
 {
     date_default_timezone_set('Europe/Madrid');
     parent::__construct('Portrait', "print_listaPerros", 1, 0);
     // use default prueba. not really needed
     $d = new Dogs("print_listaPerros");
     $res = $d->select();
     if (!is_array($res)) {
         $this->errormsg = "print_listaPerros: select() failed";
         throw new Exception($this->errormsg);
     }
     $this->lista = $res['rows'];
     // rework federation handling as parent got it from senseless prueba ID
     $this->federation = Federations::getFederation(intval($federation));
     $this->strClub = $this->federation->isInternational() ? _('Country') : _('Club');
     $this->icon = getIconPath($this->federation->get('Name'), "agilitycontest.png");
     $this->icon2 = getIconPath($this->federation->get('Name'), $this->federation->get('Logo'));
     $this->cols[8] = $this->strClub;
     // use "country" or "club" according federation
     if ($this->federation->get('WideLicense') == true) {
         // on wide license hide loe/rrc
         $this->pos[3] += $this->pos[4];
         $this->pos[4] = 0;
         $this->pos[3] += 5;
         // decrease handler name
         $this->pos[7] -= 5;
     }
 }
Example #2
0
 /**
  * Constructor
  * @param {string} Name for this object
  * @param {integer} $manga Manga ID
  * @throws Exception when
  * - cannot contact database
  * - invalid manga ID
  */
 function __construct($file, $manga)
 {
     parent::__construct($file);
     if ($manga <= 0) {
         $this->errormsg = "Resultados::Construct invalid Manga ID: {$manga}";
         throw new Exception($this->errormsg);
     }
     $this->manga = $this->__getArray("Mangas", $manga);
     if (!is_array($this->manga)) {
         $this->errormsg = "OrdenSalida::construct(): Cannot get info on manga:{$manga}";
         throw new Exception($this->errormsg);
     }
     $this->jornada = $this->__getArray("Jornadas", $this->manga['Jornada']);
     if (!is_array($this->jornada)) {
         $this->errormsg = "OrdenSalida::construct(): Cannot get jornada info on jornada:{$this->manga['Jornada']} manga:{$manga}";
         throw new Exception($this->errormsg);
     }
     $this->prueba = $this->__getArray("Pruebas", $this->jornada['Prueba']);
     if (!is_array($this->prueba)) {
         $this->errormsg = "OrdenSalida::construct(): Cannot get prueba info on prueba:{$this->jornada['Prueba']} jornada:{$this->manga['Jornada']} manga:{$manga}";
         throw new Exception($this->errormsg);
     }
     $this->federation = Federations::getFederation(intval($this->prueba['RSCE']));
     if ($this->federation == null) {
         $this->errormsg = "OrdenSalida::construct(): Cannot get federation info on prueba:{$this->jornada['Prueba']} jornada:{$this->manga['Jornada']} manga:{$manga}";
         throw new Exception($this->errormsg);
     }
 }
Example #3
0
 function createInfoPage($title, $federation = -1)
 {
     $infopage = $this->myWriter->getCurrentSheet();
     $name = _utf("Information");
     $infopage->setName($this->normalizeSheetName($name));
     // titulo
     $this->myWriter->addRowsWithStyle([[$title], [""]], $this->titleStyle);
     // en caso de estar definido, informacion de Prueba, jornada, y en su caso federacion
     if ($this->prueba != null) {
         $this->myWriter->addRowWithStyle([_utf("Contest") . ":", $this->prueba['Nombre']], $this->rowHeaderStyle);
     }
     if ($this->jornada != null) {
         $this->myWriter->addRowWithStyle([_utf("Journey") . ":", $this->jornada['Nombre']], $this->rowHeaderStyle);
     }
     if ($federation >= 0) {
         $fed = Federations::getFederation(intval($federation));
         if ($fed == null) {
             $this->myLogger->trace("Invalid federation ID:{$federation}");
         } else {
             $this->myWriter->addRowWithStyle([_utf("Federation") . ":", $fed->get('Name')], $this->rowHeaderStyle);
             $this->federation = $fed;
         }
     }
     // informacion de la aplicacion
     $this->myWriter->addRows([[""], [_utf("Program info")], ["Application: ", $this->myConfig->getEnv("program_name")], ["Version:", $this->myConfig->getEnv("version_name")], ["Revision:", $this->myConfig->getEnv("version_date")]]);
     // informacion de licencia
     $am = new AuthManager($this->myFile);
     $ainfo = $am->getRegistrationInfo();
     $this->myWriter->addRows([[""], [_utf("License Info")], ["Serial Number:", $ainfo["Serial"]], ["User:"******"User"]], ["Club:", $ainfo["Club"]]]);
 }
Example #4
0
 /**
  * inserta una manga en la jornada
  * @param {integer} $tipo ID del tipo manga (tabla 'Mangas::Tipo_Manga')
  * @param {string} $grado valor asociado al grado de la manga de la ID dada
  * @return {string} empty on success, else error 
  */
 function insert($tipo, $grado)
 {
     $this->myLogger->enter();
     $j = $this->jornada;
     // si la manga existe no hacer nada; si no existe crear manga
     $res = $this->__selectObject("count(*) AS Result", "Mangas", "( Jornada={$j} ) AND  ( Tipo={$tipo} ) AND ( Grado='{$grado}' )");
     if (!is_object($res)) {
         return $this->error("Cannot get info on Mangas for Jornada:{$j}");
     }
     if ($res->Result > 0) {
         $this->myLogger->info("Jornada:{$j} Manga:{$tipo} already exists");
     } else {
         // buscamos el equipo por defecto de la jornada y lo insertamos
         $res = $this->__selectObject("*", "Equipos", "(Jornada={$j}) AND (DefaultTeam=1)");
         if (!is_object($res)) {
             return $this->error("Cannot get default Team for Jornada:{$j}");
         }
         $team = $res->ID;
         $observaciones = http_request("Observaciones", "s", "");
         $str = "INSERT INTO Mangas ( Jornada,Tipo,Grado,Observaciones,Orden_Salida,Orden_Equipos ) VALUES ( {$j},{$tipo},'{$grado}','{$observaciones}','BEGIN,END','BEGIN,{$team},END' )";
         $rs = $this->query($str);
         if (!$rs) {
             return $this->error($this->conn->error);
         }
     }
     /* si la prueba es selectiva forzamos tipo de recorrido, y TRS */
     if ($this->pruebaObj->Selectiva != 0) {
         $fed = Federations::getFederation(intval($this->pruebaObj->RSCE));
         $grades = $fed->get('Grades');
         $doSelectiva = false;
         if ($grades == 3 && $tipo == 6) {
             $doSelectiva = true;
         }
         // 3-grades Agility Grado III
         if ($grades == 3 && $tipo == 11) {
             $doSelectiva = true;
         }
         // 3-grades Jumping Grado III
         if ($grades == 2 && $tipo == 5) {
             $doSelectiva = true;
         }
         // 3-grades Jumping Grado II
         if ($grades == 2 && $tipo == 10) {
             $doSelectiva = true;
         }
         // 2-grades Jumping Grado II
         if ($doSelectiva) {
             $str = "UPDATE Mangas\n\t\t\t\tSET Recorrido=0,\n\t\t\t\tTRS_L_Tipo=1, TRS_M_Tipo=1, TRS_S_Tipo=1, TRS_T_Tipo=1,\n\t\t\t\tTRS_L_Factor=0, TRS_M_Factor=0, TRS_S_Factor=0, TRS_T_Factor=0,\n\t\t\t\tTRS_L_Unit='%', TRS_M_Unit='%', TRS_S_Unit='%', TRS_T_Unit='%'\n\t\t\t\tWHERE ( Jornada={$j} ) AND  ( Tipo={$tipo} ) AND ( Grado='{$grado}' )";
             $rs = $this->query($str);
             if (!$rs) {
                 return $this->error($this->conn->error);
             }
         }
     }
     $this->myLogger->leave();
     return "";
 }
Example #5
0
 /**
  * Evalua la calificacion parcial del perro
  * @param {object} $p datos de la prueba
  * @param {object} $j datos de la jornada
  * @param {object} $m datos de la manga
  * @param {array} $perro datos de puntuacion del perro. Passed by reference
  * @param {array} $puestocat puesto en funcion de la categoria
  */
 public function evalPartialCalification($p, $j, $m, &$perro, $puestocat)
 {
     if ($perro['Grado'] !== "GII") {
         // solo se puntua en grado II
         parent::evalPartialCalification($p, $j, $m, $perro, $puestocat);
         return;
     }
     if ($perro['Penalizacion'] >= 400) {
         // tiene manga pendiente de salir
         $perro['Penalizacion'] = 400.0;
         $perro['Calificacion'] = "";
         $perro['CShort'] = "";
     }
     if ($perro['Penalizacion'] >= 200) {
         // no presentado: no puntua
         $perro['Penalizacion'] = 200.0;
         $perro['Calificacion'] = _("Not Present");
         $perro['CShort'] = _("N.P.");
     } else {
         if ($perro['Penalizacion'] >= 100) {
             // eliminado: no puntua
             $perro['Penalizacion'] = 100.0;
             $perro['Calificacion'] = _("Eliminated");
             $perro['CShort'] = _("Elim");
         } else {
             if ($perro['Penalizacion'] >= 26) {
                 // No clasificado: no puntua
                 $perro['Calificacion'] = _("Not Clasified");
                 $perro['CShort'] = _("N.C.");
             } else {
                 if ($perro['Penalizacion'] >= 16) {
                     // Bien: 2 puntos
                     $perro['Calificacion'] = _("Good") . " - 2";
                     $perro['CShort'] = _("Good");
                 } else {
                     if ($perro['Penalizacion'] >= 6) {
                         // Muy bien: 3 puntos
                         $perro['Calificacion'] = _("Very good") . " - 3";
                         $perro['CShort'] = _("V.G.");
                     } else {
                         if ($perro['Penalizacion'] > 0) {
                             // Excelente: 4 puntos
                             $perro['Calificacion'] = _("Excellent") . " - 4";
                             $perro['CShort'] = _("Exc");
                         } else {
                             if ($perro['Penalizacion'] == 0) {
                                 // Cero: 5 puntos
                                 $perro['Calificacion'] = _("Excellent") . " - 5";
                                 $perro['CShort'] = _("Exc");
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Example #6
0
 public function __construct($fed)
 {
     $this->federation = Federations::getFederation($fed);
     $this->myConfig = Config::getInstance();
     $this->myLogger = new Logger("importExcel(dogs)", $this->myConfig->getEnv("debug_level"));
     if (php_sapi_name() != "cli") {
         $this->myAuthMgr = new AuthManager("importExcel(dogs)");
         if (!$this->myAuthMgr->allowed(ENABLE_IMPORT)) {
             throw new Exception("ImportExcel(dogs): Feature disabled: program not registered");
         }
     }
     $this->tablename = TABLE_NAME;
     $this->myDBObject = new DBObject("ImportExcel(dogs)");
     $this->fieldList = array('DogID' => array(-2, 0, "i", "DogID", " `DogID` int(4) NOT NULL DEFAULT 0, "), 'Name' => array(-3, 1, "s", "Nombre", " `Nombre` varchar(255) NOT NULL, "), 'LongName' => array(-4, -1, "s", "NombreLargo", "`NombreLargo` varchar(255) DEFAULT NULL, "), 'Gender' => array(-5, -1, "s", "Genero", " `Genero` varchar(16) DEFAULT NULL, "), 'Breed' => array(-6, -1, "s", "Raza", " `Raza` varchar(255) DEFAULT NULL, "), 'License' => array(-7, -1, "s", "Licencia", " `Licencia` varchar(255) DEFAULT '--------', "), 'KC_ID' => array(-8, -1, "s", "LOE_RRC", " `LOE_RRC` varchar(255) DEFAULT NULL, "), 'Cat' => array(-9, 1, "s", "Categoria", " `Categoria` varchar(1) NOT NULL DEFAULT '-', "), 'Grad' => array(-10, 1, "s", "Grado", " `Grado` varchar(16) DEFAULT '-', "), 'HandlerID' => array(-11, 0, "i", "HandlerID", " `HandlerID` int(4) NOT NULL DEFAULT 0, "), 'Handler' => array(-12, 1, "s", "NombreGuia", " `NombreGuia` varchar(255) NOT NULL, "), 'ClubID' => array(-13, 0, "i", "ClubID", " `ClubID` int(4) NOT NULL DEFAULT 0, "), 'Club' => array(-14, 1, "s", "NombreClub", " `NombreClub` varchar(255) NOT NULL,"));
 }
Example #7
0
 /**
  * Constructor
  * @param {int} $prueba Prueba ID
  * @throws Exception
  */
 function __construct($prueba)
 {
     parent::__construct("clasifications.xlsx");
     setcookie('fileDownload', 'true', time() + 30, "/");
     // tell browser to hide "downloading" message box
     $p = new Pruebas("excel_Clasificaciones");
     $res = $p->selectByID($prueba);
     if (!is_array($res)) {
         $this->errormsg = "excel_Clasificaciones: getPruebaByID({$prueba}) failed";
         throw new Exception($this->errormsg);
     }
     $this->prueba = $res;
     $j = new Jornadas("excel_Clasificaciones", $prueba);
     $res = $j->selectByPrueba();
     if (!is_array($res)) {
         $this->errormsg = "excel_Clasificaciones: getJornadasByPrueba({$prueba}) failed";
         throw new Exception($this->errormsg);
     }
     $this->jornadas = $res['rows'];
     // to get mode in trs evaluation
     $this->federation = Federations::getFederation($this->prueba['RSCE']);
     $this->jdbObject = new Jueces("excelClasification");
 }
Example #8
0
 /**
  * Enumerate grados 
  * @param {integer} federation ID; -1:any
  * @return null on error; result on success
  * Notice that this is not a combogrid, just combobox, so dont result count
  */
 function gradosPerro($fed = -1)
 {
     $this->myLogger->enter();
     // evaluate federation search argument
     $f = "1";
     if ($fed >= 0) {
         // ask how many grades has selected federation
         $fedinfo = Federations::getFederation(intval($fed));
         if ($fedinfo) {
             if ($fedinfo->get('Grades') === 2) {
                 $f = "(Grado <> 'GIII') ";
             }
             $result = array();
             foreach ($fedinfo->get('ListaGrados') as $cat => $name) {
                 if ($cat === "-") {
                     array_push($result, array("Grado" => $cat, "Comentarios" => $name, "selected" => 1));
                 } else {
                     array_push($result, array("Grado" => $cat, "Comentarios" => $name, "selected" => 0));
                 }
             }
             return $result;
         }
         $this->myLogger->error("CategoriasPerro: invalid federation ID:{$fed}");
     }
     // if federation is not provided or invalid, extract all  available values from database
     // evaluate search string for query
     $q = http_request("q", "s", "");
     $like = "";
     if ($q == "") {
         $like = " WHERE Grado LIKE '%" . $q . "%'";
     }
     // query to retrieve table data
     $sql = "SELECT Grado,Comentarios FROM Grados_Perro " . $like . " ORDER BY Grado";
     $this->myLogger->query($sql);
     $rs = $this->query($sql);
     if (!$rs) {
         return $this->error($this->conn->error);
     }
     // retrieve result into an array
     $result = array();
     while ($row = $rs->fetch_array(MYSQLI_ASSOC)) {
         // add a default state for comobobox
         if ($row["Grado"] === '-') {
             $row["selected"] = 1;
             $row[2] = 1;
         } else {
             $row["selected"] = 0;
             $row[2] = 0;
         }
         // and store into result array
         array_push($result, $row);
     }
     // clean and return
     $rs->free();
     $this->myLogger->leave();
     return $result;
 }
Example #9
0
 function getFederation()
 {
     if ($this->federation != null) {
         return $this->federation;
     }
     $prb = $this->getDatosPrueba();
     $this->federation = Federations::getFederation(intval($prb->RSCE));
     $this->myLogger->trace("Datos prueba: " . json_encode($prb) . " Datos federacion " . json_encode($this->federation));
     return $this->federation;
 }
Example #10
0
 /**
  * Check if provided logo name matches with existing one
  * @param {string} $name logo to seach
  * @return {boolean} true or false
  */
 static function logoMatches($name)
 {
     $name = basename($name);
     // stip dir info
     $list = Federations::getFederationList();
     foreach ($list as $fed) {
         if (basename($fed['Logo']) === $name) {
             return true;
         }
         if (basename($fed['ParentLogo']) === $name) {
             return true;
         }
     }
     // arriving here means not found
     return false;
 }
Example #11
0
 /**
  * Evalua la calificacion final del perro
  * @param {object} $p datos de la prueba
  * @param {object} $j datos de la jornada
  * @param {object} $m1 datos de la primera manga
  * @param {object} $m22 datos de la segunda manga
  * @param {array} $c1 resultados de la primera manga
  * @param {array} $c2 resultados de la segunda manga
  * @param {array} $perro datos de puntuacion del perro. Passed by reference
  * @param {array} $puestocat puesto en funcion de la categoria
  */
 public function evalFinalCalification($p, $j, $m1, $m2, $c1, $c2, &$perro, $puestocat)
 {
     parent::evalFinalCalification($p, $j, $m1, $m2, $c1, $c2, $perro, $puestocat);
 }
Example #12
0
 static function __compose(&$data, $prueba, $jornadaid, $tiporonda, $m1, $m2)
 {
     $heights = intval(Federations::getFederation(intval($prueba['RSCE']))->get('Heights'));
     switch (intval($m1['Recorrido'])) {
         // should be the same than $m2['Recorrido']
         case 0:
             // separado
             array_push($data, Jornadas::__composeArray($prueba['ID'], $jornadaid, $tiporonda, $m1['Recorrido'], 0, $m1, $m2));
             // large
             array_push($data, Jornadas::__composeArray($prueba['ID'], $jornadaid, $tiporonda, $m1['Recorrido'], 1, $m1, $m2));
             // medium
             array_push($data, Jornadas::__composeArray($prueba['ID'], $jornadaid, $tiporonda, $m1['Recorrido'], 2, $m1, $m2));
             // small
             if ($heights == 4) {
                 array_push($data, Jornadas::__composeArray($prueba['ID'], $jornadaid, $tiporonda, $m1['Recorrido'], 5, $m1, $m2));
                 // tiny
             }
             break;
         case 1:
             // mixto
             if ($heights == 3) {
                 array_push($data, Jornadas::__composeArray($prueba['ID'], $jornadaid, $tiporonda, $m1['Recorrido'], 0, $m1, $m2));
                 // large
                 array_push($data, Jornadas::__composeArray($prueba['ID'], $jornadaid, $tiporonda, $m1['Recorrido'], 3, $m1, $m2));
                 // m+s
             } else {
                 array_push($data, Jornadas::__composeArray($prueba['ID'], $jornadaid, $tiporonda, $m1['Recorrido'], 6, $m1, $m2));
                 // l+m
                 array_push($data, Jornadas::__composeArray($prueba['ID'], $jornadaid, $tiporonda, $m1['Recorrido'], 7, $m1, $m2));
                 // s+t
             }
             break;
         case 2:
             // conjunto
             if ($heights == 3) {
                 array_push($data, Jornadas::__composeArray($prueba['ID'], $jornadaid, $tiporonda, $m1['Recorrido'], 4, $m1, $m2));
                 // l+m+s
             } else {
                 array_push($data, Jornadas::__composeArray($prueba['ID'], $jornadaid, $tiporonda, $m1['Recorrido'], 8, $m1, $m2));
                 // l+m+s+t
             }
             break;
     }
 }
Example #13
0
 /**
  * Evalua la calificacion parcial del perro
  * @param {object} $p datos de la prueba
  * @param {object} $j datos de la jornada
  * @param {object} $m datos de la manga
  * @param {array} $perro datos de puntuacion del perro. Passed by reference
  * @param {array} $puestocat puesto en funcion de la categoria
  */
 public function evalPartialCalification($p, $j, $m, &$perro, $puestocat)
 {
     if ($perro['Grado'] !== "GIII") {
         parent::evalPartialCalification($p, $j, $m, $perro, $puestocat);
         return;
     }
     if (intval($p->Selectiva) == 0) {
         parent::evalPartialCalification($p, $j, $m, $perro, $puestocat);
         return;
     }
     // arriving here means prueba selectiva and Grado III
     // comprobamos si el perro es mestizo
     if (!$this->validLicense($perro['Licencia'])) {
         // perro mestizo o extranjero no puntua
         parent::evalPartialCalification($p, $j, $m, $perro, $puestocat);
         return;
     }
     // si no tiene excelente no puntua
     if ($perro['Penalizacion'] >= 6.0) {
         parent::evalPartialCalification($p, $j, $m, $perro, $puestocat);
         return;
     }
     $pts = array("25", "20", "16", "12", "8", "6", "4", "3", "2", "1");
     // puntuacion manga de agility
     if (intval($m->Tipo) == 11) {
         $pts = array("18", "14", "11", "8", "6", "5", "4", "3", "2", "1");
     }
     // puntuacion manga de jumping
     // solo puntuan los 10 primeros
     if ($puestocat[$perro['Categoria']] > 10 || $puestocat[$perro['Categoria']] <= 0) {
         parent::evalPartialCalification($p, $j, $m, $perro, $puestocat);
         return;
     }
     // si llegamos aqui tenemos los 10 primeros perros una prueba selectiva en grado 3 con un perro no mestizo que ha sacado excelente :-)
     $pt1 = $pts[$puestocat[$perro['Categoria']] - 1];
     if ($perro['Penalizacion'] > 0) {
         $perro['Calificacion'] = _("Exc") . " - {$pt1}";
         $perro['CShort'] = _("Exc");
     }
     if ($perro['Penalizacion'] == 0) {
         $perro['Calificacion'] = _("Exc") . " (p) - {$pt1}";
         $perro['CShort'] = _("Ex P");
     }
 }
Example #14
0
 /**
  * Insert or update Tandas according Jornada Data
  */
 function populateJornada()
 {
     $this->myLogger->enter();
     // obtenemos datos de la jornada y prueba
     $j = $this->jornada;
     $p = $this->prueba;
     $f = Federations::getFederation(intval(intval($p->RSCE)));
     $this->myLogger->trace("call to getFederation({$p->RSCE}) returns: " . print_r($f, true));
     // actualizamos la lista de tandas de cada ronda
     // preagility necesita tratamiento especial
     if ($j->PreAgility2 != 0) {
         // preagility2 also handles preagility1
         $this->insert_remove($f, 1, true);
         // Pre-Agility Manga 1
         $this->insert_remove($f, 2, true);
         // Pre-Agility Manga 2
     } else {
         if ($j->PreAgility != 0) {
             $this->insert_remove($f, 1, true);
             // Pre-Agility Manga 1
             $this->insert_remove($f, 2, false);
             // Pre-Agility Manga 2
         } else {
             $this->insert_remove($f, 1, false);
             // Pre-Agility Manga 1
             $this->insert_remove($f, 2, false);
             // Pre-Agility Manga 2
         }
     }
     $this->insert_remove($f, 3, $j->Grado1 != 0 ? true : false);
     // Agility Grado I Manga 1
     $this->insert_remove($f, 4, $j->Grado1 != 0 ? true : false);
     // Agility Grado I Manga 2
     $this->insert_remove($f, 5, $j->Grado2 != 0 ? true : false);
     // Agility Grado II
     $this->insert_remove($f, 10, $j->Grado2 != 0 ? true : false);
     // Jumping Grado II
     $this->insert_remove($f, 6, $j->Grado3 != 0 ? true : false);
     // Agility Grado III
     $this->insert_remove($f, 11, $j->Grado3 != 0 ? true : false);
     // Jumping Grado III
     $this->insert_remove($f, 7, $j->Open != 0 ? true : false);
     // Agility Abierta
     $this->insert_remove($f, 12, $j->Open != 0 ? true : false);
     // Jumping Abierta
     $this->insert_remove($f, 8, $j->Equipos3 != 0 ? true : false);
     // Agility Equipos (3 mejores)
     $this->insert_remove($f, 13, $j->Equipos3 != 0 ? true : false);
     // Jumping Equipos (3 mejores)
     $this->insert_remove($f, 9, $j->Equipos4 != 0 ? true : false);
     // Agility Equipos (Conjunta)
     $this->insert_remove($f, 14, $j->Equipos4 != 0 ? true : false);
     // Jumping Equipos (Conjunta)
     $this->insert_remove($f, 15, $j->KO != 0 ? true : false);
     // Ronda K.O.
     $this->insert_remove($f, 16, $j->Especial != 0 ? true : false);
     // Manga especial
     $this->myLogger->leave();
 }
Example #15
0
 function enumerate()
 {
     // like select but with fixed order
     $this->myLogger->enter();
     // evaluate search criteria for query
     $q = http_request("q", "s", "");
     $where = "1";
     $fedstr = "1";
     if ($this->curFederation != null) {
         $fed = intval($this->curFederation->get('ID'));
         $mask = 1 << $fed;
         $this->myLogger->trace("Jueces: fed:{$this->curFederation->get('ID')} mask:{$mask}");
         $intlmask = Federations::getInternationalMask();
         $fedstr = $this->curFederation->isInternational() ? "((Internacional!=0) OR (Federations & {$intlmask})!=0)" : "((Federations & {$mask})!=0)";
     }
     if ($q !== "") {
         $where = "( Nombre LIKE '%" . $q . "%' )";
     }
     $result = $this->__select("*", "Jueces", "{$where} AND {$fedstr}", "Nombre ASC", "");
     $this->myLogger->leave();
     return $result;
 }
Example #16
0
    // 0:separate 1:mixed 2:common
    if ($operation === null) {
        throw new Exception("Call to moduleFunctions without 'Operation' requested");
    }
    switch ($operation) {
        case "list":
            $result = Federations::getFederationList();
            break;
        case "info":
            $result = Federations::getFederation($federation);
            break;
        case "enumerate":
            $result = Federations::enumerate();
            break;
        case "infomanga":
            $result = Federations::infomanga($federation, $recorrido);
            break;
        default:
            throw new Exception("moduleFunctions:: invalid operation: '{$operation}' provided");
    }
    if ($result === null) {
        throw new Exception($jueces->errormsg);
    }
    if ($result === "") {
        echo json_encode(array('success' => true));
    } else {
        echo json_encode($result);
    }
} catch (Exception $e) {
    do_log($e->getMessage());
    echo json_encode(array('errorMsg' => $e->getMessage()));
 // Creamos generador de documento
 header("Pragma: public");
 header("Expires: 0");
 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
 header("Content-Type: application/force-download");
 header("Content-Type: application/octet-stream");
 header("Content-Type: application/download");
 header("Content-Disposition: attachment;filename=clasificacion.xls");
 header("Content-Transfer-Encoding: binary ");
 $excel = new Excel($prueba, $jornada, $mangas);
 $excel->xlsBOF();
 $base = $excel->write_PageHeader($prueba, $jornada, $mangas);
 // buscamos los recorridos asociados a la mangas
 $c = new Clasificaciones("print_clasificacion_excel", $prueba, $jornada);
 $result = array();
 $heights = intval(Federations::getFederation(intval($excel->prueba->RSCE))->get('Heights'));
 switch ($excel->manga1->Recorrido) {
     case 0:
         // recorridos separados large medium small tiny
         $r = $c->clasificacionFinal($rondas, $mangas, 0);
         $base = $excel->composeTable($mangas, $r, 0, $base + 1);
         $r = $c->clasificacionFinal($rondas, $mangas, 1);
         $base = $excel->composeTable($mangas, $r, 1, $base + 1);
         $r = $c->clasificacionFinal($rondas, $mangas, 2);
         $base = $excel->composeTable($mangas, $r, 2, $base + 1);
         if ($heights != 3) {
             $r = $c->clasificacionFinal($rondas, $mangas, 5);
             $base = $excel->composeTable($mangas, $r, 5, $base + 1);
         }
         break;
     case 1:
Example #18
0
<?php

/**
 * Created by PhpStorm.
 * User: jantonio
 * Date: 21/10/15
 * Time: 14:11
 */
require_once "../modules/Federations.php";
$feds = Federations::getFederationList();
foreach ($feds as $fed) {
    echo "ID:{$fed['ID']} : {$fed['LongName']}\n";
    // print_r($fed);
}
Example #19
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.
 -->

<?php 
require_once __DIR__ . "/../../server/tools.php";
require_once __DIR__ . "/../../server/auth/Config.php";
require_once __DIR__ . "/../../modules/Federations.php";
$config = Config::getInstance();
// retrieve federation info
$f = intval(http_request("Federation", "i", 0));
$fed = Federations::getFederation($f);
if (!$fed) {
    die("Internal error::Invalid Federation ID: {$f}");
}
?>

<!-- Formulario que contiene los datos de una manga -->

<form id="competicion-formdatosmanga">
	<input type="hidden" id="dmanga_Operation" name="Operation" value=""/>
	<input type="hidden" id="dmanga_Jornada" name="Jornada" value=""/>
	<input type="hidden" id="dmanga_Manga" name="Manga" value=""/>
	<input type="hidden" id="dmanga_ID" name="ID" value=""/>
	<input type="hidden" id="dmanga_Tipo" name="Tipo" value=""/>
	<table id="competicion-tabladatosmanga">
		<tr>
Example #20
0
 /**
  * genera la tabla de resultados finales y evalua el orden de clasificacion
  * @param {array} $c1 clasificacion primera manga
  * @param {array} $c2 clasificacion segunda manga
  */
 function evalFinal($idmangas, $c1, $c2)
 {
     $this->myLogger->enter();
     $m1 = $this->__getObject("Mangas", $idmangas[0]);
     $m2 = $this->__getObject("Mangas", $idmangas[1]);
     $final = array();
     // puesto,dorsal, nombre, licencia,categoria,grado, nombreguia, nombreclub,
     // F1,R1,T1,V1,P1,C1,F2,R2,T2,V2,P2,C2, Penalizacion,Calificacion
     // Procesamos la primera manga y generamos una segunda manga "fake"
     foreach ($c1['rows'] as $item) {
         $participante = array('Participantes' => count($c1['rows']), 'Perro' => $item['Perro'], 'Dorsal' => $item['Dorsal'], 'Nombre' => $item['Nombre'], 'Licencia' => $item['Licencia'], 'Categoria' => $item['Categoria'], 'Grado' => $item['Grado'], 'Equipo' => $item['Equipo'], 'NombreEquipo' => $item['NombreEquipo'], 'NombreGuia' => $item['NombreGuia'], 'NombreClub' => $item['NombreClub'], 'LogoClub' => $item['LogoClub'], 'F1' => $item['Faltas'] + $item['Tocados'], 'R1' => $item['Rehuses'], 'E1' => $item['Eliminado'], 'N1' => $item['NoPresentado'], 'T1' => floatval($item['Tiempo']), 'V1' => $item['Velocidad'], 'P1' => $item['Penalizacion'], 'C1' => $item['CShort'], 'Puesto1' => $item['Puesto'], 'Pcat1' => $item['Pcat'], 'F2' => 0, 'R2' => 0, 'E2' => 0, 'N2' => 0, 'T2' => 0, 'V2' => 0, 'P2' => 400, 'C2' => '', 'Puesto2' => 0, 'Pcat2' => 0, 'Tiempo' => $item['Tiempo'], 'Penalizacion' => $item['Penalizacion'] + 400, 'Calificacion' => $item['CShort'], 'Puntos' => '', 'Puesto' => 0, 'Pcat' => 0);
         $final[$item['Perro']] = $participante;
     }
     if ($c2 != null) {
         // Procesamos la segunda manga
         foreach ($c2['rows'] as $item) {
             if (!isset($final[$item['Perro']])) {
                 $this->myLogger->notice("El perro con ID:{$item['Perro']} no tiene datos en la primera manga.");
                 $final[$item['Perro']] = array('Participantes' => count($c2['rows']), 'Perro' => $item['Perro'], 'Dorsal' => $item['Dorsal'], 'Nombre' => $item['Nombre'], 'Licencia' => $item['Licencia'], 'Categoria' => $item['Categoria'], 'Grado' => $item['Grado'], 'Equipo' => $item['Equipo'], 'NombreEquipo' => $item['NombreEquipo'], 'NombreGuia' => $item['NombreGuia'], 'NombreClub' => $item['NombreClub'], 'LogoClub' => $item['LogoClub'], 'F1' => 0, 'R1' => 0, 'E1' => 0, 'N1' => 0, 'T1' => 0, 'V1' => 0, 'P1' => 400, 'C1' => '', 'Puesto1' => 0, 'Pcat1' => 0, 'Puesto' => 0, 'Pcat' => 0);
             }
             $final[$item['Perro']]['F2'] = $item['Faltas'] + $item['Tocados'];
             $final[$item['Perro']]['R2'] = $item['Rehuses'];
             $final[$item['Perro']]['E2'] = $item['Eliminado'];
             $final[$item['Perro']]['N2'] = $item['NoPresentado'];
             $final[$item['Perro']]['T2'] = floatval($item['Tiempo']);
             $final[$item['Perro']]['V2'] = $item['Velocidad'];
             $final[$item['Perro']]['P2'] = $item['Penalizacion'];
             $final[$item['Perro']]['C2'] = $item['CShort'];
             $final[$item['Perro']]['Puesto2'] = $item['Puesto'];
             $final[$item['Perro']]['Pcat2'] = $item['Pcat'];
             $final[$item['Perro']]['Tiempo'] = $final[$item['Perro']]['T1'] + $final[$item['Perro']]['T2'];
             $final[$item['Perro']]['Penalizacion'] = $final[$item['Perro']]['P1'] + $final[$item['Perro']]['P2'];
             $final[$item['Perro']]['Calificacion'] = '';
             $final[$item['Perro']]['Puntos'] = '';
         }
     }
     // una vez ordenados, el índice perro ya no tiene sentido, con lo que vamos a eliminarlo
     // y reconstruir el array
     $final2 = array();
     foreach ($final as $item) {
         array_push($final2, $item);
     }
     $final = $final2;
     // re-ordenamos los datos en base a la puntuacion
     usort($final, function ($a, $b) {
         if ($a['Penalizacion'] == $b['Penalizacion']) {
             return $a['Tiempo'] > $b['Tiempo'] ? 1 : -1;
         }
         return $a['Penalizacion'] > $b['Penalizacion'] ? 1 : -1;
     });
     // calculamos campo "Puesto", "Calificacion" y Puntos
     $puestocat = array('C' => 1, 'L' => 1, 'M' => 1, 'S' => 1, 'T' => 1);
     // ultimo puesto por cada categoria
     $lastcat = array('C' => 0, 'L' => 0, 'M' => 0, 'S' => 0, 'T' => 0);
     // ultima puntuacion por cada categoria
     $countcat = array('C' => 0, 'L' => 0, 'M' => 0, 'S' => 0, 'T' => 0);
     // perros contabilizados de cada categoria
     $size = count($final);
     for ($idx = 0; $idx < $size; $idx++) {
         // vemos la categoria y actualizamos contadores de categoria
         $cat = $final[$idx]['Categoria'];
         $countcat['C']++;
         // Conjunta
         $countcat[$cat]++;
         // Por categoria
         // obtenemos la penalizacion del perro actual
         $now = 100 * $final[$idx]['Penalizacion'] + $final[$idx]['Tiempo'];
         // ajustamos puesto conjunto y guardamos resultado
         if ($lastcat['C'] != $now) {
             $lastcat['C'] = $now;
             $puestocat['C'] = $countcat['C'];
         }
         $final[$idx]['Puesto'] = $puestocat['C'];
         // ajustamos puesto por categoria y guardamos resultado
         if ($lastcat[$cat] != $now) {
             $lastcat[$cat] = $now;
             $puestocat[$cat] = $countcat[$cat];
         }
         $final[$idx]['Pcat'] = $puestocat[$cat];
         // on special journeys do not evaluate calification
         if ($this->jornada->Equipos3 != 0) {
             continue;
         }
         if ($this->jornada->Equipos4 != 0) {
             continue;
         }
         if ($this->jornada->KO != 0) {
             continue;
         }
         if ($this->jornada->Open != 0) {
             continue;
         }
         // evaluamos calificacion y puntos en funcion de la federacion y de si es o no selectiva
         $fed = Federations::getFederation(intval($this->prueba->RSCE));
         $fed->evalFinalCalification($this->prueba, $this->jornada, $m1, $m2, $c1, $c2, $final[$idx], $puestocat);
     }
     // Esto es (casi) t odo, amigos
     $result = array();
     $result['total'] = $size;
     $result['rows'] = $final;
     $result['trs1'] = $c1['trs'];
     $result['trs2'] = $c2['trs'];
     $result['jueces'] = array($c1['manga']->NombreJuez1, $c1['manga']->NombreJuez2);
     return $result;
 }
Example #21
0
 /**
  * Store logo image and name into database
  * @param {integer} $id Club ID
  * @return {string} "" on success; else error
  */
 function setLogo($id)
 {
     $this->myLogger->enter();
     // el logo 1 NO es editable y debe ser siempre "rsce.png"
     if ($id <= 1) {
         return $this->error("Cannot change Logo for club ID:{$id}");
     }
     // 1- leemos la imagen que nos viene en el post extrayendo el tipo y los datos
     $imgstr = http_request("imagedata", "s", null);
     if (!$imgstr) {
         return $this->error("No image data received for club ID:{$id}");
     }
     if (!preg_match('/data:([^;]*);base64,(.*)/', $imgstr, $matches)) {
         return $this->error("Invalid received image string data:'{$imgstr}'");
     }
     // $type=$matches[1]; // 'image/png' , 'image/jpeg', or whatever. Not really used
     $image = base64_decode(str_replace(' ', '+', $matches[2]));
     // also replace '+' to spaces or newlines
     $img = imagecreatefromstring($image);
     if (!$img) {
         return $this->error("Invalid received image string data:'{$imgstr}'");
     }
     // 2- creamos una imagen de 150x150, le anyadimos canal alfa, y hacemos un copyresampled
     $newImage = imagecreatetruecolor(150, 150);
     imagealphablending($newImage, true);
     imagesavealpha($newImage, true);
     // Allocate a transparent color and fill the new image with it.
     // Without this the image will have a black background instead of being transparent.
     $transparent = imagecolorallocatealpha($newImage, 0, 0, 0, 127);
     imagefill($newImage, 0, 0, $transparent);
     imagecopyresampled($newImage, $img, 0, 0, 0, 0, 150, 150, imagesx($img), imagesy($img));
     // 3- obtenemos el nombre del logo actual
     $row = $this->__selectObject("Nombre,Logo", "Clubes", "ID={$id}");
     if (!$row) {
         return $this->error($this->conn->error);
     }
     $logo = $row->Logo;
     $name = $row->Nombre;
     // 4- si es igual al default, generamos un nuevo nombre para el logo basado en el nombre del club
     // 	y actualizamos el nombre en la bbdd
     if (Federations::logoMatches($logo)) {
         // compose logo file name based in club name, instead (old) club ID
         // Remove all (back)slashes from name
         $logo = str_replace('\\', '', $name);
         $logo = str_replace('/', '', $logo);
         // Remove all characters that are not the separator, a-z, 0-9, or whitespace
         $logo = preg_replace('![^' . preg_quote('-') . 'a-z0-_9\\s]+!', '', strtolower($logo));
         // Replace all separator characters and whitespace by a single separator
         $logo = preg_replace('![' . preg_quote('-') . '\\s]+!u', '_', $logo);
         $logo = "{$logo}.png";
         $sql = "UPDATE Clubes SET Logo='{$logo}' WHERE (ID={$id})";
         $res = $this->query($sql);
         if (!$res) {
             return $this->error($this->conn->error);
         }
     }
     // 5- finalmente guardamos el logo en el fichero especificado en formato png
     $fname = __DIR__ . "/../../../images/logos/{$logo}";
     // default path to store logos
     // $this->myLogger->info("Trying to save png file to:'$fname'");
     imagepng($newImage, $fname);
     // seems that imagepng fails on save to file due to strange permission related issue
     // ob_start();// store output
     // imagePNG($newImage);// output to buffer
     // file_put_contents($fname, ob_get_contents(), FILE_BINARY);// write buffer to file
     // ob_end_clean();// clear and turn off buffer
     // 6- limpiamos y retornamos OK
     imagedestroy($img);
     imagedestroy($newImage);
     $this->myLogger->leave();
     return "";
 }
 $mangas[5] = http_request("Manga6", "i", 0);
 $mangas[6] = http_request("Manga7", "i", 0);
 $mangas[7] = http_request("Manga8", "i", 0);
 $mangas[8] = http_request("Manga9", "i", 0);
 // mangas 3..9 are used in KO rondas
 $mode = http_request("Mode", "i", "0");
 // 0:Large 1:Medium 2:Small 3:Medium+Small 4:Large+Medium+Small
 header("Content-type: text/plain");
 header("Content-Disposition: attachment; filename=printEtiquetas.csv");
 // buscamos los recorridos asociados a la mangas
 $dbobj = new DBObject("print_etiquetas_csv");
 $mng = $dbobj->__getObject("Mangas", $mangas[0]);
 $prb = $dbobj->__getObject("Pruebas", $prueba);
 $c = new Clasificaciones("print_etiquetas_csv", $prueba, $jornada);
 $result = array();
 $heights = intval(Federations::getFederation(intval($prb->RSCE))->get('Heights'));
 switch ($mng->Recorrido) {
     case 0:
         // recorridos separados large medium small
         $r = $c->clasificacionFinal($rondas, $mangas, 0);
         $result[0] = $r['rows'];
         $r = $c->clasificacionFinal($rondas, $mangas, 1);
         $result[1] = $r['rows'];
         $r = $c->clasificacionFinal($rondas, $mangas, 2);
         $result[2] = $r['rows'];
         if ($heights != 3) {
             $r = $c->clasificacionFinal($rondas, $mangas, 5);
             $result[5] = $r['rows'];
         }
         break;
     case 1:
Example #23
0
getLogo.php

Copyright  2013-2016 by Juan Antonio Martinez ( juansgaviota at gmail dot com )

This program is free software; you can redistribute it and/or modify it under the terms 
of the GNU General Public License as published by the Free Software Foundation; 
either version 2 of the License, or (at your option) any later version.

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.
*/
/**
 * tool to retrieve an image from server by providing federation and canonical name
 */
require_once __DIR__ . "/../../server/tools.php";
require_once __DIR__ . "/../../modules/Federations.php";
$fed = http_request("Fed", "i", http_request("Federation", "i", 0));
$logo = http_request("Logo", "s", "null.png");
$fedname = Federations::getFederation(intval($fed))->get('Name');
$iconpath = getIconPath($fedname, $logo);
$image = imagecreatefromstring(file_get_contents($iconpath));
imagealphablending($image, false);
// preserve transparency
imagesavealpha($image, true);
header('Content-Type: image/png');
imagepng($image);
imagedestroy($image);
Example #24
0
 /**
  * Evalua la calificacion parcial del perro
  * @param {object} $p datos de la prueba
  * @param {object} $j datos de la jornada
  * @param {object} $m datos de la manga
  * @param {array} $perro datos de puntuacion del perro. Passed by reference
  * @param {array} $puestocat puesto en funcion de la categoria
  */
 public function evalPartialCalification($p, $j, $m, &$perro, $puestocat)
 {
     $grad = $perro['Grado'];
     // cogemos el grado
     $cat = $perro['Categoria'];
     // cogemos la categoria
     if ($grad !== "GII") {
         // solo se puntua en grado II
         parent::evalPartialCalification($p, $j, $m, $perro, $puestocat);
         return;
     }
     $ptsmanga = array("5", "4", "3", "2", "1");
     // puntos por manga y puesto
     $pt1 = 0;
     if ($perro['Penalizacion'] < 6.0) {
         $pt1++;
     }
     // 1 punto por excelente
     if ($perro['Penalizacion'] == 0.0) {
         $pt1++;
     }
     // 2 puntos por cero
     // puntos a los 5 primeros por manga/categoria si no estan eliminados
     if ($puestocat[$cat] > 0 && $perro['Penalizacion'] < 100 && $puestocat[$cat] <= 5) {
         $pt1 += $ptsmanga[$puestocat[$cat] - 1];
     }
     if ($perro['Penalizacion'] >= 400) {
         $perro['Penalizacion'] = 400.0;
         $perro['Calificacion'] = "-";
         $perro['CShort'] = "-";
     } else {
         if ($perro['Penalizacion'] >= 200) {
             $perro['Penalizacion'] = 200.0;
             $perro['Calificacion'] = _("Not Present");
             $perro['CShort'] = _("N.P.");
         } else {
             if ($perro['Penalizacion'] >= 100) {
                 $perro['Penalizacion'] = 100.0;
                 $perro['Calificacion'] = _("Eliminated");
                 $perro['CShort'] = _("Elim");
             } else {
                 if ($perro['Penalizacion'] >= 26) {
                     $perro['Calificacion'] = _("Not Clasified");
                     $perro['CShort'] = _("N.C.");
                 } else {
                     if ($perro['Penalizacion'] >= 16) {
                         $perro['Calificacion'] = _("Good") . " - " . $pt1;
                         $perro['CShort'] = _("Good");
                     } else {
                         if ($perro['Penalizacion'] >= 6) {
                             $perro['Calificacion'] = _("V.G.") . " - " . $pt1;
                             $perro['CShort'] = _("V.G.");
                         } else {
                             if ($perro['Penalizacion'] > 0) {
                                 $perro['Calificacion'] = _("Exc") . " - " . $pt1;
                                 $perro['CShort'] = _("Exc");
                             } else {
                                 if ($perro['Penalizacion'] == 0) {
                                     $perro['Calificacion'] = _("Exc") . " - " . $pt1;
                                     $perro['CShort'] = _("Exc");
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Example #25
0
 /**
  * Constructor de la superclase 
  * @param {string} orientacion 'landscape' o 'portrait'
  * @param {string} file name of caller to be used in traces
  * @param {int} $prueba ID de la jornada
  * @param {int} jornada Jornada ID
  */
 function __construct($orientacion, $file, $prueba, $jornada = 0)
 {
     date_default_timezone_set('Europe/Madrid');
     $this->config = Config::getInstance();
     $this->myLogger = new Logger($file, $this->config->getEnv("debug_level"));
     parent::__construct($orientacion, 'mm', 'A4');
     // Portrait or Landscape
     $this->SetAutoPageBreak(true, 1.7);
     // default margin is 2cm. so enlarge a bit
     $this->installFonts($this->config->getEnv("pdf_fontfamily"));
     $this->centro = $orientacion === 'Portrait' ? 107 : 145;
     $this->myDBObject = new DBObject($file);
     $this->prueba = null;
     $this->federation = Federations::getFederation(0);
     // defaults to RSCE
     if ($prueba != 0) {
         $this->prueba = $this->myDBObject->__getObject("Pruebas", $prueba);
         $this->federation = Federations::getFederation(intval($this->prueba->RSCE));
     }
     $this->strClub = $this->federation->isInternational() ? _('Country') : _('Club');
     $fedName = $this->federation->get('Name');
     // $this->myLogger->trace("Federation is: ".json_decode($this->federation));
     $this->club = null;
     if ($prueba != 0) {
         $this->club = $this->myDBObject->__getObject("Clubes", $this->prueba->Club);
         // club organizador
     }
     $this->jornada = null;
     if ($jornada != 0) {
         $this->jornada = $this->myDBObject->__getObject("Jornadas", $jornada);
     }
     // on international contests, use logos from federation
     $this->icon = getIconPath($fedName, $this->federation->get('OrganizerLogo'));
     $this->icon2 = getIconPath($fedName, $this->federation->get('ParentLogo'));
     // on national events, use organizing club logo (if any )
     if (!$this->federation->isInternational() && isset($this->club)) {
         $this->icon = getIconPath($fedName, $this->club->Logo);
         $this->icon2 = getIconPath($fedName, $this->federation->get('Logo'));
         if ($this->icon == $this->icon2) {
             $this->icon2 = getIconPath($fedName, $this->federation->get('ParentLogo'));
         }
     }
     // handle registration info related to PDF generation
     $this->authManager = new AuthManager("print_common");
     $this->regInfo = $this->authManager->getRegistrationInfo();
     if ($this->regInfo == null || $this->regInfo['Serial'] === "00000000") {
         $this->icon = getIconPath($fedName, "agilitycontest.png");
     }
     // evaluate number of decimals to show when printing timestamps
     $this->timeResolution = $this->config->getEnv('crono_miliseconds') == "0" ? 2 : 3;
     // $this->myLogger->trace("Time resolution is ".$this->timeResolution);
 }