<?
/*
Copyright (C)2004-2007 Matthieu Perez - hide@address.com
This file is part of PhPress.
PhPress is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
PhPress is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with PhPress. If not, see <http://www.gnu.org/licenses/>.
*/
// cd.php
// lists the archive cds
require 'program/common/constantes.php' ;
require LANG_PATH . $lang ."/msg.php";
require PROG_COM_PATH .'functions_mysql.php';
require PROG_COM_PATH . 'functions_common.php';
require 'program/html/default.css';
require PROG_VIEW_PATH . "view_functions.php";
print '<title>'.TXT_FIND_A_CD.'</title>';
// headers : title and date
print "<h3>".TXT_FIND_A_CD ."</h3><hr>";
// the data are taken from the cookies and postdata.
// processing depends of the display mode :
if($view_current_display_mode=='THUMB' OR $view_current_display_mode=="ANALYSIS")
{
// a piece of header taken from the thumbnail program :
view_main_header($view_datas_id_title, $view_datas_jday, $cd_year, $cd_month, $view_current_display_mode, $lang, $db, "noicon");
$g_date=cal_from_jd($view_datas_jday, CAL_GREGORIAN);
$cd_year=$g_date[year];
// lists the cds :
$request="SELECT CdNum FROM Cds WHERE CDGroup='$view_datas_id_title' AND '$view_datas_jday' BETWEEN DateBegin AND DateEnd ORDER BY CdNum";
$query_result=sql_request($db, $request) ;
while($result=mysql_fetch_array($query_result))
{
$cdnum=$result[0];
print "<tr><td>$view_datas_id_title-<date>$cd_year</date>-<blue>$cdnum</blue> </tr></td>";
}
}
if($view_current_display_mode=='D')
{
// a piece of header taken from the thumbnail program :
view_main_header($view_datas_id_title, $view_datas_jday, $cd_year, $cd_month, $view_current_display_mode, $lang, $db, "noicon");
//retrieve interval : first day of month/last day of month
$next_month=($view_current_month+1);
$last_month_year=$view_current_year;
if($next_month==13)
{
$next_month=1;
$last_month_year=($view_current_year+1);
}
$view_begin_jday=cal_to_jd(CAL_GREGORIAN, $view_current_month, 1, $view_current_year);
$next_month_jdate=cal_to_jd(CAL_GREGORIAN, $next_month, 1, $last_month_year);
$view_end_jday=($next_month_jdate-1);
$interval_begin=$view_begin_jday;
$interval_end = $view_end_jday;
$g_date=cal_from_jd($view_datas_jday, CAL_GREGORIAN);
$cd_year=$g_date[year];
// lists the cds :
$request="SELECT CdNum FROM Pages WHERE CDGroup='$view_datas_id_title' AND JDay BETWEEN '$interval_begin' AND '$interval_end' GROUP BY CdNum";
$query_result=sql_request($db, $request) ;
while($result=mysql_fetch_array($query_result))
{
$cdnum=$result[0];
print "<tr><td>$view_datas_id_title-<date>$cd_year</date>-<blue>$cdnum</blue> </tr></td>";
}
}
if($view_current_display_mode=='M')
{
// a piece of header taken from the thumbnail program :
view_main_header($view_datas_id_title, $view_datas_jday, $cd_year, $cd_month, $view_current_display_mode, $lang, $db, "noicon");
// no need to use the jday for this mode, since we only use the year to get information
// lists the cds :
$second_request="SELECT CdNum FROM Cds WHERE CDGroup='$view_datas_id_title' AND Year='$cd_year' ORDER BY CdNum";
$second_query_result=sql_request($db, $second_request) ;
while($second_result=mysql_fetch_array($second_query_result))
{
$cdnum=$second_result[0];
print "<tr><td>$view_datas_id_title-<date>$cd_year</date>-<blue>$cdnum</blue> </tr></td>";
}
}
if($view_current_display_mode=='Y')
{
// in this mode we will list all the cds made for the current title.
// as we will proobably have hundreds of cdrom for each title, we don't display the
//list, but only count them.
$cd_year='';
// a piece of header taken from the thumbnail program :
view_main_header($view_datas_id_title, $view_datas_jday, $cd_year, $cd_month, $view_current_display_mode, $lang, $db, "noicon");
$first_request="SELECT Year FROM Cds WHERE CDGroup='$view_datas_id_title' GROUP BY Year";
$first_query_result=sql_request($db, $first_request) ;
while($first_result=mysql_fetch_array($first_query_result))
{
$year=$first_result[0];
print "<tr><td><date>$year</date> : $view_datas_id_title-<date>$year</date>-[";
// lists the cds :
$second_request="SELECT CdNum FROM Cds WHERE CDGroup='$view_datas_id_title' AND Year='$year' ORDER BY CdNum";
$second_query_result=sql_request($db, $second_request) ;
$second_result=mysql_fetch_array($second_query_result);
$cdnum=$second_result[0];
print " <blue>$cdnum</blue>";
while($second_result=mysql_fetch_array($second_query_result))
{
$cdnum=$second_result[0];
print ", <blue>$cdnum</blue>";
}
print " ]</td></tr>";
}
}
?>