<?php
/**
 * Module page - list_matchs
 *
 * Display calendar for form page.
 *
 * @package Setup
 * @author  Eric GALLENE <okrome@free.fr>
 * @link	http://www.phpcompet.com
 * @version $Id: modules/list_matchs.php,v 1.00 2006/12/06 18:15:00
 */

$monthperiode = Date("m", time());
$yearperiode = Date("Y", time());



$SELECT1 = 'SELECT '.TBL_MATCHS.'.id, '.TBL_MATCHS.'.date_day, '.TBL_MATCHS.'.id_candidate_dom, C1.shortname AS domclub, C1.imgurl AS domimg, '.TBL_MATCHS.'.id_candidate_ext, C2.shortname AS extclub, C2.imgurl AS extimg, D.day, CO.shortname AS shortname, CO.id AS id_compet
			FROM '.TBL_MATCHS.' 
			LEFT JOIN '.TBL_DAYS.' AS D ON '.TBL_MATCHS.'.id_day = D.id 
			JOIN '.TBL_COMPETITIONS.' AS CO ON D.id_compet = CO.id
			JOIN '.TBL_CLUBS.' AS C1 ON '.TBL_MATCHS.'.id_candidate_dom = C1.id 
			JOIN '.TBL_CLUBS.' AS C2 ON '.TBL_MATCHS.'.id_candidate_ext = C2.id
			WHERE '.TBL_MATCHS.'.date_day  >= NOW() ORDER BY '.TBL_MATCHS.'.date_day ASC LIMIT 10'; 
$res1   = runSQL($SELECT1);


$SELECT1 = "SELECT DISTINCT (DATE_FORMAT(date_day, '%d-%m-%Y')) AS day_date
			FROM ".TBL_MATCHS." 
			WHERE date_day  >= NOW() ORDER BY date_day ASC LIMIT 10"; 
$dateres1   = runSQL($SELECT1);

$SELECT1 = 'SELECT '.TBL_COMPETITIONS.'.id, '.TBL_COMPETITIONS.'.shortname, SCO.shortname AS subshortname 
			FROM '.TBL_COMPETITIONS.'
			LEFT JOIN '.TBL_COMPETITIONS.' AS SCO ON '.TBL_COMPETITIONS.'.subcompet = SCO.id'; 
$competres1   = runSQL($SELECT1);

$SELECT2 = 'SELECT '.TBL_MATCHS.'.id, '.TBL_MATCHS.'.date_day, '.TBL_MATCHS.'.id_candidate_dom, C1.shortname AS domclub, C1.imgurl AS domimg, '.TBL_MATCHS.'.buts_dom, '.TBL_MATCHS.'.id_candidate_ext, C2.shortname AS extclub, C2.imgurl AS extimg, '.TBL_MATCHS.'.buts_ext, D.day, CO.shortname AS shortname, CO.id AS id_compet
			FROM '.TBL_MATCHS.' 
			LEFT JOIN '.TBL_DAYS.' AS D ON '.TBL_MATCHS.'.id_day = D.id 
			JOIN '.TBL_COMPETITIONS.' AS CO ON D.id_compet = CO.id
			JOIN '.TBL_CLUBS.' AS C1 ON '.TBL_MATCHS.'.id_candidate_dom = C1.id 
			JOIN '.TBL_CLUBS.' AS C2 ON '.TBL_MATCHS.'.id_candidate_ext = C2.id
			WHERE '.TBL_MATCHS.'.date_day  <= NOW() AND '.TBL_MATCHS.'.validation > 0 ORDER BY '.TBL_MATCHS.'.date_day DESC LIMIT 10'; 
$res2   = runSQL($SELECT2);


$SELECT2 = "SELECT DISTINCT (DATE_FORMAT(date_day, '%d-%m-%Y')) AS day_date
			FROM ".TBL_MATCHS." 
			WHERE date_day  <= NOW() ORDER BY date_day DESC LIMIT 10"; 
$dateres2   = runSQL($SELECT2);

$SELECT2 = 'SELECT '.TBL_COMPETITIONS.'.id, '.TBL_COMPETITIONS.'.shortname, SCO.shortname AS subshortname 
			FROM '.TBL_COMPETITIONS.'
			LEFT JOIN '.TBL_COMPETITIONS.' AS SCO ON '.TBL_COMPETITIONS.'.subcompet = SCO.id';  
$competres2   = runSQL($SELECT2);



$this->assign('matchs_preview',	$res1);
$this->assign('matchs_result',	$res2);
$this->assign('dates_preview',	$dateres1);
$this->assign('dates_result',	$dateres2);
$this->assign('compet_preview',	$competres1);
$this->assign('compet_result',	$competres2);
$this->display('./modules/list_matchs.tpl');

?>