set_filenames(array('tpl' => $tpl));
$template->assign_var('html_head',$html_head);
$template->assign_var('head',$head);
$template->assign_var('menu',$menu);
$template->assign_var('foot',$foot);
if ( !$isDevelop or $_SESSION['IsAuthorized'] )
{
####################################################
$filter = '0.00.00';
if ( isset($_REQUEST['filter']) ){
$filter= mysql_real_escape_string( $_REQUEST['filter'] );
}
### den Titel setzen
$sql = 'SELECT '
.LangText('events.de','events.en').' AS event,'
.'events.location_id as range,'
.'events.zehntel,'
.'events.finale'
.' FROM events'
.' WHERE events.id like("'.$filter.'%")';
$db->query($sql);
$row = $db->fetch_array();
$event = $row['event'];
$range = $row['range'];
$zehntel = $row['zehntel'];
$finale = $row['finale'];
if ( $filter == '1.80.10' )
$event .= LangText( ' (Einige PDFs zeigen ganze Serien statt 10tel. Wir arbeiten dran.)',
' (Some PDFs are scored in full rings, not decimal. We\'re working on.) ' );
$template->assign_vars(array(
'title' => LangText('Disziplin: ','Discipline: ') .$event,
'th_start' => LangText('Startzeit','Time'),
'th_stand' => LangText('Stand','Lane'),
'th_name' => LangText('Name, Vorname','Surname, Given name'),
'th_team' => LangText('Delegation','Team'),
'th_place' => LangText('Platz','Place'),
'th_series' => LangText('Serien','Series'),
'th_shots' => LangText('Finale','Final'),
'th_total' => LangText('Gesamt','Total'),
'th_quali' => ($finale==0) ? LangText('Rangliste','Ranklist')
: LangText('Qualifikation','Qualification'),
'th_semi' => LangText('Semifinale','Semi Final'),
'th_medal' => LangText('Medaillen Match','Medal Match'),
'th_hits' => LangText('Treffer','Hits'),
'th_points' => LangText('Punkte','Points'),
));
### -------------------------------------------------------------------------------------------
### die Final-Ergebnisse für die Disziplin bestimmen
$finals_visible = false;
$spopi_visible = false;
$sql = 'SELECT '
.'listen.finalplatz,'
.'listen.starter_id,'
.'starter.nachname,'
.'starter.vorname,'
.'listen.teams_id,'
.'teams.kurz,'
.'teams.bezeichnung,'
.'listen.finalserie,'
.'listen.finale,'
.'listen.startnummer'
.' FROM listen'
.' INNER JOIN starter ON listen.starter_id = starter.id'
.' INNER JOIN teams ON listen.teams_id = teams.id'
.' WHERE listen.kennziffer like("' .$filter. '%") and (listen.typ="E") and (finalplatz is not null)'
.' ORDER BY listen.finalplatz';
$db->query($sql);
$width = 100.0 / 9;
$counter = 0;
while ($row = $db->fetch_array()){
$counter++;
$platz = $row['finalplatz'];
$starter_id = $row['starter_id'];
$nachname = $row['nachname'];
$vorname = $row['vorname'];
$teams_id = $row['teams_id'];
$finalserie = $row['finalserie'];
$total = $row['finale'];
$startnr = $row['startnummer'];
$s1 = '';
$s2 = '';
$s3 = '';
$s4 = '';
$s5 = '';
$s6 = '';
$s7 = '';
$s8 = '';
$s9 = '';
switch ( substr($filter,0,4) )
{
case '1.10':
case '1.80':
case '2.10':
case '2.20':# 2x3, 7x2
{
$finals_visible = true;
$shots = explode('|', $finalserie );
$shots_cnt = count( $shots );
$res = $shots[0] + $shots[1] + $shots[2];
$s1 = ''.sprintf('%.1f',$res).'
'.$shots[0].'
'.$shots[1].'
'.$shots[2];
$res += $shots[3] + $shots[4] + $shots[5];
$s2 = ''.sprintf('%.1f',$res).'
'.$shots[3].'
'.$shots[4].'
'.$shots[5];
$res += $shots[6] + $shots[7];
$s3 = ''.sprintf('%.1f',$res).'
'.$shots[6].'
'.$shots[7];
if ( $shots[8] != '0.0' ){
$res += $shots[8] + $shots[9];
$s4 = ''.sprintf('%.1f',$res).'
'.$shots[8].'
'.$shots[9];
} else { $s4 = ' '; }
if ( $shots[10] != '0.0' ){
$res += $shots[10] + $shots[11];
$s5 = ''.sprintf('%.1f',$res).'
'.$shots[10].'
'.$shots[11];
} else { $s5 = ' '; }
if ( $shots[12] != '0.0' ){
$res += $shots[12] + $shots[13];
$s6 = ''.sprintf('%.1f',$res).'
'.$shots[12].'
'.$shots[13];
} else { $s6 = ' '; }
if ( $shots[14] != '0.0' ){
$res += $shots[14] + $shots[15];
$s7 = ''.sprintf('%.1f',$res).'
'.$shots[14].'
'.$shots[15];
} else { $s7 = ' '; }
if ( $shots[16] != '0.0' ){
$res += $shots[16] + $shots[17];
$s8 = ''.sprintf('%.1f',$res).'
'.$shots[16].'
'.$shots[17];
} else { $s8 = ' '; }
if ( $shots[18] != '0.0' ){
$res += $shots[18] + $shots[19];
$s9 = ''.sprintf('%.1f',$res).'
'.$shots[18].'
'.$shots[19];
} else { $s9 = ' '; }
$pfad = ($isDevelop) ? '../pdf/' : './pdf/';
if ( file_exists($pfad.$startnr.'F.pdf') ){
$total = $total .'';
} else {
$total = $total .'';
}
$template->assign_block_vars( 'finals', array(
'platz' => $platz,
'starter_id' => $starter_id,
'nachname' => $nachname,
'vorname' => $vorname,
'teams_id' => $teams_id,
's1' => $s1,
's2' => $s2,
's3' => $s3,
's4' => $s4,
's5' => $s5,
's6' => $s6,
's7' => $s7,
's8' => $s8,
's9' => $s9,
'total' => $total,
));
}
break;
case '1.40':
case '1.60':# 3x5, 3x5, 2x5, 5x1
{ # kneeling
$finals_visible = true;
$shots = explode('|', $finalserie );
$shots_cnt = count( $shots );
$res = $shots[0] +$shots[1] +$shots[2];
$s1 = ''.sprintf('%.1f',$res).'
'
.$shots[0].'
'
.$shots[1].'
'
.$shots[2];
# prone
$res += $shots[3] + $shots[4] + $shots[5];
$s2 = ''.sprintf('%.1f',$res).'
'
.$shots[3].'
'
.$shots[4].'
'
.$shots[5];
# standing
$res += $shots[6] + $shots[7];
$s3 = ''.sprintf('%.1f',$res).'
'
.$shots[6].'
'
.$shots[7];
if ( $shots[8] != '0.0' ){
$res += $shots[8];
$s4 = ''.sprintf('%.1f',$res).'
'
.$shots[8];
}
if ( $shots[9] != '0.0' ){
$res += $shots[9];
$s5 = ''.sprintf('%.1f',$res).'
'
.$shots[9];
}
if ( $shots[10] != '0.0' ){
$res += $shots[10];
$s6 = ''.sprintf('%.1f',$res).'
'
.$shots[10];
}
if ( $shots[11] != '0.0' ){
$res += $shots[11];
$s7 = ''.sprintf('%.1f',$res).'
'
.$shots[11];
}
if ( $shots[12] != '0.0' ){
$res += $shots[12];
$s8 = ''.sprintf('%.1f',$res).'
'
.$shots[12];
}
$pfad = ($isDevelop) ? '../pdf/' : './pdf/';
if ( file_exists($pfad.$startnr.'F.pdf') ){
$total = $total .'';
} else {
$total = $total .'';
}
$template->assign_block_vars( 'finals', array(
'platz' => $platz,
'starter_id' => $starter_id,
'nachname' => $nachname,
'vorname' => $vorname,
'teams_id' => $teams_id,
's1' => $s1,
's2' => $s2,
's3' => $s3,
's4' => $s4,
's5' => $s5,
's6' => $s6,
's7' => $s7,
's8' => $s8,
's9' => $s9,
'total' => $total,
));
}
break;
case '2.30':
{ # Rapid Fire
$finals_visible = true;
$shots = explode('|', $finalserie );
$shots_cnt = count( $shots );
$res = $shots[0];
$s1 = ''.$res.'
'.$shots[0];
$res += $shots[1];
$s2 = ''.$res.'
'.$shots[1];
$res += $shots[2];
$s3 = ''.$res.'
'.$shots[2];
$res += $shots[3];
$s4 = ''.$res.'
'.$shots[3];
$res += $shots[4];
$s5 = ''.$res.'
'.$shots[4];
$res += $shots[5];
$single = explode( ';', $shots[5] );
$s6 = ''.$res.'
'.$single[0];
if ( ($shots_cnt>6) and ($shots[6] != '0') ){
$res += $shots[6];
$single = explode( ';', $shots[6] );
$s7 = ''.$res.'
'
.$single[0];
if ( count($single) > 1 )
$s7 .= ' ('.$single[1].')';
}
if ( ($shots_cnt>7) and ($shots[7] != '0') ){
$res += $shots[7];
$single = explode( ';', $shots[7] );
$s8 = ''.$res.'
'
.$single[0];
}
$total = $res;
$template->assign_block_vars( 'finals', array(
'platz' => $platz,
'starter_id' => $starter_id,
'nachname' => $nachname,
'vorname' => $vorname,
'teams_id' => $teams_id,
's1' => $s1,
's2' => $s2,
's3' => $s3,
's4' => $s4,
's5' => $s5,
's6' => $s6,
's7' => $s7,
's8' => $s8,
's9' => $s9,
'total' => $total,
));
}
break;
case '2.40':
{ # 25m Pistol
$spopi_visible = true;
$parts = explode( ';', $finalserie );
$semi_shots = explode( '|', $parts[0] );
$medal_shots = explode( '|', $parts[1] );
// 5 semi final shots
$hits = implode( ' ', array_slice( $semi_shots, 0, 5 ) );
$hits_total = $semi_shots[0] + $semi_shots[1] + $semi_shots[2] + $semi_shots[3] + $semi_shots[4];
// additional tiebreak
$tie = implode( ' ', array_slice( $semi_shots, 5 ) );
if ( $tie != '' )
$tie = ' (' .$tie. ')';
// medal match shots
$points = implode( ' ', $medal_shots );
$points_total = 0;
foreach ( $medal_shots as $shot )
$points_total += $shot;
if ( $points_total == 0 )
$points_total = '';
$pfad = ($isDevelop) ? '../pdf/' : './pdf/';
if ( file_exists($pfad.$startnr.'F.pdf') ){
$points_total = $points_total .'';
} else {
$points_total = $points_total .'';
}
$template->assign_block_vars( 'spopi', array (
'platz' => $platz,
'starter_id' => $starter_id,
'nachname' => $nachname,
'vorname' => $vorname,
'teams_id' => $teams_id,
'hits' => $hits,
'hits_total' => $hits_total,
'tie' => $tie,
'points' => $points,
'points_total' => $points_total,
));
}
}
}
$template->assign_vars(array(
'finals_visible' => ($finals_visible) ? 'block' : 'none',
'spopi_visible' => ($spopi_visible) ? 'block' : 'none',
));
### -------------------------------------------------------------------------------------------
### die Ergebnisse für die Disziplin bestimmen
$sql = 'SELECT'
.' listen.platzierung'
.',listen.starter_id'
.',starter.nachname'
.',starter.vorname'
.',listen.teams_id'
.',teams.kurz'
.',teams.bezeichnung'
.',listen.serien'
.',listen.ringzahl'
.',listen.startnummer'
.',listen.inner10s'
.' FROM listen'
.' INNER JOIN starter ON listen.starter_id = starter.id'
.' INNER JOIN teams ON listen.teams_id = teams.id'
.' WHERE listen.kennziffer like("' .$filter. '%") and (listen.typ="E")'
.' ORDER BY listen.platzierung';
$db->query($sql);
$width = 100.0 / 6;
$counter = 0;
while ($row = $db->fetch_array()){
$counter++;
$platz = $row['platzierung'];
$starter_id = $row['starter_id'];
$nachname = $row['nachname'];
$vorname = $row['vorname'];
$teams_id = $row['teams_id'];
$teams_kurz = $row['kurz'];
$teams_bez = $row['bezeichnung'];
$series = $row['serien'];
$total = $row['ringzahl'];
$startnr = $row['startnummer'];
$inner10s = $row['inner10s'];
$serien = explode('|', $series );
$serien_cnt = count( $serien );
$s1 = ' ';
$s2 = ' ';
$s3 = ' ';
$s4 = ' ';
$s5 = ' ';
$s6 = ' ';
switch ( substr($filter,0,4) )
{
case '1.40':
{
$s1 = $serien[0].'
'
.$serien[2].'
'
.$serien[4];
$s2 = $serien[1].'
'
.$serien[3].'
'
.$serien[5];
$res1 = $serien[0] + $serien[1];
$res2 = $serien[2] + $serien[3];
$res3 = $serien[4] + $serien[5];
$s3 = ''
.sprintf('%.0f', $res1).'
'
.sprintf('%.0f', $res2).'
'
.sprintf('%.0f', $res3)
.'';
$s4 = ' ';
$s5 = ' ';
$s6 = ' ';
}
break;
case '1.60':
{
$s1 = $serien[0].'
'
.$serien[4].'
'
.$serien[8];
$s2 = $serien[1].'
'
.$serien[5].'
'
.$serien[9];
$s3 = $serien[2].'
'
.$serien[6].'
'
.$serien[10];
$s4 = $serien[3].'
'
.$serien[7].'
'
.$serien[11];
$res1 = $serien[0] + $serien[1] + $serien[2] + $serien[3];
$res2 = $serien[4] + $serien[5] + $serien[6] + $serien[7];
$res3 = $serien[8] + $serien[9] + $serien[10] + $serien[11];
$s5 = ''
.sprintf('%.0f', $res1).'
'
.sprintf('%.0f', $res2).'
'
.sprintf('%.0f', $res3)
.'';
$s6 = ' ';
}
break;
default:
for ( $i=0; $i<$serien_cnt; $i++ ){
switch ( $i ){
case 0:
if ( ($serien[$i]!='0') and ($serien[$i]!='0.0') ){
if ( $zehntel ){
$shot = explode( ',', $serien[$i] );
$s1 = $shot[0] .''.$shot[1].'';
} else {
$s1 = $serien[$i];
}
}
break;
case 1:
if ( ($serien[$i]!='0') and ($serien[$i]!='0.0') ){
if ( $zehntel ){
$shot = explode( ',', $serien[$i] );
$s2 = $shot[0] .''.$shot[1].'';
} else {
$s2 = $serien[$i];
}
}
break;
case 2:
if ( ($serien[$i]!='0') and ($serien[$i]!='0.0') ){
if ( $zehntel ){
$shot = explode( ',', $serien[$i] );
$s3 = $shot[0] .''.$shot[1].'';
} else {
$s3 = $serien[$i];
}
}
break;
case 3:
if ( ($serien[$i]!='0') and ($serien[$i]!='0.0') ){
if ( $zehntel ){
$shot = explode( ',', $serien[$i] );
$s4 = $shot[0] .''.$shot[1].'';
} else {
$s4 = $serien[$i];
}
}
break;
case 4:
if ( ($serien[$i]!='0') and ($serien[$i]!='0.0') ){
if ( $zehntel ){
$shot = explode( ',', $serien[$i] );
$s5 = $shot[0] .''.$shot[1].'';
} else {
$s5 = $serien[$i];
}
}
break;
case 5:
if ( ($serien[$i]!='0') and ($serien[$i]!='0.0') ){
if ( $zehntel ){
$shot = explode( ',', $serien[$i] );
$s6 = $shot[0] .''.$shot[1].'';
} else {
$s6 = $serien[$i];
}
}
break;
}
}
}
if ( $zehntel == 0 ){
$total = substr( $total, 0, -2 );
} else {
$shot = explode( '.', $total );
$total = $shot[0].''.$shot[1].'';
}
$pfad = ($isDevelop) ? '../pdf/' : './pdf/';
if ( file_exists($pfad.$startnr.'.pdf') ){
$total = $total .'';
} else {
$total = $total .'';
}
if ( $inner10s != '0' ){
$total = $total .'' .$inner10s .'';
}
$template->assign_block_vars( 'results', array(
'platz' => $platz,
'starter_id' => $starter_id,
'nachname' => $nachname,
'vorname' => $vorname,
'teams_id' => $teams_id,
'teams_kurz' => $teams_kurz,
'teams_bez' => $teams_bez,
's1' => $s1,
's2' => $s2,
's3' => $s3,
's4' => $s4,
's5' => $s5,
's6' => $s6,
'total' => $total,
));
}
$template->assign_vars(array(
'results_visible' => ($counter>0) ? 'block' : 'none',
));
### -------------------------------------------------------------------------------------------
### die Starts für die Disziplin bestimmen
$sql = 'SELECT '
.'DATE_FORMAT(listen.datum,"'.LangText('%d.%m.%Y','%Y-%m-%d').'") AS datum,'
.'TIME_FORMAT(listen.zeit,"'.LangText('%H:%i','%h:%i %p').'") AS zeit,'
.'DATE_FORMAT(listen.datum,"%Y%m%d") as date,'
.'TIME_FORMAT(listen.zeit,"%H%i") as start,'
.'listen.stand,'
.'listen.starter_id,'
.'starter.nachname,'
.'starter.vorname,'
.'listen.teams_id,'
.'teams.kurz,'
.'teams.bezeichnung'
.' FROM listen'
.' INNER JOIN starter ON listen.starter_id = starter.id'
.' INNER JOIN teams ON listen.teams_id = teams.id'
.' WHERE listen.kennziffer like("' .$filter. '%") and (listen.typ="S")'
.' ORDER BY listen.zeit, listen.stand';
$db->query($sql);
$counter = 0;
while ($row = $db->fetch_array()){
$counter++;
$datum = $row['datum'];
$zeit = $row['zeit'];
$date = $row['date'];
$start = $row['start'];
$stand = $row['stand'];
$starter_id = $row['starter_id'];
$nachname = $row['nachname'];
$vorname = $row['vorname'];
$teams_id = $row['teams_id'];
$teams_kurz = $row['kurz'];
$teams_bez = $row['bezeichnung'];
$template->assign_block_vars( 'list', array(
'counter' => $counter,
'datum' => $datum,
'zeit' => $zeit,
'date' => $date,
'start' => $start,
'stand' => $stand,
'starter_id' => $starter_id,
'nachname' => $nachname,
'vorname' => $vorname,
'teams_id' => $teams_id,
'teams_kurz' => $teams_kurz,
'teams_bez' => $teams_bez,
'range' => $range
));
}
$template->assign_vars(array(
'starter_visible' => ($counter>0) ? 'block' : 'none',
));
}
####################################################
### Footer laden ###
$template->pparse('tpl');
?>