%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<%
function getTeamName(entryID){
var name = Server.CreateObject("ADODB.Recordset");
name.ActiveConnection = BULSCA_CON_STRING;//BULSCA current members
name.Source = "SELECT description from champs_teamNames where entry_ID_4="+entryID ;
name.CursorType = 0;
name.CursorLocation = 2;
name.LockType = 1;
name.Open();
var toReturn="";
if (!name.EOF){
toReturn=name.Fields.Item("description").Value;
}
return toReturn;
}
%>
<%
function getName(competeID){
var name = Server.CreateObject("ADODB.Recordset");
name.ActiveConnection = BULSCA_CON_STRING;//BULSCA current members
name.Source = "SELECT CHAMPS_Competitors.Last_Name,CHAMPS_Competitors.First_Name FROM CHAMPS_Competitors WHERE CHAMPS_Competitors.Competitor_ID="+competeID;
name.CursorType = 0;
name.CursorLocation = 2;
name.LockType = 1;
name.Open();
return "
"+name.Fields.Item("First_Name").Value+" "+name.Fields.Item("Last_Name").Value+" | "+competeID+" | ";
}
function details(entryID){ //Will return the name, unversity of the competitor
var check = Server.CreateObject("ADODB.Recordset");
check.ActiveConnection = BULSCA_CON_STRING;//BULSCA current members
check.Source = "SELECT `CHAMPS_ENTRIES_DETAILS_4`.`type`AS typeE,`CHAMPS_Competitors`.`Club_ID`, `CHAMPS_Competitors`.`Type` AS typeC,`CHAMPS_ENTRIES_DETAILS_4`.`Competitor_ID_1`,`CHAMPS_ENTRIES_DETAILS_4`.`Competitor_ID_2`,`CHAMPS_ENTRIES_DETAILS_4`.`Competitor_ID_3`,`CHAMPS_ENTRIES_DETAILS_4`.`Competitor_ID_4` FROM `CHAMPS_ENTRIES_DETAILS_4` AS `CHAMPS_ENTRIES_DETAILS_4`, `CHAMPS_Competitors` AS `CHAMPS_Competitors` WHERE `CHAMPS_ENTRIES_DETAILS_4`.`Competitor_ID_1` = `CHAMPS_Competitors`.`Competitor_ID` AND `CHAMPS_ENTRIES_DETAILS_4`.ENTRIES_DETAILS_4_ID ="+entryID;
check.CursorType = 0;
check.CursorLocation = 2;
check.LockType = 1;
check.Open();
var entry=""+UniClub(check.Fields.Item("Club_ID").Value)+" | "+StringClubName(check.Fields.Item("Club_ID").Value)
//adds team nam if needed
var tName=getTeamName(entryID);;
if(tName!=""){
entry=entry+" ("+ tName + ")";
}
entry=entry+" | ";
entry=entry+""+check.Fields.Item("Club_ID").Value+" | "
entry=entry+getName(check.Fields.Item("Competitor_ID_1").Value);
entry=entry+getName(check.Fields.Item("Competitor_ID_2").Value);
entry=entry+getName(check.Fields.Item("Competitor_ID_3").Value);
entry=entry+getName(check.Fields.Item("Competitor_ID_4").Value);
entry=entry+""+check.Fields.Item("typeE").Value+" | "+check.Fields.Item("typeC").Value+" | ";
return entry;
}
function getTime(entryID){ //Will return time of the compettitor
var getTimes= Server.CreateObject("ADODB.Recordset");
getTimes.ActiveConnection = BULSCA_CON_STRING;//BULSCA current members
getTimes.Source = "SELECT `ENTRY_TIME` FROM `CHAMPS_ENTRIES_DETAILS_4` AS `CHAMPS_ENTRIES_DETAILS_4` WHERE `ENTRIES_DETAILS_4_ID`="+entryID;
getTimes.CursorType = 0;
getTimes.CursorLocation = 2;
getTimes.LockType = 1;
getTimes.Open();
return getTimes.Fields.Item("ENTRY_TIME").Value;
}
function eventName(eventID){
var eventNames= Server.CreateObject("ADODB.Recordset");
eventNames.ActiveConnection = BULSCA_CON_STRING;//BULSCA current members
eventNames.Source = "SELECT `EVENT_NAME` FROM `CHAMPS_SPEED_EVENTS` AS `CHAMPS_SPEED_EVENTS` WHERE `EVENT_ID` = "+eventID;
eventNames.CursorType = 0;
eventNames.CursorLocation = 2;
eventNames.LockType = 1;
eventNames.Open();
return eventNames.Fields.Item("EVENT_NAME").Value;
}
%>
<%Session.LCID = 2057;//makes it the Uk dates%>
<%//code to make loop across all the evnt so can be placed in the Timekeeper sheet in one mass block
var e=0
var eventcode=new Array();
eventcode[0]=8;
eventcode[1]=9;
eventcode[2]=10;
eventcode[3]=11;
eventcode[4]=18;
eventcode[5]=19;
eventcode[6]=20;
eventcode[7]=22;
eventcode[8]=27;
eventcode[9]=29;
eventcode[10]=36;
for(var e=0;e<11;e++){
var currenteventcode=eventcode[e];
for(var s=0;s<17;s++){
var currentsex="M"
if(s==1){currentsex="F"}
if(s==2){currentsex="SB"}
if(s==3){currentsex="SG"}
if(s==4){currentsex="JB"}
if(s==5){currentsex="JG"}
if(s==6){currentsex="JM"}
if(s==7){currentsex="Mi"}
if(s==8){currentsex="NT"}
if(s==9){currentsex="RB9"}
if(s==10){currentsex="RG9"}
if(s==11){currentsex="RB11"}
if(s==12){currentsex="RG11"}
if(s==13){currentsex="R11"}
if(s==14){currentsex="R9"}
if(s==15){currentsex="MaM"}
if(s==16){currentsex="MaF"}
%>
<% //all the entery id and time for all compettitos
var seed = Server.CreateObject("ADODB.Recordset");
seed.ActiveConnection = BULSCA_CON_STRING;//BULSCA current members
seed.Source = "SELECT ENTRY_ID FROM (SELECT `CHAMPS_ENTRIES_ACEPTED`.`ENTRY_ID`,`CHAMPS_ENTRIES_DETAILS_4`.`ENTRY_TIME` FROM `CHAMPS_Competitors` AS `CHAMPS_Competitors`, `BUSLCA_ACREDITEDCLUB` AS `BUSLCA_ACREDITEDCLUB`, `CHAMPS_ENTRIES_DETAILS_4` AS `CHAMPS_ENTRIES_DETAILS_4`, `CHAMPS_SPEED_ENTRIES` AS `CHAMPS_SPEED_ENTRIES`, `CHAMPS_ENTRIES_ACEPTED` AS `CHAMPS_ENTRIES_ACEPTED` WHERE `CHAMPS_ENTRIES_DETAILS_4`.`ENTRY_ID` = `CHAMPS_SPEED_ENTRIES`.`ENTRY_ID` AND `CHAMPS_ENTRIES_ACEPTED`.`ENTRY_ID` = `CHAMPS_ENTRIES_DETAILS_4`.`ENTRIES_DETAILS_4_ID` AND `CHAMPS_Competitors`.`Club_ID` = `CHAMPS_SPEED_ENTRIES`.`Club_ID` AND NOT `CHAMPS_SPEED_ENTRIES`.`ENTRY_ID` IN (SELECT CHAMPS_ENTRIES_removed.ENTRY_ID FROM CHAMPS_ENTRIES_removed)AND NOT CHAMPS_ENTRIES_DETAILS_4.Competitor_ID_1 IN (SELECT CHAMPS_Competitors_removed.Competitor_ID FROM CHAMPS_Competitors_removed) AND NOT CHAMPS_ENTRIES_DETAILS_4.Competitor_ID_2 IN (SELECT CHAMPS_Competitors_removed.Competitor_ID FROM CHAMPS_Competitors_removed) AND NOT CHAMPS_ENTRIES_DETAILS_4.Competitor_ID_3 IN (SELECT CHAMPS_Competitors_removed.Competitor_ID FROM CHAMPS_Competitors_removed)AND `CHAMPS_ENTRIES_ACEPTED`.`COMP`=4 AND NOT CHAMPS_ENTRIES_DETAILS_4.Competitor_ID_4 IN (SELECT CHAMPS_Competitors_removed.Competitor_ID FROM CHAMPS_Competitors_removed) AND `CHAMPS_SPEED_ENTRIES`.`SEX` = '"+currentsex+"' AND `CHAMPS_Competitors`.`verified_by` IS NOT NULL AND `CHAMPS_ENTRIES_DETAILS_4`.`ENTRY_TIME`>0 AND `CHAMPS_SPEED_ENTRIES`.`CHAMPS_ID` = "+Request.QueryString("champs")+" AND `CHAMPS_SPEED_ENTRIES`.`EVENT_ID` = "+currenteventcode+"AND `CHAMPS_ENTRIES_DETAILS_4`.`Competitor_ID_1` = `CHAMPS_Competitors`.`Competitor_ID`) GROUP BY ENTRY_ID, ENTRY_TIME ORDER BY ENTRY_TIME DESC";
seed.CursorType = 0;
seed.CursorLocation = 2;
seed.LockType = 1;
seed.Open();
var noTime = Server.CreateObject("ADODB.Recordset");
noTime.ActiveConnection = BULSCA_CON_STRING;//BULSCA old boys
noTime.Source = "SELECT ENTRY_ID FROM (SELECT `CHAMPS_ENTRIES_ACEPTED`.`ENTRY_ID`,`CHAMPS_ENTRIES_DETAILS_4`.`ENTRY_TIME` FROM `CHAMPS_Competitors` AS `CHAMPS_Competitors`, `BUSLCA_ACREDITEDCLUB` AS `BUSLCA_ACREDITEDCLUB`, `CHAMPS_ENTRIES_DETAILS_4` AS `CHAMPS_ENTRIES_DETAILS_4`, `CHAMPS_SPEED_ENTRIES` AS `CHAMPS_SPEED_ENTRIES`, `CHAMPS_ENTRIES_ACEPTED` AS `CHAMPS_ENTRIES_ACEPTED` WHERE `CHAMPS_ENTRIES_DETAILS_4`.`ENTRY_ID` = `CHAMPS_SPEED_ENTRIES`.`ENTRY_ID` AND `CHAMPS_ENTRIES_ACEPTED`.`ENTRY_ID` = `CHAMPS_ENTRIES_DETAILS_4`.`ENTRIES_DETAILS_4_ID` AND `CHAMPS_Competitors`.`Club_ID` = `CHAMPS_SPEED_ENTRIES`.`Club_ID` AND NOT `CHAMPS_SPEED_ENTRIES`.`ENTRY_ID` IN (SELECT CHAMPS_ENTRIES_removed.ENTRY_ID FROM CHAMPS_ENTRIES_removed)AND NOT CHAMPS_ENTRIES_DETAILS_4.Competitor_ID_1 IN (SELECT CHAMPS_Competitors_removed.Competitor_ID FROM CHAMPS_Competitors_removed) AND NOT CHAMPS_ENTRIES_DETAILS_4.Competitor_ID_2 IN (SELECT CHAMPS_Competitors_removed.Competitor_ID FROM CHAMPS_Competitors_removed) AND NOT CHAMPS_ENTRIES_DETAILS_4.Competitor_ID_3 IN (SELECT CHAMPS_Competitors_removed.Competitor_ID FROM CHAMPS_Competitors_removed)AND `CHAMPS_ENTRIES_ACEPTED`.`COMP`=4 AND NOT CHAMPS_ENTRIES_DETAILS_4.Competitor_ID_4 IN (SELECT CHAMPS_Competitors_removed.Competitor_ID FROM CHAMPS_Competitors_removed) AND `CHAMPS_SPEED_ENTRIES`.`SEX` = '"+currentsex+"' AND `CHAMPS_Competitors`.`verified_by` IS NOT NULL AND `CHAMPS_ENTRIES_DETAILS_4`.`ENTRY_TIME`=0 AND `CHAMPS_SPEED_ENTRIES`.`CHAMPS_ID` = "+Request.QueryString("champs")+" AND `CHAMPS_SPEED_ENTRIES`.`EVENT_ID` = "+currenteventcode+"AND `CHAMPS_ENTRIES_DETAILS_4`.`Competitor_ID_1` = `CHAMPS_Competitors`.`Competitor_ID`) GROUP BY ENTRY_ID, ENTRY_TIME ORDER BY ENTRY_TIME DESC";
noTime.CursorType = 0;
noTime.CursorLocation = 2;
noTime.LockType = 1;
noTime.Open();
var competitors= new Array();// array to hold all the team ID in the order of there swim and tow
var num_teams=0;// the number of teams
while(!noTime.EOF){
num_teams++;
competitors[num_teams]=noTime.Fields.Item("ENTRY_ID").Value;
noTime.MoveNext();
}
noTime.Close();
while (!seed.EOF){// flushes the left overs
num_teams++;
competitors[num_teams]=seed.Fields.Item("ENTRY_ID").Value;
seed.MoveNext();
}
seed.Close();
// every person is now in the draw
if(num_teams!=0){//check to see if we have soem teams
//we now must set up the lane number array with how far extra down the list we must move to find the correct team
var laneExtra=new Array();//addtional for lane allowance
var lanes=8;//how many lanes there are
if(Request.QueryString("champs")=="3"){
lanes=10;
if(currenteventcode==11) lanes=8;
}
if(Request.QueryString("champs")=="4"){
lanes=6;
filter=1;
if(currenteventcode==11){lanes=8;filter=0;}
}
if(Request.QueryString("champs")=="5"){
if(currenteventcode==9){lanes=6;filter=1;}
}
if(Request.QueryString("champs")=="6"){
lanes=6;
}
if(Request.QueryString("champs")=="9"){
lanes=10;
if(currenteventcode==8){lanes=8;}
}
if(Request.QueryString("champs")=="12"){
lanes=10;
if(currenteventcode==9){lanes=8;}
}
if(Request.QueryString("champs")=="13"){
lanes=6;
}
if(Request.QueryString("champs")=="14"){
lanes=10;
}
if(Request.QueryString("champs")=="17"){
lanes=6;
if(currenteventcode==19){lanes=4;}
}
if(currenteventcode==16){
lanes=10;
if(currenteventcode==9){lanes=8;}
}
for(var i=1;i<=Math.floor(lanes/2);i++){//places the reltive offset requitred for lanes where i is the lane number
laneExtra[i]=2*i;
laneExtra[lanes-i+1]=2*i-1;
}
if(lanes%2!=0)laneExtra[(Math.floor(lanes/2)+1)]=lanes; // for an odd number of lanes we must the set the middle lane offset
%>
<%h_num=1; //the heat number we are currently doing%>
<% heats=Math.floor(num_teams/lanes)+1;
var extra;//varible to hodl how many teams we have before we have full heats
//code only speard heads once we have full heat before that just places in the centre of the pool
if((heats!=1)&&((num_teams%lanes)!=0)&&((num_teams%lanes)<(lanes/2))){//works out if we need 1 or 2 non-full heat these are non-spear headed
extra=lanes+num_teams%lanes;%>
<%var offset=Math.floor((Math.floor(lanes-extra/2))/2);//how far offset must the lanes be
var templaneExtra=new Array();//addtional for lane allowance
var templanes=Math.floor(extra/2);//how many lanes there are in thsi heat
for(var i=1;i<=Math.floor(templanes/2);i++){//places the reltive offset requitred for lanes where i is the lane number
templaneExtra[i]=2*i;
templaneExtra[templanes-i+1]=2*i-1;
}
if(templanes%2!=0)templaneExtra[(Math.floor(templanes/2)+1)]=templanes;
for(var i=1;i<=extra/2;i++){%>
<%=details(competitors[templaneExtra[i]])%>
| <%=getTime(competitors[templaneExtra[i]])%> |
<%}%>
<%h_num++%>
<%
var teamInHeat1=(Math.floor(extra/2));
offset=Math.floor((lanes-(extra-teamInHeat1))/2);
templaneExtra=new Array();//addtional for lane allowance
templanes=extra-teamInHeat1;//how many lanes there are in thsi heat
for(var i=1;i<=Math.floor(templanes/2);i++){//places the reltive offset requitred for lanes where i is the lane number
templaneExtra[i]=2*i;
templaneExtra[templanes-i+1]=2*i-1;
}
if(templanes%2!=0)templaneExtra[(Math.floor(templanes/2)+1)]=templanes;
for(var i=1;i<=extra-teamInHeat1;i++){%>
<%=details(competitors[templaneExtra[i]+teamInHeat1])%>
| <%=getTime(competitors[templaneExtra[i]+teamInHeat1])%> |
<%=currentsex%> | <%=currenteventcode%> |
<%}%>
<%extra=extra-lanes;//makes extra the corretc mount for having 2 heats taken palce fr the shift in the for loop
}else{//when we ahve one non ful lheat.
extra=num_teams%lanes;
if(extra==0){extra=lanes;heats--;}
%>
<%var offset=Math.floor((Math.floor(lanes-extra/2))/2);//how far offset must the lanes be
var templaneExtra=new Array();//addtional for lane allowance
var templanes=extra;//how many lanes there are in thsi heat
for(var i=1;i<=Math.floor(templanes/2);i++){//places the reltive offset requitred for lanes where i is the lane number
templaneExtra[i]=2*i;
templaneExtra[templanes-i+1]=2*i-1;
}
if(templanes%2!=0)templaneExtra[(Math.floor(templanes/2)+1)]=templanes;
for(var i=1;i<=extra;i++){%>
<%=details(competitors[templaneExtra[i]])%>
| <%=getTime(competitors[templaneExtra[i]])%> |
<%=currentsex%> | <%=currenteventcode%> |
<%}%>
<%}h_num++;//end if for first heats
//now we fill out the rest of the heat with teams
for(h_num;h_num<=heats;h_num++){//h_num on entering loop is the next heat to be dispalyed%>
<%for(var i=1;i<=lanes;i++){
arrayID=lanes*h_num-(2*lanes-extra)+laneExtra[i];// takes the maxium we could have in theses heats then take off 2 times the amount of extra teams + the off set
entryID=competitors[arrayID];%>
<%=details(entryID)%>
| <%=getTime(entryID)%> |
<%=currentsex%> | <%=currenteventcode%> |
<%}
}//end for loop for heats
}//end if for do we have teams
}//endloop sex
}//end loop eveny%>