//settings.php
function teamMatchesSchedule()
{
$this->load->library('settings_lib',array());
$this->_setLayoutData(
array(
'errorMessage' => $this->session->flashdata('errorMessage')
)
);
//creating timeslots for all clubs
$seasonID=3;
//Feching the courts info from t_clubdetails
$this->settings_lib->getClubCourtsData($seasonID);
$clubCourtsData = $this->settings_lib->clubCourtsData;
//Fetching the rounds info from t_dkrounds
$this->settings_lib->getRoundDates($seasonID);
$roundDates = $this->settings_lib->roundDates;
foreach($roundDates as $round)
{
echo "<br /><br />".$round['RoundName'];
$startDate = strtotime("+1 day", $round['startDate']);
$endDate = strtotime("+1 day", $round['endDate']);
foreach($clubCourtsData as $club)
{
echo "<br /><br /> Club ID ".$club['ClubID'];
for($i = $startDate; $i <= $endDate; $i = strtotime("+1 day", $i))
{
$day = date('l', $i);// Day name in full text (lowercase of 'L')
$date = date('Y-m-d', $i);
echo "<br />".$date." ".$day;
//insertTimeSlots($i);
}
}
}
===========================================================================================
//settings_lib.php
function getClubCourtsData($sessionID)
{
$queryString = 'select * FROM t_clubdetails WHERE SeasonID = '.$sessionID;
$query = $this->CI->query_model->executeQuery($queryString);
$this->clubCourtsData = $query->result_array();
}
function getRoundDates($sessionID)
{
$queryString = 'select RoundID, RoundName, UNIX_TIMESTAMP(DATE(RoundStartDate)) AS startDate, UNIX_TIMESTAMP(DATE(RoundEndDate)) AS endDate FROM t_dkrounds WHERE SeasonID = '.$sessionID;
$query = $this->CI->query_model->executeQuery($queryString);
$this->roundDates = $query->result_array();
}