Viewing file: rpt_tt.php (32.56 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php include('rg_controller.php'); class Rpt_tt extends Rg_controller { function rptTt () { $this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur'); $this->load->model($this->config->item("rg_folder").'mo_rg_studyyear','sy'); $this->load->model($this->config->item("ppc_folder").'mo_spc_place','rm'); $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_person','prs'); $this->load->model($this->config->item("rg_folder").'mo_rg_course','crs'); $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_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_nostudydate','nsd'); $this->load->model($this->config->item("rg_folder").'mo_rg_studytype','st');
$view = $this->input->post('view'); $acY = $this->input->post('acY'); $curId = $this->input->post('curId'); $syId = $this->input->post('syId'); $ttRmId = $this->input->post('rmId'); $ttEtpMepId = $this->input->post('mepId'); $ttEtpSepId = $this->input->post('sepId'); $ttPrsId = $this->input->post('prsId'); $crsId = $this->input->post('crsId'); $ttCoId = $this->input->post('coId');
$title = ''; if ($view == "c") { $title = "หลักสูตร ";
$this->cur->curId = $curId; $qu_cur = $this->cur->get_by_key(); if ($qu_cur->num_rows()) { $title .= $qu_cur->row()->curName; } else { $title .= "เรียนรวมหลายหลักสูตร"; }
$this->sy->syId = $syId; $qu_sy = $this->sy->get_by_key(); if ($qu_sy->num_rows()) { $title .= " ชั้นปี ".$qu_sy->row()->syCode; } } else if ($view == "r") { $this->rm->plHwId = $ttRmId; $qu_rm = $this->rm->get_by_key(); if ($qu_rm->num_rows()) { $title = "ห้อง ".$qu_rm->row()->plRmNo; } } else if ($view == "p") { $this->mep->mepId = $ttEtpMepId; $qu_mep = $this->mep->get_by_key(); if ($qu_mep->num_rows()) { $title = "สถานที่ฝึกงาน ".$qu_mep->row()->mepName; }
$this->sep->sepId = $ttEtpSepId; $qu_sep = $this->sep->get_by_key(); if ($qu_sep->num_rows()) { $title .= " : ".$qu_sep->row()->sepName; } } else if ($view == "t") { $con_qu_prs = array('prsId' => $ttPrsId); $qu_prs = $this->prs->qryPrsJoinPPC($con_qu_prs); if ($qu_prs->num_rows()) { $title = "อ.".$qu_prs->row()->name; } } else if ($view == "s") { $this->crs->crsId = $crsId; $qu_crs = $this->crs->get_by_key(); if ($qu_crs->num_rows()) { $con_qu_co = array('coId' => $ttCoId); $qu_co = $this->co->qryCoJoinCur($con_qu_co); $row_co = $qu_co->num_rows() ? $qu_co->row() : NULL;
$title = (($ttCoId == '') ? "" : "หลักสูตร ".getval('curName', $row_co)." ")."รายวิชา ".$qu_crs->row()->crsCode." ".$qu_crs->row()->crsName.(($ttCoId == '') ? "" : " กลุ่ม ".getval('coSection', $row_co)); } } // end if view
$pgIdStr = ($curId=='NULL') ? 'NULL' : $curId;
$txml = ''; $sheet = 1; $con_rs_wd = array('wdAcY' => $acY); $ord_rs_wd = array('wdAcYWeekNo' => 'ASC'); $rs_wd = $this->wd->qryWdJoinTm($con_rs_wd, $ord_rs_wd); //RSrg_WeekDateByAcY($acadYear); foreach ($rs_wd->result() as $row_wd) { $txml .= "\t<Worksheet ss:Name=\"".$sheet."\">\n"; $txml .= "\t\t<Table>\n";
$rs_prd = $this->prd->qryPrd(); $numPr = $rs_prd->num_rows();
$txml .= "\t\t\t<Column ss:Index=\"2\" ss:AutoFitWidth=\"0\" ss:Width=\"90\" ss:Span=\"".($numPr-1)."\"/>\n"; $txml .= "\t\t\t<Row ss:Height=\"25\">\n"; $txml .= "\t\t\t\t<Cell ss:MergeAcross=\"".$numPr."\" ss:StyleID=\"noBorder\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', $title)."</Data></Cell>\n"; $txml .= "\t\t\t</Row>\n"; $txml .= "\t\t\t<Row ss:Height=\"25\">\n"; if ($view == "s") { $txml .= "\t\t\t\t<Cell ss:MergeAcross=\"".$numPr."\" ss:StyleID=\"noBorder\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', "ปีการศึกษา ".$acY)."</Data></Cell>\n"; } else { $txml .= "\t\t\t\t<Cell ss:MergeAcross=\"".$numPr."\" ss:StyleID=\"noBorder\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', "ภาคการศึกษา ".$row_wd->tmCode."/".$acY." สัปดาห์ที่ ".$row_wd->wdAcYWeekNo." (".abbreDate(splitDateDb2($row_wd->wdFrDate))." - ".abbreDate(splitDateDb2($row_wd->wdToDate)).")")."</Data></Cell>\n"; } $txml .= "\t\t\t</Row>\n"; $txml .= "\t\t\t<Row ss:Height=\"25\">\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"bold\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', "วัน/เวลา")."</Data></Cell>\n"; foreach ($rs_prd->result() as $row_prd) { $txml .= "\t\t\t\t<Cell ss:StyleID=\"bold\"><Data ss:Type=\"String\">".substr($row_prd->prdFrTime, 0, 5)."-".substr($row_prd->prdToTime, 0, 5)."</Data></Cell>\n"; } $txml .= "\t\t\t</Row>\n";
$rs_dy = $this->dy->qryDy(); foreach ($rs_dy->result() as $row_dy) { //เช็คว่าแต่ละวันมีวิชาหรือไม่ ถ้าไม่มีให้ข้ามไปวันต่อไป $con_qu_tt = array(); if ($view == "c") { $con_qu_tt = array('coAcY' => $acY, 'coCurId' => $pgIdStr, 'coSyId' => $syId, 'ttWdAcYWeekNo' => $row_wd->wdAcYWeekNo, 'ttDyId' => $row_dy->dyId ); //$num = $oTt->getCountJoinCo(); //GetCountIdByAcYAndPgIdStrAndStYAndAcYWeekNoAndDyId(); } else if ($view == "r") { $con_qu_tt = array('coAcY' => $acY, 'ttRmId' => $ttRmId, 'ttWdAcYWeekNo' => $row_wd->wdAcYWeekNo, 'ttDyId' => $row_dy->dyId ); //$num = $oTt->GetCountIdByAcYAndRmIdAndAcYWeekNoAndDyId($acadYear, $ttRmId, $oWd->wdAcYWeekNo, $oDy->dayId); } else if ($view == "p") { $con_qu_tt = array('coAcY' => $acY, 'ttEtpMepId' => $ttEtpMepId, 'ttEtpSepId' => $ttEtpSepId, 'ttWdAcYWeekNo' => $row_wd->wdAcYWeekNo, 'ttDyId' => $row_dy->dyId ); //$num = $oTt->GetCountIdByAcYAndEpMepIdAndEpSepIdAndAcYWeekNoAndDyId($acadYear, $ttEpMepId, $ttEpSepId, $oWd->wdAcYWeekNo, $oDy->dayId); } else if ($view == "t") { $con_qu_tt = array('coAcY' => $acY, 'ttPrsId' => $ttPrsId, 'ttWdAcYWeekNo' => $row_wd->wdAcYWeekNo, 'ttDyId' => $row_dy->dyId ); //$num = $oTt->GetCountIdByAcYAndOfIdAndAcYWeekNoAndDyId($acadYear, $ttOfId, $oWd->wdAcYWeekNo, $oDy->dayId); } else if ($view == "s") { if ($ttCoId == "") { $con_qu_tt = array('coAcY' => $acY, 'coCrsId' => $crsId, 'ttDyId' => $row_dy->dyId ); //$num = $oTt->GetCountIdByAcYAndCoIdAndDyId($acadYear, $coId, $oDy->dayId); } else { $this->co->coId = $ttCoId; $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); $con_qu_tt = array('coAcY' => $acY, 'coSection'=>$row_cco->coSection, 'coCurId'=>$cur, 'coCrsId' => $crsId, //'ttCoId' => $ttCoId, 'ttDyId' => $row_dy->dyId ); //$num = $oTt->GetCountIdByAcYAndCoIdAndClIdAndDyId($acadYear, $coId, $ttClId, $oDy->dayId); } } $num = $this->tt->getCountJoinCo($con_qu_tt);
//-[1]---ถ้ามีวิชาในแต่ละวัน if ($num > 0) { //นับจำนวนวิชาที่เวลาซ้อนกันมากที่สุด ตาม view เพื่อจะไป rowspan $maxOvl = 0; if ($view == "c") $maxOvl = $this->tt->GetMaxOVLByAcYAndPgIdStrAndStYAndAcYWeekNoAndDyId($acY, $pgIdStr, $syId, $row_wd->wdAcYWeekNo, $row_dy->dyId); if ($view == "r") $maxOvl = $this->tt->GetMaxOVLByAcYAndRmIdAndAcYWeekNoAndDyId($acY, $ttRmId, $row_wd->wdAcYWeekNo, $row_dy->dyId); if ($view == "p") $maxOvl = $this->tt->GetMaxOVLByAcYAndEpMepIdAndEpSepIdAndAcYWeekNoAndDyId($acY, $ttEtpMepId, $ttEtpSepId, $row_wd->wdAcYWeekNo, $row_dy->dyId); if ($view == "t") $maxOvl = $this->tt->GetMaxOVLByAcYAndOfIdAndAcYWeekNoAndDyId($acY, $ttPrsId, $row_wd->wdAcYWeekNo, $row_dy->dyId); if ($view == "s") { if ($ttCoId == ""){ $maxOvl = $this->tt->GetMaxOVLByAcYAndCoIdAndDyId($acY, $crsId, $row_dy->dyId); }else{ $this->co->coId = $ttCoId; $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); $maxOvl = $this->tt->GetMaxOVLByAcYAndCoIdAndClIdAndDyId2($acY, $crsId, $cur,$row_cco->coSection , $row_dy->dyId); } }
//-[2]---สร้างอะเรย์ขนาด maxOvl x $oPr->NumRow() เริ่มที่ [1][1] $aa = array(); for ($i = 1; $i <= $maxOvl; $i++) { for ($j = 1;$j <= $numPr; $j++) $aa[$i][$j] = 0; }
//-[3]---อ่านวิชาทั้งหมดในวันนี้ เรียงตาม id $ord_rs_tt = array('ttId' => 'ASC'); // if ($view == "c") { // //$oTt->RSrg_TimeTableByAcYAndPgIdStrAndStYAndAcYWeekNoAndDyIdOrderId(); // } else if ($view == "r") { // //$oTt->RSrg_TimeTableByAcYAndRmIdAndAcYWeekNoAndDyIdOrderId($acadYear, $ttRmId, $oWd->wdAcYWeekNo, $oDy->dayId); // } else if ($view == "p") { // //$oTt->RSrg_TimeTableByAcYAndEpMepIdAndEpSepIdAndAcYWeekNoAndDyIdOrderId($acadYear, $ttEpMepId, $ttEpSepId, $oWd->wdAcYWeekNo, $oDy->dayId); // } else if ($view == "t") { // //$oTt->RSrg_TimeTableByAcYAndOfIdAndAcYWeekNoAndDyIdOrderId($acadYear, $ttOfId, $oWd->wdAcYWeekNo, $oDy->dayId); // } else if ($view == "s") { // if ($ttClId == "") { // //$oTt->RSrg_TimeTableByAcYAndCoIdAndDyIdOrderId($acadYear, $coId, $oDy->dayId); // } else { // //$oTt->RSrg_TimeTableByAcYAndCoIdAndClIdAndDyIdOrderId($acadYear, $coId, $ttClId, $oDy->dayId); // } // } $rs_tt = $this->tt->qryTtJoinCo($con_qu_tt, $ord_rs_tt);
//-[4]---loop แต่ละวิชาเพื่อไป mark ในอะเรย์ โดยเริ่มจากแถวแรก ตามคาบ //-[4.1]---อ่านออกมาทีละวิชา foreach ($rs_tt->result() as $row_tt) { //-[4.2]---loop เท่ากับจำนวน maxOvl เริ่มจาก [1] for ($i = 1; $i <= $maxOvl; $i++) { //-[4.3]---ถ้า $aa จากตำแหน่ง ttFrPr ถึง ttToPr เป็น 0 แปลว่า ว่าง ให้ใส่ id ของวิชาลงไปแทน 0 $isEmpty = true; for ($z = $row_tt->ttPrdFrTime; $z <= $row_tt->ttPrdToTime; $z++) { if ($aa[$i][$z] <> 0) { $isEmpty = false; break; //ไปยัง for $i } }
if ($isEmpty) { for ($z = $row_tt->ttPrdFrTime; $z <= $row_tt->ttPrdToTime; $z++) { //-ใส่ id ของวิชาลงไปแทน 0 $aa[$i][$z] = $row_tt->ttId; } //-ออกจาก loop ไปเรคอร์ดต่อไป เนื่องจากว่าง break; //ไปยัง while } //$isEmpty } //-[4.2]---for $i } //-[4.1]---while
if ($view <> "s") { $nsdDate = futureDay($row_wd->wdFrDate, $row_dy->dyId - 1);
$con_rs_nsd = array('nsdDate' => $nsdDate); $rs_nsd = $this->nsd->qryNsd($con_rs_nsd); //RSrg_NoStudyDateByDate(); foreach ($rs_nsd->result() as $row_nsd) { for ($i = 1; $i <= $maxOvl; $i++) { for ($z = $row_nsd->nsdPrdFrTime; $z <= $row_nsd->nsdPrdToTime; $z++) $aa[$i][$z] = '-'.$row_nsd->nsdId; } } }
//-[5]---หมด 1 วัน ก็พิมพ์ 1 ครั้ง for ($rwovl = 1; $rwovl <= $maxOvl; $rwovl++) { $txml .= "\t\t\t<Row ss:Height=\"60\">\n";
//-พิมพ์หัวแถว if ($rwovl==1) { $txml .= "\t\t\t\t<Cell ss:MergeDown=\"".($maxOvl-1)."\" ss:StyleID=\"bold\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', $row_dy->dyName)."</Data></Cell>\n"; }
//-พิมพ์รายละเอียดในแต่ละแถว for ($prd = 1; $prd <= $numPr; $prd++) { if ($aa[$rwovl][$prd] == 0) { $txml .= "\t\t\t\t<Cell ss:Index=\"".($prd+1)."\" ss:StyleID=\"center\"/>\n"; } else if ($aa[$rwovl][$prd] < 0) { $this->nsd->nsdId = substr($aa[$rwovl][$prd], 1); $qu_nsd = $this->nsd->get_by_key(); $row_nsd = $qu_nsd->row();
$nprd = $row_nsd->nsdPrdToTime - $row_nsd->nsdPrdFrTime +1;
if ($rwovl == 1) { $txml .= "\t\t\t\t<Cell ss:Index=\"".($prd+1)."\" ss:MergeAcross=\"".($nprd-1)."\" ss:MergeDown=\"".(count($aa)-1)."\" ss:StyleID=\"center\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', $row_nsd->nsdName)."</Data></Cell>\n"; }
$prd += $nprd-1; } else { $this->tt->ttId = $aa[$rwovl][$prd]; $qu_tt = $this->tt->get_by_key(); $row_tt = $qu_tt->row();
$con_qu_co = array('coId' => $row_tt->ttCoId); $qu_co = $this->co->qryCoJoinCrs($con_qu_co); $row_co = $qu_co->row();
$this->st->stId = $row_tt->ttStId; $qu_st = $this->st->get_by_key(); $row_st = $qu_st->row();
$this->rm->plHwId = $row_tt->ttRmId; $qu_rm = $this->rm->get_by_key(); $row_rm = $qu_rm->num_rows() ? $qu_rm->row() : NULL;
$this->mep->mepId = $row_tt->ttEtpMepId; $qu_mep = $this->mep->get_by_key(); $row_mep = $qu_mep->num_rows() ? $qu_mep->row() : NULL;
$this->sep->sepId = $row_tt->ttEtpSepId; $qu_sep = $this->sep->get_by_key(); $row_sep = $qu_sep->num_rows() ? $qu_sep->row() : NULL;
$con_qu_prs = array('prsId' => $row_tt->ttPrsId); $qu_prs = $this->prs->qryPrsJoinPPC($con_qu_prs); $row_prs = $qu_prs->row();
$nprd = $row_tt->ttPrdToTime - $row_tt->ttPrdFrTime +1;
$txml .= "\t\t\t\t<Cell ss:Index=\"".($prd+1)."\" ss:MergeAcross=\"".($nprd-1)."\" ss:StyleID=\"center\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', $row_co->crsCode." (".$row_co->coSection.")(".$row_st->stAbbrE.") "); if ($view == "c") $txml .= iconv('UTF-8', 'TIS-620//TRANSLIT', (is_null($row_tt->ttRmId)) ? $row_mep->mepName.':'.$row_sep->sepName.' อ.'.$row_prs->name : 'ห้อง '.$row_rm->plRmNo.' อ.'.$row_prs->name); if ($view == "r") $txml .= iconv('UTF-8', 'TIS-620//TRANSLIT', 'อ.'.$row_prs->name); if ($view == "p") $txml .= iconv('UTF-8', 'TIS-620//TRANSLIT', 'อ.'.$row_prs->name); if ($view == "t") $txml .= iconv('UTF-8', 'TIS-620//TRANSLIT', (is_null($row_tt->ttRmId)) ? $row_mep->mepName.':'.$row_sep->sepName : 'ห้อง '.$row_rm->plRmNo); if ($view == "s") $txml .= iconv('UTF-8', 'TIS-620//TRANSLIT', (is_null($row_tt->ttRmId)) ? getval('mepName', $row_mep).':'.getval('sepName', $row_sep).' อ.'.$row_prs->name.' สัปดาห์ที่ '.$row_tt->ttWdAcYWeekNo : 'ห้อง '.getval('plRmNo', $row_rm).' อ.'.$row_prs->name.' สัปดาห์ที่ '.$row_tt->ttWdAcYWeekNo); $txml .= "</Data></Cell>\n";
$prd += $nprd-1; } // end if } // end for $prd
$txml .= "\t\t\t</Row>\n"; } //-[5]--- } else { //ถ้าใน วัน ไม่มีวิชาเลย ให้แสดงเฉพาะคอลัมน์แรก $txml .= "\t\t\t<Row ss:Height=\"25\">\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"bold\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', $row_dy->dyName)."</Data></Cell>\n"; $nsdDate = futureDay($row_wd->wdFrDate, $row_dy->dyId - 1);
for ($c = 1; $c <= $numPr; $c++) { if($view == "s") { $txml .= "\t\t\t\t<Cell ss:StyleID=\"center\"/>\n"; } else { $con_rs_nsd = array('nsdDate' => $nsdDate, 'nsdPrdFrTime' => $c ); $rs_nsd = $this->nsd->qryNsd($con_rs_nsd); //RSrg_NoStudyDateByDateAndFrPr(); if ($rs_nsd->num_rows()) { $row_nsd = $rs_nsd->row(); $nprd = $row_nsd->nsdPrdToTime - $row_nsd->nsdPrdFrTime +1;
$txml .= "\t\t\t\t<Cell ss:MergeAcross=\"".($nprd-1)."\" ss:StyleID=\"center\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', $row_nsd->nsdName)."</Data></Cell>\n";
$c += $nprd-1; } else { $txml .= "\t\t\t\t<Cell ss:StyleID=\"center\"/>\n"; } // end if } // end if } // for $c $txml .= "\t\t\t</Row>\n"; } //-[1]---if $num==0 } // end foreach rs_dy
$i = 0; $rs_nsd = $this->nsd->qryNsdBetweenDateOrdNsdDateAndNsdPrdFrTime($row_wd->wdFrDate, $row_wd->wdToDate); //RSrg_NoStudyDateByBetweenDateOrderDateFrPr(); foreach ($rs_nsd->result() as $row_nsd) { $this->prd->prdId = $row_nsd->nsdPrdFrTime; $qu_prd = $this->prd->get_by_key(); $row_prd = $qu_prd->row(); $prStr = substr($row_prd->prdFrTime, 0, 5);
$this->prd->prdId = $row_nsd->nsdPrdToTime; $qu_prd = $this->prd->get_by_key(); $row_prd = $qu_prd->row(); $prStr .= ' - '.substr($row_prd->prdToTime, 0, 5);
$txml .= "\t\t\t<Row ss:Height=\"25\">\n"; if ($i == 0) { $txml .= "\t\t\t\t<Cell ss:StyleID=\"noBorder\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', "หมายเหตุ")."</Data></Cell>\n"; } $txml .= "\t\t\t\t<Cell ss:Index=\"2\" ss:MergeAcross=\"".($numPr-1)."\" ss:StyleID=\"left\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', abbreDate(splitDateDb2($row_nsd->nsdDate)).' เวลา '.$prStr.' น. '.$row_nsd->nsdName.' '.$row_nsd->nsdRemark)."</Data></Cell>\n"; $txml .= "\t\t\t</Row>\n";
$i++; }
$txml .= "\t\t</Table>\n"; $txml .= "\t</Worksheet>\n";
$sheet++;
if($view == "s") break; } // end foreach rs_wd
$data['txml'] = $txml;
$this->load->view($this->config->item("rg_folder")."v_rptTt", $data); }
function rptTt2 () { $this->load->model($this->config->item("rg_folder").'mo_rg_course','crs'); $this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co'); $this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur'); $this->load->model($this->config->item("rg_folder").'mo_rg_studyyear','sy'); $this->load->model($this->config->item("rg_folder").'mo_rg_term','tm'); $this->load->model($this->config->item("rg_folder").'mo_rg_person','prs'); $this->load->model($this->config->item("rg_folder").'mo_rg_timetable','tt'); $this->load->model($this->config->item("rg_folder").'mo_rg_period','prd'); $this->load->model($this->config->item("rg_folder").'mo_rg_weekdate','wd'); $this->load->model($this->config->item("ppc_folder").'mo_spc_place','rm'); $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_studytype','st');
$crsId = $this->input->post('crsId'); $acY = $this->input->post('acY');
$this->crs->crsId = $crsId; $qu_crs = $this->crs->get_by_key(); $row_crs = $qu_crs->num_rows() ? $qu_crs->row() : NULL;
$txml = ''; $con_rs_co = array('coAcY' => $acY, 'coCrsId' => $crsId ); $ord_rs_co = array('CAST(coSection AS SIGNED)' => 'ASC'); $rs_co = $this->co->qryCo($con_rs_co, $ord_rs_co); foreach ($rs_co->result() as $row_co) { $this->cur->curId = $row_co->coCurId; $qu_cur = $this->cur->get_by_key(); $row_cur = $qu_cur->num_rows() ? $qu_cur->row() : NULL;
$this->sy->syId = $row_co->coSyId; $qu_sy = $this->sy->get_by_key(); $row_sy = $qu_sy->row();
$this->tm->tmId = $row_co->coTmId; $qu_tm = $this->tm->get_by_key(); $row_tm = $qu_tm->row();
$con_qu_prs = array('prsId' => $row_co->coPrsId); $qu_prs = $this->prs->qryPrsJoinPPC($con_qu_prs); $row_prs = $qu_prs->num_rows() ? $qu_prs->row() : NULL; //iconv("UTF-8", "ISO-8859-1//TRANSLIT", $text) //iconv("UTF-8", "ISO-8859-1//IGNORE", $text) //$txml .= "\t<Worksheet ss:Name=\"".iconv('UTF-8', 'TIS-620//TRANSLIT', $row_co->coSection."(".substr((is_null($row_co->coCurId) ? "เรียนรวมหลายหลักสูตร" : getval('curAbbr', $row_cur)), 0, 20)." ปี".$row_sy->syCode.")")."\">\n"; // edit 11/2/2556 sitthichai $txml .= "\t<Worksheet ss:Name=\"".iconv('UTF-8', 'TIS-620//TRANSLIT', $row_co->coSection."(".(is_null($row_co->coCurId) ? "เรียนรวมหลายหลักสูตร" : getval('curAbbr', $row_cur))." ปี".$row_sy->syCode.")")."\">\n"; $txml .= "\t\t<Table>\n"; $txml .= "\t\t\t<Column ss:AutoFitWidth=\"0\" ss:Width=\"20\"/>\n"; $txml .= "\t\t\t<Column ss:AutoFitWidth=\"0\" ss:Width=\"60\"/>\n"; $txml .= "\t\t\t<Column ss:AutoFitWidth=\"0\" ss:Width=\"60\"/>\n"; $txml .= "\t\t\t<Column ss:AutoFitWidth=\"0\" ss:Width=\"180\"/>\n"; $txml .= "\t\t\t<Column ss:AutoFitWidth=\"0\" ss:Width=\"60\"/>\n"; $txml .= "\t\t\t<Column ss:AutoFitWidth=\"0\" ss:Width=\"60\"/>\n"; $txml .= "\t\t\t<Row ss:Height=\"25\">\n"; $txml .= "\t\t\t\t<Cell ss:MergeAcross=\"6\" ss:StyleID=\"noBorder\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', "หลักสูตร ".(is_null($row_co->coCurId) ? "เรียนรวมหลายหลักสูตร" : getval('curName', $row_cur))." ชั้นปี ".$row_sy->syCode)."</Data></Cell>\n"; $txml .= "\t\t\t</Row>\n"; $txml .= "\t\t\t<Row ss:Height=\"25\">\n"; $txml .= "\t\t\t\t<Cell ss:MergeAcross=\"6\" ss:StyleID=\"noBorder\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', "รายวิชา ".$row_crs->crsCode." ".$row_crs->crsName." ".$row_crs->crsUnit." กลุ่ม ".$row_co->coSection." ภาคการศึกษา ".$row_tm->tmCode."/".$row_co->coAcY)."</Data></Cell>\n"; $txml .= "\t\t\t</Row>\n"; $txml .= "\t\t\t<Row ss:Height=\"25\">\n"; $txml .= "\t\t\t\t<Cell ss:MergeAcross=\"6\" ss:StyleID=\"noBorder\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', "อาจารย์ผู้รับผิดชอบส่งเกรด อาจารย์".(is_null($row_co->coPrsId) ? "" : getval('name', $row_prs)))."</Data></Cell>\n"; $txml .= "\t\t\t</Row>\n"; $txml .= "\t\t\t<Row ss:Height=\"25\">\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"bold\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', "ที่")."</Data></Cell>\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"bold\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', "วันเดือนปี")."</Data></Cell>\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"bold\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', "เวลา")."</Data></Cell>\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"bold\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', "บท/เรื่อง/หัวข้อสอน")."</Data></Cell>\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"bold\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', "อาจารย์")."</Data></Cell>\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"bold\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', "ห้อง")."</Data></Cell>\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"bold\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', "หมายเหตุ")."</Data></Cell>\n"; $txml .= "\t\t\t</Row>\n";
$i = 1; $rs_tt = $this->tt->qryTtByCoIdGroupAllOrderAcYWeekNoDyIdFrPr($row_co->coId); foreach ($rs_tt->result() as $row_tt1) { $this->prd->prdId = $row_tt1->ttPrdFrTime; $qu_prd = $this->prd->get_by_key(); $row_prd1 = $qu_prd->row();
$this->prd->prdId = $row_tt1->ttPrdToTime; $qu_prd = $this->prd->get_by_key(); $row_prd2 = $qu_prd->row();
$this->wd->wdAcY = $row_co->coAcY; $this->wd->wdAcYWeekNo = $row_tt1->ttWdAcYWeekNo; $qu_wd = $this->wd->get_by_key(); $row_wd = $qu_wd->row();
$this->rm->plHwId = $row_tt1->ttRmId; $qu_rm = $this->rm->get_by_key(); $row_rm = $qu_rm->num_rows() ? $qu_rm->row() : NULL;
$this->mep->mepId = $row_tt1->ttEtpMepId; $qu_mep = $this->mep->get_by_key(); $row_mep = $qu_mep->num_rows() ? $qu_mep->row() : NULL;
$this->sep->sepId = $row_tt1->ttEtpSepId; $qu_sep = $this->sep->get_by_key(); $row_sep = $qu_sep->num_rows() ? $qu_sep->row() : NULL;
$this->st->stId = $row_tt1->ttStId; $qu_st = $this->st->get_by_key(); $row_st = $qu_st->row();
$txml .= "\t\t\t<Row ss:Height=\"".(($row_tt1->ttPrsId==1) ? 50 : 25*$row_tt1->ttPrsId)."\">\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"center\"><Data ss:Type=\"Number\">".$i."</Data></Cell>\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"left\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', abbreDate(splitDateDb2(futureDay($row_wd->wdFrDate, $row_tt1->ttDyId - 1))))."</Data></Cell>\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"center\"><Data ss:Type=\"String\">".substr($row_prd1->prdFrTime, 0, 5)."-".substr($row_prd2->prdToTime, 0, 5)."</Data></Cell>\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"left\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', $row_tt1->ttTitle)."</Data></Cell>\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"left\"><Data ss:Type=\"String\">"; $k = 1; $rs_tt = $this->tt->qryTtByAll($row_co->coId, $row_tt1->ttRmId, $row_tt1->ttEtpMepId, $row_tt1->ttEtpSepId, $row_tt1->ttWdAcYWeekNo, $row_tt1->ttDyId, $row_tt1->ttPrdFrTime, $row_tt1->ttPrdToTime, $row_tt1->ttStId, $row_tt1->ttTitle); foreach ($rs_tt->result() as $row_tt2) { $con_qu_prs = array('prsId' => $row_tt2->ttPrsId); $qu_prs = $this->prs->qryPrsJoinPPC($con_qu_prs); $row_prs = $qu_prs->row();
if ($k > 1) $txml .= " ";
$txml .= iconv('UTF-8', 'TIS-620//TRANSLIT', $row_prs->name);
$k++; } // end foreach row_tt2 $txml .= "</Data></Cell>\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"left\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', (is_null($row_tt1->ttRmId) ? getval('mepName', $row_mep).":".getval('sepName', $row_sep) : getval('plRmNo', $row_rm)))."</Data></Cell>\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"left\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', $row_st->stName)."</Data></Cell>\n"; $txml .= "\t\t\t</Row>\n";
$i++; }
$txml .= "\t\t</Table>\n"; $txml .= "\t\t<WorksheetOptions xmlns=\"urn:schemas-microsoft-com:office:excel\">\n"; $txml .= "\t\t\t<PageSetup>\n"; $txml .= "\t\t\t\t<Layout x:CenterHorizontal=\"1\"/>\n"; $txml .= "\t\t\t\t<PageMargins x:Bottom=\"0.8\" x:Left=\"0.5\" x:Right=\"0.5\" x:Top=\"0.8\"/>\n"; $txml .= "\t\t\t</PageSetup>\n"; $txml .= "\t\t</WorksheetOptions>\n"; $txml .= "\t</Worksheet>\n"; } // end foreach rs_co
$txml .= "\t<Worksheet ss:Name=\"".iconv('UTF-8', 'TIS-620//TRANSLIT', "รวม")."\">\n"; $txml .= "\t\t<Table>\n"; $txml .= "\t\t\t<Column ss:AutoFitWidth=\"0\" ss:Width=\"20\"/>\n"; $txml .= "\t\t\t<Column ss:AutoFitWidth=\"0\" ss:Width=\"60\"/>\n"; $txml .= "\t\t\t<Column ss:AutoFitWidth=\"0\" ss:Width=\"60\"/>\n"; $txml .= "\t\t\t<Column ss:AutoFitWidth=\"0\" ss:Width=\"180\"/>\n"; $txml .= "\t\t\t<Column ss:AutoFitWidth=\"0\" ss:Width=\"60\"/>\n"; $txml .= "\t\t\t<Column ss:AutoFitWidth=\"0\" ss:Width=\"60\"/>\n"; $txml .= "\t\t\t<Row ss:Height=\"25\">\n"; $txml .= "\t\t\t\t<Cell ss:MergeAcross=\"6\" ss:StyleID=\"noBorder\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', "รายวิชา ".getval('crsCode', $row_crs)." ".getval('crsName', $row_crs)." ".getval('crsUnit', $row_crs)." ปีการศึกษา ".$acY)."</Data></Cell>\n"; $txml .= "\t\t\t</Row>\n"; $txml .= "\t\t\t<Row ss:Height=\"25\">\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"bold\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', "ที่")."</Data></Cell>\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"bold\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', "วันเดือนปี")."</Data></Cell>\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"bold\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', "เวลา")."</Data></Cell>\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"bold\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', "บท/เรื่อง/หัวข้อสอน")."</Data></Cell>\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"bold\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', "อาจารย์")."</Data></Cell>\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"bold\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', "ห้อง")."</Data></Cell>\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"bold\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', "หมายเหตุ")."</Data></Cell>\n"; $txml .= "\t\t\t</Row>\n";
$i = 1; $rs_tt = $this->tt->qryTtByAcYCrsIdGroupAllOrderAcYWeekNoDyIdFrPr($acY, $crsId); foreach ($rs_tt->result() as $row_tt1) { $this->co->coId = $row_tt1->ttCoId; $qu_co = $this->co->get_by_key(); $row_co = $qu_co->num_rows() ? $qu_co->row() : NULL;
$this->prd->prdId = $row_tt1->ttPrdFrTime; $qu_prd = $this->prd->get_by_key(); $row_prd1 = $qu_prd->row();
$this->prd->prdId = $row_tt1->ttPrdToTime; $qu_prd = $this->prd->get_by_key(); $row_prd2 = $qu_prd->row();
$this->wd->wdAcY = $row_co->coAcY; $this->wd->wdAcYWeekNo = $row_tt1->ttWdAcYWeekNo; $qu_wd = $this->wd->get_by_key(); $row_wd = $qu_wd->row();
$this->rm->plHwId = $row_tt1->ttRmId; $qu_rm = $this->rm->get_by_key(); $row_rm = $qu_rm->num_rows() ? $qu_rm->row() : NULL;
$this->mep->mepId = $row_tt1->ttEtpMepId; $qu_mep = $this->mep->get_by_key(); $row_mep = $qu_mep->num_rows() ? $qu_mep->row() : NULL;
$this->sep->sepId = $row_tt1->ttEtpSepId; $qu_sep = $this->sep->get_by_key(); $row_sep = $qu_sep->num_rows() ? $qu_sep->row() : NULL;
$this->st->stId = $row_tt1->ttStId; $qu_st = $this->st->get_by_key(); $row_st = $qu_st->row();
$txml .= "\t\t\t<Row ss:Height=\"".(($row_tt1->ttPrsId==1) ? 50 : 25*$row_tt1->ttPrsId)."\">\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"center\"><Data ss:Type=\"Number\">".$i."</Data></Cell>\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"left\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', abbreDate(splitDateDb2(futureDay($row_wd->wdFrDate, $row_tt1->ttDyId - 1))))."</Data></Cell>\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"center\"><Data ss:Type=\"String\">".substr($row_prd1->prdFrTime, 0, 5)."-".substr($row_prd2->prdToTime, 0, 5)."</Data></Cell>\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"left\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', $row_tt1->ttTitle)."</Data></Cell>\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"left\"><Data ss:Type=\"String\">"; $k = 1; $rs_tt = $this->tt->qryTtByAll($row_tt1->ttCoId, $row_tt1->ttRmId, $row_tt1->ttEtpMepId, $row_tt1->ttEtpSepId, $row_tt1->ttWdAcYWeekNo, $row_tt1->ttDyId, $row_tt1->ttPrdFrTime, $row_tt1->ttPrdToTime, $row_tt1->ttStId, $row_tt1->ttTitle); foreach ($rs_tt->result() as $row_tt2) { $con_qu_prs = array('prsId' => $row_tt2->ttPrsId); $qu_prs = $this->prs->qryPrsJoinPPC($con_qu_prs); $row_prs = $qu_prs->row();
if ($k > 1) $txml .= " ";
$txml .= iconv('UTF-8', 'TIS-620//TRANSLIT', $row_prs->name);
$k++; } $txml .= "</Data></Cell>\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"left\"><Data ss:Type=\"String\">".(is_null($row_tt1->ttRmId) ? getval('mepName', $row_mep).":".getval('sepName', $row_sep) : getval('plRmNo', $row_rm))."</Data></Cell>\n"; $txml .= "\t\t\t\t<Cell ss:StyleID=\"left\"><Data ss:Type=\"String\">".iconv('UTF-8', 'TIS-620//TRANSLIT', $row_st->stName." กลุ่ม ".$row_co->coSection)."</Data></Cell>\n"; $txml .= "\t\t\t</Row>\n";
$i++; } $txml .= "\t\t</Table>\n"; $txml .= "\t\t<WorksheetOptions xmlns=\"urn:schemas-microsoft-com:office:excel\">\n"; $txml .= "\t\t\t<PageSetup>\n"; $txml .= "\t\t\t\t<Layout x:CenterHorizontal=\"1\"/>\n"; $txml .= "\t\t\t\t<PageMargins x:Bottom=\"0.8\" x:Left=\"0.5\" x:Right=\"0.5\" x:Top=\"0.8\"/>\n"; $txml .= "\t\t\t</PageSetup>\n"; $txml .= "\t\t</WorksheetOptions>\n"; $txml .= "\t</Worksheet>\n";
$data['txml'] = $txml;
$this->load->view($this->config->item("rg_folder")."v_rptTt2", $data); } } ?>
|