Viewing file: timetable2.php (61.04 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php include("timetable.php"); class timetable2 extends Timetable { var $sess_prsItId = ""; var $sess_prsUsId = ""; public function __construct() { parent::__construct(); $personId = $this->session->userdata('UsPsCode'); $this->sess_prsItId = 1; $this->sess_prsUsId = $personId; if(substr($personId, 0, 5)=='psout') { $this->sess_prsItId = 2; $this->sess_prsUsId = substr($personId, 5); } } function timeTable(){ if ($this->input->server('REQUEST_METHOD') === 'POST') { $tbtmcAcY = $this->input->post('tbtmcAcY'); $tbcurId = $this->input->post('tbcurId'); $tbsyId = $this->input->post('tbsyId'); $tbwdAcYWeekNo = $this->input->post('tbwdAcYWeekNo'); $tbmepId = $this->input->post('tbmepId'); $tbsepId = $this->input->post('tbsepId'); $tbprsId = $this->input->post('tbprsId'); $tbcrsId = $this->input->post('tbcrsId'); $tbcoSection = $this->input->post('tbcoSection'); $tbrmId = $this->input->post('tbrmId'); $view = $this->input->post('view'); $stdId = $this->input->post('stdId'); $lnk = $this->input->post('lnk');
$this->load->model($this->config->item("rg_folder").'mo_rg_period','prd'); $this->load->model($this->config->item("rg_folder").'mo_rg_day','dy'); $this->load->model($this->config->item("rg_folder").'mo_rg_timetable','tt'); $this->load->model($this->config->item("rg_folder").'mo_rg_weekdate','wd'); $this->load->model($this->config->item("rg_folder").'mo_rg_course','crs'); $this->load->model($this->config->item("rg_folder").'mo_rg_studytype','st'); $this->load->model($this->config->item("rg_folder").'mo_rg_person','ps'); $this->load->model($this->config->item("rg_folder").'mo_rg_mainexternalplace','mep'); $this->load->model($this->config->item("rg_folder").'mo_rg_subexternalplace','sep'); $this->load->model($this->config->item("rg_folder").'mo_rg_nostudydate','nsd'); $this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd'); $this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co'); $rs_prd = $this->prd->qryPrd(); $num_prd = $rs_prd->num_rows(); $rs_dy = $this->dy->qryDy(); $i=1; foreach($rs_dy->result() as $row_dy){ $arr_dy[$row_dy->dyId] = $i; $i++; } $dy_flip = array_flip($arr_dy); $tb = "<table class=\"headCol\">"; $tb .= "<tr align=\"center\"><th> </th>"; // พิมพ์ัเวลา $i=1; foreach($rs_prd->result() as $row_prd){ $tb .= "<th>".($i+1)."<br />".substr($row_prd->prdFrTime, 0, 5)." - ".substr($row_prd->prdToTime, 0, 5)."</th>"; $prd_val[$row_prd->prdId] = $i; $i++; } $prd_range = $rs_prd->num_rows(); $prd_flip = array_flip($prd_val); $tb .= "</tr>"; $ct = 0; foreach($rs_dy->result() as $row_dy){ switch ($view) { case "c": ($tbcurId<>"")? $con_co = array('coAcY'=>$tbtmcAcY,'coCurId'=>$tbcurId,'ttWdAcYWeekNo'=>$tbwdAcYWeekNo,'ttDyId'=>$row_dy->dyId) : $con_co = array('coAcY'=>$tbtmcAcY,'ttWdAcYWeekNo'=>$tbwdAcYWeekNo,'ttDyId'=>$row_dy->dyId); ($tbsyId<>"")? $con_co = array('coAcY'=>$tbtmcAcY,'coCurId'=>$tbcurId,'coSyId'=>$tbsyId,'ttWdAcYWeekNo'=>$tbwdAcYWeekNo,'ttDyId'=>$row_dy->dyId) : ""; $ord_co = array('ttId'=>''); $rs_tt= $this->tt->qryTtJoinCo($con_co,$ord_co); //echo $this->db->last_query(); $num = $rs_tt->num_rows(); //echo $num."<br>"; break; case "r": ($tbrmId<>"")? $con_co = array('coAcY'=>$tbtmcAcY,'ttRmId'=>$tbrmId,'ttWdAcYWeekNo'=>$tbwdAcYWeekNo,'ttDyId'=>$row_dy->dyId) : $con_co = array('coAcY'=>$tbtmcAcY,'ttWdAcYWeekNo'=>$tbwdAcYWeekNo,'ttDyId'=>$row_dy->dyId); $ord_co = array('ttId'=>''); $rs_tt= $this->tt->qryTtJoinCo($con_co,$ord_co); $num = $rs_tt->num_rows(); break; case "p": ($tbmepId<>"")? $con_co = array('coAcY'=>$tbtmcAcY,'ttEtpMepId'=>$tbmepId,'ttWdAcYWeekNo'=>$tbwdAcYWeekNo,'ttDyId'=>$row_dy->dyId) : $con_co = array('coAcY'=>$tbtmcAcY,'ttWdAcYWeekNo'=>$tbwdAcYWeekNo,'ttDyId'=>$row_dy->dyId); ($tbsepId<>"" and $tbsepId<>"%")? $con_co = array('coAcY'=>$tbtmcAcY,'ttEtpMepId'=>$tbmepId,'ttEtpSepId'=>$tbsepId,'ttWdAcYWeekNo'=>$tbwdAcYWeekNo,'ttDyId'=>$row_dy->dyId) : ""; $ord_co = array('ttId'=>''); $rs_tt= $this->tt->qryTtJoinCo($con_co,$ord_co); $num = $rs_tt->num_rows(); break; case "t": ($tbprsId<>"")? $con_co = array('coAcY'=>$tbtmcAcY,'ttPrsId'=>$tbprsId,'ttWdAcYWeekNo'=>$tbwdAcYWeekNo,'ttDyId'=>$row_dy->dyId) : $con_co = array('coAcY'=>$tbtmcAcY,'ttWdAcYWeekNo'=>$tbwdAcYWeekNo,'ttDyId'=>$row_dy->dyId); $ord_co = array('ttId'=>''); $rs_tt= $this->tt->qryTtJoinCo($con_co,$ord_co); $num = $rs_tt->num_rows(); break; case "s": //$sec_cur = ($tbcoSection<>"")? explode(",",$tbcoSection) : NULL; //$cur_id = ($sec_cur[1]<>"")? $sec_cur[1] : "NULL"; //($tbcoSection<>"")? $con_co = array('coAcY'=>$tbtmcAcY,'coSection'=>$sec_cur[0],'coCurId'=>$cur_id,'coCrsId'=>$tbcrsId,'ttDyId'=>$row_dy->dyId) : $con_co = array('coAcY'=>$tbtmcAcY,'coCrsId'=>$tbcrsId,'ttDyId'=>$row_dy->dyId); //($tbcoSection<>"")? $con_co = array('coAcY'=>$tbtmcAcY,'coId'=>$tbcoSection,'ttDyId'=>$row_dy->dyId) : $con_co = array('coAcY'=>$tbtmcAcY,'coCrsId'=>$tbcrsId,'ttDyId'=>$row_dy->dyId); $ord_co = array('ttId'=>''); $this->co->coId = $tbcoSection; $qu_cco = $this->co->get_by_key(); $row_cco = ($qu_cco->num_rows()>0) ? $qu_cco->row() : NULL; $cur = (getval('coCurId', $row_cco)=="") ? "NULL" : getval('coCurId', $row_cco); ($tbcoSection<>"")? $con_co = array('coAcY'=>$tbtmcAcY,'coSection'=>$row_cco->coSection,'coCurId'=>$cur,'coCrsId'=>$tbcrsId,'ttDyId'=>$row_dy->dyId,'ttWdAcYWeekNo'=>$tbwdAcYWeekNo) : $con_co = array('coAcY'=>$tbtmcAcY,'coCrsId'=>$tbcrsId,'ttDyId'=>$row_dy->dyId,'ttWdAcYWeekNo'=>$tbwdAcYWeekNo); $rs_tt= $this->tt->qryTtJoinCo($con_co,$ord_co); $num = $rs_tt->num_rows(); break; case "st": $rs_tt= $this->tt->rdJointt($stdId,$tbtmcAcY,$tbwdAcYWeekNo,$row_dy->dyId); $num = $rs_tt->num_rows(); break; } if($num>0){ switch ($view) { case "c": $qu_max = $this->tt->GetMaxOVLByAcYAndPgIdStrAndStYAndAcYWeekNoAndDyId($tbtmcAcY,$tbcurId,$tbsyId,$tbwdAcYWeekNo,$row_dy->dyId); $max = $qu_max; break; case "r": $qu_max = $this->tt->GetMaxOVLByAcYAndRmIdAndAcYWeekNoAndDyId($tbtmcAcY,$tbrmId,$tbwdAcYWeekNo,$row_dy->dyId); $max = $qu_max; break; case "p": $qu_max = $this->tt->GetMaxOVLByAcYAndEpMepIdAndEpSepIdAndAcYWeekNoAndDyId($tbtmcAcY,$tbmepId,$tbsepId,$tbwdAcYWeekNo,$row_dy->dyId); $max = $qu_max; break; case "t": $qu_max = $this->tt->GetMaxOVLByAcYAndOfIdAndAcYWeekNoAndDyId($tbtmcAcY,$tbprsId,$tbwdAcYWeekNo,$row_dy->dyId); $max = $qu_max; break; case "s": //$sec_cur = ($tbcoSection<>"")? explode(",",$tbcoSection) : NULL; //$cur_id = ($sec_cur[1]<>"")? $sec_cur[1] : "NULL"; //$qu_max = ($tbcoSection<>"")? : $this->tt->GetMaxOVLByAcYAndCoIdAndDyId($tbtmcAcY,$tbcrsId,$row_dy->dyId); if($tbcoSection<>""){ $this->co->coId = $tbcoSection; $qu_cco = $this->co->get_by_key(); $row_cco = ($qu_cco->num_rows()>0) ? $qu_cco->row() : NULL; $cur = (getval('coCurId', $row_cco)=="") ? "" : getval('coCurId', $row_cco); //echo $cur; $qu_max = $this->tt->GetMaxOVLByAcYAndCoIdAndClIdAndDyId2($tbtmcAcY,$tbcrsId,$cur,$row_cco->coSection,$row_dy->dyId); }else{ $qu_max = $this->tt->GetMaxOVLByAcYAndCoIdAndDyId($tbtmcAcY,$tbcrsId,$row_dy->dyId); } //$qu_max = $this->tt->GetMaxOVLByAcYAndCoIdAndDyId($tbtmcAcY,$tbcrsId,$row_dy->dyId); //echo $this->db->last_query(); $max = $qu_max; break; case "st": $qu_max = $this->tt->GetMaxOVLByStIdAndAcYAndAcYWeekNoAndDyId($stdId,$tbtmcAcY,$tbwdAcYWeekNo,$row_dy->dyId); $max = $qu_max; break; } $map_tb = array(); for($i=1; $i<=$max; $i++) { for($j=1;$j<=$num_prd; $j++) $map_tb[$i][$j] = 0; } foreach($rs_tt->result() as $row_tt){ for($i=1; $i<=$max; $i++) { //-[4.3]---ถ้า $map_tb จากตำแหน่ง ttFrPr ถึง ttToPr เป็น 0 แปลว่า ว่าง ให้ใส่ id ของวิชาลงไปแทน 0 $isEmpty = true; for($z=$prd_val[$row_tt->ttPrdFrTime];$z<=$prd_val[$row_tt->ttPrdToTime];$z++) { if($map_tb[$i][$z] <> 0) { $isEmpty = false; break; //ไปยัง for $i } } if($isEmpty) { for($z=$prd_val[$row_tt->ttPrdFrTime]; $z<=$prd_val[$row_tt->ttPrdToTime]; $z++) { //-ใส่ id ของวิชาลงไปแทน 0 $map_tb[$i][$z] = $row_tt->ttId; } //-ออกจาก loop ไปเรคอร์ดต่อไป เนื่องจากว่าง break; //ไปยัง while } //$isEmpty } //-[4.2]---for $i } if($view <> "s") { $con_wd = array('wdAcY'=>$tbtmcAcY,'wdAcYWeekNo'=>$tbwdAcYWeekNo); $qu_wd= $this->wd->qryWd($con_wd); $row_wd = (isset($qu_wd) && $qu_wd!=NULL) ? $qu_wd->row() : NULL; if($qu_wd->num_rows()>0){ $nsdDate = futureDay($row_wd->wdFrDate, $row_dy->dyId-1); } $con_nsd = array('nsdDate'=>$nsdDate); $rs_nsd= $this->nsd->qrynsdDate($nsdDate); if($rs_nsd->num_rows()>0){ foreach($rs_nsd->result() as $row_nsd){ for($i=1; $i<=$max; $i++) { for($z=$prd_val[$row_nsd->nsdPrdFrTime]; $z<=$prd_val[$row_nsd->nsdPrdToTime]; $z++) $map_tb[$i][$z] = '-'.$row_nsd->nsdId; } } } } for($i=1; $i<=$max; $i++) { $tb .= "<tr height=\"50\" align=\"center\">"; if($i==1) { $tb .= "<td rowspan=\"".$max."\" bgcolor=\"".$this->config->item("rg_time_table_day")."\">".$row_dy->dyName."</td>"; } for($j=1;$j<=$num_prd; $j++){ if($map_tb[$i][$j] < 0) { $this->nsd->nsdId = substr($map_tb[$i][$j], 1); $qu_nsd = $this->nsd->get_by_key(); $row_nsd = (isset($qu_nsd) && $qu_nsd!=NULL) ? $qu_nsd->row() : NULL; $col = ($prd_val[$row_nsd->nsdPrdToTime]-$prd_val[$row_nsd->nsdPrdFrTime])+1; if($i==1) { $tb .= "<td colspan=\"".$col."\" rowspan=\"".$max."\" bgcolor=\"".$this->config->item("rg_time_table_nostudy")."\"><font size=\"2\" title=\"".$row_nsd->nsdRemark."\">".$row_nsd->nsdName."</font></td>"; } $j = $prd_val[$row_nsd->nsdPrdToTime]; }else if($map_tb[$i][$j] == 0) { $tb .= "<td> </td>"; }else{ $con_tt = array('ttId'=>$map_tb[$i][$j]); $qu_tt= $this->tt->qryTtJoinCo($con_tt); $row_tt = (isset($qu_tt) && $qu_tt!=NULL) ? $qu_tt->row() : NULL; $this->crs->crsId = $row_tt->coCrsId; $qu_crs = $this->crs->get_by_key(); $row_crs = (isset($qu_crs) && $qu_crs!=NULL) ? $qu_crs->row() : NULL; $this->st->stId = $row_tt->ttStId; $qu_st = $this->st->get_by_key(); $row_st = (isset($qu_st) && $qu_st!=NULL) ? $qu_st->row() : NULL; $this->mep->mepId = $row_tt->ttEtpMepId; $qu_mep = $this->mep->get_by_key(); $row_mep = (isset($qu_mep) && $qu_mep!=NULL) ? $qu_mep->row() : NULL; $this->sep->sepId = $row_tt->ttEtpSepId; $qu_sep = $this->sep->get_by_key(); $row_sep = (isset($qu_sep) && $qu_sep!=NULL) ? $qu_sep->row() : NULL; $this->ps->prsId = $row_tt->ttPrsId; $qu_ps1 = $this->ps->get_by_key(); $row_ps1 = (isset($qu_ps1) && $qu_ps1!=NULL) ? $qu_ps1->row() : NULL; //echo $this->db->last_query()."<br>"; $ps_con = array('prsUsId'=>$row_ps1->prsUsId,'prsItId'=>$row_ps1->prsItId); //$qu_ps2 = $this->ps->qryPsJoinPp($ps_con); $qu_ps2 = $this->ps->qryPrsJoinPPC($ps_con); //echo $this->db->last_query()."<br>"; $row_ps2 = (isset($qu_ps2) && $qu_ps2!=NULL) ? $qu_ps2->row() : NULL; $this->load->model($this->config->item("ppc_folder").'mo_spc_place','spc'); $con_rm = array('plHwId'=>$row_tt->ttRmId); $qu_rm = $this->spc->qryRm($con_rm); $row_rm = (isset($qu_rm) && $qu_rm!=NULL) ? $qu_rm->row() : NULL; /*if($view <> "st") { $letter = "<a href=\"javascript:void(0)\" title=\"".$row_crs->crsName."\" onClick=\"setData('".$row_tt->ttId."','".site_url().$this->config->item('rg_folder')."timetable2/selectData','".site_url().$this->config->item('rg_folder')."timetable2/loadDelTb');\" class=\"blue\">".$row_crs->crsCode."</a><br />(".$row_tt->coSection.") (".$row_st->stAbbrE.") - "; }else{ $letter = $row_crs->crsCode."<br />(".$row_tt->coSection.") (".$row_st->stAbbrE.") - "; }*/ if($lnk=="mng"){ $letter = "<a href=\"javascript:void(0)\" title=\"".$row_crs->crsName."\" onClick=\"setData('".$row_tt->ttId."','".site_url()."/".$this->config->item('rg_folder')."timetable2/selectData','".site_url()."/".$this->config->item('rg_folder')."timetable2/loadDelTb');\" class=\"blue\">".$row_crs->crsCode."</a><br />(".$row_tt->coSection.") (".$row_st->stAbbrE.") <a href=\"javascript:void(0)\" class=\"blue\" title=\"ลบ\" onClick=\"confirmDel2({'delIdTT':'".$row_tt->ttId."'},'myform','".site_url()."/".$this->config->item('rg_folder')."timetable2/del_TimeTable')\">-</a> "; }else if($lnk=="excell"){ $letter = "<a href=\"".site_url()."/".$this->config->item('rg_folder')."rpt_regis/RptRis109/$row_tt->coId/$row_tt->coAcY/$row_tt->coTmId/".((getval('coCurId', $row_tt)=="")? "mix":$row_tt->coCurId)."/E\" title=\"".$row_crs->crsName."\" class=\"blue\">".$row_crs->crsCode."</a><br />(".$row_tt->coSection.") (".$row_st->stAbbrE.") - "; }else if($lnk=="no"){ $letter = "<span title=\"".$row_crs->crsName."\">".$row_crs->crsCode."</span><br />(".$row_tt->coSection.") (".$row_st->stAbbrE.") - "; } switch ($view) { case "c": $letter .=(($row_tt->ttRmId==NULL)? (($qu_mep->num_rows()>0)? getval('mepName', $row_mep) : NULL).(($qu_sep->num_rows()>0)? ":".getval('sepName', $row_sep) : NULL)."<br />".(($qu_ps2->num_rows()>0)? "อ.".getval('fName', $row_ps2)." ".getval('lName', $row_ps2) : NULL) : (($qu_rm->num_rows()>0)? "ห้อง ".getval('plRmNo', $row_rm) : NULL)."<br />".(($qu_ps2->num_rows()>0)? "อ.".getval('fName', $row_ps2)." ".getval('lName', $row_ps2) : NULL)); break; case "r": $letter .= (($qu_ps2->num_rows()>0)? "อ.".getval('fName', $row_ps2)." ".getval('lName', $row_ps2).(($tbrmId=="")? NULL: "<br />ห้อง ".getval('plRmNo', $row_rm)) : NULL); break; case "p": $letter .= (($qu_ps2->num_rows()>0)? "อ.".getval('fName', $row_ps2)." ".getval('lName', $row_ps2) : NULL); break; case "t": $letter .=(($row_tt->ttRmId==NULL)? (($qu_mep->num_rows()>0)? getval('mepName', $row_mep) : NULL).":".(($qu_sep->num_rows()>0)? getval('sepName', $row_sep) : NULL) : (($qu_rm->num_rows()>0)? "ห้อง ".getval('plRmNo', $row_rm) : NULL)); break; case "s": $letter .=(($row_tt->ttRmId==NULL)? (($qu_mep->num_rows()>0)? getval('mepName', $row_mep) : NULL).":".(($qu_sep->num_rows()>0)? getval('sepName', $row_sep) : NULL)."<br />".(($qu_ps2->num_rows()>0)? "อ.".getval('fName', $row_ps2)." ".getval('lName', $row_ps2) : NULL)."<br />".(($row_tt->ttWdAcYWeekNo<>NULL)? "สัปดาห์ที่ ".$row_tt->ttWdAcYWeekNo : NULL) : (($qu_rm->num_rows()>0)? "ห้อง ".getval('plRmNo', $row_rm) : NULL)."<br />".(($qu_ps2->num_rows()>0)? "อ.".getval('fName', $row_ps2)." ".getval('lName', $row_ps2) : NULL)."<br />".(($row_tt->ttWdAcYWeekNo<>NULL)? "สัปดาห์ที่ ".$row_tt->ttWdAcYWeekNo : NULL)); break; case "st": $letter .=(($row_tt->ttRmId==NULL)? (($qu_mep->num_rows()>0)? getval('mepName', $row_mep) : NULL).(($qu_sep->num_rows()>0)? ":".getval('sepName', $row_sep) : NULL)."<br />".(($qu_ps2->num_rows()>0)? "อ.".getval('fName', $row_ps2)." ".getval('lName', $row_ps2) : NULL) : (($qu_rm->num_rows()>0)? "ห้อง ".getval('plRmNo', $row_rm) : NULL)."<br />".(($qu_ps2->num_rows()>0)? "อ.".getval('fName', $row_ps2)." ".getval('lName', $row_ps2) : NULL)); break; } $col = ($prd_val[$row_tt->ttPrdToTime]-$prd_val[$row_tt->ttPrdFrTime])+1; $tb .= "<td colspan=\"".$col."\" bgcolor=\"".(($i==1)? $this->config->item("rg_time_table_duplicate") : $this->config->item("rg_time_table_unduplicate"))."\" >".$letter."</td>"; $j = $prd_val[$row_tt->ttPrdToTime]; } } } }else{ $tb .= "<tr height=\"50\" align=\"center\"><td bgcolor=\"".$this->config->item("rg_time_table_day")."\">".$row_dy->dyName."</td>"; $con_wd = array('wdAcY'=>$tbtmcAcY,'wdAcYWeekNo'=>$tbwdAcYWeekNo); $qu_wd= $this->wd->qryWd($con_wd); $row_wd = (isset($qu_wd) && $qu_wd!=NULL) ? $qu_wd->row() : NULL; if($qu_wd->num_rows()>0){ $nsdDate = futureDay($row_wd->wdFrDate, $row_dy->dyId-1); } for($j=1;$j<=$prd_range;$j++){ if($qu_wd->num_rows()<=0){ $tb .= "<td> </td>"; }else if($view == "s") { $tb .= "<td> </td>"; }else{ $qu_nsd = $this->nsd->RSrg_NoStudyDateByDateAndFrPr($nsdDate,$prd_flip[$j]); $row_nsd = (isset($qu_nsd) && $qu_nsd!=NULL) ? $qu_nsd->row() : NULL; if($qu_nsd->num_rows()>0){ $col = ($prd_val[$row_nsd->nsdPrdToTime]-$prd_val[$row_nsd->nsdPrdFrTime])+1; $tb .= "<td colspan=\"".$col."\" bgcolor=\"".$this->config->item("rg_time_table_nostudy")."\"><font size=\"2\" title=\"".$row_nsd->nsdRemark."\">".$row_nsd->nsdName."</font></td>"; $j = $prd_val[$row_nsd->nsdPrdToTime]; }else{ $tb .= "<td> </td>"; } } } } } $tb .= "</tr></table>"; $tmp['timetable'] = $tb; $this->wd->wdAcY = $tbtmcAcY; $this->wd->wdAcYWeekNo = $tbwdAcYWeekNo; $rs_wd = $this->wd->get_by_key(); $row_wd= (isset($rs_wd) && $rs_wd!=NULL) ? $rs_wd->row() : NULL; if($rs_wd->num_rows()>0){ $rs_nsd = $this->nsd->qryNsdBetweenDateOrdNsdDateAndNsdPrdFrTime($row_wd->wdFrDate, $row_wd->wdToDate); $tbnsd=""; if($rs_nsd->num_rows()>0){ $tbnsd .= "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"; foreach($rs_nsd->result() as $row_nsd){ $this->prd->prdId = $row_nsd->nsdPrdFrTime; $fr = $this->prd->get_by_key(); $this->prd->prdId = $row_nsd->nsdPrdToTime; $to = $this->prd->get_by_key(); $row_fr= (isset($fr) && $fr!=NULL) ? $fr->row() : NULL; $row_to= (isset($to) && $to!=NULL) ? $to->row() : NULL; $prStr = substr($row_fr->prdFrTime, 0, 5); $prStr .= ' - '.substr($row_to->prdToTime, 0, 5); $tbnsd .= "<tr><td><font size=\"2\">".abbreDate(splitDateDb2($row_nsd->nsdDate))." เวลา ".$prStr." น. ".$row_nsd->nsdName." ".$row_nsd->nsdRemark."</font></td></tr>"; } $tbnsd .= "</table>"; } $tmp['tbnsd'] = $tbnsd; } echo json_encode($tmp); } } function courseInYear(){ if ($this->input->server('REQUEST_METHOD') === 'POST') { $this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co'); $this->load->model($this->config->item("rg_folder").'mo_rg_course','crs'); $tbtmcAcY = $this->input->post('tmcAcY'); $con_co = array('coAcY'=>$tbtmcAcY); $gob_co = array('coCrsId'=>'coCrsId'); $ord_co = array('crsCode'=>'','crsName'=>''); $rs_co = $this->co->qryCoJoinCrs($con_co,$ord_co,$gob_co); $opt = ""; if($rs_co->num_rows()>0){ //$opt .= "<option value=\"\">-- เลือกรายวิชา --</option>"; foreach($rs_co->result() as $row_co){ $this->crs->crsId = $row_co->coCrsId; $qu_crs = $this->crs->get_by_key(); if($qu_crs->num_rows()>0){ $row_crs = (isset($qu_crs) && $qu_crs!=NULL) ? $qu_crs->row() : NULL; $opt .= "<option value=\"".$row_crs->crsId."\">".$row_crs->crsCode." ".$row_crs->crsName."</option>"; } } }else{ $opt .= "<option value=\"\">-- ไม่พบรายวิชา --</option>"; } echo $opt; } } function sectionInCourse(){ if ($this->input->server('REQUEST_METHOD') === 'POST') { $this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co'); $this->load->model($this->config->item("rg_folder").'mo_rg_course','crs'); $this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur'); $tbtmcAcY = $this->input->post('tmcAcY'); $tbcrsId = $this->input->post('tbcrsId'); $con_co = array('coAcY'=>$tbtmcAcY,'coCrsId'=>$tbcrsId); $gob_co = array('coCurId'=>'coCurId','coSection'=>'coSection'); //'coTmId'=>'coTmId', //$ord_co = array('coCrsId'=>'','coSection'=>''); $rs_co = $this->co->qryCo($con_co,'',$gob_co); //echo $this->db->last_query(); $opt = ""; if($rs_co->num_rows()>0){ $opt .= "<option value=\"\">-- ทุกกลุ่ม --</option>"; foreach($rs_co->result() as $row_co){ $this->cur->curId = $row_co->coCurId; $qu_cur = $this->cur->get_by_key(); $row_cur = (isset($qu_cur) && $qu_cur!=NULL) ? $qu_cur->row() : NULL; $abb = ($qu_cur->num_rows()>0)? $row_cur->curAbbr:"เรียนรวมหลายหลักสูตร"; //$opt .= "<option value=\"".$row_co->coSection.",".$row_co->coCurId."\">".$row_co->coSection." (".$abb.")</option>"; $opt .= "<option value=\"".$row_co->coId."\">".$row_co->coSection." (".$abb.")</option>"; } }else{ $opt .= "<option value=\"\">-- ไม่พบ --</option>"; } echo $opt; } } function selectData(){ if ($this->input->server('REQUEST_METHOD') === 'POST') { $this->load->model($this->config->item("rg_folder").'mo_rg_timetable','tt'); $this->load->model($this->config->item("rg_folder").'mo_rg_ttteachingmethod','tttm'); $this->load->model($this->config->item("rg_folder").'mo_rg_teachingmethod','tm'); $id = $this->input->post('id'); $tt_con = array('ttId'=>$id); $rs_tt= $this->tt->qryTtJoinCo($tt_con);
$data = array(); $set_con = array(); $set_ord = array(); $set_gro = array(); if($rs_tt->num_rows()>0){ $row_tt = (isset($rs_tt) && $rs_tt!=NULL) ? $rs_tt->row() : NULL; $data['coAcY'] = $row_tt->coAcY; $data['coTmId'] = $row_tt->coTmId; $data['coId'] = $row_tt->coId; $data['ttId'] = $row_tt->ttId; $data['ttRmId'] = $row_tt->ttRmId; //หาสิทธิ์ if($row_tt->coCurId=="NULL"){ $id = "0"; }else{ $id = $row_tt->coCurId; } $this->load->model($this->config->item("rg_folder").'mo_rg_person','prs'); $this->load->model($this->config->item("rg_folder").'mo_rg_personpermission','pp'); $prs_con = array('prsUsId'=>$this->sess_prsUsId,'prsItId'=>$this->sess_prsItId); $qu_prs = $this->prs->qryPrs($prs_con); if ($qu_prs->num_rows() > 0) { $row_prs = $qu_prs->row(); $pp_con = array('ppPrsId'=>$row_prs->prsId,'ppAcY'=>$row_tt->coAcY,'ppTmId'=>$row_tt->coTmId,'ppCurId'=>$id); $qu_pp = $this->pp->qryPp($pp_con); if ($qu_pp->num_rows() > 0) { $row = $qu_pp->row(); $data['pp'] = $row->ppTT; } else{ $data['pp'] = "N"; } }else{ $data['pp'] = "N"; } /// ค้นหา หลักสูตร $this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co'); $this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur'); $set_con = array_merge($set_con, array('coAcY'=>$row_tt->coAcY,'coTmId'=>$row_tt->coTmId)); if($row_tt->coCurId==""){ $data['coCurId'] = "NULL"; }else{ $data['coCurId'] = $row_tt->coCurId; } // ค้นหาชั้นปี $data['coSyId'] = $row_tt->coSyId; if($row_tt->coCurId==""){ $curId = "NULL"; }else{ $curId = $row_tt->coCurId; } $set_con = array_merge($set_con, array('curId'=>$curId)); // ค้นหารายวิชา $set_con = array_merge($set_con, array('syId'=>$row_tt->coSyId)); $set_gro = array('crsId'=>'crsName'); $opt = '-- เลือกรายวิชา --'; $qu = $this->co->qry_optionCo($set_con,'',$set_gro,$opt);
if(count($qu)==1){ $qu[''] = '-- ไม่พบรายวิชา --'; } $attr = 'id="crsId" onChange="get_option();checkSubmit();"'; $data['crs'] = form_dropdown('crsId',$qu,$row_tt->coCrsId,$attr); $data['crsId'] = $row_tt->coCrsId; // ค้นหากลุ่ม $set_con = array_merge($set_con, array('crsId'=>$row_tt->coCrsId)); $set_ord = array('coSection'=>''); $set_gro = array('coSection'=>'coSection'); $opt = ''; $qu = $this->co->qry_optionCo($set_con,$set_ord,$set_gro,$opt); if(count($qu)>1){ $qu['%'] = '-- ทุกกลุ่ม --'; ksort($qu); } if(count($qu)==0){ $qu[''] = '-- ไม่พบ --'; } $attr = 'id="coSection" onChange="get_option();checkSubmit();"'; $data['sec'] = form_dropdown('coSection',$qu,$row_tt->coSection,$attr); //ค้นหา สถานที่ฝึกหลัก $this->load->model($this->config->item("rg_folder").'mo_rg_externalplace','etp'); $set_con = ''; $set_gro = array('mepId'=>'mepName'); $opt = '-- เลือกสถานที่ฝึกหลัก --'; $set_ord = ''; $qu = $this->etp->mep_optionsJoinMepSep($set_con,$set_ord,$set_gro,$opt); if(count($qu)>=1){ $attr = 'id="mepId" onChange="get_option();checkSubmit();"'; $data['mep'] = form_dropdown('mepId',$qu,$row_tt->ttEtpMepId,$attr).' : '; $attr = 'id="tbmepId" onChange="Sync(this.id);"'; $data['tbmep'] = form_dropdown('tbmepId',$qu,$row_tt->ttEtpMepId,$attr); }else{ $qu[''] = '-- ไม่พบสถานฝึกหลัก --'; $data['mep'] = form_dropdown('mepId',$qu,$row_tt->ttEtpMepId,$attr).' : '; $data['tbmep'] = form_dropdown('tbmepId',$qu,$row_tt->ttEtpMepId,$attr); } if($row_tt->ttEtpMepId!=''){ $cond = array('mepId'=>$row_tt->ttEtpMepId); // ค้นหา สถานที่ฝึกย่อย $set_con = $cond ; $set_gro = array('sepId'=>'sepId'); $opt = ''; $set_ord = ''; $qu = $this->etp->sep_optionsJoinMepSep($set_con,$set_ord,$set_gro,$opt);
if(count($qu)==0){ $qu[''] = '-- ไม่พบสถานฝึกย่อย --'; } $attr = 'id="sepId" onChange="get_option();checkSubmit();"'; $data['sep'] = form_dropdown('sepId',$qu,$row_tt->ttEtpSepId,$attr); $attr = 'id="tbsepId" onChange="Sync(this.id);"'; $data['tbsep'] = form_dropdown('tbsepId',$qu,$row_tt->ttEtpSepId,$attr); }else{ $data['sep'] = ''; $data['tbsep'] = ''; } // ค้นหา สัปดาห์ $this->load->model($this->config->item("rg_folder").'mo_rg_weekdate','wd'); $set_con = array('wdAcY'=>$row_tt->coAcY); $set_gro = ''; $opt = ''; $set_ord = '';//array('wdAcYWeekNo'=>''); $qu = $this->wd->opt_WeekNoFrToDate($set_con,$set_ord,$set_gro,$opt);
if(count($qu)==0){ $qu[0] = '-- ไม่พบหลักสูตรที่เปิดใน ปีศึกษานี้ --'; } $attr = 'id="wdAcYWeekNo" onChange="get_option();"'; $data['wd'] = form_dropdown('wdAcYWeekNo',$qu,(setValue('ttWdAcYWeekNo',$row_tt) == '')? $wdAcYWeekNo : setValue('ttWdAcYWeekNo',$row_tt),$attr); $attr = 'id="tbwdAcYWeekNo" onChange="Sync(this.id);"'; $data['tbwd'] = form_dropdown('tbwdAcYWeekNo',$qu,$row_tt->ttWdAcYWeekNo,$attr); $attr = 'id="tbwdAcYWeekNo"'; $data['tbwd2'] = form_dropdown('tbwdAcYWeekNo',$qu,$row_tt->ttWdAcYWeekNo,$attr); $data['day'] = $row_tt->ttDyId; $data['ttPrdFrTime'] = $row_tt->ttPrdFrTime; // หาคาบเรียน เวลาสิ้นสุดคาบเรียน $this->load->model($this->config->item("rg_folder").'mo_rg_period','prd'); $set_con = array('1'=>'1'); $set_gro = ''; $opt = ''; $set_ord = array('prdId'=>''); $this->prd->prdId = $row_tt->ttPrdFrTime;
$qu = $this->prd->get_options_toTime($set_con,$set_ord,$set_gro,$opt); $attr = 'id="prdToTime" onChange="get_option();"'; $data['prdTo'] = form_dropdown('prdToTime',$qu,$row_tt->ttPrdToTime,$attr); $data['ttStId'] = $row_tt->ttStId; $data['ttTitle'] = $row_tt->ttTitle; $data['ttPrsId'] = $row_tt->ttPrsId; $point[0] = $data; // End หา dropdown $ttt_rs = $this->tttm->get_by_key_ttId($this->input->post('id')); if($ttt_rs->num_rows()>0){ $val = ""; $tm_id = ""; foreach($ttt_rs->result() as$row_ttt){ $this->tm->tcmId = $row_ttt->tttTcmId; $qu_tm = $this->tm->get_by_key(); $row_tm = (isset($qu_tm) && $qu_tm!=NULL) ? $qu_tm->row() : NULL; if($qu_tm->num_rows()>0){ $val .= "-".$row_tm->tcmName."\n"; $tm_id .= "<input type=\"hidden\" name=\"tmc[]\" value=\"".$row_tm->tcmId."\">"; } } $data2['txt'] = $val; $data2['id'] = $tm_id; $point[1] = $data2; } }else{ $point = ""; } echo json_encode($point); // $this->auto_render = FALSE; } } function insert_update_TimeTable(){ $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<font color="red">','</font>'); $this->form_validation->set_rules('ttId',' ','trim|xss_clean'); $this->form_validation->set_rules('tmcAcY',' ','trim|required|xss_clean'); $this->form_validation->set_rules('tmId',' ','trim|required|xss_clean'); $this->form_validation->set_rules('curId',' ','trim|required|xss_clean'); $this->form_validation->set_rules('syId',' ','trim|required|xss_clean'); $this->form_validation->set_rules('crsId',' ','trim|required|xss_clean'); $this->form_validation->set_rules('coSection',' ','trim|required|xss_clean'); $this->form_validation->set_rules('place',' ','trim|required|xss_clean'); if($this->input->post('edit')){ $this->form_validation->set_rules('day',' ','required|trim|xss_clean'); $this->form_validation->set_rules('prsId',' ','trim|required|xss_clean'); }else{ $this->form_validation->set_rules('dyId[]',' ','required|trim|xss_clean'); $this->form_validation->set_rules('prs[]',' ','required|trim|xss_clean'); } $this->form_validation->set_rules('wdAcYWeekNo',' ','trim|required|xss_clean'); //$this->form_validation->set_rules('tmc[]',' ','required|trim|xss_clean'); $this->form_validation->set_rules('numWeek',' ','trim|xss_clean'); $this->form_validation->set_rules('prdFrTime',' ','trim|required|xss_clean'); $this->form_validation->set_rules('prdToTime',' ','trim|required|xss_clean'); $this->form_validation->set_rules('stId',' ','trim|required|xss_clean'); //$this->form_validation->set_rules('tcmName',' ','trim|required|xss_clean'); //$this->form_validation->set_rules('title',' ','trim|xss_clean'); if($this->form_validation->run() == true) { $flgmsg = 0; $this->load->model($this->config->item("rg_folder").'mo_rg_timetable','tt'); $this->load->model($this->config->item("rg_folder").'mo_rg_ttteachingmethod','tttm'); $this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co'); $this->load->model($this->config->item("rg_folder").'mo_rg_weekdate','wd'); $this->load->model($this->config->item("rg_folder").'mo_rg_nostudydate','nsd'); $week = $this->input->post('wdAcYWeekNo'); $ctdy = count($this->input->post('dyId')); $dy= $this->input->post('dyId'); $ctprs = count($this->input->post('prs')); $prs= $this->input->post('prs'); $cttm = count($this->input->post('tmc')); $tm= $this->input->post('tmc'); //หาเวลาซ้ำ if($this->input->post('edit')){ $numweek=1; }else{ $numweek=$this->input->post('numWeek'); } $sum = false; for($k=1;$k<=$numweek;$k++){ $this->wd->wdAcY = $this->input->post('tmcAcY'); $this->wd->wdAcYWeekNo = $week; $qu_wd = $this->wd->get_by_key(); $row_wd = (isset($qu_wd) && $qu_wd!=NULL) ? $qu_wd->row() : NULL; for($j=0;$j<$ctdy;$j++){ for($i=0; $i<numDay($row_wd->wdFrDate,$row_wd->wdToDate)+1; $i++) { $nsdDate = futureDay($row_wd->wdFrDate, $i); $dt = date('N', strtotime($nsdDate)); if($this->input->post('edit')){ $tmp_day = $this->input->post('day'); }else{ $tmp_day = $dy[$j]; } if($dt==$tmp_day){ $nsd = $this->nsd->qryNsdByDateAndFrTimeAndToTime($nsdDate,$this->input->post('prdFrTime'),$this->input->post('prdToTime')); if($nsd->num_rows()>0){ $sum = true; $flgmsg = 21; break; } } } } $week = $week+1; } if($this->input->post('coSection')=='%'){ $con_co = array('coAcY'=>$this->input->post('tmcAcY'), 'coCurId'=>$this->input->post('curId'),'coSyId'=>$this->input->post('syId'),'coTmId'=>$this->input->post('tmId'), 'coCrsId'=>$this->input->post('crsId')); $rs_co = $this->co->qryCo($con_co); $rs_co = $this->co->qryCo($con_co); if($rs_co->num_rows()>0){ foreach($rs_co->result() as$row_co){ $week = $this->input->post('wdAcYWeekNo'); if($sum==false){ if(!$this->input->post('edit')){ //add for($i=1;$i<=$numweek;$i++){ for($j=0;$j<$ctdy;$j++){ for($v=0;$v<$ctprs;$v++){ $this->tt->ttWdAcYWeekNo = $week; $this->tt->ttTitle = $this->input->post('title'); $this->tt->ttCoId = getval('coId', $row_co); $this->tt->ttRmId = ($this->input->post('place')==1)? $this->input->post('rmId') : NULL; $this->tt->ttEtpMepId = ($this->input->post('place')==2)? $this->input->post('mepId') : NULL; $this->tt->ttEtpSepId = ($this->input->post('place')==2)? $this->input->post('sepId') : NULL; $this->tt->ttDyId = $dy[$j]; $this->tt->ttPrdFrTime = $this->input->post('prdFrTime'); $this->tt->ttPrdToTime = $this->input->post('prdToTime'); $this->tt->ttPrsId = $prs[$v]; $this->tt->ttStId = $this->input->post('stId'); $this->tt->insert(); $this->tttm->tttTtId = $this->tt->last_insert_id(); for($k=0;$k<$cttm;$k++){ if($tm[$k]!==NULL){ $this->tttm->tttTcmId = $tm[$k]; $this->tttm->insert(); } } $flgmsg = 10; } } $week = $week+1; } } } } if($sum==false){ $dt = array( 'tt-tmcAcY'=>$this->input->post('tmcAcY'), 'tt-tmId'=>$this->input->post('tmId'), 'tt-curId'=>$this->input->post('curId'), 'tt-syId'=>$this->input->post('syId'), 'tt-crsId'=>$this->input->post('crsId'), 'tt-coSection'=>$this->input->post('coSection'), 'tt-place'=>$this->input->post('place'), 'tt-mepId'=>$this->input->post('mepId'), 'tt-sepId'=>$this->input->post('sepId'), 'tt-rmId'=>$this->input->post('rmId'), 'tt-wdAcYWeekNo'=>$this->input->post('wdAcYWeekNo'), 'tt-numWeek'=>$this->input->post('numWeek'), 'tt-dyId'=>$this->input->post('dyId'), 'tt-prdFrTime'=>$this->input->post('prdFrTime'), 'tt-prdToTime'=>$this->input->post('prdToTime'), 'tt-prsbox'=>$this->input->post('prsbox'), 'tt-prs'=>$this->input->post('prs'), 'tt-stId'=>$this->input->post('stId'), 'tt-tcmName'=>$this->input->post('tcmName'), 'tt-tmc'=>$this->input->post('tmc'), 'tt-title'=>$this->input->post('title'), 'tt-btadd'=>$this->input->post('btadd'), ); //$this->session->set_userdata('dt', $dt); $this->session->set_flashdata('dt', $dt); //เพิ่ม หรือ แก้ไข สำเร็จ $this->session->set_flashdata('msg', $flgmsg); redirect($this->config->item("rg_folder")."timetable/arranged_schedule/default"); }else{ //เวลาซ้ำ //$this->session->set_flashdata('msg', $flgmsg); redirect($this->config->item("rg_folder")."timetable/arranged_schedule/default"); } } }else{ $con_co = array('coAcY'=>$this->input->post('tmcAcY'),'coSection'=>$this->input->post('coSection'), 'coCurId'=>$this->input->post('curId'),'coSyId'=>$this->input->post('syId'),'coTmId'=>$this->input->post('tmId'), 'coCrsId'=>$this->input->post('crsId')); $qu_co = $this->co->qryCo($con_co); $row_co = (isset($qu_co) && $qu_co!=NULL) ? $qu_co->row() : NULL; $week = $this->input->post('wdAcYWeekNo'); if($sum==false){ //เวลาไม่ซ้ำ if($this->input->post('edit')){ //edit $this->tt->ttId = $this->input->post('ttId'); $this->tt->ttWdAcYWeekNo = $week; $this->tt->ttTitle = $this->input->post('title'); $this->tt->ttCoId = getval('coId', $row_co); $this->tt->ttRmId = ($this->input->post('place')==1)? $this->input->post('rmId') : NULL; $this->tt->ttEtpMepId = ($this->input->post('place')==2)? $this->input->post('mepId') : NULL; $this->tt->ttEtpSepId = ($this->input->post('place')==2)? $this->input->post('sepId') : NULL; $this->tt->ttDyId = $this->input->post('day'); $this->tt->ttPrdFrTime = $this->input->post('prdFrTime'); $this->tt->ttPrdToTime = $this->input->post('prdToTime'); $this->tt->ttPrsId = $this->input->post('prsId'); $this->tt->ttStId = $this->input->post('stId'); $this->tt->update(); $this->tttm->tttTtId = $this->input->post('ttId'); $this->tttm->deleteByttId(); $this->tttm->tttTtId = $this->input->post('ttId'); for($k=0;$k<$cttm;$k++){ if($tm[$k]!==NULL){ $this->tttm->tttTcmId = $tm[$k]; $this->tttm->insert(); } } $flgmsg = 10; }else{ //add for($i=1;$i<=$numweek;$i++){ for($j=0;$j<$ctdy;$j++){ for($v=0;$v<$ctprs;$v++){ $this->tt->ttWdAcYWeekNo = $week; $this->tt->ttTitle = $this->input->post('title'); $this->tt->ttCoId = getval('coId', $row_co); $this->tt->ttRmId = ($this->input->post('place')==1)? $this->input->post('rmId') : NULL; $this->tt->ttEtpMepId = ($this->input->post('place')==2)? $this->input->post('mepId') : NULL; $this->tt->ttEtpSepId = ($this->input->post('place')==2)? $this->input->post('sepId') : NULL; $this->tt->ttDyId = $dy[$j]; $this->tt->ttPrdFrTime = $this->input->post('prdFrTime'); $this->tt->ttPrdToTime = $this->input->post('prdToTime'); $this->tt->ttPrsId = $prs[$v]; $this->tt->ttStId = $this->input->post('stId'); $this->tt->insert(); $this->tttm->tttTtId = $this->tt->last_insert_id(); for($k=0;$k<$cttm;$k++){ if($tm[$k]!==NULL){ $this->tttm->tttTcmId = $tm[$k]; $this->tttm->insert(); } } $flgmsg = 10; } } $week = $week+1; } //---- $dt = array( 'tt-tmcAcY'=>$this->input->post('tmcAcY'), 'tt-tmId'=>$this->input->post('tmId'), 'tt-curId'=>$this->input->post('curId'), 'tt-syId'=>$this->input->post('syId'), 'tt-crsId'=>$this->input->post('crsId'), 'tt-coSection'=>$this->input->post('coSection'), 'tt-place'=>$this->input->post('place'), 'tt-mepId'=>$this->input->post('mepId'), 'tt-sepId'=>$this->input->post('sepId'), 'tt-rmId'=>$this->input->post('rmId'), 'tt-wdAcYWeekNo'=>$this->input->post('wdAcYWeekNo'), 'tt-numWeek'=>$this->input->post('numWeek'), 'tt-dyId'=>$this->input->post('dyId'), 'tt-prdFrTime'=>$this->input->post('prdFrTime'), 'tt-prdToTime'=>$this->input->post('prdToTime'), 'tt-prsbox'=>$this->input->post('prsbox'), 'tt-prs'=>$this->input->post('prs'), 'tt-stId'=>$this->input->post('stId'), 'tt-tcmName'=>$this->input->post('tcmName'), 'tt-tmc'=>$this->input->post('tmc'), 'tt-title'=>$this->input->post('title'), 'tt-btadd'=>$this->input->post('btadd'), ); //$this->session->set_userdata('dt', $dt); $this->session->set_flashdata('dt', $dt); } //เพิ่ม หรือ แก้ไข สำเร็จ $this->session->set_flashdata('msg', $flgmsg); redirect($this->config->item("rg_folder")."timetable/arranged_schedule/default"); }else{ //เวลาซ้ำ //$this->session->set_flashdata('msg', $flgmsg); redirect($this->config->item("rg_folder")."timetable/arranged_schedule/default"); } } }else{ $this->arranged_schedule("default"); } } function loadDelTb(){ if ($this->input->server('REQUEST_METHOD') === 'POST') { $this->load->model($this->config->item("rg_folder").'mo_rg_period','prd'); $this->load->model($this->config->item("rg_folder").'mo_rg_day','dy'); $this->load->model($this->config->item("rg_folder").'mo_rg_timetable','tt'); $this->load->model($this->config->item("rg_folder").'mo_rg_weekdate','wd'); $this->load->model($this->config->item("rg_folder").'mo_rg_course','crs'); $this->load->model($this->config->item("rg_folder").'mo_rg_studytype','st'); $this->load->model($this->config->item("rg_folder").'mo_rg_person','ps'); $this->load->model($this->config->item("rg_folder").'mo_rg_mainexternalplace','mep'); $this->load->model($this->config->item("rg_folder").'mo_rg_subexternalplace','sep'); $this->load->model($this->config->item("rg_folder").'mo_rg_config','cfg'); $qu_cfg = $this->cfg->qryCfg(); if($row = $qu_cfg->row()) { $tr_color_even = $row->cfgBgClSwapTr; } $year = $this->input->post('year'); $tmId = $this->input->post('tm'); $curId = $this->input->post('cur'); $crsId = $this->input->post('crsId'); $tbwdAcYWeekNo = $this->input->post('tbwdAcYWeekNo'); /*$con_co = array('coAcY'=>$year,'coTmId'=>$tmId,'coCurId'=>$curId); $ord_co = array('ttWdAcYWeekNo'=>'ASC','ttDyId'=>'ASC');*/ //$rs_tt= $this->tt->getTTByUTF8($year,$tmId,$curId,$crsId,$tbwdAcYWeekNo); // edit 1/7/2556 $rs_tt= $this->tt->getTTByUTF8($year,$tmId,$curId,$crsId); // create 1/7/2556 $tb =form_open($this->config->item("rg_folder")."timetable2/del_TimeTable"); $tb .= "<table width=\"100%\"><tr align=\"center\"><th><span class=\"h error\">ลบตารางสอน</span></th></tr><tr></td>"; $tb .= "<table class=\"headCol\">"; $tb .= "<tr><th class=\"deleteCol\">เลือก</th><th class=\"date\">สัปดาห์ที่</th><th class=\"hourCol\">วัน เวลา</th><th>ห้อง/สถานที่ฝึกงาน</th><th class=\"teacherCol\">ชื่ออาจารย์ผู้สอน</th></tr>"; foreach($rs_tt->result() as$row_tt){ $this->dy->dyId = $row_tt->ttDyId; $qu_dy = $this->dy->get_by_key(); $row_dy = (isset($qu_dy) && $qu_dy!=NULL) ? $qu_dy->row() : NULL; $this->crs->crsId = $row_tt->coCrsId; $qu_crs = $this->crs->get_by_key(); $row_crs = (isset($qu_crs) && $qu_crs!=NULL) ? $qu_crs->row() : NULL; $this->wd->wdAcYWeekNo = $row_tt->ttWdAcYWeekNo; $this->wd->wdAcY = $year; $qu_wd = $this->wd->get_by_key(); $row_wd = (isset($qu_wd) && $qu_wd!=NULL) ? $qu_wd->row() : NULL; $this->st->stId = $row_tt->ttStId; $qu_st = $this->st->get_by_key(); $row_st = (isset($qu_st) && $qu_st!=NULL) ? $qu_st->row() : NULL; $this->mep->mepId = $row_tt->ttEtpMepId; $qu_mep = $this->mep->get_by_key(); $row_mep = (isset($qu_mep) && $qu_mep!=NULL) ? $qu_mep->row() : NULL; $this->sep->sepId = $row_tt->ttEtpSepId; $qu_sep = $this->sep->get_by_key(); $row_sep = (isset($qu_sep) && $qu_sep!=NULL) ? $qu_sep->row() : NULL; $this->prd->prdId = $row_tt->ttPrdFrTime; $qu_fr = $this->prd->get_by_key(); $row_fr = (isset($qu_fr) && $qu_fr!=NULL) ? $qu_fr->row() : NULL; $this->prd->prdId = $row_tt->ttPrdToTime; $qu_to = $this->prd->get_by_key(); $row_to = (isset($qu_to) && $qu_to!=NULL) ? $qu_to->row() : NULL; $this->ps->prsId = $row_tt->ttPrsId; $qu_ps1 = $this->ps->get_by_key(); $row_ps1 = (isset($qu_ps1) && $qu_ps1!=NULL) ? $qu_ps1->row() : NULL; $ps_con = array('prsUsId'=>$row_ps1->prsUsId,'prsItId'=>$row_ps1->prsItId); //$qu_ps2 = $this->ps->qryPsJoinPp($ps_con); $qu_ps2 = $this->ps->qryPrsJoinPPC($ps_con); $row_ps2 = (isset($qu_ps2) && $qu_ps2!=NULL) ? $qu_ps2->row() : NULL; $this->load->model($this->config->item("ppc_folder").'mo_spc_place','spc'); $con_rm = array('plHwId'=>$row_tt->ttRmId); $qu_rm = $this->spc->qryRm($con_rm); $row_rm = (isset($qu_rm) && $qu_rm!=NULL) ? $qu_rm->row() : NULL; //onclick=\"checkall()\" $tb .= "<tr onmouseover=\"bgColor='".$tr_color_even."'\" onmouseout=\"bgColor='".$this->config->item("rg_mouseout")."'\">"; $tb .= "<td align=\"center\"><input type=\"checkbox\" onClick=\"checkSubmit();\" id=\"delId[]\" name=\"delId[]\" value=\"".$row_tt->ttId."\" /></td><td class=\"indent\">".$row_tt->ttWdAcYWeekNo." : ".(($qu_wd->num_rows()>0)? abbreDate2(getval('wdFrDate', $row_wd)) : NULL)." - ".(($qu_wd->num_rows()>0)? abbreDate2(getval('wdToDate', $row_wd)) : NULL)."</td><td class=\"indent\">".(($qu_dy->num_rows()>0)? getval('dyAbbrE', $row_dy) : NULL)." ".(($qu_fr->num_rows()>0)? substr(getval('prdFrTime', $row_fr), 0, 5) : NULL)." - ".(($qu_to->num_rows()>0)? substr(getval('prdToTime', $row_to), 0, 5) : NULL)." ".(($qu_fr->num_rows()>0)? "(".getval('stAbbrE', $row_st).")" : NULL)."</td><td class=\"indent\">".(($row_tt->ttRmId==NULL)? (($qu_mep->num_rows()>0)? getval('mepName', $row_mep) : NULL)." : ".(($qu_sep->num_rows()>0)? getval('sepName', $row_sep) : NULL) : (($qu_rm->num_rows()>0)? "ห้อง ".getval('plRmNo', $row_rm) : NULL))."</td><td class=\"indent\">".(($qu_ps2->num_rows()>0)? "อ.".getval('fName', $row_ps2)." ".getval('lName', $row_ps2) : NULL)."</td>"; $tb .= "</tr>"; } $tb .= "<td colspan=\"5\"><button type=\"button\" name=\"selectall\" >เลือกทั้งหมด</button>".nbs(1)."<button type=\"button\" name=\"cancel\">ยกเลิกทั้งหมด</button></td>"; $tb .= "<tr><td colspan=\"5\" align=\"center\"><span id=\"del\"><input type=\"submit\" value=\"บันทึก\" name=\"btdel\" id=\"btdel\"> <input type=\"button\" onClick=\"back();\" name=\"can\" value=\"ย้อนกลับ\"></span></td></tr>"; $tb .= "</table></td></tr></table>"; echo $tb; } } function del_TimeTable(){ $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<span color="error">','</span>'); if($this->input->post('delIdTT')){ $this->form_validation->set_rules('delIdTT',' ','trim|required|xss_clean'); }else{ $this->form_validation->set_rules('delId[]',' ','trim|required|xss_clean'); } if($this->form_validation->run() == true) { $flgmsg = 0; $this->load->model($this->config->item("rg_folder").'mo_rg_timetable','tt'); $this->load->model($this->config->item("rg_folder").'mo_rg_ttteachingmethod','tttm'); if($this->input->post('delIdTT')){ $id= $this->input->post('delIdTT'); $this->tttm->tttTtId = $id; $this->tttm->deleteByttId(); $this->tt->ttId = $id; $this->tt->delete(); }else{ $ctid = count($this->input->post('delId')); $id= $this->input->post('delId'); for($i=0;$i<$ctid;$i++){ $this->tttm->tttTtId = $id[$i]; $this->tttm->deleteByttId(); $this->tt->ttId = $id[$i]; $this->tt->delete(); } } $flgmsg = 30; $this->session->set_flashdata('msg', $flgmsg); redirect($this->config->item("rg_folder")."timetable/arranged_schedule/default"); }else{ $this->arranged_schedule("default"); } } function showClassStudy(){ $this->output($this->config->item("rg_folder")."v_beforeShowClassStudy"); } function beforeShowClassStudy(){ $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<font color="red">','</font>'); $this->form_validation->set_rules('stdCode',' ','trim|xss_clean'); $this->form_validation->set_rules('stdName',' ','trim|xss_clean'); $this->form_validation->set_rules('stdSurname',' ','trim|xss_clean'); if($this->form_validation->run() == true) { $this->load->model($this->config->item("rg_folder").'mo_rg_student','std'); if($this->input->post('stdCode') !="" || $this->input->post('stdName') !="" || $this->input->post('stdSurname') !=""){ $con_std = array('stdCode'=>'%'.$this->input->post('stdCode').'%','stdName'=>'%'.$this->input->post('stdName').'%','stdSurname'=>'%'.$this->input->post('stdSurname').'%'); $ord_std = array('stdCode'=>''); $this->contents['rs_std'] = $this->std->qryStdJoinPf($con_std,$ord_std); }else{ $this->contents['str_fault'] = $this->config->item('str_fault'); } $this->output($this->config->item("rg_folder")."v_beforeShowClassStudy"); }else{ $this->showClassStudy(); } } function showTimeTableSt(){ $this->load->model($this->config->item("rg_folder").'mo_rg_student','std'); $this->load->model($this->config->item("rg_folder").'mo_rg_studyyear','sy'); $this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd'); $this->load->model($this->config->item("rg_folder").'mo_rg_termconfig','tmc'); $this->load->model($this->config->item("rg_folder").'mo_rg_term','tm'); if($this->input->post('stdId')){ $stdId = $this->input->post('stdId'); }else{ $login = $this->session->userdata('UsPsCode'); $con_std_login = array('stdCode' => $login); $std_login = $this->std->qryStd($con_std_login); if($std_login->num_rows()) { $stdId = $std_login->row()->stdId; } } if(!Empty($stdId)){ $group_AcY = array('tmcAcY'=>'tmcAcY'); $rs_tmc= $this->tmc->get_options('',array('tmcAcY'=>'DESC'),$group_AcY); $this->contents['AcY'] = $rs_tmc; $con_std = array('stdId'=>$stdId); $qu_std = $this->std->qryStdDetails($con_std); $this->contents['qu_std'] = $qu_std; if($qu_std->num_rows()>0){ $row_std = (isset($qu_std) && $qu_std!=NULL) ? $qu_std->row() : NULL; $this->sy->syId = $row_std->stdSyId; $this->contents['qu_sy'] = $this->sy->get_by_key(); $con_rd = array('rdStdId'=>$row_std->stdSyId); $rs_rd = $this->rd->qryRdJnCrsOpCrs($con_rd); } $this->output($this->config->item("rg_folder")."v_showTimeTableSt"); }else{ $this->beforeShowClassStudy(); } } function getExam(){ if ($this->input->server('REQUEST_METHOD') === 'POST') { $this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd'); $this->load->model($this->config->item("rg_folder").'mo_rg_config','cfg'); $this->load->model($this->config->item("rg_folder").'mo_rg_examschedule','es'); $this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co'); $this->load->model($this->config->item("rg_folder").'mo_rg_person','ps'); $this->load->model($this->config->item("rg_folder").'mo_rg_period','prd'); $this->load->model($this->config->item("rg_folder").'mo_rg_studytype','st'); $this->load->model($this->config->item("rg_folder").'mo_rg_examtype','ex'); $qu_cfg = $this->cfg->qryCfg(); if($row = $qu_cfg->row()) { $table_color_even = $row->cfgBgClTrAndTd; $tr_color_even = $row->cfgBgClSwapTr; $font_color_table = $row->cfgFnClHeadTb; $font_color_err = $row->cfgFnClErrSpec; } $rs_et = $this->ex->qryEx(); if($this->input->post('stdId')){ $std = $this->input->post('stdId'); }else if($this->input->post('up')){ $up = $this->input->post('up'); $prs_id = $up; } $AcY = $this->input->post('tbtmcAcY'); $ex = "<table width=\"100%\">"; foreach($rs_et->result() as$row_et){ $ex .= "<tr> <td><br><span class=\"h error\">ตารางสอบ$row_et->exName</span></td> </tr>"; $ex .= "<tr><td><table class=\"headCol\"><tr><th width=\"10%\">รหัสรายวิชา</th> <th width=\"25%\" align=\"center\">รายวิชา</th> <th class=\"groupCol\">กลุ่ม</th> <th width=\"10%\">วันที่สอบ</th> <th width=\"15%\">เวลาสอบ</th> <th width=\"10%\">ห้องสอบ</th> <th width=\"25%\">อาจารย์ผู้คุมสอบ</th></tr>"; $i = 0; if($this->input->post('stdId')){ $rs_ex = $this->rd->RSClassExamByStIdAndAcYAndExCode($std, $AcY, $row_et->exType); }else if($this->input->post('up')){ $rs_ex = $this->rd->RSClassExamByTecAndAcYAndExCode($prs_id, $AcY, $row_et->exType); }
if($rs_ex->num_rows()>0){ foreach($rs_ex->result() as$row_ex){ $con_co = array('coId'=>$row_ex->coId); $rs_co = $this->co->qryCoJoinCrs($con_co); $row_co = (isset($rs_co) && $rs_co!=NULL) ? $rs_co->row() : NULL; $k = 0; $con_es = array('esCoId'=>$row_ex->coId,'esExamType'=>$row_et->exType); $rs_es = $this->es->qryEs($con_es); if($rs_es->num_rows()>0){ foreach($rs_es->result() as$row_es){ $this->ps->prsId = $row_es->esPrsId; $qu_ps1 = $this->ps->get_by_key(); $row_ps1 = (isset($qu_ps1) && $qu_ps1!=NULL) ? $qu_ps1->row() : NULL; $ps_con = array('prsUsId'=>$row_ps1->prsUsId); $qu_ps2 = $this->ps->qryPrsJoinPPC($ps_con);
$row_ps2 = (isset($qu_ps2) && $qu_ps2!=NULL) ? $qu_ps2->row() : NULL; if($k == 0){ $officerNames = $row_ps2->name; }else{ $officerNames .= '<br>'.$row_ps2->name; } $k++; } $this->load->model($this->config->item("ppc_folder").'mo_spc_place','spc'); $con_rm = array('plHwId'=>$row_es->esRmId); $qu_rm = $this->spc->qryRm($con_rm); $row_rm = (isset($qu_rm) && $qu_rm!=NULL) ? $qu_rm->row() : NULL; $this->prd->prdId = $row_es->esPrdFrTime; $fr = $this->prd->get_by_key(); $this->prd->prdId = $row_es->esPrdToTime; $to = $this->prd->get_by_key(); $this->st->stId = $row_es->esStId; $qu_st = $this->st->get_by_key(); $row_st = (isset($qu_st) && $qu_st!=NULL) ? $qu_st->row() : NULL; $row_fr= (isset($fr) && $fr!=NULL) ? $fr->row() : NULL; $row_to= (isset($to) && $to!=NULL) ? $to->row() : NULL; $prStr = substr($row_fr->prdFrTime, 0, 5); $prStr .= ' - '.substr($row_to->prdToTime, 0, 5); } $ex .= "<tr onmouseover=\"bgColor='".$tr_color_even."'\" onmouseout=\"bgColor='".$this->config->item("rg_mouseout")."'\">"; $ex .= "<td height=\"22\" align=\"center\">".$row_co->crsCode."</td>"; $ex .= "<td class=\"indent\">".$row_co->crsName."</td>"; $ex .= "<td class=\"indent\">".$row_co->coSection."</td>"; $ex .= "<td class=\"indent\">".abbreDate2($row_es->esDate)."</td>"; $ex .= "<td class=\"indent\">".$prStr."</font></td>"; //$ex .= "<td class=\"indent\">".getval('plRmNo', $row_rm)." (".$row_st->stAbbrE.")</td>"; $ex .= "<td class=\"indent\">".getval('plRmNo', $row_rm)."</td>"; $ex .= "<td class=\"indent\">".$officerNames."</td>"; $i++; } } if($i == 0) { $ex .= "<tr> <td colspan=\"7\" align=\"center\"><br><span class=\"error\">** ไม่ปรากฏรายการตารางสอบในฐานข้อมูล **</span></td> </tr>"; } $ex .= "</table></td></tr><tr><td><span class=\"error\">** ข้อมูลที่ปรากฏในตารางสอบ คือ (C) บรรยาย, (L) ปฏิบัติ</span><br><br></td></tr>"; } $ex .= "</table>"; $tmp['tbexam'] = $ex; echo json_encode($tmp); $this->auto_render = FALSE; } } function showTeachHoursT(){ if ($this->input->server('REQUEST_METHOD') === 'POST') { $this->load->model($this->config->item("rg_folder").'mo_rg_person','prs'); $this->load->model($this->config->item("rg_folder").'mo_rg_termconfig','tmc'); $this->load->model($this->config->item("rg_folder").'mo_rg_term','tm'); $this->load->model($this->config->item("rg_folder").'mo_rg_studytype','st'); $this->load->model($this->config->item("rg_folder").'mo_rg_period','prd'); $this->load->model($this->config->item("rg_folder").'mo_rg_timetable','tt'); $this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co'); $this->load->model($this->config->item("rg_folder").'mo_rg_course','crs'); $this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur'); $rs_prd = $this->prd->qryPrd(); $num_prd = $rs_prd->num_rows(); $i=1; foreach($rs_prd->result() as $row_prd){ $prd_val[$row_prd->prdId] = $i; $i++; } $prd_range = $rs_prd->num_rows(); $prd_flip = array_flip($prd_val); $prsId = $this->input->post('prsId'); $acY = (($this->input->post('acY'))? $this->input->post('acY'):$this->session->userdata('acY')); $tmId = (($this->input->post('tmId'))? $this->input->post('tmId'):$this->session->userdata('tmId')); $this->contents['year'] = $acY; $this->contents['tmId'] = $tmId; $this->contents['tmc'] = $this->tmc->get_optionsGroupAcY('N',array('tmcAcY'=>'DESC')); $this->contents['tm'] = $this->tm->get_options('',array('tmName'=>''),'','N'); $prs_con = array('prsId'=>$prsId); $qu_prs = $this->prs->qryPrsJoinPPC($prs_con); $this->contents['prsId'] = $prsId; $this->contents['qu_prs'] = $qu_prs; $rs_st = $this->st->qrySt(); $this->contents['rs_st'] = $rs_st; $row_prs = (isset($qu_prs) && $qu_prs!=NULL) ? $qu_prs->row() : NULL; $rs_tt = $this->tt->RSrg_TimeTableByAcYAndSeAndOfIdGroupClIdOrderPgId($acY, $tmId, $prsId); $sum_all = 0; $arr_tt = array(); $i=0; if($rs_tt->num_rows()>0){ foreach($rs_tt->result() as$row_tt){ $this->co->coId = $row_tt->ttCoId; $qu_co = $this->co->get_by_key(); $row_co = ($qu_co->num_rows()>0) ? $qu_co->row() : NULL; $this->cur->curId = $row_co->coCurId; $qu_cur = $this->cur->get_by_key(); $row_cur = ($qu_cur->num_rows>0) ? $qu_cur->row() : NULL;
$this->crs->crsId = $row_co->coCrsId; $qu_crs = $this->crs->get_by_key(); $row_crs = ($qu_crs->num_rows>0) ? $qu_crs->row() : NULL; $arr_tt[$i]['cur'] = ((getval('curName', $row_cur)=="") ? 'เรียนรวมหลายหลักสูตร' : getval('curName', $row_cur)); $arr_tt[$i]['crsCode'] = getval('crsCode', $row_crs); $arr_tt[$i]['crsName'] = getval('crsName', $row_crs); $arr_tt[$i]['coSection'] = getval('coSection', $row_co); $arr_tt[$i]['coSyId'] = getval('coSyId', $row_co); $sum_row = 0; $sum_col = 0; foreach($rs_st->result() as$row_st){ $hour = 0; $con_tt2 = array('ttCoId'=>$row_tt->ttCoId,'ttPrsId'=>$prsId,'ttStId'=>$row_st->stId); $rs_hour = $this->tt->qryTtJoinCo($con_tt2); if($rs_hour->num_rows()>0){ foreach($rs_hour->result() as$row_hour){ $hour += ($prd_val[$row_hour->ttPrdToTime]-$prd_val[$row_hour->ttPrdFrTime])+1; } } $arr_tt[$i][$row_st->stId] = $hour; //echo "type = ".$row_st->stAbbrE." hour = ".$hour; $sum_row += $hour; } $arr_tt[$i]['sum'] = $sum_row; //echo "-->".$sum_row; $sum_all += $sum_row; $i++; } $this->contents['arr_tt'] = $arr_tt; $arr_sum = array(); foreach($rs_st->result() as$row_st){ $hour = 0; $con_tt2 = array('coAcY'=>$acY,'coTmId'=>$tmId,'ttPrsId'=>$prsId,'ttStId'=>$row_st->stId); $rs_hour = $this->tt->qryTtJoinCo($con_tt2); if($rs_hour->num_rows()>0){ foreach($rs_hour->result() as$row_hour){ $hour += ($prd_val[$row_hour->ttPrdToTime]-$prd_val[$row_hour->ttPrdFrTime])+1; } $arr_sum[$row_st->stId]=$hour; }else{ $arr_sum[$row_st->stId]=0; } } $this->contents['arr_sum'] = $arr_sum; $this->contents['sum_all'] = $sum_all; } $this->output_detail($this->config->item("rg_folder")."v_showTeachHoursT"); } } }
|