= $line_len) { // We need the next char break; } $next_char = substr($line, $new_pos + $cur_len, $enclosure_len); if ((! $enclosure) || ($next_char != $enclosure)) { $non_escape = true; } } $cur_pos = $new_pos; if ($in_value && (! $non_escape)) { $cur_value .= mb_substr($line, $last_value, $cur_pos - $last_value); if ($cur_char == $escape) { // Skip escape char $cur_pos += $escape_len; } $last_value = $cur_pos; } else if (($cur_char == "\n") || ($cur_char == "\r") || ($cur_char == "\r\n")) { $blank_start_lines = ($cur_pos == 0); ++$cur_pos; $cur_pos = $cur_pos + strspn($line, "\n\r", $cur_pos); if (! $blank_start_lines) { $complete = true; } else { $last_value = $cur_pos; continue; } } if ($cur_char == $delim || $complete) { if (is_null($fields)) { $fields = array(); } $fields[] = $cur_value . trim(mb_substr($line, $last_value, $cur_pos - $last_value)); $last_value = $cur_pos + $cur_len; $cur_value = ''; } else if ($cur_char == $enclosure) { if ($in_value) { $cur_value .= mb_substr($line, $last_value, $cur_pos - $last_value); } $last_value = $cur_pos + $cur_len; $in_value = ! $in_value; } if ($complete) { break; } $cur_pos += $cur_len; } } } fseek($file_handle, $cur_pos - strlen($line), SEEK_CUR); if ($cur_pos - strlen($line) < 0) { return $fields; } else { return FALSE; } } ################################################################################ function page_header() ################################################################################ { print "\n"; print "\n"; print " \n"; print " \n"; print " Fyzicke testy\n"; print " \n"; // print " \n"; print " \n"; print " \n"; } ################################################################################ function page_footer() ################################################################################ { print " \n"; print "\n"; } ################################################################################ function time2sec( $time ) ################################################################################ { //http://www.plug.org/pipermail/plug/2007-September/027732.html //Kenneth Burgener kenneth at mail1.ttak.org //Thu Sep 27 17:25:32 MDT 2007 // INPUT: string formatted in "hh:mm:ss.ms" // RETURN: time converted to seconds // RETURN: -1 for invalid $msec = 0; // mili second container $tokens = array(); // token array $token = ""; // token string // Parse string for( $i = 0 ; $i < strlen($time); $i++ ) { $char = $time[$i]; if( $char == ":" ) { // handle h/m/s delimiter $tokens[] = $token; $token = ""; } else if( $char == "." ) { // handle msec delimiter $msec = substr($time, $i); break; } else { // handle token $token .= $char; } } $tokens[] = $token; // add final token to token array // Calculate seconds $total = 0; for( $i = count($tokens), $j = 0; $i > 0; $i--, $j++ ) { switch($i) { case 3: // handle hours $total += 60 * 60 * $tokens[$j]; break; case 2: // handle minutes $total += 60 * $tokens[$j]; break; case 1: // handle seconds $total += 1 * $tokens[$j]; break; default: // handle other situations return(-1); } } // Return result, with msec added return( 0 + $total + $msec ); } ################################################################################ function category($c) ################################################################################ { switch($c) { case 1: return("I."); case 2: return("II."); case 3: return("III."); case 4: return("IV."); default: return("Dead Man (zadny stupen)"); } } ################################################################################ function reverse_category($c) ################################################################################ { switch($c) { case "1" : return(1); case "2" : return(2); case "3": return(3); case "4" : return(4); case "1." : return(1); case "2." : return(2); case "3.": return(3); case "4." : return(4); case "I" : return(1); case "II" : return(2); case "III": return(3); case "IV" : return(4); case "I." : return(1); case "II." : return(2); case "III.": return(3); case "IV." : return(4); default: return("Dead Man (zadny stupen)"); } } ################################################################################ function exercise($e) ################################################################################ { switch($e) { case "beh": return("běh 2000 metrů"); case "plav": return("plavání 200 metrů"); case "prednoz":return("přednožování v lehu"); case "lehsed": return("leh-sed"); case "kliky": return("kliky"); case "shyby": return("shyby"); case "none": return("Neabsoloval"); default: return("bad selection of excercise"); } } ################################################################################ function category_to_tablecat($sex, $cat) ################################################################################ { if ($sex == "female" and $cat > 2) { return 2;} return 1; } ################################################################################ function age_category($sex, $age, $cat) ################################################################################ { if ($age < 18) {return 0;} if ($sex == "male" or $sex == "female" and $cat < 3) { if ($age <= 29) {$vk = vk1;} if ($age >= 30 and $age <= 35) {$vk = vk2;} if ($age >= 36 and $age <= 40) {$vk = vk3;} if ($age >= 41 and $age <= 45) {$vk = vk4;} if ($age >= 46 and $age <= 50) {$vk = vk5;} if ($age >= 51) {$vk = vk6;} } else if ($sex == "female" and $cat >= 3) { if ($age <= 25) {$vk = vk1;} if ($age >= 26 and $age <= 30) {$vk = vk2;} if ($age >= 31 and $age <= 35) {$vk = vk3;} if ($age >= 36 and $age <= 40) {$vk = vk4;} if ($age >= 41 and $age <= 45) {$vk = vk5;} if ($age >= 46) {$vk = vk6;} } return $vk; } ################################################################################ function calculate_results_disc1($casy, $sex, $disc1, $res1, $age, $cat) ################################################################################ { #leh sedy, prednozovani $vk = age_category($sex, $age, $cat); $points1 = 0; #print "casy[lap][category_to_tablecat($sex, $cat)][$vk][maxe]"; if ($res1 > $casy["lap"][category_to_tablecat($sex, $cat)][$vk][maxe]) { $points1 = ($res1 - $casy["lap"][category_to_tablecat($sex, $cat)][$vk][maxe]) * 2 + $casy["lap"][category_to_tablecat($sex, $cat)][maxpoints]; } else if ($res1 < $casy["lap"][category_to_tablecat($sex, $cat)][$vk][mine]) { $points1 = 0; } else { $points1 = $casy["lap"][category_to_tablecat($sex, $cat)][$vk][$res1]; } return $points1; } ################################################################################ function calculate_results_disc2($casy, $sex, $disc2, $res2, $age, $cat) ################################################################################ { $vk = age_category($sex, $age, $cat); $points2 = 0; switch ($disc2) { case "kliky": $b = 2; break; case "shyby": $b = 4; break; } if ($res2 > $casy[$disc2][category_to_tablecat($sex, $cat)][$vk][maxe]) { $points2 = ($res2 - $casy[$disc2][category_to_tablecat($sex, $cat)][$vk][maxe]) * $b + $casy[$disc2][category_to_tablecat($sex, $cat)][maxpoints]; } else if ($res2 < $casy[$disc2][category_to_tablecat($sex, $cat)][$vk][mine]) { $points2 = 0; } else { $points2 = $casy[$disc2][category_to_tablecat($sex, $cat)][$vk][$res2]; } return $points2; } ################################################################################ function calculate_results_disc3($casy, $sex, $disc3, $res3, $age, $cat) ################################################################################ { $vk = age_category($sex, $age, $cat); $points3 = 0; if (time2sec($res3) < time2sec($casy[$disc3][category_to_tablecat($sex, $cat)][$vk][mint])) { $sec = time2sec($casy[$disc3][category_to_tablecat($sex, $cat)][$vk][mint]) - time2sec($res3); $points3 = $casy[$disc3][category_to_tablecat($sex, $cat)][maxpoints] + (int)($sec / 2); } else { // print "[ $disc3 ][ $cat ][ $vk]"; foreach ($casy[$disc3][category_to_tablecat($sex, $cat)][$vk] as $k => $v ) { // print $k." ".$v."
"; if (time2sec($res3) >= time2sec($k)) { $points3 = $v; break; } } } return $points3; } ################################################################################ function sex($s) ################################################################################ { if ($s=="male") { return convert_to_widle("muž"); } else { return convert_to_widle("žena"); } } ################################################################################ function calculate_results($casy, $sex, $disc1, $disc2, $disc3, $res1, $res2, $res3, $age, $cat) ################################################################################ { print "
"; $vk = age_category($sex, $age, $cat); print "vek ".$age." pohlavi ".($sex=="male"?"muz":"zena")." vekova kategorie VK".$vk." skupina ".category($cat)."
"; print "
"; $points1 = 0; $points2 = 0; $points3 = 0; print "

Disciplina 1.: ".exercise($disc1)." vykon:$res1

"; //print "casy[lap][$cat][$vk][$res1]:".$casy[lap][$cat][$vk][$res1]."!
\n"; if ($res1 > $casy["lap"][$cat][$vk][maxe]) { $points1 = ($res1 - $casy["lap"][$cat][$vk][maxe]) * 2 + $casy["lap"][kat2][maxpoints]; } else if ($res1 < $casy["lap"][$cat][$vk][mine]) { $points1 = 0; } else { $points1 = $casy["lap"][$cat][$vk][$res1]; } print "

Bodu:$points1


"; $total_points += $points1; print "

Disciplina 2.: ".exercise($disc2)." vykon:$res2

"; switch ($disc2) { case "kliky": $b = 2; break; case "shyby": $b = 4; break; } //print "casy[$disc2][$cat][$vk][$res2]:"; if ($res2 > $casy[$disc2][$cat][$vk][maxe]) { $points2 = ($res2 - $casy[$disc2][$cat][$vk][maxe]) * $b + $casy[$disc2][kat2][maxpoints]; } else if ($res2 < $casy[$disc2][$cat][$vk][mine]) { $points2 = 0; } else { //print "casy[$disc2][$cat][$vk][$res2]:"; $points2 = $casy[$disc2][$cat][$vk][$res2]; } print "

Bodu:$points2


"; $total_points += $points2; print "

Disciplina 3.: ".exercise($disc3)." vykon:$res3

"; //print "casy[$disc3][$cat][$vk][$res3]:".$casy[$disc3][$cat][$vk][$res3]."
\n"; print time2sec($res3)." ".time2sec($casy[$disc3][$cat][$vk][mint])."
"; if (time2sec($res3) < time2sec($casy[$disc3][$cat][$vk][mint])) { print "superman"; $sec = time2sec($casy[$disc3][$cat][$vk][mint]) - time2sec($res3); $points3 = $casy[$disc3][$cat][maxpoints] + (int)($sec / 2); } else { print "[ $disc3 ][ $cat ][ $vk]"; foreach ($casy[$disc3][$cat][$vk] as $k => $v ) { print $k." ".$v."
"; if (time2sec($res3) >= time2sec($k)) { $points3 = $v; break; } } } print "

Bodu:$points3


"; $total_points += $points3; print "

Soucet:"; print "$total_points


"; final_result($points1, $points2, $points3, $cat, $disc1, $disc2, $disc3); } ################################################################################ function final_result($p1, $p2, $p3, $cat, $d1, $d2, $d3) ################################################################################ { if (eval_points($p1, $p2, $p3, $cat, $d1, $d2, $d3)) { return "UDĚLAL"; } else { return "NEUDĚLAL"; } } ################################################################################ function eval_points($p1, $p2, $p3, $kat, $disc1, $disc2, $disc3) ################################################################################ { $valid = 0; if ($kat == 1 and $p1 >= 25 and $p2 >= 25 and $p3 >= 50 and $p1 + $p2 + $p3 >= 105) { $valid = 1; } if ($kat == 2 and $p1 >= 20 and $p2 >= 20 and $p3 >= 40 and $p1 + $p2 + $p3 >= 95) { $valid = 1; } if ($kat == 3 and ($p1 >= 14 or $p2 >= 14) and $p3 >= 28 and $p1 + $p2 + $p3 >= 42) { $valid = 1; } if ($kat == 4) { if ($disc1 != "none" and p1 >= 10) { $valid = 1; } if ($disc2 != "none" and p2 >= 10) { $valid = 1; } if ($disc3 != "none" and p3 >= 20) { $valid = 1; } } return $valid; } ################################################################################ function show_form() ################################################################################ { print "
\n"; print "\n"; print " Muz\n"; print "
\n"; print " Zena\n"; print "
\n"; print "kategorie:\n"; print "\n"; print "
\n"; print "vek: \n"; print "
\n"; print "Discipliny\n"; print "
\n"; print "\n"; print "vykon: \n"; print "
\n"; print "\n"; print "vykon: \n"; print "
\n"; print "\n"; print "vykon: \n"; print "\n"; print "

\n"; print "\n"; print "
\n"; } ################################################################################ function show_upload_dialog() ################################################################################ { print "
Soubor:


Datum testu:

"; } ################################################################################ function process_file($casy) ################################################################################ { print "
"; print $_FILES['uploadedfile']['name']; print "
"; print $_FILES['uploadedfile']['type']; print "
"; print $_FILES['uploadedfile']['size']; print "
"; print $_FILES['uploadedfile']['tmp_name']; print "
"; print $_FILES['uploadedfile']['error']; print "
"; $target_path = "uploads/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "Soubor ".basename($_FILES['uploadedfile']['name'])." byl uspesne nahran na server"; $date = get_param("test_date"); parse_csv($target_path,$casy, $date); } else { echo "Chyba pri otevirani souboru, mozna je prilis velky"; } } ################################################################################ function detectUTF8($string) ################################################################################ { return preg_match('%(?: [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte |\xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs |[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte |\xED[\x80-\x9F][\x80-\xBF] # excluding surrogates |\xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 |[\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 |\xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 )+%xs', $string); } #/** # * Charset-2-charset conversion by dgx # * ----------------------------------- # * # * This source file is subject to the GNU GPL license. # * # * @author David Grudl # * @link http://davidgrudl.com/ # * @copyright Copyright (c) 2006 David Grudl # * @license GNU GENERAL PUBLIC LICENSE # * @category Text # * @version 1.0 # */ #WINDOWS-1250 to UTF-8 function win2utf($s) { static $tbl = array("\x80"=>"\xe2\x82\xac","\x81"=>"","\x82"=>"\xe2\x80\x9a","\x83"=>"","\x84"=>"\xe2\x80\x9e","\x85"=>"\xe2\x80\xa6","\x86"=>"\xe2\x80\xa0","\x87"=>"\xe2\x80\xa1","\x88"=>"","\x89"=>"\xe2\x80\xb0","\x8a"=>"\xc5\xa0","\x8b"=>"\xe2\x80\xb9","\x8c"=>"\xc5\x9a","\x8d"=>"\xc5\xa4","\x8e"=>"\xc5\xbd","\x8f"=>"\xc5\xb9","\x90"=>"","\x91"=>"\xe2\x80\x98","\x92"=>"\xe2\x80\x99","\x93"=>"\xe2\x80\x9c","\x94"=>"\xe2\x80\x9d","\x95"=>"\xe2\x80\xa2","\x96"=>"\xe2\x80\x93","\x97"=>"\xe2\x80\x94","\x98"=>"","\x99"=>"\xe2\x84\xa2","\x9a"=>"\xc5\xa1","\x9b"=>"\xe2\x80\xba","\x9c"=>"\xc5\x9b","\x9d"=>"\xc5\xa5","\x9e"=>"\xc5\xbe","\x9f"=>"\xc5\xba","\xa0"=>"\xc2\xa0","\xa1"=>"\xcb\x87","\xa2"=>"\xcb\x98","\xa3"=>"\xc5\x81","\xa4"=>"\xc2\xa4","\xa5"=>"\xc4\x84","\xa6"=>"\xc2\xa6","\xa7"=>"\xc2\xa7","\xa8"=>"\xc2\xa8","\xa9"=>"\xc2\xa9","\xaa"=>"\xc5\x9e","\xab"=>"\xc2\xab","\xac"=>"\xc2\xac","\xad"=>"\xc2\xad","\xae"=>"\xc2\xae","\xaf"=>"\xc5\xbb","\xb0"=>"\xc2\xb0","\xb1"=>"\xc2\xb1","\xb2"=>"\xcb\x9b","\xb3"=>"\xc5\x82","\xb4"=>"\xc2\xb4","\xb5"=>"\xc2\xb5","\xb6"=>"\xc2\xb6","\xb7"=>"\xc2\xb7","\xb8"=>"\xc2\xb8","\xb9"=>"\xc4\x85","\xba"=>"\xc5\x9f","\xbb"=>"\xc2\xbb","\xbc"=>"\xc4\xbd","\xbd"=>"\xcb\x9d","\xbe"=>"\xc4\xbe","\xbf"=>"\xc5\xbc","\xc0"=>"\xc5\x94","\xc1"=>"\xc3\x81","\xc2"=>"\xc3\x82","\xc3"=>"\xc4\x82","\xc4"=>"\xc3\x84","\xc5"=>"\xc4\xb9","\xc6"=>"\xc4\x86","\xc7"=>"\xc3\x87","\xc8"=>"\xc4\x8c","\xc9"=>"\xc3\x89","\xca"=>"\xc4\x98","\xcb"=>"\xc3\x8b","\xcc"=>"\xc4\x9a","\xcd"=>"\xc3\x8d","\xce"=>"\xc3\x8e","\xcf"=>"\xc4\x8e","\xd0"=>"\xc4\x90","\xd1"=>"\xc5\x83","\xd2"=>"\xc5\x87","\xd3"=>"\xc3\x93","\xd4"=>"\xc3\x94","\xd5"=>"\xc5\x90","\xd6"=>"\xc3\x96","\xd7"=>"\xc3\x97","\xd8"=>"\xc5\x98","\xd9"=>"\xc5\xae","\xda"=>"\xc3\x9a","\xdb"=>"\xc5\xb0","\xdc"=>"\xc3\x9c","\xdd"=>"\xc3\x9d","\xde"=>"\xc5\xa2","\xdf"=>"\xc3\x9f","\xe0"=>"\xc5\x95","\xe1"=>"\xc3\xa1","\xe2"=>"\xc3\xa2","\xe3"=>"\xc4\x83","\xe4"=>"\xc3\xa4","\xe5"=>"\xc4\xba","\xe6"=>"\xc4\x87","\xe7"=>"\xc3\xa7","\xe8"=>"\xc4\x8d","\xe9"=>"\xc3\xa9","\xea"=>"\xc4\x99","\xeb"=>"\xc3\xab","\xec"=>"\xc4\x9b","\xed"=>"\xc3\xad","\xee"=>"\xc3\xae","\xef"=>"\xc4\x8f","\xf0"=>"\xc4\x91","\xf1"=>"\xc5\x84","\xf2"=>"\xc5\x88","\xf3"=>"\xc3\xb3","\xf4"=>"\xc3\xb4","\xf5"=>"\xc5\x91","\xf6"=>"\xc3\xb6","\xf7"=>"\xc3\xb7","\xf8"=>"\xc5\x99","\xf9"=>"\xc5\xaf","\xfa"=>"\xc3\xba","\xfb"=>"\xc5\xb1","\xfc"=>"\xc3\xbc","\xfd"=>"\xc3\xbd","\xfe"=>"\xc5\xa3","\xff"=>"\xcb\x99"); return strtr($s, $tbl); } function cs_win2ascii($s) { return strtr($s, "\xe1\xe4\xe8\xef\xe9\xec\xed\xbe\xe5\xf2\xf3\xf6\xf5\xf4\xf8\xe0\x9a\x9d\xfa\xf9\xfc\xfb\xfd\x9e\xc1\xc4\xc8\xcf\xc9\xcc\xcd\xbc\xc5\xd2\xd3\xd6\xd5\xd4\xd8\xc0\x8a\x8d\xda\xd9\xdc\xdb\xdd\x8e", "aacdeeillnoooorrstuuuuyzAACDEEILLNOOOORRSTUUUUYZ"); } ################################################################################ function convert_to_utf($str) ################################################################################ { if (detectUTF8($str)) { return $str; } else { # $converted = iconv("CP1250//TRANSLIT", "UTF-8//IGNORE", $str); $converted = win2utf($str); # $converted = cs_win2ascii($str); return $converted; } } ################################################################################ function convert_to_widle($str) ################################################################################ { $converted = iconv("UTF-8", "WINDOWS-1250//TRANSLIT", $str); return $converted; } ################################################################################ function parse_csv($param, $casy, $date) ################################################################################ { global $pdf; $row = 1; $handle = fopen("$param", "r"); $csv_handle = fopen("test.csv", "w"); $test_id = 0; while (($data = fgetcsv_ex($handle, 1000, ";")) !== FALSE) { $disc1 = 0; $disc2 = 0; $disc3 = 0; $res1 = 0; $res2 = 0; $res3 = ""; $num = count($data); echo "\n"; $row++; for ($c=0; $c < $num; $c++) { print "\n"; } $oec = $data[0]; if ($oec == "") { unset($data); continue; } $test_id++; $current_year = date("Y"); //calculate_results($casy, $sex, $disc1, $disc2, $disc3, $res1, $res2, $res3, $age, $cat) //print "casy[lap][1][1][36]:".$casy[lap][1][1][36]."!
\n"; // calculate_results($casy, $sex, $data[11], $data[12], $data[13], $data[8], $data[9], $data[10], $data[14], $data[6]); $date_of_test = $date; $ho = $data[1]; $titul = $data[2]; $firstname = convert_to_utf($data[3]); $lastname = convert_to_utf($data[4]); $name = $firstname." ".$lastname; $birth = $data[5]; $cat = reverse_category($data[6]); if ($data[7]=="m" or $data[7]=="muz" or $data[24]=="male" or ereg("^mu.*" , $data[7])) {$sex = "male";} if ($data[7]=="z" or $data[7]=="zena" or $data[24]=="female" or ereg(".*ena$" , $data[7])) {$sex = "female";} $age = $data[8]; if ($data[9] != "") { $disc2 = "kliky"; $res2 = $data[9]; } #9 jsou vysledky z 8 if ($data[11] != "") { $disc2 = "shyby"; $res2 = $data[11]; } if ($data[13] != "") { $disc1 = "lehsed"; $res1 = $data[13]; } if ($data[15] != "") { $disc1 = "prednoz"; $res1 = $data[15]; } if ($data[17] != "") { $disc3 = "beh"; $res3 = $data[17]; } if ($data[19] != "") { $disc3 = "plav"; $res3 = $data[19]; } $utvar = $data[23]; # output_form($casy, $sex, $data[11], $data[12], $data[13], $data[8], $data[9], $data[10], $data[14], $data[6], $utvar, $date, $data[2]." ".$data[3], $birth, $date_of_test); output_form($casy, $sex, $disc1, $disc2, $disc3, $res1, $res2, $res3, $age, $cat, $utvar, $date_of_test, $name, $birth, $date_of_test, $vk, $titul, $firstname, $lastname, $ho, $oec, $test_id."/".$current_year); unset($data); } fclose($handle); $pdf->Output("test.pdf"); print "

pdf

"; print "

csv

"; } ################################################################################ function get_param($param) ################################################################################ { if (isset($_GET[$param])) {return($_GET[$param]);} if (isset($_POST[$param])) {return($_POST[$param]);} } ################################################################################ function output_form($casy, $sex, $disc1, $disc2, $disc3, $res1, $res2, $res3, $age, $cat, $utvar, $date, $name, $birth, $date, $vk, $titul, $firstname, $lastname, $ho, $oec, $test_id) ################################################################################ { print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print ""; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; $vk = age_category($sex, $age, $cat); print "\n"; $p1 = calculate_results_disc1($casy, $sex, $disc1, $res1, $age, $cat); $p2 = calculate_results_disc2($casy, $sex, $disc2, $res2, $age, $cat); $p3 = calculate_results_disc3($casy, $sex, $disc3, $res3, $age, $cat); print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
Poradove cislo
Utvar $utvarJmeno: $name, $titul, $oecRok $birthSkupina ".category($cat)."
VK: věk ".$age." pohlaví ".($sex=="male"?"muz":"zena")." věková kategorie VK".$vk."1:".exercise($disc1)." $res1bodu: $p12:".exercise($disc2)." $res2bodu: $p23:".exercise($disc3)." $res3bodu: $p3
celkem ".($p1 + $p2 + $p3)."hodnoceni ".final_result($p1, $p2, $p3, $cat, $disc1, $disc2, $disc3)."datum $date



\n"; pdf_page($test_id, $ho, $firstname, $lastname, $titul, $birth, $oec, $date, $cat); csv_row($p2, $p1, $p3, $disc2, $disc1, $disc3, $res2, $res1, $res3, $test_id, $ho, $firstname, $lastname, $titul, $birth, $oec, $date, $sex, $cat); } ################################################################################ function csv_row($p1, $p2, $p3, $d1, $d2, $d3, $r1, $r2, $r3, $test_id, $ho, $firstname, $lastname, $titul, $birth, $oec, $date, $sex, $cat) ################################################################################ { $csv_handle = fopen("test.csv", "a"); fwrite ($csv_handle, "$oec;"); fwrite ($csv_handle, "$ho;"); fwrite ($csv_handle, "$titul;"); fwrite ($csv_handle, convert_to_widle("$firstname;")); fwrite ($csv_handle, convert_to_widle("$lastname;")); fwrite ($csv_handle, "$birth;"); fwrite ($csv_handle, category($cat).";"); fwrite ($csv_handle, sex("$sex").";"); fwrite ($csv_handle, ";"); if ($d1 == "kliky") { fwrite ($csv_handle, "$r1;$p1;0;0;"); } else { fwrite ($csv_handle, "0;0;$r1;$p1;"); } if ($d2 == "lehsed") { fwrite ($csv_handle, "$r2;$p2;0;0;"); } else { fwrite ($csv_handle, "0;0;$r2;$p2;"); } if ($d3 == "beh") { fwrite ($csv_handle, "$r3;$p3;0;0;"); } else { fwrite ($csv_handle, "0;0;$r3;$p3;"); } fwrite ($csv_handle, $p1 + $p2 + $p3.";"); fwrite ($csv_handle, convert_to_widle(final_result($p1, $p2, $p3, $cat, $d1, $d2, $d3).";")); fwrite ($csv_handle, "$date;"); fwrite ($csv_handle, "\n"); fclose($csv_handle); } ################################################################################ function latin2($text) ################################################################################ { return iconv('UTF-8', 'ISO-8859-2', $text); } class PDF extends FPDF{ ################################################################################ function center_line($text, $size) ################################################################################ { $t2 = latin2($text); $this->SetFont('Arial','',$size); $w = $this->GetStringWidth($t2) + 6; $this->SetX((210 - $w) / 2); $this->Cell(20, $size/2, $t2, 0, 0, 'L'); $this->Ln(); } ################################################################################ function BasicTable($a0, $a1, $a2, $a3, $a4, $a5, $a6, $a7, $cat) ################################################################################ { $uchazec = 0; $this->Ln(); $this->Ln(); $this->center_line("HZS Olomouckeho kraje Fyz: $a0", 12); $this->Ln(); $this->Ln(); $this->Ln(); $this->center_line("OSVĚDČENÍ", 30); $this->center_line("o tělesné zdatnosti", 16); if ($uchazec) { $this->center_line("uchazeče o přijetí do lužebního poměru příslušníka Hasičského záchranného sboru ČR", 12); } $this->center_line("příslušníka Hasičského záchranného sboru ČR", 12); $this->center_line("pro výkon na služebním místě, na které byl ustanoven,", 12); $this->Ln(); $this->Cell(60,7,latin2("Hodnostní označení"),1); $this->Cell(120,7,latin2($a1),1); $this->Ln(); $this->Cell(60,7,latin2("Příjmení,titul"),1); $str = latin2($a3); if ($a4 != "") { $str .= ", ".latin2($a4); } $this->Cell(120,7,$str,1); $this->Ln(); $this->Cell(60,7,latin2("Jméno"),1); $this->Cell(120,7,latin2($a2),1); $this->Ln(); if ($uchazec) { $this->Cell(60,7,latin2("Datum narození uchazeče"),1); $this->Cell(120,7,latin2($a5),1); $this->Ln(); } $this->Cell(60,7,latin2("Osobní evidenční číslo"),1); $this->Cell(120,7,latin2($a6),1); $this->Ln(); $this->Cell(180,7,"",1); $this->Ln(); $this->Cell(90,7,latin2("Datum konání zkoušky"),1); $this->Cell(90,7,latin2("Podpis vedoucího zkušební komise"),1); $this->Ln(); $this->Cell(90,7,latin2($a7),1); $this->Cell(90,7,latin2(""),1); $this->Ln(); for ($i = 0; $i < 15; $i++) { $this->Cell(90,5,"",1); $this->Cell(90,5,"",1); $this->Ln(); } $this->Ln(); $this->center_line("splnil/a požadavky na tělesnou zdatnost podle", 12); $this->center_line("zákona č. 361/2003 Sb.,o služebním poměru příslušníků bezpečnostních sborů", 12); }} $pdf = new PDF(); ################################################################################ function pdf_page($a0, $a1, $a2, $a3, $a4, $a5, $a6, $a7, $cat) ################################################################################ { global $pdf; $pdf->SetFont('Arial','',14); $pdf->AddPage(); $pdf->BasicTable($a0, $a1, $a2, $a3, $a4, $a5, $a6, $a7, $cat); } // $pdf->Output(); ################################################################################ # MAIN ################################################################################ $pdf->AddFont('Arial','','arial.php'); if (isset($_GET['action'])) {$action = $_GET['action'];} if (isset($_POST['action'])) {$action = $_POST['action'];} page_header(); print ""; print "\n"; print "
ukazkovy soubor csv"; print "
ukazkovy soubor xls s legendou"; print "

program pracuje pouze se soubory csv, po spocitani vrati zase csv soubor, ktery lze potom vlozit do vysledne excel tabulky. Policko vek v xls se pocita automaticky.

"; switch ($action) { case 'file': process_file($casy); break; case 'show_file_form': show_upload_dialog(); break; case 'show_form': show_form(); break; case 'results': echo "

Vysledek

"; $sex = get_param("sex"); $age = get_param("age"); $disc1 = get_param("disc1"); $disc2 = get_param("disc2"); $disc3 = get_param("disc3"); $res1 = get_param("disc1res"); $res2 = get_param("disc2res"); $res3 = get_param("disc3res"); if ($res1 == "" and $disc1 != "none" or $res2 == "" and $disc2 != "none" or $res3 == "" and $disc3 != "none") { print("Spatne zadani, nektere discipliny nemaji vyplnene vykony"); die(); } $cat = get_param("cat"); calculate_results($casy, $sex, $disc1, $disc2, $disc3, $res1, $res2, $res3, $age, $cat); break; case 'jinakokotina': echo "i equals 2"; break; } page_footer(); ?>