<?php
/**
 * @package linea21.core
 * @subpackage theme
 * @author linea21 <info@linea21.com>
 * @version $id SVN
 * @access public
 * @license http://opensource.org/licenses/gpl-3.0.html
 */

//////////// Check Inclusion de pages ////////////
if (!class_exists('auth')){
  include_once("../lib/lib_common.php");
  ReloadIndex('admin');
}
////////////

$req_listsdtheme = "SELECT * FROM " . T_SD_THEME . " ORDER BY sdtheme_range, sdtheme_id;";

$req_maxthemeid = "SELECT MAX(theme_id) AS maxid FROM " . T_THEME . ";";

$req_list_theme = "SELECT T.theme_id, T.theme_name, T.theme_statut, SDT.sdtheme_name, SDT.sdtheme_id FROM " . T_THEME . " AS T LEFT OUTER JOIN ". T_SD_THEME ." AS SDT ON SDT.sdtheme_id=T.theme_sd_theme WHERE T.theme_statut  <> 'E' ORDER BY sdtheme_range DESC, sdtheme_name ASC, theme_name ASC;";

$req_quickbox_listadd = "SELECT theme_id, theme_name, DATE_FORMAT(theme_date_crea, '".toStringSqlDate('long')."') AS theme_date_crea_display FROM " . T_THEME . " WHERE theme_statut  <> 'E' ORDER BY theme_date_crea DESC LIMIT 0 , 10;";

$req_quickbox_listsup = "SELECT theme_id, theme_name, DATE_FORMAT(theme_date_crea, '".toStringSqlDate()."') AS theme_date_crea_display, DATE_FORMAT(theme_last_modify, '".toStringSqlDate('long')."') AS theme_last_modify_display FROM " . T_THEME . " WHERE theme_statut  = 'E' ORDER BY theme_last_modify DESC
LIMIT 0 , 10;";

$req_quickbox_listmod = "SELECT theme_id, theme_name, DATE_FORMAT(theme_date_crea, '".toStringSqlDate()."') AS theme_date_crea_display, DATE_FORMAT(theme_last_modify, '".toStringSqlDate('long')."') AS theme_last_modify_display FROM " . T_THEME . " WHERE theme_statut <> 'E' ORDER BY theme_last_modify DESC
LIMIT 0 , 10;";



function SQL_getonetheme($theme_id) {
  $requete ="SELECT T.theme_id, T.theme_name, T.theme_visual_uri, T.theme_desc_project, T.theme_desc_dashboard, T.theme_desc_publication, T.theme_desc_news, T.theme_desc_workshop, T.theme_statut, DATE_FORMAT(T.theme_date_crea, '".toStringSqlDate()."') AS theme_date_crea, DATE_FORMAT(T.theme_last_modify, '".toStringSqlDate('long')."') AS theme_last_modify, SDT.sdtheme_name, SDT.sdtheme_id FROM " . T_THEME . " AS T LEFT OUTER JOIN ". T_SD_THEME ." AS SDT ON SDT.sdtheme_id=T.theme_sd_theme WHERE T.theme_id='".$theme_id."' LIMIT 1;";
  return $requete;
}

function SQL_getoneSDtheme($sdtheme_id) {
  $requete="SELECT sdtheme_id, sdtheme_name FROM " . T_SD_THEME . " WHERE sdtheme_id=".$sdtheme_id.";";
  return $requete;
}

function SQL_getoneCompleteSDtheme($sdtheme_id) {
  $requete="SELECT sdtheme_id AS theme_id, sdtheme_name AS theme_name, sdtheme_description AS theme_description, DATE_FORMAT(sdtheme_date_crea, '".toStringSqlDate()."') AS theme_date_crea_display, DATE_FORMAT(sdtheme_last_modify, '".toStringSqlDate('long')."') AS theme_last_modify_display FROM " . T_SD_THEME . " WHERE sdtheme_id='".$sdtheme_id."' LIMIT 1;";
  return $requete;
}

function SQL_getlist4sup($theme_id) {
  $requete= "SELECT theme_id, theme_name, sdtheme_id, sdtheme_name FROM " . T_THEME . " LEFT OUTER JOIN ".T_SD_THEME." ON sdtheme_id=theme_sd_theme WHERE theme_statut <> 'E' AND theme_id<>'".$theme_id."' ORDER BY sdtheme_name DESC, theme_name ASC;";
  return $requete;
}

function SQL_getSDlist4sup($theme_id) {
  $requete= "SELECT sdtheme_id, sdtheme_name FROM " . T_SD_THEME . " WHERE sdtheme_id <> '".$theme_id."' ORDER BY sdtheme_name DESC;";
  return $requete;
}

?>
