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);
function fmtRes( $res ){
$str = sprintf('%.1f',$res);
$part = explode('.',$str);
return $part[0] .''.$part[1].'';
}
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="'.$filter.'"';
$db->query($sql);
$row = $db->fetch_array();
$event = $row['event'];
$range = $row['range'];
$zehntel = $row['zehntel'];
$finale = $row['finale'];
$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.startid'
.' FROM listen'
.' INNER JOIN starter ON listen.starter_id = starter.id'
.' INNER JOIN teams ON listen.teams_id = teams.id'
.' WHERE (listen.kennziffer="' .$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'];
$startid = $row['startid'];
$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 = ''.fmtRes($res).'
'.fmtRes($shots[0]).'
'.fmtRes($shots[1]).'
'.fmtRes($shots[2]);
$res += $shots[3] + $shots[4] + $shots[5];
$s2 = ''.fmtRes($res).'
'.fmtRes($shots[3]).'
'.fmtRes($shots[4]).'
'.fmtRes($shots[5]);
$res += $shots[6] + $shots[7];
$s3 = ''.fmtRes($res).'
'.fmtRes($shots[6]).'
'.fmtRes($shots[7]);
if ( $shots_cnt > 8 ){
$res += $shots[8] + $shots[9];
$s4 = ''.fmtRes($res).'
'.fmtRes($shots[8]).'
'.fmtRes($shots[9]);
} else { $s4 = ' '; }
if ( $shots_cnt > 10 ){
$res += $shots[10] + $shots[11];
$s5 = ''.fmtRes($res).'
'.fmtRes($shots[10]).'
'.fmtRes($shots[11]);
} else { $s5 = ' '; }
if ( $shots_cnt > 12 ){
$res += $shots[12] + $shots[13];
$s6 = ''.fmtRes($res).'
'.fmtRes($shots[12]).'
'.fmtRes($shots[13]);
} else { $s6 = ' '; }
if ( $shots_cnt > 14 ){
$res += $shots[14] + $shots[15];
$s7 = ''.fmtRes($res).'
'.fmtRes($shots[14]).'
'.fmtRes($shots[15]);
} else { $s7 = ' '; }
if ( $shots_cnt > 16 ){
$res += $shots[16] + $shots[17];
$s8 = ''.fmtRes($res).'
'.fmtRes($shots[16]).'
'.fmtRes($shots[17]);
} else { $s8 = ' '; }
if ( $shots_cnt > 18 ){
$res += $shots[18] + $shots[19];
$s9 = ''.fmtRes($res).'
'.fmtRes($shots[18]).'
'.fmtRes($shots[19]);
} else { $s9 = ' '; }
$pfad = ($isDevelop) ? '../pdf/' : './pdf/';
if ( file_exists($pfad.$startid.'F.pdf') ){
$total = fmtRes($total) .'';
} else {
$total = fmtRes($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 );
$knd1 = array_sum( array_slice($shots, 0,5) );
$knd2 = array_sum( array_slice($shots, 5,5) );
$knd3 = array_sum( array_slice($shots,10,5) );
$res = $knd1 +$knd2 +$knd3;
$s1 = ''.fmtRes($res).'
'
.fmtRes($knd1).'
'
.fmtRes($knd2).'
'
.fmtRes($knd3);
# prone
$lgd1 = array_sum( array_slice($shots,15,5) );
$lgd2 = array_sum( array_slice($shots,20,5) );
$lgd3 = array_sum( array_slice($shots,25,5) );
$res += $lgd1 + $lgd2 + $lgd3;
$s2 = ''.fmtRes($res).'
'
.fmtRes($lgd1).'
'
.fmtRes($lgd2).'
'
.fmtRes($lgd3);
# standing
$sth1 = array_sum( array_slice($shots,30,5) );
$sth2 = array_sum( array_slice($shots,35,5) );
$res += $sth1 + $sth2;
$s3 = ''.fmtRes($res).'
'
.fmtRes($sth1).'
'
.fmtRes($sth2);
if ( $shots_cnt > 40 ){
$res += $shots[40];
$s4 = ''.fmtRes($res).'
'
.fmtRes($shots[40]);
}
if ( $shots_cnt > 41 ){
$res += $shots[41];
$s5 = ''.fmtRes($res).'
'
.fmtRes($shots[41]);
}
if ( $shots_cnt > 42 ){
$res += $shots[42];
$s6 = ''.fmtRes($res).'
'
.fmtRes($shots[42]);
}
if ( $shots_cnt > 43 ){
$res += $shots[43];
$s7 = ''.fmtRes($res).'
'
.fmtRes($shots[43]);
}
if ( $shots_cnt > 44 ){
$res += $shots[44];
$s8 = ''.fmtRes($res).'
'
.fmtRes($shots[44]);
}
$pfad = ($isDevelop) ? '../pdf/' : './pdf/';
if ( file_exists($pfad.$startid.'F.pdf') ){
$total = fmtRes($total) .'';
} else {
$total = fmtRes($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.$startid.'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.startid'
.',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="' .$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'];
$startid = $row['startid'];
$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 ){
$s1 = fmtRes($serien[$i]);
} else {
$s1 = $serien[$i];
}
}
break;
case 1:
if ( ($serien[$i]!='0') and ($serien[$i]!='0.0') ){
if ( $zehntel ){
$s2 = fmtRes($serien[$i]);
} else {
$s2 = $serien[$i];
}
}
break;
case 2:
if ( ($serien[$i]!='0') and ($serien[$i]!='0.0') ){
if ( $zehntel ){
$s3 = fmtRes($serien[$i]);
} else {
$s3 = $serien[$i];
}
}
break;
case 3:
if ( ($serien[$i]!='0') and ($serien[$i]!='0.0') ){
if ( $zehntel ){
$s4 = fmtRes($serien[$i]);
} else {
$s4 = $serien[$i];
}
}
break;
case 4:
if ( ($serien[$i]!='0') and ($serien[$i]!='0.0') ){
if ( $zehntel ){
$s5 = fmtRes($serien[$i]);
} else {
$s5 = $serien[$i];
}
}
break;
case 5:
if ( ($serien[$i]!='0') and ($serien[$i]!='0.0') ){
if ( $zehntel ){
$s6 = fmtRes($serien[$i]);
} else {
$s6 = $serien[$i];
}
}
break;
}
}
}
if ( $zehntel == 0 ){
$total = substr( $total, 0, -2 );
} else {
$total = fmtRes($total);
}
if ( $platz == 998 ){
$platz = "AK";
}
if ( $platz == 999 ){
$total = "DSQ";
}
$pfad = ($isDevelop) ? '../pdf/' : './pdf/';
if ( file_exists($pfad.$startid.'.pdf') ){
$total = $total .'';
} else {
$total = $total .'';
}
if ( $inner10s != '0' ){
$total = $total .'' .$inner10s .'';
}
$template->assign_block_vars( 'results', array(
'platz' => ( $platz == 999 ) ? "DSQ" : $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="' .$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,
'event_id' => $filter
));
}
$template->assign_vars(array(
'starter_visible' => ($counter>0) ? 'block' : 'none',
));
}
####################################################
### Footer laden ###
$template->pparse('tpl');
?>