|
|
|
พี่คับ.อยากทราบว่าต้องทำงัยคือตอนนี้ผมเขียน code ปฎิทินขึ้นมา แต่มันยังขาดเดือนอื้น และปุ่มเลื่อนเดือน อ่าคับ ตอนนี้มันขึ้นเฉพาะเดือนมกราคม คือต้องการให้กดเลื่อนเดือนได้คับ |
|
|
|
|
|
|
|
Code (PHP)
<?
function ChkDay($myDay){
$x = 0;
if ($myDay == "Sunday"){
$x = 1;
}else if ($myDay == "Monday"){
$x = 2;
}else if ($myDay == "Tuesday"){
$x = 3;
}else if ($myDay == "Wednesday"){
$x = 4;
}else if ($myDay == "Thursday"){
$x = 5;
}else if ($myDay == "Friday"){
$x = 6;
}else if ($myDay == "Saturday"){
$x = 7;
}
return $x;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ปฏิทินการลางาน</title>
<script type="text/javascript" charset="utf-8">
function Chk1(x){
if (document.form1.Vac_vacationname1[x - 1].checked == true){
document.form1.Vac_vacationname2[x - 1].disabled = true;
document.form1.Vac_vacationname3[x - 1].disabled = true;
}else{
document.form1.Vac_vacationname2[x - 1].disabled = false;
document.form1.Vac_vacationname3[x - 1].disabled = false;
}
}
function Chk2(x){
if (document.form1.Vac_vacationname2[x - 1].checked == true){
document.form1.Vac_vacationname1[x - 1].disabled = true;
document.form1.Vac_vacationname3[x - 1].disabled = true;
}else{
document.form1.Vac_vacationname1[x - 1].disabled = false;
document.form1.Vac_vacationname3[x - 1].disabled = false;
}
}
function Chk3(x){
if (document.form1.Vac_vacationname3[x - 1].checked == true){
document.form1.Vac_vacationname2[x - 1].disabled = true;
document.form1.Vac_vacationname1[x - 1].disabled = true;
}else{
document.form1.Vac_vacationname2[x - 1].disabled = false;
document.form1.Vac_vacationname1[x - 1].disabled = false;
}
}
function mySave1(x,month1,yaer1){
var myID = document.getElementById("For_FormID").value;
var myIDPer = document.getElementById("IDPersonnel").value;
var myIDLae = document.getElementById("Lae_LaeveID").value;
var myIDdate = document.getElementById("For_RecordTime").value;
for (i=0;i<=x - 1;i++){
if (document.form1.Vac_vacationname1[i].checked){
window.location="savecalendar.php?For_FormID=" + myID + "&IDPersonnel=" + myIDPer + "&Lae_LaeveID=" + myIDLae + "&For_RecordTime=" + myIDdate + "&Vac_date=" + (i+1) + "&Vac_month=" + month1 + "&Vac_yaer=" + yaer1 + "&Vac_vacationname=1 ";
//alert("savecalendar.php?For_FormID=" + myID + "&IDPersonnel=" + myIDPer + "&Lae_LaeveID=" + myIDLae + "&Vac_date=" + (i+1) + "&Vac_month=" + month1 + "&Vac_yaer=" + yaer1 + "&Vac_vacationname=1 ");
}
if (document.form1.Vac_vacationname2[i].checked){
window.location="savecalendar.php?For_FormID=" + myID + "&IDPersonnel=" + myIDPer + "&Lae_LaeveID=" + myIDLae + "&For_RecordTime=" + myIDdate + "&Vac_date=" + (i+1) + "&Vac_month=" + month1 + "&Vac_yaer=" + yaer1 + "&Vac_vacationname=2 ";
//alert("savecalendar.php?For_FormID=" + myID + "&IDPersonnel=" + myIDPer + "&Lae_LaeveID=" + myIDLae + "&Vac_date=" + (i+1) + "&Vac_month=" + month1 + "&Vac_yaer=" + yaer1 + "&Vac_vacationname=2 ");
}
if (document.form1.Vac_vacationname3[i].checked){
window.location="savecalendar.php?For_FormID=" + myID + "&IDPersonnel=" + myIDPer + "&Lae_LaeveID=" + myIDLae + "&For_RecordTime=" + myIDdate + "&Vac_date=" + (i+1) + "&Vac_month=" + month1 + "&Vac_yaer=" + yaer1 + "&Vac_vacationname=3 ";
//alert("savecalendar.php?For_FormID=" + myID + "&IDPersonnel=" + myIDPer + "&Lae_LaeveID=" + myIDLae + "&Vac_date=" + (i+1) + "&Vac_month=" + month1 + "&Vac_yaer=" + yaer1 + "&Vac_vacationname=3 ");
}
}
}
</script>
</head>
<body>
<input type="checkbox" name="xx1" id="xx1">
<label for="xx1">xx1</label>
<?php
// set the default timezone to use. Available since PHP 5.1
date_default_timezone_set('UTC');
// Prints something like: Monday
echo date("l");
// Prints something like: Monday 8th of August 2005 03:12:46 PM
?><br /><?
echo date('l jS \of F Y h:i:s A');;;
?><br /><?
// Prints: July 1, 2000 is on a Saturday
echo "July 1, 2000 is on a " . date("l", mktime(0, 0, 0, 7, 1, 2000));
?><br /><?
/* use the constants in the format parameter */
// prints something like: Mon, 15 Aug 2005 15:12:46 UTC
echo date(DATE_RFC822);
?><br /><?
// prints something like: 2000-07-01T00:00:00+00:00
echo date(DATE_ATOM, mktime(0, 0, 0, 7, 1, 2000));
?>
<br />
<br /><? echo "xx = " . date("l", mktime(0, 0, 0, 7, 1, 2013)); ?>
<br /><? echo "xx = " . date("l", mktime(0, 0, 0, 7, 2, 2013)); ?>
<br /><? echo "xx = " . date("l", mktime(0, 0, 0, 7, 3, 2013)); ?>
<br /><? echo "xx = " . date("l", mktime(0, 0, 0, 7, 4, 2013)); ?>
<br /><? echo "xx = " . date("l", mktime(0, 0, 0, 7, 5, 2013)); ?>
<br /><? echo "xx = " . date("l", mktime(0, 0, 0, 7, 6, 2013)); ?>
<br /><? echo "xx = " . date("l", mktime(0, 0, 0, 7, 7, 2013)); ?>
<br />
<?php
$info = cal_days_in_month( CAL_GREGORIAN , 1 , 2013 ) ;
echo $info ;
?>
<?
$info = cal_days_in_month( CAL_GREGORIAN , 1, 2013 ) ;
$Vac_datelaeve = 1;
$x1 = 1;
$x = ChkDay(date("l", mktime(0, 0, 0, 1, 1, 2013)));
echo "x = " . $x;
echo " month = " . date("m");
?>
<form name="form1" method="post" action="savecalendar.php">
<p>
<label></label>
<label>
<div align="center">รหัสใบลา
<input name="For_FormID" type="text" id="For_FormID" value="<?=$newid?>" readonly/>
รหัสประจำตัว
<input name="IDPersonnel" type="text" id="IDPersonnel" value="<?php echo $row_FF['IDPersonnel']; ?>" readonly>
ประเภทการลา </label>
<select name="Lae_LaeveID" id="Lae_LaeveID">
<option value="0">เลือก</option>
<option value="1">ลาป่วย</option>
<option value="2">ลากิจ</option>
<option value="3">ลาพักร้อน</option>
<option value="4">ลาคลอด</option>
</select>
<label>วันที่บันทึก
<input name="For_RecordTime" id="For_RecordTime" type="text" value="<?PHP echo date("Y-m-d");?>" size="12" readonly/>
</label>
<table border="1" cellspacing="1" width="90%" align="center">
<tr align="center">
<td height="21" bgcolor="#FFFFFF"><img src="Images/cal_fastreverse.gif" width="13" height="9"></td>
<td colspan="5" bgcolor="#FFFFFF">
</td>
<td width="15%" bgcolor="#FFFFFF"><img src="Images/cal_fastforward.gif" width="13" height="9"></td>
</tr>
<tr align="center">
<td width="15%" height="50px" bgcolor="red">อาทิตย์</td>
<td width="14%" bgcolor="gray">จันทร์</td>
<td width="14%" bgcolor="gray">อังคาร</td>
<td width="14%" bgcolor="gray">พุธ</td>
<td width="14%" bgcolor="gray">พฤหัสบดี</td>
<td width="14%" bgcolor="gray">ศุกร์</td>
<td bgcolor="red">เสาร์</td>
</tr>
<? $x1 = $x1 - $x + 1;
for($j=0;$j<7;$j++){ ?>
<tr>
<? for($i=1;$i<=7;$i++){ ?>
<td align="center" height="100px" valign="top">
<? if ($x1>0&&$x1<=$info){ ?>
<table width="100%" align="center" border="0" cellspacing="0">
<tr align="center">
<td colspan="2" height="50px"><? echo $x1; ?></td>
</tr>
<tr align="center">
<td colspan="2">
<div align="center">
<input name="Vac_vacationname1" type="checkbox" id="Vac_vacationname1" onClick="Chk1(<? echo $x1; ?>);"
value="1" />
เต็มวัน</div></td>
</tr>
<tr align="center">
<td>
<input name="Vac_vacationname2" type="checkbox" id="Vac_vacationname2" onClick="Chk2(<? echo $x1; ?>);"
value="2" />เช้า</td>
<td>
<input name="Vac_vacationname3" type="checkbox" id="Vac_vacationname3" onClick="Chk3(<? echo $x1; ?>);" value="3" />บ่าย</td>
</tr>
</table>
<? } $x1++; ?></td>
<?}?>
</tr>
<?
if($x1>$info){
$j = 7;
}}?>
<tr align="center">
<td colspan="7"><label>
</label>
<input type="button" name="Submit1" value="บันทึก" id="Submit1" onClick="mySave1('<? echo $info ?>',
'<? echo date("m"); ?>','<? echo date("Y"); ?>')" title="บันทึกข้อมูลใหม่"> </td>
</tr>
<tr align="center">
<td colspan="7"> </td>
</tr>
</table>
</form>
<? echo "day of month = " . $info; ?>
</body>
</html>
Tag : PHP
|
|
|
|
|
|
Date :
2013-01-23 10:10:35 |
By :
pongtave |
View :
802 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|