require_once"./dbconfig.php";
require_once"./config.php";
require_once"../../db/util/nslib.php";
require "DB.php";
$db =& DB::connect($dsn);
if (DB::isError($db)) {
$db->getMessage();
$db->getDebugInfo();
die("connect error");
}
//区分
$kubun_cond = null;
$kubun_array = null;
if ($_REQUEST['kbn'] == "" || $_REQUEST['kbn'] == null) {
$kbn = "cap";
} else if ($_REQUEST['kbn'] == "cap") {
$kbn = "cap";
} else if ($_REQUEST['kbn'] == "e") {
$kbn = "e";
} else if ($_REQUEST['kbn'] == "p") {
$kbn = "p";
} else if ($_REQUEST['kbn'] == "s") {
$kbn = "s";
} else if ($_REQUEST['kbn'] == "cm") {
$kbn = "cm";
} else {
$kbn = "cap";
}
$o_smarty->assign("kbn",$kbn);
$kubun_cond = array(
"cap"=>"(kubun = 'Coronary' or kubun = 'Peripheral')",
"e"=>"(kubun = 'Electrophysiology')",
"p"=>"(kubun = 'Peripheral')",
"s"=>"(kubun = 'Surgical')",
"cm"=>"(kubun = 'Co-medical')",
);
//タイトル横に表示する用
$kubun_p = array(
"cap"=>"Coronary and Peripheral",
"e"=>"Electrophysiology",
"p"=>"Peripheral",
"s"=>"Surgical",
"cm"=>"Co-medical",
);
$o_smarty->assign("kubun_p",$kubun_p);
//セッション名を日本語か英語か判定
if ($kbn == "s" || $kbn == "cm") {
$session_mei__name = 'session_mei_j';
} else {
$session_mei__name = 'session_mei';
}
//日付一覧を取得
$sql = "SELECT distinct(s_day_p) from program where {$kubun_cond[$kbn]} order by s_day_p";
//echo $sql;
//exit;
//$stt = $db->prepare($sql);
$result = $db->getAll($sql,array(),DB_FETCHMODE_ASSOC);
if (DB::isError($result)) {
echo $result->getMessage() . "
";
echo $result->getDebugInfo();
die("
ERROR
");
}
$program_days_data = $result;
//var_dump($program_days_data);
$o_smarty->assign("program_days_data",$program_days_data);
//日付一覧よりホール一覧を取得
foreach($program_days_data as $key=>$val) {
if ($val['s_day_p'] != null) {
$sql = "SELECT distinct(room_e) from program where {$kubun_cond[$kbn]} and s_day_p = ? and room_e is not null";
//$stt = $db->prepare($sql);
$result = $db->getAll($sql,array($val['s_day_p']),DB_FETCHMODE_ASSOC);
if (DB::isError($result)) {
echo $result->getMessage() . "
";
echo $result->getDebugInfo();
die("
ERROR
");
}
$program_halls_data[$val['s_day_p']] = $result;
}
}
//var_dump($program_halls_data);
$o_smarty->assign("program_halls_data",$program_halls_data);
//ホール一覧よりROOMを取得
foreach($program_halls_data as $day_key=>$day_val) {
foreach($day_val as $hall_key=>$hall_val) {
if ($hall_val['room_e'] != null) {
//echo "date:{$day_key}:key:{$hall_key},val:{$hall_val['room_e']}
";
//$sql = "SELECT distinct(room_mei) from program where {$kubun_cond[$kbn]} and s_day_p = ? and room_e = ? order by room_mei";
$sql = "SELECT distinct on (room_mei) room_mei, floor_mei from program where {$kubun_cond[$kbn]} and s_day_p = ? and room_e = ? order by room_mei";
//$stt = $db->prepare($sql);
$result = $db->getAll($sql,array($day_key,$hall_val['room_e']),DB_FETCHMODE_ASSOC);
//var_dump($result);
//echo "
";
if (DB::isError($result)) {
echo $result->getMessage() . "
";
echo $result->getDebugInfo();
die("
ERROR
");
}
foreach ($result as $rm_key=>$rm_val) {
if ($rm_val['room_mei'] != null) {
$program_rooms_data[$day_key][$hall_val['room_e']]['room_mei'][] = $rm_val['room_mei'];
$floor_names[$rm_val['room_mei']] = $rm_val['floor_mei'];
$program_rooms_data[$day_key][$hall_val['room_e']]['room_count']++;
//ROOMごとのセッションデータを取得
$sql = "SELECT
s_day_p,
s_time_p,
e_time_p,
s_timestamp,
e_timestamp,
room_mei,
shurui,
{$session_mei__name} as session_mei,
room_e
from program
where interid is not null
and {$kubun_cond[$kbn]}
and room_e is not null
and room_mei is not null
and s_day_p = ?
and room_e = ?
and room_mei = ?
and www is null
group by
s_day_p,
s_time_p,
e_time_p,
s_timestamp,
e_timestamp,
room_mei,
shurui,
{$session_mei__name},
room_e,
floor_mei
order by s_day_p,s_time_p,e_time_p
";
//$stt = $db->prepare($sql);
$session_result = $db->getAll($sql,array($day_key,$hall_val['room_e'],$rm_val['room_mei']),DB_FETCHMODE_ASSOC);
if (DB::isError($session_result)) {
echo $session_result->getMessage() . "
";
echo $session_result->getDebugInfo();
die("
ERROR
");
}
//var_dump($session_result);
$session_data[$day_key][$hall_val['room_e']][$rm_val['room_mei']] = $session_result;
//$session_data[$day_key][$hall_val['room_e']][$rm_val['room_mei']] = $session_result;
}
}
}
}
}
//var_dump($program_rooms_data);
//var_dump($session_data);
//var_dump($floor_names);
//exit;
//exit;
$o_smarty->assign("program_rooms_data",$program_rooms_data);
$o_smarty->assign("floor_names",$floor_names);
$o_smarty->assign("session_data",$session_data);
//var_dump($program_rooms_data);
//exit;
//ROOMごとのセッションデータを取得
/*
foreach($program_halls_data as $day_key=>$day_val) {
foreach($day_val as $hall_key=>$hall_val) {
echo "dayval:{$day_val},hallval:{$hall_val},room_key:{$room_key}:{$room_val}";
foreach($program_rooms_data[$day_val][$hall_val]['room_e'] as $room_key=>$room_val) {
echo "{$room_key}:{$room_val}";
if ($room_val != null) {
echo $room_val;
$sql = "SELECT
s_day_p,
s_time_p,
e_time_p,
room_mei,
shurui,
kubun,
session_mei,
room_e
from program where interid is not null
and s_day_p = ?
and room_e = ?
and room_mei = ?
group by
s_day_p,
s_time_p,
e_time_p,
room_mei,
shurui,
kubun,
session_mei,
room_e
order by s_day_p,s_time_p,e_time_p
";
//$stt = $db->prepare($sql);
$result = $db->getAll($sql,array($room_val),DB_FETCHMODE_ASSOC);
if (DB::isError($result)) {
echo $result->getMessage() . "
";
echo $result->getDebugInfo();
die("
ERROR
");
}
// echo "day:{$hall_key},hall:{$room_key},room:{$room_val}
";
// $session_data[$hall_key][$room_key][$room_val] = $result;
foreach ($result as $rm_key=>$rm_val) {
if ($rm_val['room_mei'] != null) {
$program_rooms_data[$day_key][$hall_val['room_e']]['room_mei'][] = $rm_val['room_mei'];
$program_rooms_data[$day_key][$hall_val['room_e']]['room_count']++;
}
}
}
}
}
}
var_dump($result);
*/
//exit;
//exit;
/*
$sql = "SELECT s_day_p,s_time_p,e_time_p,room_mei,shurui,kubun,session_mei,room_e from program where interid is not null group by s_day_p,s_time_p,e_time_p,room_mei,shurui,kubun,session_mei,room_e order by s_day_p,s_time_p,e_time_p,room_e";
//$stt = $db->prepare($sql);
$result = $db->getAll($sql,array(),DB_FETCHMODE_ASSOC);
if (DB::isError($result)) {
echo $result->getMessage() . "
";
echo $result->getDebugInfo();
die("
ERROR
");
}
$program_data = $result;
*/
/*
foreach($session_data as $skey=>$sval) {
echo <<<_SESSIONDATA_
{$sval['s_day_p']}:{$sval['s_time_p']}:{$sval['e_time_p']}:{$sval['room_e']}:{$sval['shurui']}:{$sval['session_mei']}
_SESSIONDATA_;
}
*/
//$o_smarty->assign("program_data",$program_data);
//当日08:00のUNIXTIMESTAMPを設定
$o_smarty->display("2006/program/program_glance.tpl");
exit;
?>