TIM004.php 11.7 KB
<?php 
//*****************************************************************************
//* 
//* プログラム名:タイムカードCSVダウンロード
//* プログラムID:TIM004.php
//* 機能        :タイムカード CSVダウンロード
//* 作成者      :
//* 
//*****************************************************************************
header("Content-type: text/html; charset=EUC-JP");

include("include/session_start.inc");
include("include/SessionChk.inc");
include('include/smarty.conf');

$strDBinc="include/dbcon.inc";
include($strDBinc);


//社員情報取得
$strSQL="SELECT syain_cd,name_kj_sei,name_kj_mei".
				" FROM syain_tbl Where del_flg=true Order By Disp_rank";
$objData = pg_exec($strSQL);
for($intCnt = 0; $intCnt < pg_numrows($objData) ; $intCnt++) {
		$objRecData = pg_fetch_object($objData, $intCnt);
		$strSyain[$intCnt][0]=$objRecData->syain_cd;
		$strSyain[$intCnt][1]=$objRecData->name_kj_sei.$objRecData->name_kj_mei;
		$strSyain[$intCnt][2]="";
		$strSQL = "SELECT * From syozoku_tbl Where syain_cd='".$strSyain[$intCnt][0]."' ";
		$objBumon = pg_exec($strSQL);
		for($i = 0; $i < pg_numrows($objBumon) ; $i++) {
				$objRecBumon = pg_fetch_object($objBumon, $i);
				$strSyain[$intCnt][2].=$objRecBumon->syozoku_cd."/";
		}
}

//全部門
$strSQL = "SELECT syozoku_cd,bumon_name,disp_rank From mst_bumon Where del_flg=0 Order By disp_rank";
$objBumon = pg_exec($strSQL);
for($intCnt = 0; $intCnt < pg_numrows($objBumon) ; $intCnt++) {
		$objRecBumon = pg_fetch_object($objBumon, $intCnt);
		$strBumon[$intCnt][0]=$objRecBumon->syozoku_cd;
		$strBumon[$intCnt][1]=$objRecBumon->bumon_name;
}


$calYMD1 = date("Y")."/".date("m")."/".date("d");
$calYMD2 = date("Y")."/".date("m")."/".date("d");


?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=EUC-JP">
<META http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" type="text/css" href="basefont.css">
<TITLE>E-グルPro</TITLE>
<!--カレンダーScriptの設定-->
<script type="text/javascript" src="./lib/jkl-calendar.js" charset="Shift_JIS"></script>
<script type="text/javascript" src="./lib/jslb_ajax.js"></script>
<script type="text/javascript" src="xmlhttp.js"></script>

<SCRIPT LANGUAGE="JAVASCRIPT">
<!--

function cal_load(){
	Select_visibility(1);
	if(document.getElementById("calid") != null){
		document.getElementById("calid").style.display="none";
		document.getElementById("calid").innerHTML="";
	}
	if(document.getElementById("calid2") != null){
		document.getElementById("calid2").style.display="none";
		document.getElementById("calid2").innerHTML="";
	}
}

function Select_visibility(flg){
	var MaxCount = document.e_gru.getElementsByTagName("select").length;
	for(i=0;i<MaxCount;i++){
		if(flg==0){
			document.e_gru.getElementsByTagName("select")[i].style.visibility = "hidden";
		}else{
			document.e_gru.getElementsByTagName("select")[i].style.visibility = "";
		}
	}
}

//--------------------------
//  オールチェック
//--------------------------
function All_chk(intSts){
		if (document.e_gru.syain_chk.length){
				if (intSts==1){
						for(i = 0 ; i <= document.e_gru.syain_chk.length-1; i++ ){
							document.e_gru.syain_chk[i].checked=false;
						}
				}else{
						for(i = 0 ; i <= document.e_gru.syain_chk.length-1; i++ ){
							document.e_gru.syain_chk[i].checked=true;
						}
				}
		}else{
				if (intSts==1){
						document.e_gru.syain_chk.checked=false;
				}else{
						document.e_gru.syain_chk.checked=true;
				}
		}
}

//--------------------------
//  部門チェック
//--------------------------
function All_chk2(){
	All_chk(1);
	if (document.e_gru.syain_chk.length){
			for(i = 0 ; i <= document.e_gru.syain_chk.length-1; i++ ){
					arr = (document.e_gru.syain_hid[i].value).split("/");
					for(j=0;j<arr.length;j++){
							if (document.e_gru.bumon.value==arr[j]){
									document.e_gru.syain_chk[i].checked=true;
									break;
							}
					}
			}
	}else{
			arr = (document.e_gru.syain_hid.value).split("/");
			for(j=0;j<arr.length;j++){
					if (document.e_gru.bumon.value==arr[j]){
							document.e_gru.syain_chk.checked=true;
							break;
					}
			}
	}
}

//--------------------------
//  CSVダウンロード
//--------------------------
function CSVDownLoad(){

		//開始年月日入力チェック
		if(document.e_gru.st_year.value=="" && document.e_gru.st_mon.value != ""){
				alert("開始年を選択してください");
				return false;
		}
		if(document.e_gru.st_year.value=="" && document.e_gru.st_mon.value==""&& document.e_gru.st_day.value != ""){
				alert("開始年、開始月を選択してください");
				return false;
		}
		if(document.e_gru.st_year.value!="" && document.e_gru.st_mon.value==""&& document.e_gru.st_day.value != ""){
				alert("開始月を選択してください");
				return false;
		}
		//終了年月日入力チェック
		if(document.e_gru.ed_year.value=="" && document.e_gru.ed_mon.value != ""){
				alert("終了年を選択してください");
				return false;
		}
		if(document.e_gru.ed_year.value=="" && document.e_gru.ed_mon.value==""&& document.e_gru.ed_day.value != ""){
				alert("終了年、終了月を選択してください");
				return false;
		}
		if(document.e_gru.ed_year.value!="" && document.e_gru.ed_mon.value==""&& document.e_gru.ed_day.value != ""){
				alert("終了月を選択してください");
				return false;
		}

		prm  = "";
		prm_list="";
		if (document.e_gru.syain_chk.length){
				for(i = 0 ; i <= document.e_gru.syain_chk.length-1; i++ ){
						if (document.e_gru.syain_chk[i].checked==true){
								prm_list+=document.e_gru.syain_chk[i].value+",";
						}
				}
		}else{
				prm_list+=document.e_gru.syain_chk.value+",";
		}
		if (prm_list==""){
				alert("社員を最低一人を選択してください。");
				return false;
		}
		prm  = "lst_data="+prm_list;
		prm += "&st_year="+document.e_gru.st_year.value;
		prm += "&st_mon="+document.e_gru.st_mon.value;
		prm += "&st_day="+document.e_gru.st_day.value;
		prm += "&ed_year="+document.e_gru.ed_year.value;
		prm += "&ed_mon="+document.e_gru.ed_mon.value;
		prm += "&ed_day="+document.e_gru.ed_day.value;

		document.e_gru.action = "TIM902.php?"+prm;
		location.href = document.e_gru.action;
}

//カレンダー表示
function cal_get(strDate, divid){
	arrYMD = strDate.split("/");
	if(divid == "calid"){
		document.getElementById("calid").style.display="";
		objY = document.e_gru.st_year;
		objM = document.e_gru.st_mon;
		objD = document.e_gru.st_day;
	}else if(divid == "calid2"){
		document.getElementById("calid2").style.display="";
		objY = document.e_gru.ed_year;
		objM = document.e_gru.ed_mon;
		objD = document.e_gru.ed_day;
	}

	//年
	for(i=0;i<objY.options.length;i++){
		if(objY.options[i].value == eval(arrYMD[0])){
			objY.selectedIndex = i;
			break;
		}
	}
	//月
	for(i=0;i<objM.options.length;i++){
		if(objM.options[i].value == arrYMD[1]){
			objM.selectedIndex = i;
			break;
		}
	}
	//日
	for(i=0;i<objD.options.length;i++){
		if(objD.options[i].value == arrYMD[2]){
			objD.selectedIndex = i;
			break;
		}
	}

	cal  = new JKL.Calendar("calid","e_gru","colname1");
	cal2 = new JKL.Calendar("calid2","e_gru","colname2");
}

document.onclick=function(){
	Select_visibility(1);
	if(document.getElementById("calid") != null){
		document.getElementById("calid").style.display="none";
		document.getElementById("calid").innerHTML="";
	}
	if(document.getElementById("calid2") != null){
		document.getElementById("calid2").style.display="none";
		document.getElementById("calid2").innerHTML="";
	}
}


var cal  = new JKL.Calendar("calid","e_gru","colname1");
var cal2 = new JKL.Calendar("calid2","e_gru","colname2");

-->
</script>

</HEAD>
<BODY onLoad="cal_load();">
<form name="e_gru">
<?php 
$intLoop=date("Y")-2004+3;
?>
<br>
<TABLE width="580">
	<TR> 
		<TD>
			<TABLE cellspacing="1" cellpadding="1" width="100%" align="center" class="mainColor" border="0"> 
				<TR> 
					<TD width=95 height=25 class="toneDown"><span class=Normalfont>出力期間</span></TD> 
					<TD height=25 bgcolor="#ffffff">
						開始日
						<SELECT name=st_year> 
							<option value="" selected>----</option>;
							<?php 
									for ($i = 0 ; $i <= $intLoop ; $i++) {
											$intSetValue=2004+$i;
											echo '<option value='.$intSetValue.'>'.$intSetValue.'</option>';
									}
							?>
						</SELECT>
						<SELECT name=st_mon> 
							<option value="" selected>---</option>;
							<?php 
									for ($i = 1 ; $i <= 12 ; $i++) {
											echo '<option value="'.sprintf('%02d',$i).'">'.$i.'</option>';
									}
							?>
						</SELECT>
						<SELECT name=st_day> 
							<option value="" selected>---</option>;
							<?php 
									for ($i = 1 ; $i <= 31 ; $i++) {
											echo '<option value="'.sprintf('%02d',$i).'">'.$i.'</option>';
									}
							?>
						</SELECT>
						<!--カレンダー表示-->
						<a href="javascript:cal.write();">
							<img id="dateLink1" src="./image/calendar.gif" alt="日付選択" border="0" style="vertical-align:middle;margin:5px"/>
						</a>
						<input type="hidden" name="colname1" value="<?php echo $calYMD2 ;?>">
						<div id="calid" ></div>
						<br>終了日
						<SELECT name=ed_year> 
							<option value="">----</option>;
							<?php 
									for ($i = 0 ; $i <= $intLoop ; $i++) {
											$intSetValue=2004+$i;
											echo '<option value="'.$intSetValue.'" ';
											if (date("Y") == $intSetValue) {
													echo 'selected';
											}
											echo '>'.$intSetValue.'</option>';
									}
							?>
						</SELECT>
						<SELECT name=ed_mon> 
							<option value="">---</option>;
							<?php 
									for ($i = 1 ; $i <= 12 ; $i++) {
											echo '<option value="'.sprintf('%02d',$i).'" ';
											if (date("n") == $i) {
													echo 'selected';
											}
											echo '>'.$i.'</option>';
									}
							?>
						</SELECT>
						<SELECT name=ed_day> 
							<option value="" selected>---</option>;
							<?php 
									for ($i = 1 ; $i <= 31 ; $i++) {
											echo '<option value="'.sprintf('%02d',$i).'" ';
											if (date("d") == $i) {
													echo 'selected';
											}
											echo '>'.$i.'</option>';
									}
							?>
						</SELECT>
						<!--カレンダー表示-->
						<a href="javascript:cal2.write();">
							<img id="dateLink2" src="./image/calendar.gif" alt="日付選択" border="0" style="vertical-align:middle;margin:5px"/>
						</a>
						<input type="hidden" name="colname2" value="<?php echo $calYMD2 ;?>">
						<div id="calid2" ></div>
						<span class=Normalfont> </span><br>
					</TD> 
				</TR> 
				<TR>
					<TD width=95 height=25 class="toneDown"><span class=Normalfont>出力部門</span></TD> 
					<TD height=25 bgcolor="#ffffff">
						<select name="bumon" onchange="All_chk2();">
						<?php 	
								for($intCnt = 0; $intCnt < count($strBumon) ; $intCnt++) {	
									echo '<option value="'.$strBumon[$intCnt][0].'">'.$strBumon[$intCnt][1].'</option>';
								}
						?>
						</select>
					</TD>
				</TR> 
				<TR>
					<TD width=95 height=25 class="toneDown"><span class=Normalfont>出力社員</span></TD> 
					<TD height=25 bgcolor="#ffffff">
						<INPUT type="button" onclick="All_chk(0);" value="全選択">&nbsp;
						<INPUT type="button" onclick="All_chk(1);" value="全解除"><BR>

						<?php 
								for($intCnt = 0; $intCnt < count($strSyain) ; $intCnt++) {
										echo '<input type="checkbox" name="syain_chk" id="'.$strSyain[$intCnt][0].'" value="'.$strSyain[$intCnt][0].'">';
										echo '<label for="'.$strSyain[$intCnt][0].'">';
										echo '<span class="Normalfont">'.$strSyain[$intCnt][1].'</span>';
										echo '</label><BR>';
										echo '<input type="hidden" name="syain_hid" value="'.$strSyain[$intCnt][2].'">';
								}
						?>
					</TD>
				</TR> 
			</TABLE>
		</TD>
	</TR> 
</TABLE>
<input type="button" onClick="CSVDownLoad();" name = "btnCsv" value="ダウンロード"> <input type="button" onClick="javascript:window.close();" name = "btnCsv" value="閉じる">
</form>
</BODY>
</HTML>