Viewing file: addCopyTimeTable.php (16.96 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
session_start();
include_once "../global.php";
include_once "../link/function.php";
include_once "../class/clsProgram.php";
include_once "../class/clsSysStudentYearDes.php";
include_once "../class/clsSysSemesterDes.php";
include_once "../class/clsClass.php";
include_once "../class/clsCourse.php";
include_once "../class/clsRoom.php";
include_once "../class/clsDay.php";
include_once "../class/clsPeriod.php";
include_once "../class/clsOfficer.php";
include_once "../class/clsrg_SysStudyType.php";
include_once "../class/clsrg_OFSetTT.php";
include_once "../class/clsrg_WeekDate.php";
include_once "../class/clsrg_CopyTimeTable.php";
include_once "../class/clsrg_MainExternalPlace.php";
include_once "../class/clsrg_SubExternalPlace.php";
include_once "../class/clsrg_NoStudyDate.php";
openWindow();
checkWeekDayJS();
isvaliddate();
futureDayJS();
$conn = new Connection();
$oPg = new Program();
$oSy = new SysStudentYearDes();
$oSse = new SysSemesterDes();
$oCl1 = new Class1();
$oCl2 = new Class1();
$oCo = new Course();
$oRm = new Room();
$oDy = new Day();
$oPr1 = new Period();
$oPr2 = new Period();
$oOf = new Officer();
$oSt = new rg_SysStudyType();
$oOst = new rg_OFSetTT();
$oWd = new rg_WeekDate();
$oCt = new rg_CopyTimeTable();
$oMep = new rg_MainExternalPlace();
$oSep = new rg_SubExternalPlace();
$oNsd = new rg_NoStudyDate();
?>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
<link href="../source/style.css" rel="stylesheet" type="text/css">
<script language="javascript" src="../source/calendarDateInput.js"></script>
<script language="javascript">
function checkFormat() {
f = document.pc;
chk = false;
if(f.programId.value=="") {
alert('กรุณาเลือก หลักสูตร');
f.programId.focus();
return false;
}
if(f.studentYear.value=="") {
alert('กรุณาเลือก ชั้นปี');
f.studentYear.focus();
return false;
}
if(f.coId.value=="") {
alert('กรุณาเลือก รายวิชา');
f.coId.focus();
return false;
}
if(f.ctRmId.value=="") {
alert('กรุณาเลือก ห้อง');
f.ctRmId.focus();
return false;
}
if(f.ctEpMepId.disabled==false && f.ctEpMepId.value=="") {
alert('กรุณาเลือก สถานที่ฝึกงาน');
return false;
}
for(i=1; i<=7; i++) {
var ctDyId = document.getElementsByName("ctDyId["+i+"]");
if(ctDyId[0].checked==true)
chk = true;
}
if(!chk) {
alert('กรุณาเลือก วัน');
return false;
}
if(f.ctFrPr.value=="") {
alert('กรุณาเลือก จากคาบ');
f.ctFrPr.focus();
return false;
}
if(f.ctToPr.value=="") {
alert('กรุณาเลือก ถึงคาบ');
f.ctToPr.focus();
return false;
}
if(parseInt(f.ctFrPr.value) > parseInt(f.ctToPr.value)) {
alert('จากคาบ ต้อง <= ถึงคาบ');
f.ctToPr.focus();
return false;
}
if(f.ctOfId.value=="") {
alert('กรุณาเลือก ชื่ออาจารย์ผู้สอน');
f.ctOfId.focus();
return false;
}
if(f.ctSstId.value=="") {
alert('กรุณาเลือก ประเภทการสอน');
f.ctSstId.focus();
return false;
}
}
function doChange() {
f = document.pc;
var pgId = f.programId.value;
var stY = f.studentYear.value;
var acY = f.acadYear.value;
var tmId = f.semester.value;
var coId = f.coId.value;
var ofCode = f.officerCode.value;
location.href = "addCopyTimeTable.php?programId="+pgId+"&studentYear="+stY+"&acadYear="+acY+"&semester="+tmId+"&coId="+coId+"&officerCode="+ofCode;
}
function ChangeEp() {
f = document.pc;
s = document.getElementById("search");
if(f.ctRmId.value=="NULL") {
f.mepName.disabled = "";
f.sepName.disabled = "";
f.ctEpMepId.disabled = "";
f.ctEpSepId.disabled = "";
s.style.display = "";
}
else {
f.mepName.disabled = "none";
f.sepName.disabled = "none";
f.ctEpMepId.disabled = "none";
f.ctEpSepId.disabled = "none";
s.style.display = "none";
}
}
</script>
<form name="pc" method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
<input type="hidden" name="view" value="<?=$view?>">
<input type="hidden" name="officerCode" value="<?=$officerCode?>">
<table width="100%" cellpadding="1" cellspacing="1" border="0">
<tr>
<td><font size="2"><b>หลักสูตร</b></font></td>
<td colspan="3"><select name="programId" onChange="doChange()">
<option value="">--เลือก--</option>
<option value="NULL" <?php echo ($programId=='NULL') ? 'selected' : '';?>>เรียนรวมหลายหลักสูตร</option>
<?php
$oPg->RSProgramByStatusIsYOrderName();
while($oPg->GetRecord()) {
?>
<option value="<?php echo $oPg->programId;?>" <?php echo ($oPg->programId==$programId) ? 'selected' : '';?>><?php echo $oPg->programName;?></option>
<?php
}
?>
</select>
<font color="<?php echo $GLOBALS['COLOR_FONT_3'];?>">*</font></td>
</tr>
<tr bgcolor="<?php echo $GLOBALS['COLOR_BG_TD_4'];?>">
<td width="14%"><font size="2"><b>ชั้นปี</b></font></td>
<td width="36%"><select name="studentYear" onChange="doChange()">
<option value="">--เลือก--</option>
<?php
$oSy->RSSysStudentYearDes();
while($oSy->GetRecord()) {
?>
<option value="<?php echo $oSy->studentYear;?>" <?php echo ($oSy->studentYear==$studentYear) ? 'selected' : '';?>><?php echo $oSy->studentYear;?></option>
<?php
}
?>
</select>
<font color="<?php echo $GLOBALS['COLOR_FONT_3'];?>">*</font></td>
<?php
if(!$semester)
$semester = $GLOBALS["SEMESTER"];
if(!$acadYear)
$acadYear = $GLOBALS["ACADYEAR"];
?>
<td width="17%"><font size="2"><b>ภาค/ปีการศึกษา</b></font></td>
<td width="33%"><select name="semester" onChange="doChange()">
<?php
$oSse->RSSysSemesterDes();
while($oSse->GetRecord()) {
?>
<option value="<?php echo $oSse->semester;?>" <?php echo ($oSse->semester==$semester) ? 'selected' : '';?>><?php echo $oSse->semesterName;?></option>
<?php
}
?>
</select>
/
<select name="acadYear" onChange="doChange()">
<?php
$oCl1->RSClassGroupAcY();
while($oCl1->GetRecord()) {
?>
<option value="<?php echo $oCl1->acadYear;?>" <?php echo ($oCl1->acadYear==$acadYear) ? 'selected' : '';?>><?php echo $oCl1->acadYear;?></option>
<?php
}
?>
</select>
<font color="<?php echo $GLOBALS['COLOR_FONT_3'];?>">*</font></td>
</tr>
<tr>
<td><font size="2"><b>รายวิชา</b></font></td>
<td colspan="3"><select name="coId" onChange="doChange()">
<option value="">--เลือก--</option>
<?php
if($programId == 'NULL')
$oCl1->RSClassByPgIdIsNullAndAcYAndStYAndSeGroupCoIdOrderCoCodeCoName($acadYear, $studentYear, $semester);
else
$oCl1->RSClassByPgIdAndAcYAndStYAndSeGroupCoIdOrderCoCodeCoName($programId, $acadYear, $studentYear, $semester);
while($oCl1->GetRecord()) {
$oCo->SearchByKey($oCl1->courseId);
$oCo->GetRecord();
?>
<option value="<?php echo $oCl1->courseId;?>" <?php echo ($oCl1->courseId==$coId) ? 'selected' : '';?>><?php echo $oCo->courseCode.' '.$oCo->courseName;?></option>
<?php
}
?>
</select>
<font color="<?php echo $GLOBALS['COLOR_FONT_3'];?>">*</font>
<font size="2"><b>กลุ่ม</b></font>
<select name="ctClId">
<option value="">ทุกกลุ่ม</option>
<?php
if($programId == 'NULL')
$oCl1->RSClassByPgIdIsNullAndAcYAndStYAndSeAndCoIdOrderSection($acadYear, $studentYear, $semester, $coId);
else
$oCl1->RSClassByPgIdAndAcYAndStYAndSeAndCoIdOrderSection($programId, $acadYear, $studentYear, $semester, $coId);
while($oCl1->GetRecord()) {
?>
<option value="<?php echo $oCl1->classId;?>" <?php echo ($oCl1->classId==$ctClId) ? 'selected' : '';?>><?php echo $oCl1->section;?></option>
<?php
}
?>
</select>
<font color="<?php echo $GLOBALS['COLOR_FONT_3'];?>">*</font></td>
</tr>
<tr bgcolor="<?php echo $GLOBALS['COLOR_BG_TD_4'];?>">
<td><font size="2"><b>ห้อง</b></font></td>
<td><select name="ctRmId" onChange="ChangeEp()">
<option value="">--เลือก--</option>
<option value="NULL" <?php echo ($ctRmId=='NULL') ? 'selected' : '';?>>สถานที่ฝึกงาน</option>
<?php
$oRm->RSRoom();
while($oRm->GetRecord()) {
?>
<option value="<?php echo $oRm->roomId;?>" <?php echo ($oRm->roomId==$ctRmId) ? 'selected' : '';?>><?php echo $oRm->roomNo;?></option>
<?php
}
?>
</select>
<font color="<?php echo $GLOBALS['COLOR_FONT_3'];?>">*</font></td>
<td><font size="2"><b>สถานที่ฝึกงาน</b></font></td>
<td><input type="text" name="mepName" value="<?php echo $mepName;?>" size="13" class="input2" readonly>
:
<input type="text" name="sepName" value="<?php echo $sepName;?>" size="7" class="input2" readonly>
<img src="../picture/search.gif" width="15" height="19" border="0" align="absmiddle" id="search" style="CURSOR: hand; display: <?php echo ($ctRmId=='NULL') ? '' : 'none';?>;" onclick='OpenWindow("epTableCT.php",500,400)'>
<font color="<?php echo $GLOBALS['COLOR_FONT_3'];?>">*</font>
<input type="hidden" name="ctEpMepId" value="<?php echo $ctEpMepId;?>" <?php echo ($ctRmId=='NULL') ? '' : 'disabled';?>>
<input type="hidden" name="ctEpSepId" value="<?php echo $ctEpSepId;?>" <?php echo ($ctRmId=='NULL') ? '' : 'disabled';?>></td>
</tr>
<tr>
<td><font size="2"><b>สัปดาห์ที่</b></font></td>
<td><select name="ctWdAcYWeekNo">
<?php
$oWd->RSrg_WeekDateByAcY($acadYear);
while($oWd->GetRecord()) {
?>
<option value="<?php echo $oWd->wdAcYWeekNo;?>" <?php echo ($oWd->wdAcYWeekNo==$ctWdAcYWeekNo) ? 'selected' : '';?>><?php echo $oWd->wdAcYWeekNo.': '.abbreDate(splitDateDb2($oWd->wdFrDate)).' - '.abbreDate(splitDateDb2($oWd->wdToDate));?></option>
<?php
}
?>
</select></td>
<td><font size="2"><b>จำนวน</b></font></td>
<td><select name="numWeek">
<?php
$i = 1;
while($i <= 52) {
?>
<option value="<?php echo $i;?>" <?php echo ($i==$numWeek) ? 'selected' : '';?>><?php echo $i;?></option>
<?php
$i++;
}
?>
</select>
<font size="2"><b>สัปดาห์</b></font></td>
</tr>
<tr bgcolor="<?php echo $GLOBALS['COLOR_BG_TD_4'];?>">
<td><font size="2"><b>วัน</b></font></td>
<td colspan="3">
<?php
$i = 1;
$oDy->RSDay();
while($oDy->GetRecord()) {
?>
<input type="checkbox" name="ctDyId[<?php echo $i;?>]" value="<?php echo $oDy->dayId;?>" <?php echo ($oDy->dayId==$ctDyId[$i]) ? 'checked' : '';?>>
<font size="2"><?php echo $oDy->dayName;?> </font>
<?php
$i++;
}
?>
<font color="<?php echo $GLOBALS['COLOR_FONT_3'];?>">*</font></td>
</tr>
<tr>
<td><font size="2"><b>จากคาบ</b></font></td>
<td><select name="ctFrPr">
<option value="">--เลือก--</option>
<?php
$oPr1->RSPeriod();
while($oPr1->GetRecord()) {
?>
<option value="<?php echo $oPr1->period;?>" <?php echo ($oPr1->period==$ctFrPr) ? 'selected' : '';?>><?php echo substr($oPr1->startTime, 0, 5).'-'.substr($oPr1->endTime, 0, 5);?></option>
<?php
}
?>
</select>
<font size="2"><b>ถึงคาบ</b></font>
<select name="ctToPr">
<option value="">--เลือก--</option>
<?php
$oPr1->RSPeriod();
while($oPr1->GetRecord()) {
?>
<option value="<?php echo $oPr1->period;?>" <?php echo ($oPr1->period==$ctToPr) ? 'selected' : '';?>><?php echo substr($oPr1->startTime, 0, 5).'-'.substr($oPr1->endTime, 0, 5);?></option>
<?php
}
?>
</select>
<font color="<?php echo $GLOBALS['COLOR_FONT_3'];?>">*</font></td>
<td><font size="2"><b>ชื่ออาจารย์ผู้สอน</b></font></td>
<td><select name="ctOfId">
<option value="">--เลือก--</option>
<?php
$oOf->RSOfficerOrderNmAndSn();
while($oOf->GetRecord()) {
?>
<option value="<?php echo $oOf->officerId;?>" <?php echo ($oOf->officerId==$ctOfId) ? 'selected' : '';?>><?php echo $oOf->officerName.' '.$oOf->officerSurname;?></option>
<?php
}
?>
</select>
<font color="<?php echo $GLOBALS['COLOR_FONT_3'];?>">*</font></td>
</tr>
<tr bgcolor="<?php echo $GLOBALS['COLOR_BG_TD_4'];?>">
<td><font size="2"><b>ประเภทการสอน</b></font></td>
<td colspan="3"><select name="ctSstId">
<option value="">--เลือก--</option>
<?php
$oSt->RSrg_SysStudyType();
while($oSt->GetRecord()) {
?>
<option value="<?php echo $oSt->sstId;?>" <?php echo ($oSt->sstId==$ctSstId) ? 'selected' : '';?>><?php echo $oSt->sstName;?></option>
<?php
}
?>
</select>
<font color="<?php echo $GLOBALS['COLOR_FONT_3'];?>">*</font>
<?php
$oCt->RSrg_CopyTimeTableByAcYAndSeAndConfirmIsY($acadYear, $semester);
$oOf->SearchByOfficerCode($officerCode);
$oOf->GetRecord();
$ostPgId = ($programId==0 || $programId=='' || $programId=='NULL') ? 0 : $programId;
$oOst->SearchByKeyAndWLIsY($oOf->officerId, $acadYear, $semester, $ostPgId);
?>
<input type="submit" name="submit" value="บันทึก" onClick="return checkFormat()" <?php echo (!$oCt->GetRecord() && $oOst->GetRecord()) ? '' : 'disabled';?>></td>
</tr>
</table>
</form>
<?php
if($submit) {
$showTitle = true;
if($ctClId == "") {
if($programId == 'NULL')
$oCl1->RSClassByPgIdIsNullAndAcYAndStYAndSeAndCoIdOrderSection($acadYear, $studentYear, $semester, $coId);
else
$oCl1->RSClassByPgIdAndAcYAndStYAndSeAndCoIdOrderSection($programId, $acadYear, $studentYear, $semester, $coId);
}
else
$oCl1->SearchByKey($ctClId);
while($oCl1->GetRecord()) {
$ctClId = $oCl1->classId;
for($k=1; $k<=7; $k++) {
if($ctDyId[$k]) {
// ถ้าไม่ว่าง เช็ค ห้อง วัน เวลา ว่า ว่างหรือไม่
if($oCt->GetCountOVLByAcYAndRmIdAndEpMepIdAndEpSepIdAndAcYWeekNoAndDyIdAndFrPrAndToPr($acadYear, $ctRmId, $ctEpMepId, $ctEpSepId, $ctWdAcYWeekNo, $ctDyId[$k], $ctFrPr, $ctToPr) > 0) {
$oCl2->SearchByKey($ctClId);
$oCl2->GetRecord();
$oCo->SearchByKey($oCl2->courseId);
$oCo->GetRecord();
?>
<font size="2" color="<?php echo $GLOBALS["COLOR_FONT_6"];?>">
<?php
if($showTitle) {
?>
<b>รายวิชา
<?php echo $oCo->courseCode.' '.$oCo->courseName.' กลุ่ม '.$oCl2->section;?></b>
ห้อง วัน เวลาเรียน ซ้ำกับรายวิชา<br>
<?php
$showTitle = false;
}
$oCt->RSrg_CopyTimeTableByAcYAndRmIdAndEpMepIdAndEpSepIdAndAcYWeekNoAndDyIdAndFrPrAndToPr($acadYear, $ctRmId, $ctEpMepId, $ctEpSepId, $ctWdAcYWeekNo, $ctDyId[$k], $ctFrPr, $ctToPr);
while($oCt->GetRecord()) {
$oCl2->SearchByKey($oCt->ctClId);
$oCl2->GetRecord();
$oCo->SearchByKey($oCl2->courseId);
$oCo->GetRecord();
$oSt->SearchByKey($oCt->ctSstId);
$oSt->GetRecord();
$oRm->SearchByKey($oCt->ctRmId);
$oRm->GetRecord();
$oMep->SearchByKey($oCt->ctEpMepId);
$oMep->GetRecord();
$oSep->SearchByKey($oCt->ctEpSepId);
$oSep->GetRecord();
$oDy->SearchByKey($oCt->ctDyId);
$oDy->GetRecord();
$oPr1->SearchByKey($oCt->ctFrPr);
$oPr1->GetRecord();
$oPr2->SearchByKey($oCt->ctToPr);
$oPr2->GetRecord();
echo $oCo->courseCode.' '.$oCo->courseName.' กลุ่ม '.$oCl2->section.'('.$oSt->sstAbbrEng.') ';
echo (is_null($oCt->ctRmId)) ? $oMep->mepName.':'.$oSep->sepName : 'ห้อง '.$oRm->roomNo;
echo ' วัน'.$oDy->dayName.' เวลา '.substr($oPr1->startTime, 0, 5).' - '.substr($oPr2->endTime, 0, 5).' น.<br>';
} // end while
?>
</font>
<?php
} // end if
for($i=$ctWdAcYWeekNo; $i<($ctWdAcYWeekNo+$numWeek); $i++) {
$oWd->SearchByKey($acadYear, $i);
$oWd->GetRecord();
$oNsd->RSrg_NoStudyDateByDateAndFrPrAndToPr(futureDay($oWd->wdFrDate, $ctDyId[$k]-1), $ctFrPr, $ctToPr);
if(!$oNsd->GetRecord()) {
$oCt->SearchByAll($ctClId, $ctRmId, $ctEpMepId, $ctEpSepId, $i, $ctDyId[$k], $ctFrPr, $ctToPr, $ctOfId, $ctSstId);
if(!$oCt->GetRecord()) {
$oCt->AddNew();
$oCt->ctClId = $ctClId;
$oCt->ctRmId = ($ctRmId=='NULL') ? 'NULL' : $ctRmId;
$oCt->ctEpMepId = ($ctEpMepId=='') ? 'NULL' : $ctEpMepId;
$oCt->ctEpSepId = ($ctEpSepId=='') ? 'NULL' : $ctEpSepId;
$oCt->ctWdAcYWeekNo = $i;
$oCt->ctDyId = $ctDyId[$k];
$oCt->ctFrPr = $ctFrPr;
$oCt->ctToPr = $ctToPr;
$oCt->ctOfId = $ctOfId;
$oCt->ctSstId = $ctSstId;
$oCt->ctTtId='NULL';
$oCt->ctLtId='NULL';
$oCt->ctConfirm='N';
$oCt->ctUpdateUserId=$officerCode;
$oCt->ctUpdateDateTime=date('Y-m-d H:i:s');
$oCt->Save();
} // end if
} // end if
} // end for $i
} // end if
} // end for $k
} // end while
}
?>
<script language="javascript">
//reload bottom frame
parent.bottomFrame.location = "showCopyTimeTable.php?programId=<?=$programId?>&studentYear=<?=$studentYear?>&acadYear=<?=$acadYear?>&semester=<?=$semester?>&coId=<?=$coId?>&ctClId=<?=$ctClId?>&ctRmId=<?=$ctRmId?>&mepName=<?=$mepName?>&sepName=<?=$sepName?>&ctEpMepId=<?=$ctEpMepId?>&ctEpSepId=<?=$ctEpSepId?>&ctWdAcYWeekNo=<?=$ctWdAcYWeekNo?>&numWeek=<?=$numWeek?>&ctDyId[1]=<?=$ctDyId[1]?>&ctDyId[2]=<?=$ctDyId[2]?>&ctDyId[3]=<?=$ctDyId[3]?>&ctDyId[4]=<?=$ctDyId[4]?>&ctDyId[5]=<?=$ctDyId[5]?>&ctDyId[6]=<?=$ctDyId[6]?>&ctDyId[7]=<?=$ctDyId[7]?>&ctFrPr=<?=$ctFrPr?>&ctToPr=<?=$ctToPr?>&ctOfId=<?=$ctOfId?>&ctSstId=<?=$ctSstId?>&view=<?=$view?>&officerCode=<?=$officerCode?>";
</script>
|