|
|
 |
Home > 강의실예약
|
|
*/
?>
class Layout{
var $LayoutPass; //TPL파일경로
var $contents = array(); //템플릿파일내용
/////////////////////////////////////////////////////////////////////////////////// [Print_view]
function Print_view($filename, $contents="", $view_contents="", $loop_contents="", $loop_num="", $return="") {
$result = $this->File_read($filename, $contents, $view_contents, $loop_contents, $loop_num);
echo $result;
}
/////////////////////////////////////////////////////////////////////////////////// [Return_view]
function Return_view($filename, $contents="", $view_contents="", $loop_contents="", $loop_num="") {
$result = $this->File_read($filename, $contents, $view_contents, $loop_contents, $loop_num);
return $result;
}
/////////////////////////////////////////////////////////////////////////////////// [File_read]
function File_read($filename, $contents, $view_contents, $loop_contents, $loop_num) {
if($filename) {
$this->contents = $contents;
$this->view_contents = $view_contents;
$file = $this->LayoutPass .$filename;
$line = file($file);
while(list($key, $val) = each($line)) {
if(ereg("", $val, $regs)) {
$val = "";
$loop = "y";
} else if(ereg("", $val, $regs)) {
$val = "";
$loop = "";
$result .= $this->Loop_view($loop_var, $loop_contents, $loop_num);
unset($loop_var);
} else if(ereg("", $val, $regs)) $hidden_line = $this->Line_confirm($val);
else if(ereg("", $val, $regs)) $hidden_line = "";
if($loop) $loop_var[$key] = $val;
else if(!$hidden_line) {
$val = ereg_replace("", "", $val);
$val = ereg_replace("", "", $val);
$result .= $this->Split_line($val);
}
}
} else {
while(list($key, $val ) = each($contents)) {
$result .= $contents[$key];
}
}
return $result;
}
/////////////////////////////////////////////////////////////////////////////////// [Loop_view]
function Loop_view($loop_var, $loop_contents, $loop_num) {
for($i=0; $i<$loop_num; $i++) {
$this->Loop_define($loop_contents, $i);
$result .= $this->Loop_contents($loop_var);
}
return $result;
}
/////////////////////////////////////////////////////////////////////////////////// [Loop_define]
function Loop_define($loop_contents, $i) {
while(list($key, $val) = each($loop_contents)) {
$this->contents[$key] = $val[$i];
}
}
/////////////////////////////////////////////////////////////////////////////////// [Loop_contents]
function Loop_contents($loop_var) {
while(list($key, $val) = each($loop_var)) {
if(ereg("", $val, $regs)) $hidden_line = $this->Line_confirm($val);
else if(ereg("", $val, $regs)) $hidden_line = "";
if(!$hidden_line) {
$val = ereg_replace("", "", $val);
$val = ereg_replace("", "", $val);
$result .= $this->Split_line($val);
}
}
return $result;
}
/////////////////////////////////////////////////////////////////////////////////// [Line_confirm]
function Line_confirm($what) {
$what = trim($what);
for($i=0; $iview_contents); $i++) {
$val = "";
if($what == $val) $view = "y";
}
$hidden = (!$view) ? "y": "";
return $hidden;
}
/////////////////////////////////////////////////////////////////////////////////// [Split_line]
function Split_line($line) {
$split_val = split("({[A-Z0-9_]+})", $line);
for($i=0; $iPrint_define($regs[1]);
$line = ereg_replace($regs[1],"$print",$line);
}
}
return $line;
}
/////////////////////////////////////////////////////////////////////////////////// [Print_define]
function Print_define($what) {
$what_val = str_replace("{", "", $what);
$what_val = str_replace("}", "", $what_val);
$print = $this->contents[$what_val];
return $print;
}
}
?>
require_once $RootPath."Class/Common_class.php"; //공용클래스호출
class UserClass extends CommonClass {
function UserClass($db=array(),$tplPath) { //생성자메서드
$this->CommonClass($db,$tplPath);
}
function User_menuList(){
$this->Tpl = "_Reserve_menu";
$this->getPrintScreen();
}
function User_reserveList($Vars){ //강의실별 예약/결과
$Value = $this->Class_room($Vars['class']);
$this->Argv['CLASS_ROOM'] = $this->Class_table($Value,4,"./reserve.php?Nav=reserveList");
if(!empty($Vars['class'])) $this->Class_calender($Vars['class']);
$this->Tpl = "_Admin_calender";
$this->getPrintScreen("YMD");
}
function User_reserveInsert($Vars){ //강의실별 예약등록
$this->dirfile = new dirfile();
$this->Argv['METHOD'] = "0";
$this->Argv['RDATE'] = $Vars['day'];
$this->Argv['RTIME'] = $Vars['time'];
$this->Argv['RROOM'] = $Vars['class'];
$timming = $Vars['time'] - 8;
$this->Argv['DAY_TIME'] = $Vars['day']." ".$this->timeName[$timming];
$this->DBConnection();
$Value = $this->Class_room($Vars['class']);
for($i=0; $i < count($Value['title']); $i++) $pattern[$i] = $Value['class'][$i];
$this->Argv['S_ROOM'] = $this->dirfile->print_select($Vars['class'],$pattern,"","","");
unset($pattern);
$m = $this->Class_emptytime($Vars['time'],$Vars['day'],$Vars['class'],"");
for($i=1; $i <= $m; $i++) $pattern[$i] = $this->timeName[($timming-1)+$i];
$this->Argv['TIME'] = $this->dirfile->print_select("",$pattern,"","",1);
unset($pattern);
for($i=1; $i < 26; $i++){
$pattern[$i] = $i."주간";
}
$this->Argv['WEEK'] = $this->dirfile->print_select("",$pattern,"","",1);
$this->Ment = array("USER_INPUT","CLASS_INSERT","USER_INSERT");
$this->Tpl = "_Reserve_room";
$this->getPrintScreen();
}
function User_reserveEdit($Vars){ //예약정보 수정
if(!$this->password_Chk($Vars['cno'],$Vars['checkpass'])){
$this->js->set_Msg('패스워드 인증실패');
exit($this->js->err_Back());
}
$this->dirfile = new dirfile();
if(!empty($Vars['move'])) $this->Argv['MOVE'] = $Vars['move'];
$this->DBConnection();
$SQL = "SELECT * from reserve where r_num = ".$Vars['cno'];
$this->mysql->query($SQL,'SQL');
$lt = mysql_fetch_object($this->mysql->get_Result('SQL'));
$this->Argv['CNO'] = $Vars['cno'];
switch($lt->r_method){
case "D" : $this->Argv['METHOD'] = "0"; $this->Argv['METHOD1'] = "A"; break;
case "W" : $this->Argv['METHOD'] = "1"; $this->Argv['METHOD1'] = "B"; break;
}
$this->Argv['FORNUM'] = 2;
$this->Argv['APPLICANT'] = $lt->r_applicant;
$this->Argv['CONTACT'] = $lt->r_tel;
$this->Argv['EMAIL'] = $lt->r_email;
$this->Argv['NUMBER'] = $lt->r_number;
$this->Argv['POSITION'] = $lt->r_position;
$timming = $lt->r_apptime - 8;
$this->Argv['DAY_TIME'] = $lt->r_appdate." ".$this->timeName[$timming];
$m = $this->Class_emptytime($lt->r_apptime,$lt->r_appdate,$lt->r_class,$lt->r_num);
for($i=1; $i <= $m; $i++) $pattern[$i] = $this->timeName[($timming-1)+$i];
$this->Argv['TIME'] = $this->dirfile->print_select($lt->r_timefor,$pattern,"","",1);
unset($pattern);
for($i=1; $i < 26; $i++){
$pattern[$i] = $i."주간";
}
$this->Argv['WEEK'] = $this->dirfile->print_select($lt->r_weekfor,$pattern,"","",1);
unset($pattern);
$this->Argv['INTENTION'] = ereg_replace(" ","\n",$lt->r_memo);
$this->Argv['RROOM'] = $lt->r_class;
$this->Argv['OLDCHECKPASS'] = $Vars['checkpass'];
$this->Ment = array("USER_INPUT","CLASS_EDIT","USER_EDIT");
$this->Tpl = "_Reserve_room";
$this->getPrintScreen();
}
function User_reserveInsertok($Vars){ //예약등록처리
$this->DBConnection();
$this->string = new string();
if(strcmp($Vars['rmethod'],"A")) $this->Class_weekChk($Vars); //주간예약체크(2010.03.21)
$number = (strcmp($Vars['rmethod'],"C")) ? $Vars['number'] : 0;
$SQL = "INSERT INTO reserve VALUES('',password('".$Vars['passwd']."'),'".$Vars['rRoom']."','".$Vars['rmethod']."','".$Vars['applicant']."','".$Vars['contact']."','".$Vars['email']."',".$number.",'".$Vars['position']."','".$Vars['rDate']."',".$Vars['rTime'].",".$Vars['time'].",".$Vars['week'].",'".$this->string->board_TypeText($Vars['intention'])."','Y',NOW())";
$this->mysql->query($SQL,'SQL',"insert");
$SQL = "SELECT r_num from reserve order by r_num desc limit 1";
$this->mysql->query($SQL,'SQL');
$lt = mysql_fetch_object($this->mysql->get_Result('SQL'));
$count = ($Vars['week'] > 0) ? $Vars['week'] : 1;
$this->CalenderInsert($Vars['time'],$Vars['rTime'],$Vars['rmethod'],$count,$Vars['rDate'],$lt->r_num,$Vars['rRoom'],"S","ADD");
$this->DBDisconnection();
$this->js->location("parent","./reserve.php?Nav=reserveList&class=".$Vars['rRoom']);
}
function User_reserveEditok($Vars){ //예약정보 수정처리
if(!$this->password_Chk($Vars['cno'],$Vars['oldcheckpass'])){
$this->js->set_Msg('패스워드 인증실패');
exit($this->js->err_Back());
}
$this->DBConnection();
$this->string = new string();
$SQL = "SELECT * from reserve where r_num=".$Vars['cno'];
$this->mysql->query($SQL,'SQL');
$lt = mysql_fetch_object($this->mysql->get_Result('SQL'));
$admission = "S";
if(strcmp($lt->r_state,$admission)) $chkadmission = "Y";
if($lt->r_weekfor <> $Vars['week'] && $lt->r_timefor <> $Vars['time']){
$this->CalenderInsert($Vars['time'],$lt->r_apptime,$lt->r_method,$Vars['week'],$lt->r_appdate,$Vars['cno'],$lt->r_class,$admission,"READD");
$chkadmission = "N";
}else if($lt->r_weekfor <> $Vars['week']){
$this->CalenderInsert($Vars['time'],$lt->r_apptime,$lt->r_method,$Vars['week'],$lt->r_appdate,$Vars['cno'],$lt->r_class,$admission,"READD");
$chkadmission = "N";
}else if($lt->r_timefor <> $Vars['time']){
$this->CalenderInsert($Vars['time'],$lt->r_apptime,$lt->r_method,1,$lt->r_appdate,$Vars['cno'],$lt->r_class,$admission,"EDIT");
$chkadmission = "N";
}
if(!strcmp($chkadmission,"Y")){
$this->CalenderInsert($Vars['time'],$lt->r_apptime,$lt->r_method,1,$lt->r_appdate,$Vars['cno'],$lt->r_class,$admission,"EDIT");
}
$number = (strcmp($lt->r_method,"C")) ? $Vars['number'] : 0;
$sqlquery = "r_password=password('".$Vars['passwd']."'),r_applicant='".$Vars['applicant']."',r_tel='".$Vars['contact']."',r_email='".$Vars['email']."',r_number=".$number.",r_position='".$Vars['position']."',r_timefor=".$Vars['time'].",r_weekfor=".$Vars['week'].",r_memo='".$this->string->board_TypeText($Vars['intention'])."',r_state='".$admission."'";
$SQL = "UPDATE reserve SET ".$sqlquery." where r_num=".$Vars['cno'];
$this->mysql->query($SQL,'SQL',"update");
$this->DBDisconnection();
$this->Tpl = "_Admin_close";
$this->Argv['CLOSE_ROOM'] = $lt->r_class;
$this->getPrintScreen();
}
function User_reserveDelok($Vars){ //예약정보 삭제처리
if(!$this->password_Chk($Vars['cno'],$Vars['checkpass'])){
$this->js->set_Msg('패스워드 인증실패');
exit($this->js->err_Back());
}
$this->DBConnection();
//예약정보삭제
$SQL = "DELETE from reserve where r_num=".$Vars['cno'];
$this->mysql->query($SQL,'SQL','delete');
//예약카렌더삭제
$SQL = "DELETE from reserve_calender where rc_reservenum=".$Vars['cno'];
$this->mysql->query($SQL,'SQL','delete');
$this->DBDisconnection();
$this->Tpl = "_Admin_close";
$this->Argv['CLOSE_ROOM'] = $Vars['room'];
$this->getPrintScreen();
}
function User_reserveInfo($Vars){ //예약정보
$this->DBConnection();
$SQL = 'SELECT * from reserve where r_num="'.$Vars['cno'].'" ';
$this->mysql->query($SQL,'SQL');
$lt = mysql_fetch_object($this->mysql->get_Result('SQL'));
$using = (!strcmp($lt->r_method,"D")) ? "일회" : "정기";
$state = (!strcmp($lt->r_state,"Y")) ? "승인" : "대기";
$this->Argv = array("ROOMNUM"=>$lt->r_class, "DAY"=>$Vars['day'], "TIME"=>$Vars['time'],
"APPLICANT"=>$lt->r_applicant, "TEL"=>$lt->r_tel, "EMAIL"=>$lt->r_email,
"NUMBER"=>$lt->r_number, "POSITION"=>$lt->r_position, "MEMO"=>$lt->r_memo,
"STATE"=>$state, "USING"=>$using,"RESERVENO"=>$Vars['cno']
);
if(!strcmp($lt->r_state,"S")) $this->Ment = array("EDIT_BUTTON");
$this->Tpl = "_Reserve_info";
$this->getPrintScreen();
}
function User_reservePass($Vars){
if(!strcmp($Vars['mod'],"edit")) $this->Argv['RESERVE_MOVE'] = "reserveEdit";
else if(!strcmp($Vars['mod'],"del")){
$this->Argv['RESERVE_MOVE'] = "reserveDelok";
$this->Argv['RESERVE_ROOM'] = $Vars['room'];
$this->Ment = array("DELETE_INPUT");
}
$this->Argv['RESERVE_NO'] = $Vars['cno'];
$this->Tpl = "passwd";
$this->getPrintScreen();
}
function password_Chk($cno, $pass){
if(!$cno || !$pass){
$this->js->set_Msg('패스워드 인증실패');
exit($this->js->err_Back());
}
$this->DBConnection();
$SQL = "SELECT count(*) as cnt from reserve where r_num=".$cno." and r_password=password('".$pass."')";
$this->mysql->query($SQL,'SQL');
$row = mysql_fetch_object($this->mysql->get_Result('SQL'));
if($row->cnt > 0) return true;
else return false;
}
}
?>
| |