function auto_sort($team) { echo "<h3>" . $team['name'] . "</h3>"; echo $team['manager']; $bench = array(); $pitch = array(); $gk = array(); $df = array(); $md = array(); $fw = array(); for ($i = 1; $i <= 15; $i++) { $url = "http://fantasy.premierleague.com/web/api/elements/" . $team[$i] . "/"; $content = file_get_contents($url); $json = json_decode($content, true); //Player switch ($json['type_name']) { case "Goalkeeper": $gk[] = $json; break; default: $outfield[] = $json; } //end switch } //end for //bench lower scoring goalie $bench_gk = get_min($gk); $bench[] = $bench_gk; //remove bench goalie from gk array $key = array_search($bench_gk, $gk); unset($gk[$key]); //bench three outfield players for ($i = 1; $i <= 3; $i++) { $sub = get_min($outfield); $bench[] = $sub; $key = array_search($sub, $outfield); unset($outfield[$key]); } //end for //add goalie to 'pitch' team foreach ($gk as $g) { $pitch[] = $g; } //end foreach //add all non-benched outfielders to pitch team foreach ($outfield as $out) { $pitch[] = $out; } //set table layout echo "<table><tr><td>First team</td><td>Subs</td></tr><tr><td style='text-align: center;' valign=top>"; //here we go - try to output pitch team $team_total = 0; /* EDIT sort by player type (5/4/2016) echo $gk[0] . "<br />"; for ($i = 0; $i <= 9; $i++) { if ($outfield[$i]['type_name'] != $outfield[$i - 1]['type_name']){ echo "<br />"; } echo $outfield[$i] . " "; } /END edit */ foreach ($pitch as $pit) { $team_total += $pit['total_points']; echo "<p>" . $pit['first_name'] . " " . $pit['second_name'] . ", " . $pit['type_name'] . " (" . $pit['team_name'] . ") " . $pit['total_points'] . "points</p>"; } echo "</td><td valign=top>"; //here we go - try to output bench team $bench_total = 0; foreach ($bench as $ben) { $bench_total += $ben['total_points']; echo "<p>" . $ben['first_name'] . " " . $ben['second_name'] . ", " . $ben['team_name'] . " " . $ben['total_points'] . "points</p>"; } echo "</td></tr><tr><td>"; echo "<p><b>On pitch: {$team_total} points</p></b></td><td>"; $squad_total = $team_total + $bench_total; echo "<p>On bench: {$bench_total} points</p>"; echo "<p>Combined first team & subs: {$squad_total} points</p>"; echo "</td></tr></table>"; }
# --------------------------------- For Duplicate Entry Start -------------------------------------- # # -------------------------------------- # $sel_per_id = DBGet(DBQuery('SELECT PERIOD_ID, DAYS FROM course_period_var WHERE COURSE_PERIOD_ID = \'' . $cp_id . '\'')); $sel_period_id = $sel_per_id[1]['PERIOD_ID']; $sel_days = $sel_per_id[1]['DAYS']; $ignore_existing_period_ret = DBGet(DBQuery('SELECT IGNORE_SCHEDULING FROM school_periods WHERE PERIOD_ID=\'' . $sel_period_id . '\'')); $ignore_existing_period = $ignore_existing_period_ret[1]['IGNORE_SCHEDULING']; if ($ignore_existing_period == 'Y') { $sel_period_id = ''; } if ($sel_period_id) { $sel_st_time = DBGet(DBQuery('SELECT START_TIME, END_TIME FROM school_periods WHERE PERIOD_ID = \'' . $sel_period_id . '\'')); $sel_start_time = $sel_st_time[1]['START_TIME']; $min_sel_start_time = get_min($sel_start_time); $sel_end_time = $sel_st_time[1]['END_TIME']; $min_sel_end_time = get_min($sel_end_time); } # ---------------------------- Days conflict ------------------------------------ # // $j = 0; for ($i = 0; $i < $day_st_count; $i++) { $clip = substr($days, $i, 1); $pos = strpos($sel_days, $clip); if ($pos !== false) { $j++; } } // # ---------------------------- Days conflict ------------------------------------ # if ($j != 0) { $time_clash_found = 0;
$values .= "'" . str_replace("\\'", "''", $value) . "',"; $go = true; } } $sql .= '(' . substr($fields, 0, -1) . ') values(' . substr($values, 0, -1) . ')'; if ($go) { DBQuery($sql); } # ----------------------------- Length Calculate start --------------------- # $p_id = DBGet(DBQuery("SELECT max(PERIOD_ID) AS period_id FROM SCHOOL_PERIODS WHERE SYEAR='" . UserSyear() . "' AND SCHOOL_ID='" . UserSchool() . "'")); $period_id = $p_id[1]['PERIOD_ID']; $time_chk = DBGet(DBQuery("SELECT START_TIME,END_TIME FROM SCHOOL_PERIODS WHERE PERIOD_ID='{$period_id}' AND SYEAR='" . UserSyear() . "' AND SCHOOL_ID='" . UserSchool() . "'")); $start_tm_chk = $time_chk[1][START_TIME]; $end_tm_chk = $time_chk[1][END_TIME]; $st_mod = get_min($start_tm_chk); $et_mod = get_min($end_tm_chk); $length = $et_mod - $st_mod; $sql_up = "update SCHOOL_PERIODS set length = " . $length . " where period_id='{$period_id}' and syear='" . UserSyear() . "' and school_id='" . UserSchool() . "'"; $res_up = mysql_query($sql_up); # -------------------------------------------------------------------------- # } } } } } DrawBC("School Setup > " . ProgramTitle()); #echo "Modules.php?modname=$_REQUEST[modname]"; if (clean_param($_REQUEST['modfunc'], PARAM_ALPHAMOD) == 'remove' && AllowEdit()) { $prd_id = paramlib_validation($colmn = PERIOD_ID, $_REQUEST[id]); $has_assigned_RET = DBGet(DBQuery("SELECT COUNT(*) AS TOTAL_ASSIGNED FROM COURSE_PERIODS WHERE PERIOD_ID='{$prd_id}'")); $has_assigned = $has_assigned_RET[1]['TOTAL_ASSIGNED'];