}
// Print match list. Round 1
for ($i = 0; $i < $count; $i++) {
    if (count($courts) >= $count / 2) {
        $team['T1'][] = $players[$i];
        $team['T2'][] = $players[++$i];
        $team['court'][] = $courts[$i / 2];
        $team['time'][] = $allocate_time;
        Scheduling::saveEventMatch($event_id, $tour_id, $team['T1'][$i / 2], $team['T2'][$i / 2], $team['court'][$i / 2], $allocate_time, 0);
    } else {
        shuffle($courts);
        $team['T1'][] = $players[$i];
        $team['T2'][] = $players[++$i];
        $team['court'][] = $courts[0];
        $team['time'][] = $allocate_time;
        Scheduling::saveEventMatch($event_id, $tour_id, $team['T1'][$i / 2], $team['T2'][$i / 2], $team['court'][$i / 2], $allocate_time, 0);
    }
}
//BYE CASE
//n - no of rounds in the tournament
$n = Scheduling::getRounds($tour_id);
for ($y = 2; $y <= $n; $y++) {
    $last_allocated_time = Scheduling::getLastTimeAllocation($tour_id, $y - 1);
    $bye_team = Scheduling::getBye($tour_id, $y - 1);
    $matches = Scheduling::getMatchesByRound($tour_id, $y - 1);
    $match_per_day = Scheduling::getMatchCount($tour_id);
    $day_count = Scheduling::getDayGap($tour_id);
    $allocated_count = Scheduling::getTimeAllocationDay($tour_id, $last_allocated_time);
    if ($allocated_count < $match_per_day) {
        $allocate_time1 = $last_allocated_time;
    } else {
Пример #2
0
        $allocated_count = Scheduling::getTimeAllocationDay($tour_id, $last_allocated_time_1);
        if ($allocated_count <= $match_per_day) {
            $allocate_time = $time[0];
        } else {
            for ($i = 1; $i < $day_count; $i++) {
                $last_allocated_time_1 = Scheduling::getLastTimeAllocation($tour_id, 1);
                $new_time = date('Y-m-d H:i:s', strtotime(date("Y-m-d 10:00:00", strtotime($last_allocated_time_1)) . " +1 day"));
                $allocated_count = Scheduling::getTimeAllocationDay($tour_id, $new_time);
                if ($allocated_count <= $match_per_day) {
                    $allocate_time = $new_time;
                }
            }
        }
        shuffle($courts);
        //$t- default bye for round 1
        Scheduling::saveEventMatch($event_id, $tour_id, $value, $t, $courts[0], $allocate_time, $winner_bracket);
    }
}
//BYE CASE
//n - no of rounds in the tournament
$n = Scheduling::getRounds($tour_id);
for ($y = 2; $y <= $n; $y++) {
    $last_allocated_time = Scheduling::getLastTimeAllocation($tour_id, $y - 1);
    $matches = Scheduling::getMatchesWithBye($tour_id, $y - 1);
    $match_per_day = Scheduling::getMatchCount($tour_id);
    $day_count = Scheduling::getDayGap($tour_id);
    $allocated_count = Scheduling::getTimeAllocationDay($tour_id, $last_allocated_time);
    if ($allocated_count <= $match_per_day) {
        $allocate_time1 = $last_allocated_time;
    } else {
        for ($m = 1; $m < $day_count; $m++) {
        $allocated_count = Scheduling::getTimeAllocationDay($tour_id, $last_allocated_time_1);
        if ($allocated_count <= $match_per_day) {
            $allocate_time = $time[0];
        } else {
            for ($i = 1; $i < $day_count; $i++) {
                $last_allocated_time_1 = Scheduling::getLastTimeAllocation($tour_id, 1);
                $new_time = date('Y-m-d H:i:s', strtotime(date("Y-m-d 10:00:00", strtotime($last_allocated_time_1)) . " +1 day"));
                $allocated_count = Scheduling::getTimeAllocationDay($tour_id, $new_time);
                if ($allocated_count <= $match_per_day) {
                    $allocate_time = $new_time;
                }
            }
        }
        shuffle($courts);
        //$t- default bye for round 1
        Scheduling::saveEventMatch($event_id, $tour_id, $value, $t, $courts[0], $allocate_time, 1);
    }
}
//BYE CASE
//n - no of rounds in the tournament
$n = Scheduling::getRounds($tour_id);
for ($y = 2; $y <= $n; $y++) {
    $last_allocated_time = Scheduling::getLastTimeAllocation($tour_id, $y - 1);
    //$bye_team=Scheduling::getBye($tour_id,$y-1);
    $matches = Scheduling::getMatchesWithBye($tour_id, $y - 1);
    $match_per_day = Scheduling::getMatchCount($tour_id);
    $day_count = Scheduling::getDayGap($tour_id);
    $allocated_count = Scheduling::getTimeAllocationDay($tour_id, $last_allocated_time);
    if ($allocated_count <= $match_per_day) {
        $allocate_time1 = $last_allocated_time;
    } else {