$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(“

To go back to the main page for division: “.$results[0]->division.” Game ID Home Team Location Date and Time

gameDate);

?>

gameID);?> homeTeam);?> location != “Please Set Location” && $division->location != “Set Location”) {echo($division->location);}?> gameDate)); } ?>


found no away games

“);
}

$qry=$wpdb->prepare(“select M.id as ‘gameID’,
Home.title as ‘homeTeam’,
Away.title as ‘awayTeam’,
Division.title as ‘division’,
coalesce(M.date,’2019-01-01 00:00:00′) as ‘gameDate’,
M.location as ‘location’,
MM.fieldID as ‘fieldID’,
AwayM.schedulingContactName as ‘contactName’,
AwayM.schedulingContactPhone as ‘contactPhone’,
AwayM.schedulingContactEmail as ‘contactEmail’
from
wp_mysl_matches MM
join
4Ao_leaguemanager_matches M on MM.id = M.id
join
4Ao_leaguemanager_leagues Division on Division.id = M.league_id
join
4Ao_leaguemanager_teams Home on Home.id = M.home_team
join
4Ao_leaguemanager_teams Away on Away.id = M.away_team
left outer join
wp_mysl_teams AwayM on Away.id = AwayM.id
where M.season = ‘%s’ and Home.id =%d”
,$_GET[‘season’]
,$_GET[‘teamID’]
);

//echo($qry);

$results = $wpdb->get_results($qry);

if($results)
{

$qry = “SELECT id, trim(city) as ‘city’, trim(fieldName) as ‘fieldName’, trim(streetAddress) as ‘streetAddress’ FROM wp_mysl_fields ORDER BY city, fieldName”;
$fields = $wpdb->get_results($qry);

echo(“

Step 2:

Please enter your Home Games here.
“);

?>

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”

city != $prevCity)
{
if($prevCity != “”)
{
echo(““);
}

$prevCity = trim($field->city);
?>

“);
}
?>

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).


Game ID Away Team Home Game Location / Date / Time

gameDate);

?>

“.$division->awayTeam.”
Scheduling Contact Info:
“.$division->contactName. ”
“.$division->contactPhone.”
Select Field Locationcity != $prevCity)
{
if($prevCity != “”)
{
echo(““);
}

$prevCity = trim($field->city);
?>

“);
}
?>
Specific Field (if any): **Note – you may not enter a Specific Field Name until a Field Location is selected. Game Date: “/> Time:

found no home games

“);
}

?>

Contact Info:

Below is the scheduling contact info for all of the teams in your division

prepare( “SELECT lt.title as ‘teamName’,mt.schedulingContactName as ‘schedulingContactName’,mt.schedulingContactPhone as ‘schedulingContactPhone’,mt.schedulingContactEmail as ‘schedulingContactEmail’ FROM 4Ao_leaguemanager_teams lt join wp_mysl_teams mt on lt.id =mt.id where lt.id != %d and lt.season = %s and league_id in (select league_id from 4Ao_leaguemanager_teams where id = %d)”,$teamID, $_GET[‘season’],$teamID);

$results = $wpdb->get_results( $qry );

foreach($results as $result)
{
echo(“

“);
echo(“

“);
echo(“

“);
echo(“

“);
echo(“

“);
echo(“

“);
}

?>

Team Name Scheduling Contact Name Scheduling Contact Phone Scheduling Contact Email
“.$result->teamName.” “.$result->schedulingContactName.” “.$result->schedulingContactPhone.” “.$result->schedulingContactEmail.”

get_var( $wpdb->prepare( “select title from 4Ao_leaguemanager_teams where id = %d”,$teamID ));
$divisionName = $wpdb->get_var( $wpdb->prepare( “SELECT division.title FROM 4Ao_leaguemanager_teams team join 4Ao_leaguemanager_leagues division on team.league_id = division.id WHERE team.id = %d”,$teamID ));

?>

Please enter a valid registration code number for: