$to)) && !is_user_logged_in()) :
echo(“Scheduling is currently unavailable. The online scheduling period for Fall 2019 is August 11th 8am – August 18th 11pm”);
else :
$teamID = $_GET[‘teamID’] ?: $_POST[‘teamID’];
if($_POST[‘validateBTN’])
{
$qry = $wpdb->prepare( “select hash from wp_mysl_teams where id = %d and teamPIN = %d LIMIT 1”,$teamID, $_POST[‘teamPIN’] );
$validated = $wpdb->get_var( $qry );
if(!$validated)
{
echo(“I’m sorry, that number does not check out. If you are repeatedly unable to validate, please contact your Club representative who can lookup your code.”);
}
}
if ($_POST[‘validated’] || $validated)
{
if ($_POST[‘data’] && $_POST[‘saveGrid’])
{
$atLeastOneError = 0;
$numChanges = 0;
foreach($_POST[‘data’] as $var)
{
if($var[‘scheduleDatePicker’])
{
$theTimestamp = strtotime(trim($var[‘scheduleDatePicker’]));
$formattedDate = date(‘Y-m-d’,$theTimestamp);
$formattedDate = $formattedDate.” “.trim($var[‘Hour’]).”:00″;
}
else
{
$formattedDate = ‘2019-01-01 00:00:00’;
}
$result = $wpdb->update(‘4Ao_leaguemanager_matches’,
array(
‘location’ => trim($var[‘Location’]),
‘date’ => $formattedDate
),
array(
‘id’ => $var[‘GameID’]
),
array(
‘%s’,
‘%s’
),
array(
‘%d’
)
);
$result2 = $wpdb->update(‘wp_mysl_matches’,
array(
‘fieldID’ => trim($var[‘fieldID’])
),
array(
‘id’ => $var[‘GameID’]
),
array(
‘%s’
),
array(
‘%d’
)
);
if ($result === false || $result2 === false)
{
echo(“Schedule save error on gameID: “.$var[‘GameID’].”“);
$atLeastOneError = 1;
}
else
{
$numChanges++;
}
}
echo(“Successfully updated “.$numChanges.” games. Please continue on if you wish to make further changes.“);
}
if ($_GET[‘teamID’] || $_POST[‘teamID’])
{
$teamID = $_GET[‘teamID’] ?: $_POST[‘teamID’];
$teamHash = $wpdb->get_var( $wpdb->prepare( “select hash from wp_mysl_teams where id = %d LIMIT 1”,$teamID ));
$teamName = $wpdb->get_var( $wpdb->prepare( “select title from 4Ao_leaguemanager_teams where id = %d”,$teamID ));
if($_POST[‘setDefaultField’])
{
$qry = “update wp_mysl_teams set fieldID =”.$_POST[‘defaultField’].” where id =”.$_GET[‘teamID’];
$result = $wpdb->query($qry);
if(!(false === $result))
{
$qry = “update wp_mysl_matches set fieldID=”.$_POST[‘defaultField’].” where id in (select id from 4Ao_leaguemanager_matches where home_team=”.$_GET[‘teamID’].”)”;
$result2 = $wpdb->query($qry);
if(false === $result2)
{
echo(“Error setting default field, please alert MYSL”);
}
}
else
{
echo(“Error setting default field, please alert MYSL.”);
}
}
$defaultField = $wpdb->get_var( $wpdb->prepare( “select fieldID from wp_mysl_teams where id = %d LIMIT 1”,$teamID ));
if($_POST[‘hash’] == $teamHash || $_GET[‘hash’] == $teamHash || $validated ==$teamHash)
{
$qry= $wpdb->prepare(“select M.id as gameID, Home.title as homeTeam, Away.title as awayTeam, Division.title as division, Division.id as divisionID,
coalesce(M.date,’2019-01-01 00:00:00′) as gameDate, COALESCE(F.fieldName,’ – ‘,M.location) as location
from wp_mysl_matches MM
join 4Ao_leaguemanager_matches M on M.id = MM.id
join
4Ao_leaguemanager_teams Home on Home.id = M.home_team
join
4Ao_leaguemanager_teams Away on Away.id = M.away_team
join
4Ao_leaguemanager_leagues Division on Division.id = M.league_id
left outer join
wp_mysl_fields F on MM.fieldID = F.id
where M.season = ‘%s’ and M.away_team = %d”
,$_GET[‘season’]
,$_GET[‘teamID’]
);
$results = $wpdb->get_results($qry);
if($results)
{
echo(“
Team default field: If you’d like to set a default field for all of your home games, please choose that field here, and click “Set default field” | |
Below you may change the Month, Day of the Month, and Start time for each of your home games. You can pick a new Field Location from the pick list, and also key in any Field Specifics (For example: “Field Number 5”).
If your field is not available in any of the drop-down lists, please click HERE to email MYSL about the missing field(s).