DUT004.php 3.97 KB
<?php 
//*****************************************************************************
//* 
//* プログラム名:当番表
//* プログラムID:DUT004.php
//* 機能        :更新.挿入.削除
//* 作成者      :
//* 
//*****************************************************************************
header("Content-type: text/html; charset=EUC-JP");

//***************************
//* インクルードファイル
//***************************
include("./include/session_start.inc");
include("./include/SessionChk.inc");
include('./include/smarty.conf');

//20081007 POST処理へ変更
//include("inc/subRepURI.inc");

//**** DB接続 ****//
include("./include/dbcon.inc");


$strSQL="";
$objRecSet="null";

//20081007 POST処理へ変更
//$contents = mb_convert_encoding(subRepURI($contents), "EUC-JP", "auto");
$contents = mb_convert_encoding($contents, "eucJP-win", "auto");

//予約日
$touban_st_date=$st_year."/".$st_mon."/".$st_day;
$touban_ed_date=$ed_year."/".$ed_mon."/".$ed_day;

//予約時間
if ($st_hour != ""){
	if ($st_minute==""){
		$st_minute="00";
	}
	$touban_st_time=$st_hour.":".$st_minute.":00";
}
if ($ed_hour != ""){
	if ($ed_minute==""){
		$ed_minute="00";
	}
	$touban_ed_time=$ed_hour.":".$ed_minute.":00";
}
$reg_date =date("Y/m/d");
$reg_time=date("H:i:s");

//スケジュールリンクの場合
echo "intlink = ".$intlink."\n";
if ($intlink==1){
		//SeqNo取得
		$strSQL = "Select seq FROM touban_tbl Order By seq desc";
		$objRecSet = pg_exec($strSQL);
		if($objRecSet==false){
				echo("SQL実行に失敗しました(seq取得)");
				exit;
		}
		$intCnt=pg_numrows($objRecSet);
		if ($intCnt == 0){
				$intCnt=$intCnt+1;
		}
		else{
				$objRevData = pg_fetch_object($objRecSet, 0);
				$intCnt=$objRevData->seq+1;
		}

		$strSQL="";
		$objData="null";
		if ($strsel==""){
				$strsel="/".$PHP_SYAIN_CD ."/";
		}else{
				$strsel="/".$PHP_SYAIN_CD .$strsel;
		}
		
		$strSQL = "Insert Into touban_tbl (seq,toban_no,syain_cd,touban_st_date,touban_ed_date,".
							"touban_st_time,touban_ed_time,touban_contents,link_cd)".
							" VALUES ($intCnt,$intTantou,'$strsel','$touban_st_date','$touban_ed_date',".
							"'$touban_st_time','$touban_ed_time','".addslashes($contents)."',1)";

		echo "strSQL = ".$strSQL."\n";
		$objData = pg_exec($strSQL);
		if($objData==false){
			echo("SQL実行に失敗しました(Insert)");
			exit;
		}
		header("Location:TOP000.php");
}

//更新処理
if ($intsyorists==1){
		//データ更新
		if ($intsts != 0){
				$strSQL="";
				$objData="null";
				$strSQL = "Update touban_tbl Set toban_no=$intTouban,syain_cd='/$strsel',".
									"touban_st_date='$touban_st_date',touban_ed_date='$touban_ed_date',".
									"touban_st_time='$touban_st_time',touban_ed_time='$touban_ed_time',".
									"touban_contents='".addslashes($contents)."'".
									"Where seq=$intsts";
				$objData = pg_exec($strSQL);
				if($objData==false){
					echo("SQL実行に失敗しました(Update)");
					exit;
				}
		}else {
				//SeqNo取得
				$strSQL = "Select seq FROM touban_tbl Order By seq desc";
				$objRecSet = pg_exec($strSQL);
				if($objRecSet==false){
					echo("SQL実行に失敗しました(seq取得)");
					exit;
				}
				$intCnt=pg_numrows($objRecSet);
				if ($intCnt == 0){
					$intCnt=$intCnt+1;
				}
				else{
					$objRevData = pg_fetch_object($objRecSet, 0);
					$intCnt=$objRevData->seq+1;
				}
				
				//データ挿入(リンクなし)
				//$intTouban="3";
				$strSQL="";
				$objData="null";
				echo "intTouban = ".$intTouban;
				$strSQL = "Insert Into touban_tbl (seq,toban_no,syain_cd,touban_st_date,touban_ed_date,".
									"touban_st_time,touban_ed_time,touban_contents,link_cd)".
									" VALUES ($intCnt,$intTouban,'/$strsel','$touban_st_date','$touban_ed_date',".
									"'$touban_st_time','$touban_ed_time','".addslashes($contents)."',0)";

				$objData = pg_exec($strSQL);
				if($objData==false){
					echo("SQL実行に失敗しました(Insert)");
					exit;
				}
		}
}else{
		//削除
		$strSQL = "Delete FROM touban_tbl WHERE seq = $intsts";
		$objRec = pg_exec($strSQL);
		if($objRec==false){
				echo("SQL実行に失敗しました(Delete)");
				exit;
		}
}
?>