function getTargetsScript() { $ret = "<script>var TargetFaces = new Array();\n"; foreach (getTargets() as $div => $c) { $ret .= "TargetFaces['{$div}']=new Array();\n"; foreach ($c as $cl => $faces) { $ret .= "TargetFaces['{$div}']['{$cl}']=new Array();\n"; foreach ($faces as $id => $face) { $ret .= "TargetFaces['{$div}']['{$cl}']['p{$id}']='" . str_replace("'", "\\'", $face) . "';\n"; } } } $ret .= '</script>'; return $ret; }
$AvTargets[$r->TarId] = get_text($r->TarDescr); } $select = "SELECT ToType,ToNumDist AS TtNumDist " . "FROM Tournament " . "WHERE ToId=" . StrSafe_DB($_SESSION['TourId']) . " "; //print $select;exit; $rs = safe_r_sql($select); if (safe_num_rows($rs) == 1) { $r = safe_fetch($rs); $numDist = $r->TtNumDist; } if ($numDist != 0) { $colspan = 2 + $numDist + $Advanced; $select = "SELECT DISTINCT t.* " . "FROM TargetFaces t " . "WHERE TfTournament=" . StrSafe_DB($_SESSION['TourId']) . " "; //print $select;exit; $rsDist = safe_r_sql($select); } foreach ($DefinedTargets = getTargets(false) as $Target => $divs) { foreach ($divs as $Div => $cl) { foreach ($cl as $Class => $default) { if ($default) { unset($AvDiv[$Div][$Class]); } } } } $JS_SCRIPT = array('<script type="text/javascript" src="../Common/ajax/ObjXMLHttpRequest.js"></script>', '<script type="text/javascript" src="Fun_AJAX_ManTargets.js"></script>', '<script type="text/javascript" src="../Common/Fun_JS.inc.js"></script>', '<script type="text/javascript">var StrConfirm="' . get_text('MsgAreYouSure') . '"; ' . 'var CannotDelete="' . get_text('CannotDelete', 'Tournament') . '"; </script>'); $PAGE_TITLE = get_text('MenuLM_Targets'); include 'Common/Templates/head.php'; ?> <div align="center"> <table class="Tabella"> <tbody id="tbody">
/** * Ritorna un array con le persone. * * @param int $Id: id della persona se si vuole solo una riga * @param string $OrderBy: clausola order by * @return mixed[]: array con le persone */ function GetRows($Id = null, $OrderBy = null, $AllTargets = false) { $ret = array(); $DefTargets = getTargets(); if ($OrderBy === null) { $OrderBy = "QuSession ASC,QuTargetNo ASC "; } $Errore = 0; $Select = ""; if (!$AllTargets) { $Select = "SELECT e.*,IF(EnDob!='0000-00-00',EnDob,'0000-00-00 00:00:00') AS Dob,c.CoCode,c.CoName,c2.CoCode AS CoCode2,c2.CoName AS CoName2, c3.CoCode AS CoCode3,c3.CoName AS CoName3," . "q.QuSession AS `Session`,SUBSTRING(q.QuTargetNo,2) AS TargetNo,ToWhenFrom,TfName, " . "EdEmail " . "FROM Entries AS e LEFT JOIN Countries AS c ON e.EnCountry=c.CoId AND e.EnTournament=c.CoTournament " . "LEFT JOIN Countries AS c2 ON e.EnCountry2=c2.CoId AND e.EnTournament=c2.CoTournament " . "LEFT JOIN Countries AS c3 ON e.EnCountry3=c3.CoId AND e.EnTournament=c3.CoTournament " . "LEFT JOIN TargetFaces ON EnTournament=TfTournament AND EnTargetFace=TfId " . "LEFT JOIN ExtraData ON EdType='E' and EdId=EnId " . "INNER JOIN Qualifications AS q ON e.EnId=q.QuId " . "INNER JOIN Tournament ON EnTournament=ToId " . "WHERE e.EnTournament=" . StrSafe_DB($_SESSION['TourId']) . " /*AND EnAthlete=1*/ " . ($Id != '' ? " AND EnId=" . StrSafe_DB($Id) : '') . " " . "ORDER BY " . $OrderBy . " "; } else { $Select = "(SELECT EnId,EnIocCode,EnTournament,EnDivision,EnClass,EnSubClass,EnAgeClass," . "EnCountry,EnSubTeam,EnCountry2,EnCountry3,EnCtrlCode,Dob," . "EnCode,EnName,EnFirstName,EnBadgePrinted,EnAthlete," . "EnSex,EnWChair,EnSitting,EnIndClEvent,EnTeamClEvent,EnIndFEvent,EnTeamFEvent,EnTeamMixEvent," . "EnDoubleSpace,EnPays,EnStatus,EnTargetFace,EnTimestamp,TfName, " . "CoCode,CoName,CoCode2,CoName2,CoCode3,CoName3," . "SUBSTRING(AtTargetNo,1,1) AS `Session`,SUBSTRING(AtTargetNo,2) AS TargetNo,ToWhenFrom, EdEmail " . "FROM " . "AvailableTarget LEFT JOIN (" . "SELECT " . "EnId,EnIocCode,EnTournament,EnDivision,EnClass,EnSubClass,EnAgeClass,EdEmail," . "EnCountry,EnSubTeam,EnCountry2,EnCountry3,EnCtrlCode,IF(EnDob!='0000-00-00',EnDob,'0000-00-00 00:00:00') AS Dob," . "EnCode,EnName,EnFirstName,EnBadgePrinted,EnAthlete," . "EnSex,EnWChair,EnSitting,EnIndClEvent,EnTeamClEvent,EnIndFEvent,EnTeamFEvent,EnTeamMixEvent," . "EnDoubleSpace,EnPays,EnStatus,EnTargetFace,EnTimestamp,TfName, " . "c.CoCode AS CoCode,c.CoName AS CoName,c2.CoCode AS CoCode2,c2.CoName AS CoName2,c3.CoCode AS CoCode3,c3.CoName AS CoName3, q.QuSession AS `Session`,SUBSTRING(q.QuTargetNo,2) AS TargetNo,q.QuTargetNo AS QuTargetNo,ToWhenFrom " . "FROM Entries AS e LEFT JOIN Countries AS c ON e.EnCountry=c.CoId AND e.EnTournament=c.CoTournament " . "LEFT JOIN Countries AS c2 ON e.EnCountry2=c2.CoId AND e.EnTournament=c2.CoTournament " . "LEFT JOIN Countries AS c3 ON e.EnCountry3=c3.CoId AND e.EnTournament=c3.CoTournament " . "LEFT JOIN TargetFaces ON EnTournament=TfTournament AND EnTargetFace=TfId " . "LEFT JOIN ExtraData ON EdType='E' and EdId=EnId " . "INNER JOIN Qualifications AS q ON e.EnId=q.QuId " . "INNER JOIN Tournament ON EnTournament=ToId " . "WHERE e.EnTournament=" . StrSafe_DB($_SESSION['TourId']) . " /*AND EnAthlete=1*/ " . ($Id != '' ? " AND EnId=" . StrSafe_DB($Id) : '') . " " . "ORDER BY " . $OrderBy . " " . ") AS sq ON AtTournament=EnTournament AND AtTargetNo=QuTargetNo " . "WHERE AtTournament=" . StrSafe_DB($_SESSION['TourId']) . " /*AND EnAthlete=1*/) " . "UNION ALL " . "(SELECT EnId,EnIocCode,EnTournament,EnDivision,EnClass,EnSubClass,EnAgeClass," . "EnCountry,EnSubTeam,EnCountry2,EnCountry3,EnCtrlCode,IF(EnDob!='0000-00-00',EnDob,'0000-00-00 00:00:00') AS Dob," . "EnCode,EnName,EnFirstName,EnBadgePrinted,EnAthlete,EdEmail," . "EnSex,EnWChair,EnSitting,EnIndClEvent,EnTeamClEvent,EnIndFEvent,EnTeamFEvent,EnTeamMixEvent," . "EnDoubleSpace,EnPays,EnStatus,EnTargetFace,EnTimestamp,TfName, " . "c.CoCode AS CoCode,c.CoName AS CoName,c2.CoCode AS CoCode2,c2.CoName AS CoName2,c3.CoCode AS CoCode3,c3.CoName AS CoName3," . "q.QuSession AS `Session`,SUBSTRING(q.QuTargetNo,2) AS TargetNo,ToWhenFrom " . "FROM " . "Entries LEFT JOIN Countries AS c ON EnCountry=c.CoId AND EnTournament=c.CoTournament " . "LEFT JOIN TargetFaces ON EnTournament=TfTournament AND EnTargetFace=TfId " . "LEFT JOIN Countries AS c2 ON EnCountry2=c2.CoId AND EnTournament=c2.CoTournament " . "LEFT JOIN Countries AS c3 ON EnCountry3=c3.CoId AND EnTournament=c3.CoTournament " . "LEFT JOIN ExtraData ON EdType='E' and EdId=EnId " . "INNER JOIN Qualifications AS q ON EnId=q.QuId " . "INNER JOIN Tournament ON EnTournament=ToId " . "WHERE EnTournament=" . StrSafe_DB($_SESSION['TourId']) . " AND QuTargetNo='' " . ($Id != '' ? " AND EnId=" . StrSafe_DB($Id) : '') . ") " . "ORDER BY " . $OrderBy . " "; } //print $Select;exit; $Rs = safe_r_sql($Select); if (safe_num_rows($Rs) > 0) { while ($MyRow = safe_fetch($Rs)) { if ($MyRow->EnId !== null) { if (empty($DefTargets[$MyRow->EnDivision][$MyRow->EnClass])) { // the target is missing for this entry... so sets the EnTargetFace to 0 safe_w_sql("update Entries set EnTargetFace=0 where EnId={$MyRow->EnId}"); $MyRow->EnTargetFace = 0; } elseif (empty($DefTargets[$MyRow->EnDivision][$MyRow->EnClass][$MyRow->EnTargetFace])) { // the assigned target face doesn't exists so resets to the first one (default) reset($DefTargets[$MyRow->EnDivision][$MyRow->EnClass]); list($TfId, $TfFace) = each($DefTargets[$MyRow->EnDivision][$MyRow->EnClass]); safe_w_sql("update Entries set EnTargetFace={$TfId} where EnId={$MyRow->EnId}"); $MyRow->EnTargetFace = $TfId; } } $ret[] = array('id' => $MyRow->EnId, 'ioccode' => $MyRow->EnIocCode, 'code' => $MyRow->EnCode, 'status' => $MyRow->EnStatus, 'session' => $MyRow->Session != 0 ? $MyRow->Session : '', 'targetno' => $MyRow->TargetNo, 'firstname' => stripslashes($MyRow->EnFirstName), 'name' => stripslashes($MyRow->EnName), 'email' => stripslashes($MyRow->EdEmail), 'sex_id' => $MyRow->EnSex, 'sex' => $MyRow->EnId !== null ? $MyRow->EnSex == 0 ? get_text('ShortMale', 'Tournament') : get_text('ShortFemale', 'Tournament') : '', 'ctrl_code' => $MyRow->EnCtrlCode, 'dob' => $MyRow->Dob, 'country_id' => $MyRow->EnCountry, 'country_code' => $MyRow->CoCode, 'country_name' => stripslashes($MyRow->CoName), 'sub_team' => $MyRow->EnSubTeam, 'country_id2' => $MyRow->EnCountry2, 'country_code2' => $MyRow->CoCode2, 'country_name2' => stripslashes($MyRow->CoName2), 'country_id3' => $MyRow->EnCountry3, 'country_code3' => $MyRow->CoCode3, 'country_name3' => stripslashes($MyRow->CoName3), 'division' => $MyRow->EnDivision, 'class' => $MyRow->EnClass, 'ageclass' => $MyRow->EnAgeClass, 'subclass' => $MyRow->EnSubClass, 'targetface' => $MyRow->EnTargetFace, 'targetface_name' => $MyRow->TfName, 'indcl' => $MyRow->EnIndClEvent, 'teamcl' => $MyRow->EnTeamClEvent, 'indfin' => $MyRow->EnIndFEvent, 'teamfin' => $MyRow->EnTeamFEvent, 'mixteamfin' => $MyRow->EnTeamMixEvent, 'wc' => $MyRow->EnWChair, 'double' => $MyRow->EnDoubleSpace); } } return $ret; }
/** * Retrieves all links for a certain RecType * * @param mixed $system System reference * @param mixed $rectype Rectype reference */ function getLinks($system, $rectypes) { $links = array(); // Go through all rectypes for ($i = 0; $i < sizeof($rectypes); $i++) { // Find relations $relations = getRelations($system, $rectypes[$i]); // Find all targets for each relation foreach ($relations as $relation) { //get counts by target $targets = getTargets($system, $rectypes[$i], $relation); // Construct a link for each target foreach ($targets as $target) { $link = new stdClass(); /* example relation:Object count:0 id:16 ids:"10" name:"Person(s) concerned" type:"resource" source:1 target:9 targetcount:0 */ // Records $link->source = $i; $link->target = getIndex($rectypes, $target); $link->relation = $relation; // Counts $link->targetcount = $target->count; $link->relation->count = $target->count; //print_r($link); array_push($links, $link); } } } return $links; }