예제 #1
0
function showResult(&$smarty)
{
    $tour_id = trim($_REQUEST['id']);
    $tournaments = new tournaments($tour_id);
    $datalist = $tournaments->getPositionList();
    $smarty->assign('datalist', $datalist);
    $smarty->assign('course_msg', "There are currently no register player.");
    //drawresult
    $select = $_POST['id_round'];
    $none = true;
    $data = $tournaments->getRoundList();
    $key = 0;
    $mark = 0;
    foreach ($data as $var) {
        switch ($var['round_no']) {
            case 1:
                $nama = "First";
                break;
            case 2:
                $nama = "Second";
                break;
            case 3:
                $nama = "Third";
                break;
            case 4:
                $nama = "Fourth";
                break;
            case 5:
                $nama = "Fifth";
                break;
            default:
                $nama = "";
                break;
        }
        $list[$key]['param'] = $nama;
        $list[$key]['value'] = $var['round_id'];
        $list[$key]['selected'] = "";
        if ($select == $var['round_id']) {
            $list[$key]['selected'] = "selected";
            $none = false;
            $mark = $key;
        }
        $key++;
    }
    if ($none) {
        $list[0]['selected'] = "selected";
    }
    $smarty->assign('list', $list);
    $tour_fact = new tournament_factory();
    $capek = $tour_fact->getTournaments($tour_id);
    $course_fact = new course_factory();
    $course = $course_fact->get_course($capek->course_id);
    $par = $course->get_detail();
    $hole = $par["hole"];
    $key = 1;
    $in_par = 0;
    $out_par = 0;
    for ($j = 0; $j <= 18; $j++) {
        $par = $hole[$j]["par"];
        if ($j <= 8) {
            $out_par += $par;
        } else {
            $in_par += $par;
        }
        $smarty->assign('hole' . $key . '_par', $par);
        $key++;
    }
    $smarty->assign('out_par', $out_par);
    $smarty->assign('in_par', $in_par);
    $smarty->assign('total_par', $in_par + $out_par);
    $id_round = $list[$mark]['value'];
    $restlist = $capek->getResultRound($id_round);
    $smarty->assign('playerlist', $restlist);
}