Viewing file: grade.php (70.45 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php include("rg_controller.php"); class grade extends Rg_controller {
protected $sess_prsUsId; protected $sess_prsItId;
function __construct() { parent::__construct(); if(strpos($this->config->item('rg_wg_grade'), $this->session->userdata('UsWgID')) === false) { redirect("logout"); }
$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 showCrsSendGrd() { $this->load->model($this->config->item("rg_folder").'mo_rg_termconfig','tmc'); $this->load->model($this->config->item("rg_folder").'mo_rg_term','tm');
$acY = $this->session->userdata('acY'); $tmId = $this->session->userdata('tmId');
$this->contents['acY'] = $acY; $this->contents['tmId'] = $tmId; $this->contents['view'] = 's'; if (!isset($this->contents['tc'])) { $this->contents['tc'] = ''; }
/* $grp_rs_tmc เก็บตัวแปร array ที่ใช้ในส่วนของ group by */ $this->contents['rs_tmc'] = $this->tmc->get_optionsGroupAcY('');
/* $ord_rs_tm เก็บตัวแปร array ที่ใช้ในส่วนของ order by */ $ord_rs_tm = array('tmName' => 'ASC'); $this->contents['rs_tm'] = $this->tm->get_options('', $ord_rs_tm);
$this->output($this->config->item("rg_folder")."v_showCourseSendGrade"); }
function tc_showCrsSendGrd() { $this->load->model($this->config->item("rg_folder").'mo_rg_person','prs'); $this->load->model($this->config->item("rg_folder").'mo_rg_acadconfig','ac'); $this->load->model($this->config->item("rg_folder").'mo_rg_schedule','sd'); $this->load->model($this->config->item("rg_folder").'mo_rg_termconfig','tmc'); $this->load->model($this->config->item("rg_folder").'mo_rg_term','tm');
$personId = $this->session->userdata('UsPsCode'); $acY_R = $this->session->userdata('acY_R'); $tmId_R = $this->session->userdata('tmId_R');
$con_qu_prs = array('prsUsId' => $this->sess_prsUsId, 'prsItId' => $this->sess_prsItId); $qu_prs = $this->prs->qryPrs($con_qu_prs);
if ($qu_prs->num_rows()) { $this->contents['tc'] = 'tc_';
$qu_ac = $this->ac->qryAc();
$qu_sd = $this->sd->qrySdByAcYTmIdSendGrDate($acY_R, $tmId_R, getNowDate()); if (($qu_ac->row()->acNoLockT == 'T') || $qu_sd->num_rows()) { } else { $this->contents['err_msg'] = "ไม่สามารถดำเนินการส่งเกรดได้<br />เนื่องจากไม่อยู่ในช่วงส่งเกรด"; }
$this->showCrsSendGrd(); } else { $msg = "ท่านไม่มีสิทธิ์ในเมนูนี้"; $this->session->set_flashdata('msg', $msg); redirect($this->config->item("rg_folder")."msg/err_msg"); } }
function showCrs($acY, $tmId, $view) { $this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd'); $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_courseopenfor','cof'); $this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur'); $this->load->model($this->config->item("rg_folder").'mo_rg_config','cfg');
$data['tc'] = ''; $data['flagSendGr'] = 1; $i = 0; $arr = array(); if ($view == 's') { $rs_rd = $this->rd->qryRdByAcYTmIdGroupCurIdSyIdCrsId($acY, $tmId); } else { $rs_rd = $this->rd->qryRdByAcYTmIdGroupCoId($acY, $tmId); }
foreach ($rs_rd->result() as $row_rd) { $clIdStr = ''; $sumEnrollSeat = 0; $flagSomeSend = 0; $flagAllSend = 1; $this->co->coId = $row_rd->rdCoId; $qu_co = $this->co->get_by_key(); $row_co1 = $qu_co->row();
if ($view == 's') { $k = 0; $ord_rs_co = array('CAST(coSection AS SIGNED)' => 'ASC'); if (is_null($row_co1->coCurId)) { $con_rs_co = array('coCurId' => 'NULL', 'coAcY' => $row_co1->coAcY, 'coSyId' => $row_co1->coSyId, 'coTmId' => $row_co1->coTmId, 'coCrsId' => $row_co1->coCrsId ); $rs_co = $this->co->qryCo($con_rs_co, $ord_rs_co); } else { $con_rs_co = array('coCurId' => $row_co1->coCurId, 'coAcY' => $row_co1->coAcY, 'coSyId' => $row_co1->coSyId, 'coTmId' => $row_co1->coTmId, 'coCrsId' => $row_co1->coCrsId ); $rs_co = $this->co->qryCo($con_rs_co, $ord_rs_co); } foreach ($rs_co->result() as $row_co2) { if ($k == 0) { $clIdStr .= $row_co2->coId; } else { $clIdStr .= ','.$row_co2->coId; } $sumEnrollSeat += $row_co2->coNumSeatReg; if ($row_co2->coSendGradeStatus == 'Y') { $flagSomeSend = 1; } else { $flagAllSend = 0; }
$k++; } } else { $clIdStr = $row_rd->rdCoId; }
// หาหลักสูตรที่เรียนรายวิชานี้ $pgNames = ''; if (is_null($row_co1->coCurId)) { $k = 0; $con_rs_cof = array('cofCoId' => $row_co1->coId); $rs_cof = $this->cof->qryCof($con_rs_cof); foreach ($rs_cof->result() as $row_cof) { $this->cur->curId = $row_cof->cofCurId; $qu_cur = $this->cur->get_by_key(); if ($k == 0) { $pgNames = $qu_cur->row()->curName; } else { $pgNames .= '<br /> '.$qu_cur->row()->curName; }
$k++; } } else { $this->cur->curId = $row_co1->coCurId; $qu_cur = $this->cur->get_by_key();
$pgNames = $qu_cur->row()->curName; }
$this->crs->crsId = $row_co1->coCrsId;
$arr[$i]['view'] = $view; $arr[$i]['crs'] = $this->crs->get_by_key(); $arr[$i]['co'] = $this->co->get_by_key(); $arr[$i]['pgNames'] = $pgNames; $arr[$i]['clIdStr'] = $clIdStr; $arr[$i]['sumEnrollSeat'] = $sumEnrollSeat; $arr[$i]['flagSomeSend'] = $flagSomeSend; $arr[$i]['flagAllSend'] = $flagAllSend;
$i++; }
$data['rs'] = $arr; $data['qu_cfg'] = $this->cfg->qryCfg();
echo $this->load->view($this->config->item("rg_folder")."v_showCourseSendGradeRow", $data, TRUE); }
function tc_showCrs($acY, $tmId, $view) { $this->load->model($this->config->item("rg_folder").'mo_rg_acadconfig','ac'); $this->load->model($this->config->item("rg_folder").'mo_rg_schedule','sd'); $this->load->model($this->config->item("rg_folder").'mo_rg_person','prs'); $this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd'); $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_courseopenfor','cof'); $this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur'); $this->load->model($this->config->item("rg_folder").'mo_rg_config','cfg');
$acY_R = $this->session->userdata('acY_R'); $tmId_R = $this->session->userdata('tmId_R'); $personId = $this->session->userdata('UsPsCode');
$data['tc'] = 'tc_';
$qu_ac = $this->ac->qryAc();
$qu_sd = $this->sd->qrySdByAcYTmIdSendGrDate($acY_R, $tmId_R, getNowDate()); if (($qu_ac->row()->acNoLockT == 'T') || $qu_sd->num_rows()) { $data['flagSendGr'] = 1; } else { $data['flagSendGr'] = 0; }
$con_qu_prs = array('prsUsId' => $this->sess_prsUsId, 'prsItId' => $this->sess_prsItId); $qu_prs = $this->prs->qryPrs($con_qu_prs); $row_prs = $qu_prs->row();
$i = 0; $arr = array(); if ($view == 's') { $rs_rd = $this->rd->qryRdByAcYTmIdGroupCurIdSyIdCrsId($acY, $tmId); } else { $rs_rd = $this->rd->qryRdByAcYTmIdGroupCoId($acY, $tmId); }
foreach ($rs_rd->result() as $row_rd) { $clIdStr = ''; $sumEnrollSeat = 0; $flagSomeSend = 0; $flagAllSend = 1; $this->co->coId = $row_rd->rdCoId; $qu_co = $this->co->get_by_key(); $row_co1 = $qu_co->row();
if ($view == 's') { $k = 0; $ord_rs_co = array('CAST(coSection AS SIGNED)' => 'ASC'); if (is_null($row_co1->coCurId)) { $con_rs_co = array('coCurId' => 'NULL', 'coAcY' => $row_co1->coAcY, 'coSyId' => $row_co1->coSyId, 'coTmId' => $row_co1->coTmId, 'coCrsId' => $row_co1->coCrsId ); $rs_co = $this->co->qryCo($con_rs_co, $ord_rs_co); } else { $con_rs_co = array('coCurId' => $row_co1->coCurId, 'coAcY' => $row_co1->coAcY, 'coSyId' => $row_co1->coSyId, 'coTmId' => $row_co1->coTmId, 'coCrsId' => $row_co1->coCrsId ); $rs_co = $this->co->qryCo($con_rs_co, $ord_rs_co); }
foreach ($rs_co->result() as $row_co2) { if ($k == 0) { $clIdStr .= $row_co2->coId; } else { $clIdStr .= ','.$row_co2->coId; } $sumEnrollSeat += $row_co2->coNumSeatReg; if ($row_co2->coSendGradeStatus == 'Y') { $flagSomeSend = 1; } else { $flagAllSend = 0; }
$k++; } } else { $clIdStr = $row_rd->rdCoId; }
$flagIsNull = 0; $rs_co = $this->co->qryCoByClIdStrPrsIdIsNull($clIdStr); if ($rs_co->num_rows()) { $flagIsNull = 1; }
$flagNotOfId = 0; $rs_co = $this->co->qryCoByClIdStrNotPrsId($clIdStr, $row_prs->prsId); if ($rs_co->num_rows()) { $flagNotOfId = 1; }
if (!$flagIsNull && !$flagNotOfId) { // หาหลักสูตรที่เรียนรายวิชานี้ if (is_null($row_co1->coCurId)) { $k = 0; $con_rs_cof = array('cofCoId' => $row_co1->coId); $rs_cof = $this->cof->qryCof($con_rs_cof); foreach ($rs_cof->result() as $row_cof) { $this->cur->curId = $row_cof->cofCurId; $qu_cur = $this->cur->get_by_key(); if ($k == 0) { $pgNames = $qu_cur->row()->curName; } else { $pgNames .= '<br /> '.$qu_cur->row()->curName; }
$k++; } } else { $this->cur->curId = $row_co1->coCurId; $qu_cur = $this->cur->get_by_key();
$pgNames = $qu_cur->row()->curName; }
$this->crs->crsId = $row_co1->coCrsId;
$arr[$i]['view'] = $view; $arr[$i]['crs'] = $this->crs->get_by_key(); $arr[$i]['co'] = $this->co->get_by_key(); $arr[$i]['pgNames'] = $pgNames; $arr[$i]['clIdStr'] = $clIdStr; $arr[$i]['sumEnrollSeat'] = $sumEnrollSeat; $arr[$i]['flagSomeSend'] = $flagSomeSend; $arr[$i]['flagAllSend'] = $flagAllSend;
$i++; } }
$data['rs'] = $arr; $data['qu_cfg'] = $this->cfg->qryCfg();
echo $this->load->view($this->config->item("rg_folder")."v_showCourseSendGradeRow", $data, TRUE); }
function addSendGrade($confirm=0) { $this->load->model($this->config->item("rg_folder").'mo_rg_person','prs'); $this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co'); $this->load->model($this->config->item("rg_folder").'mo_rg_timetable','tt'); $this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd'); $this->load->model($this->config->item("rg_folder").'mo_rg_student','std'); $this->load->model($this->config->item("rg_folder").'mo_rg_allowsendgrade','asg'); $this->load->model($this->config->item("rg_folder").'mo_rg_registfee','rf'); $this->load->model($this->config->item("rg_folder").'mo_rg_grade','grd');
$coId = $this->input->post('coId'); $clIdStr = $this->input->post('clIdStr'); $view = $this->input->post('view'); $tc = $this->input->post('tc');
$this->contents['coId'] = $coId; $this->contents['clIdStr'] = $clIdStr; $this->contents['view'] = $view; $this->contents['tc'] = $tc;
if ($tc) { $personId = $this->session->userdata('UsPsCode');
$con_qu_prs = array('prsUsId' => $this->sess_prsUsId, 'prsItId' => $this->sess_prsItId); $qu_prs = $this->prs->qryPrs($con_qu_prs); $row_prs = $qu_prs->row();
$flagIsNull = 0; $qu_co = $this->co->qryCoByClIdStrPrsIdIsNull($clIdStr); if ($qu_co->num_rows()) { $flagIsNull = 1; }
$flagNotOfId = 0; $qu_co = $this->co->qryCoByClIdStrNotPrsId($clIdStr, $row_prs->prsId); if ($qu_co->num_rows()) { $flagNotOfId = 1; }
if ($flagIsNull || $flagNotOfId) { $msg = "ไม่สามารถบันทึกเกรดนักศึกษาได้<br />เนื่องจากท่านไม่ใช่อาจารย์ผู้รับผิดชอบส่งเกรดรายวิชานี้"; $this->session->set_flashdata('msg', $msg); redirect($this->config->item('rg_folder').'msg/err_msg'); } }
$con_qu_co = array('coId' => $coId); $this->contents['qu_co'] = $this->co->qryCoJoinCrs($con_qu_co);
$this->contents['qu_tt'] = $this->tt->qryTeacher($clIdStr);
$this->co->coId = $coId; $qu_co = $this->co->get_by_key(); $row_co = $qu_co->row(); $i = 0; $arr = array(); $rs_rd = $this->rd->qryRdByClIdStrAcYTmId($clIdStr, $row_co->coAcY, $row_co->coTmId);
foreach ($rs_rd->result() as $row_rd) { $con_qu_std = array('stdCode' => $row_rd->stdCode); $qu_std = $this->std->qryStdJoinPfCur($con_qu_std);
$row_std = $qu_std->row();
$this->asg->asgStdId = $row_std->stdId; $this->asg->asgTmId = $row_co->coTmId; $this->asg->asgAcY = $row_co->coAcY; $qu_asg = $this->asg->get_by_key();
$con_qu_rf = array('rfStdId' => $row_std->stdId, 'rfAcY' => $row_co->coAcY, 'rfSyId' => $row_std->stdSyId, 'rfTmId' => $row_co->coTmId ); $qu_rf = $this->rf->getSumBalance($con_qu_rf); $clr = 0; if ($qu_rf && $qu_asg->num_rows()) { $clr = 1; }
$disabled = ""; if ($qu_rf && ($qu_asg->num_rows() == 0)) { $disabled = "disabled"; }
$arr[$i]['clr'] = $clr; $arr[$i]['disabled'] = $disabled; $arr[$i]['qu_rf'] = $qu_rf; $arr[$i]['qu_std'] = $this->std->qryStdJoinPf($con_qu_std); $arr[$i]['rdCoId'] = $row_rd->rdCoId; $arr[$i]['rdGrade'] = $row_rd->rdGrade;
$con_rs_grd = array('grdGtpId' => $row_std->curGtpId); $arr[$i]['rs_grd'] = $this->grd->get_options($con_rs_grd, "", "", 'y');
$i++; }
$cnt_grd = 0; $grd = array(); if (isset($row_std)) { $rs_grd = $this->grd->qryGtpId($row_std->curGtpId); if($rs_grd->num_rows()) { foreach($rs_grd->result() as $row_grd) { $grd[$cnt_grd]['grade'] = $row_grd->grdGrade; $grd[$cnt_grd]['sum'] = $this->rd->getCountStdIdByGrade($clIdStr, $row_co->coAcY, $row_co->coTmId, $row_grd->grdGrade); $cnt_grd++; } } }
$this->contents['grd'] = $grd; $this->contents['rs'] = $arr;
if ($confirm) { $disabled_btnPrint = 1; $disabled_btnConfirm = 0; if ($confirm == 1) { $rs_rd = $this->rd->qryRdByClIdStrGradeIsEmpty($clIdStr); if ($rs_rd->num_rows()) { $disabled_btnConfirm = 1; } } else if ($confirm == 2) { $disabled_btnPrint = 0; $disabled_btnConfirm = 1; } $this->contents['disabled_btnPrint'] = $disabled_btnPrint; $this->contents['disabled_btnConfirm'] = $disabled_btnConfirm; $this->output($this->config->item("rg_folder")."v_showAfterSendGrade"); } else { $this->output($this->config->item("rg_folder")."v_addSendGrade"); } }
function addGradeTextarea() { $this->load->model($this->config->item("rg_folder").'mo_rg_person','prs'); $this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co'); $this->load->model($this->config->item("rg_folder").'mo_rg_timetable','tt'); $this->load->model($this->config->item("rg_folder").'mo_rg_grade','grd');
$coId = $this->input->post('coId'); $clIdStr = $this->input->post('clIdStr'); $view = $this->input->post('view'); $tc = $this->input->post('tc');
$this->contents['coId'] = $coId; $this->contents['clIdStr'] = $clIdStr; $this->contents['view'] = $view; $this->contents['tc'] = $tc;
if ($tc) { $personId = $this->session->userdata('UsPsCode');
$con_qu_prs = array('prsUsId' => $this->sess_prsUsId, 'prsItId' => $this->sess_prsItId); $qu_prs = $this->prs->qryPrs($con_qu_prs); $row_prs = $qu_prs->row();
$flagIsNull = 0; $qu_co = $this->co->qryCoByClIdStrPrsIdIsNull($clIdStr); if ($qu_co->num_rows()) { $flagIsNull = 1; }
$flagNotOfId = 0; $qu_co = $this->co->qryCoByClIdStrNotPrsId($clIdStr, $row_prs->prsId); if ($qu_co->num_rows()) { $flagNotOfId = 1; }
if ($flagIsNull || $flagNotOfId) { $msg = "ไม่สามารถบันทึกเกรดนักศึกษาได้<br />เนื่องจากท่านไม่ใช่อาจารย์ผู้รับผิดชอบส่งเกรดรายวิชานี้"; $this->session->set_flashdata('msg', $msg); redirect($this->config->item('rg_folder').'msg/err_msg'); } }
$con_qu_co = array('coId' => $coId); $this->contents['qu_co'] = $this->co->qryCoJoinCrs($con_qu_co);
$this->contents['qu_tt'] = $this->tt->qryTeacher($clIdStr); $this->contents['rs_grd'] = $this->grd->qryGrdJoinGtp(); // เลือกแสดงเกรดทั้งหมด
$this->output($this->config->item("rg_folder")."v_addGradeTextarea"); }
function processSendGrade() { $rdGrade = $this->input->post('rdGrade');
$this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd');
$stdId = $this->input->post('stdId'); $rdCoId = $this->input->post('rdCoId');
for ($i = 0; $i < count($stdId); $i++) { if(isset($rdGrade[$i]) && $rdGrade[$i]!='') { $con_rs_rd = array('rdStdId' => $stdId[$i], 'rdCoId' => $rdCoId[$i], 'rdAcY' => $this->input->post('rdAcY'), 'rdTmId' => $this->input->post('rdTmId') ); $rs_rd = $this->rd->qryRd($con_rs_rd); $row_rd = $rs_rd->row();
$this->rd->rdStdId = $row_rd->rdStdId; $this->rd->rdAcY = $row_rd->rdAcY; $this->rd->rdTmId = $row_rd->rdTmId; $this->rd->rdCoId = $row_rd->rdCoId; $this->rd->rdSeq = $row_rd->rdSeq; $this->rd->get_by_key(TRUE);
$this->rd->rdGrade = $rdGrade[$i]; $this->rd->rdUpdateUserId = $this->session->userdata('UsLogin'); $this->rd->rdUpdateDate = date('Y-m-d H:i:s'); $this->rd->update(); } } $this->addSendGrade(1); }
function processSendGradeTextarea() { $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<div class="error">','</div>'); $this->form_validation->set_rules('txt','','trim|xss_clean');
if($this->form_validation->run() == true) { $this->load->model($this->config->item("rg_folder").'mo_rg_student','std'); $this->load->model($this->config->item("rg_folder").'mo_rg_grade','grd'); $this->load->model($this->config->item("rg_folder").'mo_rg_allowsendgrade','asg'); $this->load->model($this->config->item("rg_folder").'mo_rg_registfee','rf'); $this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd');
$txt = $this->input->post('txt'); $acY = $this->input->post('acY'); $tmId = $this->input->post('tmId'); $clIdStr = $this->input->post('clIdStr');
//$lines = explode("\r\n", $txt); $lines = explode("\n", $txt); for ($i = 0; $i < count($lines); $i++) { if ($lines[$i]) { list($stdCode, $grdGrade) = preg_split("/ /", $lines[$i]);
$con_qu_std = array('stdCode' => $stdCode, 'stdGenStatus' => 'Y' ); $qu_std = $this->std->qryStdJoinCur($con_qu_std); $row_std = $qu_std->row();
$con_qu_grd = array('grdGrade' => $grdGrade, 'grdGtpId' => $row_std->curGtpId ); $qu_grd = $this->grd->qryGrd($con_qu_grd);
if ($stdCode && $grdGrade && $qu_std->num_rows() && $qu_grd->num_rows()) { $this->asg->asgStdId = $row_std->stdId; $this->asg->asgTmId = $tmId; $this->asg->asgAcY = $acY; $qu_asg = $this->asg->get_by_key();
$con_qu_rf = array('rfStdId' => $row_std->stdId, 'rfAcY' => $acY, 'rfSyId' => $row_std->stdSyId, 'rfTmId' => $tmId ); $qu_rf = $this->rf->getSumBalance($con_qu_rf); // edit 18/09/2556 นำเข้า excel ไม่ต้องดูว่าจ่ายเงินหรือยัง เพราะถ้ายังไม่จ่ายจะไม่เห้นเกรดอยู่แล้ว ต้องบันทึกได้ //if (!$qu_rf || $qu_asg->num_rows()) { $qu_rd = $this->rd->qryRdByStdIdClIdStr($row_std->stdId, $clIdStr); if ($qu_rd->num_rows()) { $row_rd = $qu_rd->row();
$this->rd->rdAcY = $row_rd->rdAcY; $this->rd->rdStdId = $row_rd->rdStdId; $this->rd->rdTmId = $row_rd->rdTmId; $this->rd->rdCoId = $row_rd->rdCoId; $this->rd->rdSeq = $row_rd->rdSeq; $this->rd->get_by_key(TRUE);
$this->rd->rdGrade = $grdGrade; $this->rd->rdUpdateUserId = $this->session->userdata('UsLogin'); $this->rd->rdUpdateDate = date('Y-m-d H:i:s'); $this->rd->update(); } //} } } }
$this->addSendGrade(1); } else { $this->addGradeTextarea(); } }
// ##### start แก้เกรด function showCrsEditGrd() { $this->load->model($this->config->item("rg_folder").'mo_rg_termconfig','tmc'); $this->load->model($this->config->item("rg_folder").'mo_rg_term','tm');
$acY = $this->session->userdata('acY'); $tmId = $this->session->userdata('tmId');
$this->contents['acY'] = $acY; $this->contents['tmId'] = $tmId;
$this->contents['rs_tmc'] = $this->tmc->get_optionsGroupAcY('');
$ord_rs_tm = array('tmName' => 'ASC'); $this->contents['rs_tm'] = $this->tm->get_options('', $ord_rs_tm);
$this->output($this->config->item("rg_folder")."v_showCourseEditGrade"); } function showCrs_editGrd($acY, $tmId) { $this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd'); $this->load->model($this->config->item("rg_folder").'mo_rg_courseopenfor','cof'); $this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co'); $this->load->model($this->config->item("rg_folder").'mo_rg_config','cfg');
$con_rs_rd = array('rdAcY' => $acY, 'rdTmId' => $tmId); $ord_rs_rd = array('coCurId' => 'ASC', 'crsCode' => 'ASC', 'crsName' => 'ASC', 'CAST(coSection AS SIGNED)' => 'ASC'); $grp_rs_rd = array('rdCoId' => 'rdCoId'); $rs_rd = $this->rd->qryRdJoinCoCrs($con_rs_rd,$ord_rs_rd,$grp_rs_rd);
$arr = array(); $i = 0; if($rs_rd->num_rows()) { foreach($rs_rd->result() as $row_rd) {
$arr[$i]['rd'] = $row_rd;
if(is_null($row_rd->coCurId)) { $con_rs_cof = array('cofCoId' => $row_rd->coId); $rs_cof = $this->cof->qryCofJoinCur($con_rs_cof,'','');
$arr[$i]['clIdStr'] = $row_rd->coId; $arr[$i]['cur'] = $rs_cof;
} else { $con_rs_cur = array('coCurId' => $row_rd->coCurId, 'coId' => $row_rd->coId); $ord_rs_cur = array('curName' => 'ASC'); $rs_cur = $this->co->qryCoJoinCur($con_rs_cur,$ord_rs_cur,'');
$arr[$i]['clIdStr'] = $row_rd->coId; $arr[$i]['cur'] = $rs_cur; }
$i++; } } $data['acY'] = $acY; $data['tmId'] = $tmId; $data['arr'] = $arr; $data['qu_cfg'] = $this->cfg->qryCfg();
echo $this->load->view($this->config->item("rg_folder")."v_showCourseEditGradeRow", $data, TRUE); } function editGrd() { $this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co'); $this->load->model($this->config->item("rg_folder").'mo_rg_term','tm'); $this->load->model($this->config->item("rg_folder").'mo_rg_timetable','tt'); $this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd'); $this->load->model($this->config->item("rg_folder").'mo_rg_grade','grd'); $this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur');
$coId = $this->input->post('coId'); $tmId = $this->input->post('tmId'); $acY = $this->input->post('acY');
$con_rs_co = array('coId' => $coId); $this->contents['qu_co'] = $this->co->qryCoJoinCrs($con_rs_co,'','');
$this->tm->tmId = $tmId; $this->contents['qu_tm'] = $this->tm->get_by_key(); $this->contents['qu_tt'] = $this->tt->qryTeacher($coId);
$con1_rs_rd = array('rdCoId' => $coId, 'rdAcY' => $acY, 'rdTmId' => $tmId, 'stdSstId' => 1); $con2_rs_rd = array('rdCoId' => $coId, 'rdAcY' => $acY, 'rdTmId' => $tmId, 'ssmSstId' => 1); $rs_rd = $this->rd->qryRdJoinStdSsm($con1_rs_rd,$con2_rs_rd);
$i = 0; $arr = array(); if($rs_rd->num_rows()) { foreach($rs_rd->result() as $row_rd) { $this->cur->curId = $row_rd->stdCurId; $this->cur->get_by_key(TRUE); $con_rs_grd = array('grdGtpId' => $this->cur->curGtpId); $rs_grd = $this->grd->get_options($con_rs_grd);
$arr[$i]['rd'] = $row_rd; $arr[$i]['grd'] = $rs_grd;
$i++; } } $this->contents['arr'] = $arr;
$this->output($this->config->item("rg_folder")."v_editGrd"); } function processEditGrd() { $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<div class="error">','</div>'); $this->form_validation->set_rules('docNo','เลขที่คำสั่ง','trim|required|xss_clean'); if($this->form_validation->run() == true) { $this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd');
$coId = $this->input->post('coId'); $acY = $this->input->post('acY'); $tmId = $this->input->post('tmId'); $docNo = $this->input->post('docNo'); $cnt = $this->input->post('cnt');
$this->db->trans_begin(); for($i=0; $i<$cnt; $i++) { if($this->input->post('chk'.$i)=='Y') { $con_qu_rd = array('rdStdId' => $this->input->post('stdId'.$i), 'rdCoId' => $coId, 'rdAcY' => $acY, 'rdTmId' => $tmId); $qu_rd = $this->rd->qryRd($con_qu_rd,'',''); if($qu_rd->num_rows()) { $this->rd->row2attribute($qu_rd->row()); $this->rd->rdGrade = $this->input->post('grdId'.$i); $this->rd->rdDocNo = $docNo; $this->rd->rdUpdateDate = date('Y-m-d H:i:s'); $this->rd->rdUpdateUserId = $this->session->userdata('UsLogin'); $this->rd->update(); } } }
if($this->db->trans_status() === false) $this->db->trans_rollback(); else $this->db->trans_commit();
//$this->editGrd(); redirect($this->config->item("rg_folder")."grade/showCrsEditGrd"); } else { $this->editGrd(); } } // ##### end แก้เกรด
// ##### start ยืนยันการแสดงผลเกรด function confirmShowGrdStd() { $this->load->model($this->config->item("rg_folder").'mo_rg_termconfig','tmc'); $this->load->model($this->config->item("rg_folder").'mo_rg_term','tm');
$acY = $this->session->userdata('acY'); $tmId = $this->session->userdata('tmId');
$this->contents['acY'] = $acY; $this->contents['tmId'] = $tmId;
$this->contents['rs_tmc'] = $this->tmc->get_optionsGroupAcY('');
$ord_rs_tm = array('tmName' => 'ASC'); $this->contents['rs_tm'] = $this->tm->get_options('', $ord_rs_tm);
$this->output($this->config->item("rg_folder")."v_confirmShowGradeStd"); } function showCrs_confirmGrd($acY, $tmId) { $this->load->model($this->config->item("rg_folder").'mo_rg_config','cfg'); $this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd'); $this->load->model($this->config->item("rg_folder").'mo_rg_courseopenfor','cof'); $this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur');
$con_rs_rd = array('rdAcY' => $acY, 'rdTmId' => $tmId, 'coSendGradeStatus' => 'Y', 'coDeclareStatus' => 'N' ); $ord_rs_rd = array('coCurId' => 'ASC', 'crsCode' => 'ASC', 'crsName' => 'ASC', 'CAST(coSection AS SIGNED)' => 'ASC' ); $grp_rs_rd = array('rdCoId' => 'rdCoId'); $rs_rd = $this->rd->qryRdJoinCoCrs($con_rs_rd,$ord_rs_rd,$grp_rs_rd);
$i = 0; $arr = array(); if($rs_rd->num_rows()) { foreach($rs_rd->result() as $row_rd) {
$arr[$i]['rd'] = $row_rd;
if(is_null($row_rd->coCurId)) { $con_rs_cof = array('cofCoId' => $row_rd->coId); $rs_cof = $this->cof->qryCofJoinCur($con_rs_cof,'',''); $arr[$i]['cur'] = $rs_cof; } else { $this->cur->curId = $row_rd->coCurId; $qu_cur = $this->cur->get_by_key();
$arr[$i]['cur'] = $qu_cur; }
$i++; } } $data['arr'] = $arr; $data['qu_cfg'] = $this->cfg->qryCfg();
echo $this->load->view($this->config->item("rg_folder")."v_confirmShowGradeStdRow", $data, TRUE); } function processConfirmShowGrdStd() { $this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co');
$cnt = $this->input->post('cnt');
$this->db->trans_begin(); for($i=0; $i<$cnt; $i++){ if($this->input->post('chk'.$i)=='Y') { $this->co->coId = $this->input->post('coId'.$i); $this->co->get_by_key(TRUE);
$this->co->coDeclareStatus = 'Y'; $this->co->update(); } }
if($this->db->trans_status() === false) { $this->db->trans_rollback(); $this->contents['flg'] = "ไม่สำเร็จ"; } else { $this->db->trans_commit(); $this->contents['flg'] = "สำเร็จ"; }
$this->output($this->config->item("rg_folder")."v_processConfirmShowGrdStd"); } // ##### end ยืนยันการแสดงผลเกรด
// ##### start ตรวจสอบรายวิชาที่ยังไม่ได้ส่งเกรด function checkNoSendGrdCrs() { $this->load->model($this->config->item("rg_folder").'mo_rg_termconfig','tmc'); $this->load->model($this->config->item("rg_folder").'mo_rg_term','tm');
$acY = $this->session->userdata('acY'); $tmId = $this->session->userdata('tmId');
$this->contents['acY'] = $acY; $this->contents['tmId'] = $tmId;
$this->contents['rs_tmc'] = $this->tmc->get_optionsGroupAcY('');
$ord_rs_tm = array('tmName' => 'ASC'); $this->contents['rs_tm'] = $this->tm->get_options('', $ord_rs_tm);
$this->output($this->config->item("rg_folder")."v_checkNoSendGradeCourse"); } function showCrs_noSendGrd($acY, $tmId) { $this->load->model($this->config->item("rg_folder").'mo_rg_config','cfg'); $this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur'); $this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd'); $this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co');
$con_rs_cur = array('curStatus' => 'Y'); $ord_rs_cur = array('curName' => 'ASC'); $rs_cur = $this->cur->qryCur($con_rs_cur, $ord_rs_cur);
$i = 0; $arr = array(); if($rs_cur->num_rows()) { foreach($rs_cur->result() as $row_cur) {
$arr[$i]['cur'] = $row_cur;
// coCurId IS NOT NULL $con_rs_rd = array('rdAcY' => $acY, 'rdTmId' => $tmId, 'coCurId' => $row_cur->curId); $rs_rd = $this->rd->qryRdCoIdJoinCoCrs($con_rs_rd,''); if($rs_rd->num_rows()) { foreach($rs_rd->result() as $row_rd) { $con_co = array('coId' => $row_rd->rdCoId, 'coSendGradeStatus' => 'N'); $ord_co = array('crsCode' => 'ASC', 'crsName' => 'ASC', 'CAST(coSection AS SIGNED)' => 'ASC' ); $co = $this->co->qryResponsibilityCo($con_co, $ord_co); $arr[$i]['co'][] = $co; } } else { $arr[$i]['co'][] = NULL; }
// coCurId IS NULL $con_rs_rd = array('rdAcY' => $acY, 'rdTmId' => $tmId, 'coCurId' => 'NULL', 'cofCurId' => $row_cur->curId); $rs_rd2 = $this->rd->qryRdJoinCoCrsCof($con_rs_rd,''); if($rs_rd2->num_rows()) { foreach($rs_rd2->result() as $row_rd2) { $con_co2 = array('coId' => $row_rd2->rdCoId, 'coSendGradeStatus' => 'N'); $ord_co2 = array('crsCode' => 'ASC', 'crsName' => 'ASC', 'CAST(coSection AS SIGNED)' => 'ASC' ); $co2 = $this->co->qryResponsibilityCo($con_co2, $ord_co2);
$arr[$i]['co2'][] = $co2; } } else { $arr[$i]['co2'] = NULL; }
$i++; } } $data['arr'] = $arr; $data['qu_cfg'] = $this->cfg->qryCfg();
echo $this->load->view($this->config->item("rg_folder")."v_checkNoSendGradeCourseRow", $data, TRUE); } // ##### end ตรวจสอบรายวิชาที่ยังไม่ได้ส่งเกรด
// ##### start printSendGradePDF function printSendGradePDF($showGrade = 0) { $this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co'); $this->load->model($this->config->item("rg_folder").'mo_rg_timetable','tt'); $this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd'); $this->load->model($this->config->item("rg_folder").'mo_rg_student','std'); $this->load->model($this->config->item("rg_folder").'mo_rg_grade','grd'); $this->load->model($this->config->item("rg_folder").'mo_rg_person','prs'); $this->load->model($this->config->item("rg_folder").'mo_rg_studentsummary','ssm'); $this->load->model($this->config->item("rg_folder").'mo_rg_registfee','rf'); $coId = $this->input->post('coId'); $clIdStr = $this->input->post('clIdStr'); $view = $this->input->post('view');
$this->contents['view'] = $view;
$con_qu_co = array('coId' => $coId); $qu_co = $this->co->qryCoJoinCrsCur($con_qu_co); $row_co = $qu_co->row(); $this->contents['qu_co'] = $qu_co;
//$qu_tt = $this->tt->qryTeacher($clIdStr); //$this->contents['prsNames'] = $qu_tt->row()->prsName; $this->contents['prsNames'] = array(); $qu_tt = $this->tt->qryTeacher2($clIdStr); $i=0; foreach($qu_tt->result() as $row){ $this->contents['prsNames'][$i] = $row->prefixName.$row->fName.' '.$row->lName.' '; $i++; } $arr = array(); $i = 0; //$rs_rd = $this->rd->qryRdByClIdStrAcYTmId($clIdStr, $row_co->coAcY, $row_co->coTmId); // เดิม printPDF เฉพาะเด็ก sstId=1 $rs_rd = $this->rd->qryRdJoinStdOrdStdCode($clIdStr, $row_co->coAcY, $row_co->coTmId);
if($rs_rd->num_rows()) { foreach ($rs_rd->result() as $row_rd) { $con_qu_std = array('stdId' => $row_rd->rdStdId); $qu_std = $this->std->qryStdJoinPfSst($con_qu_std); $arr[$i]['qu_std'] = $qu_std;
$con_qu_ssm = array('ssmStdId' => $row_rd->rdStdId, 'ssmAcY' => $row_co->coAcY, 'ssmTmId' => $row_co->coTmId); $qu_ssm = $this->ssm->qrySsmSst($con_qu_ssm); if ($row_co->coSendGradeStatus == 'Y' || $showGrade == 1) { if($row_rd->rdGrade) { $arr[$i]['rdGrade'] = $row_rd->rdGrade; } else { if($qu_ssm->num_rows()) { $arr[$i]['rdGrade'] = $qu_ssm->row()->sstName; } else { $arr[$i]['rdGrade'] = $qu_std->row()->sstName; } } } else { $arr[$i]['rdGrade'] = ''; } // 11/4/2556 ถ้าค้างค่าใช้จ่าย ไม่แสดงเกรด ดูรายเทอม if($showGrade == 0 ){ // $con_qu_rf = array('rfStdId' => $row_rd->rdStdId); $con_qu_rf = array('rfStdId' => $row_rd->rdStdId, 'rfAcY' => $row_co->coAcY, 'rfTmId' => $row_co->coTmId ); $rfBalance = $this->rf->getSumBalance($con_qu_rf ); if( $rfBalance > 0 ){ $arr[$i]['rdGrade'] = '-'; } } $i++; } } $this->contents['rs1'] = $arr;
$arr = array(); $i = 0; $con_rs_grd = array('grdGtpId' => $row_co->curGtpId); $rs_grd = $this->grd->qryGrd($con_rs_grd); foreach ($rs_grd->result() as $row_grd) { $arr[$i]['grdGrade'] = $row_grd->grdGrade; $arr[$i]['cntStd'] = $this->rd->getCountStdIdByGrade($clIdStr, $row_co->coAcY, $row_co->coTmId, $row_grd->grdGrade);
$i++; } $this->contents['rs2'] = $arr;
$con_qu_prs = array('prsId' => $row_co->coPrsId); $qu_prs = $this->prs->qryPrsJoinPPC($con_qu_prs); if ($qu_prs->num_rows()) { $this->contents['prsName'] = $qu_prs->row()->name; } else { $this->contents['prsName'] = ''; }
$this->output_pdf($this->config->item("rg_folder")."v_printSendGradePDF"); } // ##### end printSendGradePDF
// ##### start แก้เกรดนักศึกษาแยกตามรายวิชา function searchSendGrd() { $this->load->model($this->config->item("rg_folder").'mo_rg_term','tm');
$this->contents['rs_tm'] = $this->tm->get_options('','','','y'); $this->contents['acY'] = $this->session->userdata('acY'); $this->contents['tmId'] = $this->session->userdata('tmId');
$this->output($this->config->item("rg_folder")."v_searchSendGrade"); } function beforeEditSendGrd() { $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<div class="error">','</div>'); $this->form_validation->set_rules('stdCode',' ','trim|required|integer|is_natural_no_zero|xss_clean'); $this->form_validation->set_rules('acY',' ','callback_checkAdY'); $this->form_validation->set_rules('tmId',' ','trim|required|xss_clean');
if($this->form_validation->run() == true) { $this->editSendGrade(); } else { $this->searchSendGrd(); } } function editSendGrade($edit=0) { $this->load->model($this->config->item("rg_folder").'mo_rg_student','std'); $this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd'); $this->load->model($this->config->item("rg_folder").'mo_rg_grade','grd');
$stdCode = $this->input->post('stdCode'); $acY = $this->input->post('acY'); $tmId = $this->input->post('tmId'); $edit = $this->input->post('edit') ? $this->input->post('edit') : $edit;
if($edit==1) { $coId = $this->input->post('coId'); $stdId = $this->input->post('stdId'); }
$this->contents['acY'] = $acY; $this->contents['tmId'] = $tmId;
$con_qu_std = array('stdCode' => $stdCode); $qu_std = $this->std->qryStdJoinSdtPfCurSySstElv($con_qu_std); $this->contents['qu_std'] = $qu_std;
if($qu_std->num_rows()) { $con_rs_rd = array('rdStdId' => $qu_std->row()->stdId, 'rdAcY' => $acY, 'rdTmId' => $tmId); $ord_rs_rd = array('crsCode' => 'ASC', 'crsName' => 'ASC' ); $this->contents['rs_rd'] = $this->rd->qryRdJnCrsOpCrs($con_rs_rd, $ord_rs_rd); $con_rs_grd = array('grdGtpId' => $qu_std->row()->curGtpId); $this->contents['rs_grd'] = $this->grd->get_options($con_rs_grd,'','','y'); }
if($edit==1) { $this->contents['flgShow'] = $coId; }
$this->output($this->config->item("rg_folder")."v_beforeEditSendGrade"); } function processEditSendGrade() { $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<div class="error">','</div>'); $this->form_validation->set_rules('rdGrade',' ','trim|required|xss_clean'); $this->form_validation->set_rules('docNo',' ','trim|required|xss_clean');
if($this->form_validation->run() == true) { $this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd');
$stdCode = $this->input->post('stdCode'); $stdId = $this->input->post('stdId'); $acY = $this->input->post('acY'); $tmId = $this->input->post('tmId'); $coId = $this->input->post('coId');
$con_qu_rd = array('rdStdId' => $stdId, 'rdCoId' => $coId, 'rdAcY' => $acY, 'rdTmId' => $tmId); $qu_rd = $this->rd->qryRd($con_qu_rd,'',''); if($qu_rd->num_rows()) { $this->rd->row2attribute($qu_rd->row()); $this->rd->rdGrade = $this->input->post('rdGrade'); $this->rd->rdDocNo = $this->input->post('docNo'); $this->rd->rdUpdateDate = date('Y-m-d H:i:s'); $this->rd->rdUpdateUserId = $this->session->userdata('UsLogin'); $this->rd->update(); }
$this->editSendGrade(); } else { $this->editSendGrade(1); } } // ##### end แก้เกรดนักศึกษาแยกตามรายวิชา
function processConfirmSendGrade() { $this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co'); $this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd');
$clIdStr = $this->input->post('clIdStr'); $rdAcY = $this->input->post('rdAcY'); $rdTmId = $this->input->post('rdTmId');
$clIdStrArr = explode(",", $clIdStr); for ($i = 0; $i < count($clIdStrArr); $i++) { $this->co->coId = $clIdStrArr[$i]; $this->co->get_by_key(TRUE);
$this->co->coSendGradeStatus = 'Y'; $this->co->update(); }
$rs_rd = $this->rd->qryRdByClIdStrAcYTmId($clIdStr, $rdAcY, $rdTmId); foreach ($rs_rd->result() as $row_rd1) { $con_rs_rd = array('rdStdId' => $row_rd1->rdStdId, 'rdCoId' => $row_rd1->rdCoId, 'rdAcY' => $rdAcY, 'rdTmId' => $rdTmId ); $rs_rd = $this->rd->qryRd($con_rs_rd); $row_rd2 = $rs_rd->row();
$this->rd->rdAcY = $row_rd2->rdAcY; $this->rd->rdStdId = $row_rd2->rdStdId; $this->rd->rdTmId = $row_rd2->rdTmId; $this->rd->rdCoId = $row_rd2->rdCoId; $this->rd->rdSeq = $row_rd2->rdSeq; $this->rd->get_by_key(TRUE); $this->rd->rdNoCalGPA = 'N'; $this->rd->rdUpdateUserId = $this->session->userdata('UsLogin'); $this->rd->rdUpdateDate = date('Y-m-d H:i:s'); $this->rd->update(); } $this->addSendGrade(2); }
function calGradeCur () { $this->load->model($this->config->item("rg_folder").'mo_rg_term','tm');
$this->contents['rs_tm'] = $this->tm->get_options('','','',FALSE); $this->contents['acY'] = $this->session->userdata('acY');
$this->output($this->config->item("rg_folder")."v_calGradeCurriculum"); }
function processCalGradeCur() { $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<div class="error">','</div>'); $this->form_validation->set_rules('curName',' ','trim|required|xss_clean'); $this->form_validation->set_rules('curId',' ','trim|required|xss_clean'); $this->form_validation->set_rules('stdTmIdAdmit',' ','trim|required|xss_clean'); $this->form_validation->set_rules('adY',' ','trim|required|nemeric|is_natural_no_zero|xss_clean'); $this->form_validation->set_rules('acY',' ','trim|required|integer|is_natural_no_zero|callback_checkAcY'); $this->form_validation->set_rules('tmId',' ','trim|required|xss_clean'); $this->form_validation->set_rules('syId',' ','trim|integer|is_natural_no_zero|callback_checkSy|required|xss_clean'); if($this->form_validation->run() == true) { $this->load->model($this->config->item("rg_folder").'mo_rg_student','std'); $this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd'); $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');
$curId = $this->input->post('curId'); $adY = $this->input->post('adY'); $syId = $this->input->post('syId'); $acY = $this->input->post('acY'); $tmId = $this->input->post('tmId');
$con_rs_std = array('stdCurId' => $curId, 'stdAdY' => $adY, 'stdSyId' => $syId ); $ord_rs_std = array('stdCode' => 'ASC'); $rs_std = $this->std->qryStd($con_rs_std, $ord_rs_std); foreach ($rs_std->result() as $row_std) { if (($acY < $this->session->userdata('acY_R')) || ($acY == $this->session->userdata('acY_R') && $tmId <= $this->session->userdata('tmId_R'))) { $rs_rd = $this->rd->qryRdByCurIdAdYSyIdAcYTmId($curId, $adY, $syId, $acY, $tmId); if ($rs_rd->num_rows()) { $this->calGradeByStdIdAcYTmId($row_std->stdId, $acY, $tmId); } } }
// start ใช้ใน view $this->cur->curId = $curId; $this->contents['qu_cur'] = $this->cur->get_by_key();
$this->contents['adY'] = $adY;
$this->sy->syId = $syId; $this->contents['qu_sy'] = $this->sy->get_by_key();
$this->contents['acY'] = $acY;
$this->tm->tmId = $tmId; $this->contents['qu_tm'] = $this->tm->get_by_key();
// echo "<br />".$acY."===".$this->session->userdata('acY_R'); // echo "<br />".$acY."===".$this->session->userdata('acY_R'); // echo "<br />".$tmId."==".$this->session->userdata('tmId_R');
if (($acY > $this->session->userdata('acY_R')) || ($acY == $this->session->userdata('acY_R') && $tmId > $this->session->userdata('tmId_R'))) { $this->contents['err_msg'] = "** ไม่สามารถประมวลผลเกรดนักศึกษาตามหลักสูตร ในภาคการศึกษา ".$tmId." ปีการศึกษา ".$acY." **"; }
$this->contents['rs_std'] = $this->std->qryStdByCurIdAndAdYAndSyIdJoinSsmPfSdtCurGen($acY,$tmId,$curId,$adY,$syId);
$this->output($this->config->item("rg_folder")."v_processCalGradeCurriculum"); } else { $this->calGradeCur(); } }
function calGradeByStdIdAcYTmId($stdId, $acY, $tmId) { $this->load->model($this->config->item("rg_folder").'mo_rg_acadconfig','ac'); $this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd'); $this->load->model($this->config->item("rg_folder").'mo_rg_student','std'); $this->load->model($this->config->item("rg_folder").'mo_rg_studentsummary','ssm');
$qu_ac = $this->ac->qryAc(); $acCalGradeF = $qu_ac->row()->acCalGradeF;
$divisor = 0; if ($acCalGradeF == 1) { $divisor = $this->rd->getAllFDivisorGPAX($stdId, $acY, $tmId); } else if ($acCalGradeF == 2) { $divisor = $this->rd->getOneFDivisorGPAX($stdId, $acY, $tmId); }
$this->std->stdId = $stdId; $this->std->get_by_key(TRUE); $this->std->stdCreditAttempt = $this->rd->calCumCreditAttempt($stdId, $acY, $tmId); $this->std->stdCreditSatisfy = $this->rd->calCumCreditSatisfy($stdId, $acY, $tmId); $this->std->stdGPA = ($divisor) ? $this->rd->getDividendGPAX($stdId, $acY, $tmId) / $divisor : 0; $this->std->stdUpdateDate = date('Y-m-d H:i:s'); $this->std->stdUpdateUsLogin = $this->session->userdata('UsLogin'); if ($this->std->stdGPA < 1.75) { $this->std->stdSstIdTmp = 7; } else { $this->std->stdSstIdTmp = 1; } $this->std->update(); $this->ssm->ssmStdId = $stdId; $this->ssm->ssmAcY = $acY; $this->ssm->ssmTmId = $tmId; $qu_ssm = $this->ssm->get_by_key(); if ($qu_ssm->num_rows()) { $this->ssm->get_by_key(TRUE); $this->ssm->ssmGPA = ($this->rd->getAllFDivisorGPA($stdId, $acY, $tmId)) ? $this->rd->getDividendGPA($stdId, $acY, $tmId) / $this->rd->getAllFDivisorGPA($stdId, $acY, $tmId) : 0; $this->ssm->ssmCreditAttempt = $this->rd->getSumCrAtByStdIdAcYTmId($stdId, $acY, $tmId); $this->ssm->ssmCreditSatisfy = $this->rd->calCreditSatisfy($stdId, $acY, $tmId); $this->ssm->ssmCreditPoint = $this->rd->getAllFDivisorGPA($stdId, $acY, $tmId); $this->ssm->ssmGPAX = ($divisor) ? $this->rd->getDividendGPAX($stdId, $acY, $tmId) / $divisor : 0; $this->ssm->ssmSumCreditAttempt = $this->rd->calCumCreditAttempt($stdId, $acY, $tmId); $this->ssm->ssmSumCreditSatisfy = $this->rd->calCumCreditSatisfy($stdId, $acY, $tmId); $this->ssm->ssmSumCreditPoint = $divisor; $this->ssm->ssmUpdateDate = date('Y-m-d H:i:s'); $this->ssm->ssmUpdateUserId = $this->session->userdata('UsLogin'); $this->ssm->update(); } else { $this->ssm->ssmStdId = $stdId; $this->ssm->ssmTmId = $tmId; $this->ssm->ssmAcY = $acY; $this->ssm->ssmGPA = ($this->rd->getAllFDivisorGPA($stdId, $acY, $tmId)) ? $this->rd->getDividendGPA($stdId, $acY, $tmId) / $this->rd->getAllFDivisorGPA($stdId, $acY, $tmId) : 0; $this->ssm->ssmCreditAttempt = $this->rd->getSumCrAtByStdIdAcYTmId($stdId, $acY, $tmId); $this->ssm->ssmCreditSatisfy = $this->rd->calCreditSatisfy($stdId, $acY, $tmId); $this->ssm->ssmCreditPoint = $this->rd->getAllFDivisorGPA($stdId, $acY, $tmId); $this->ssm->ssmGPAX = ($divisor) ? $this->rd->getDividendGPAX($stdId, $acY, $tmId) / $divisor : 0; $this->ssm->ssmSumCreditAttempt = $this->rd->calCumCreditAttempt($stdId, $acY, $tmId); $this->ssm->ssmSumCreditSatisfy = $this->rd->calCumCreditSatisfy($stdId, $acY, $tmId); $this->ssm->ssmSumCreditPoint = $divisor; $this->ssm->ssmApprover = ""; $this->ssm->ssmRefNo = ""; $this->ssm->ssmApproveDate = ""; $this->ssm->ssmPassStatus = 0; $this->ssm->ssmSstId = $this->std->stdSstId; $this->ssm->ssmSstIdApproveSpe = NULL; $this->ssm->ssmSyId = $this->std->stdSyId; $this->ssm->ssmCreateDate = date('Y-m-d H:i:s'); $this->ssm->ssmCreateUserId = $this->session->userdata('UsLogin'); $this->ssm->ssmUpdateDate = date('Y-m-d H:i:s'); $this->ssm->ssmUpdateUserId = $this->session->userdata('UsLogin'); $this->ssm->insert(); } }
function searchCalGrade() {
$this->output($this->config->item("rg_folder")."v_searchCalGrade"); }
function calGrade() { $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<div class="error">','</div>'); $this->form_validation->set_rules('stdCode',' ','trim|required|integer|xss_clean');
if($this->form_validation->run() == true) { $this->load->model($this->config->item("rg_folder").'mo_rg_student','std'); $this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd');
$stdCode = $this->input->post('stdCode');
$con_qu_std = array('stdCode' => $stdCode, 'stdSstId' => 1, 'stdGenStatus' => 'Y' );
$qu_std = $this->std->qryStd($con_qu_std, "", ""); if ($qu_std->num_rows()) { $this->contents['qu_std'] = $this->std->qryStdJoinPfCurSySstElv($con_qu_std, "", "");
$con_rs_rd = array('rdStdId' => $this->contents['qu_std']->row()->stdId); $grp_rs_rd = array('rdAcY', 'rdTmId'); $this->contents['rs_rd'] = $this->rd->qryRdJoinSsm($con_rs_rd, "", $grp_rs_rd); } else { $this->contents['err_msg'] = "** ไม่ปรากฏรหัสนักศึกษาดังกล่าวในฐานข้อมูล "; }
$this->output($this->config->item("rg_folder")."v_calGrade.php"); } else { $this->searchCalGrade(); } }
function processCalGrade() { $stdId = $this->input->post('stdId'); $acY = $this->input->post('acY'); $tmId = $this->input->post('tmId');
$this->calGradeByStdIdAcYTmId($stdId, $acY, $tmId);
$this->contents['success_msg'] = "กระบวนการประมวลผลเกรดสำเร็จ";
$this->calGrade(); }
function showConfirmCalGrade() { $this->load->model($this->config->item("rg_folder").'mo_rg_term','tm');
$this->contents['rs_tm'] = $this->tm->get_options('','','',FALSE); $this->contents['acY'] = $this->session->userdata('acY');
$this->output($this->config->item("rg_folder")."v_showConfirmCalGrade"); }
function confirmCalGrade() { $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<div class="error">','</div>'); $this->form_validation->set_rules('curName',' ','trim|xss_clean'); $this->form_validation->set_rules('curId',' ','trim|required|xss_clean'); $this->form_validation->set_rules('stdTmIdAdmit',' ','trim|required|xss_clean'); $this->form_validation->set_rules('adY',' ','trim|required|nemeric|is_natural_no_zero|xss_clean'); $this->form_validation->set_rules('acY',' ','trim|required|integer|is_natural_no_zero|callback_checkAcY'); $this->form_validation->set_rules('tmId',' ','trim|required|xss_clean'); $this->form_validation->set_rules('syId',' ','trim|integer|callback_checkSy|required|xss_clean'); if($this->form_validation->run() == true) { $this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur'); $this->load->model($this->config->item("rg_folder").'mo_rg_term','tm'); $this->load->model($this->config->item("rg_folder").'mo_rg_studyyear','sy'); $this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
$curId = $this->input->post('curId'); $adY = $this->input->post('adY'); $syId = $this->input->post('syId');
$this->cur->curId = $curId; $this->contents['qu_cur'] = $this->cur->get_by_key();
$this->contents['adY'] = $this->input->post('adY'); $this->contents['stdTmIdAdmit'] = $this->input->post('stdTmIdAdmit'); $this->contents['acY'] = $this->input->post('acY');
$this->tm->tmId = $this->input->post('tmId'); $this->contents['qu_tm'] = $this->tm->get_by_key();
$this->sy->syId = $this->input->post('syId'); $this->contents['qu_sy'] = $this->sy->get_by_key();
$con_rs_std = array('stdCurId' => $curId, 'stdAdY' => $adY, 'stdSyId' => $syId ); $ord_rs_std = array('stdCode' => 'ASC'); //$this->contents['rs_std'] = $this->std->qryStdJoinPfCurSySstElv($con_rs_std, $ord_rs_std); $this->contents['rs_std'] = $this->std->qryStdJoinPfSstTmp($con_rs_std, $ord_rs_std);
$this->output($this->config->item("rg_folder")."v_confirmCalGrade"); } else { $this->showConfirmCalGrade(); } }
// ยืนยันการประมวลผลเกรดนักศึกษา คือ นศ. ติดโปร ทำได้ตั้งแต่ ปี 1 เทอม 2 เป็นต้นไป function processConfirmCalGrade() { $this->load->model($this->config->item("rg_folder").'mo_rg_student','std'); $this->load->model($this->config->item("rg_folder").'mo_rg_studentsummary','ssm');
$stdId = $this->input->post('stdId'); $acY = $this->input->post('acY'); $tmId = $this->input->post('tmId');
for ($i = 0; $i < count($stdId); $i++) { $this->std->stdId = $stdId[$i]; $this->std->get_by_key(TRUE);
if (($stdId[$i] != '') && (($this->std->stdSyId == 1 && $tmId != 1) || ($this->std->stdSyId != 1))) { $this->std->stdSstId = $this->std->stdSstIdTmp; $this->std->updateUserId = $this->session->userdata('UsLogin'); $this->std->updateDateTime = date('Y-m-d H:i:s'); $this->std->update();
$this->ssm->ssmStdId = $stdId[$i]; $this->ssm->ssmTmId = $tmId; $this->ssm->ssmAcY = $acY;
$qu_ssm = $this->ssm->get_by_key(); if ($qu_ssm->num_rows()) { $this->ssm->get_by_key(TRUE);
$this->ssm->ssmSstId = $this->std->stdSstId; $this->ssm->ssmUpdateDate = date('Y-m-d H:i:s'); $this->ssm->ssmUpdateUserId = $this->session->userdata('UsLogin'); $this->ssm->update(); } else { $this->ssm->ssmStdId = $stdId[$i]; $this->ssm->ssmTmId = $tmId; $this->ssm->ssmAcY = $acY; $this->ssm->ssmGPA = 0; $this->ssm->ssmCreditAttempt = 0; $this->ssm->ssmCreditSatisfy = 0; $this->ssm->ssmCreditPoint = 0; $this->ssm->ssmGPAX = 0; $this->ssm->ssmSumCreditAttempt = 0; $this->ssm->ssmSumCreditSatisfy = 0; $this->ssm->ssmSumCreditPoint = 0; $this->ssm->ssmApprover = ""; $this->ssm->ssmRefNo = ""; $this->ssm->ssmApproveDate = ""; $this->ssm->ssmPassStatus = 0; $this->ssm->ssmSstId = $this->std->stdSstId; $this->ssm->ssmSstIdApproveSpe = NULL; $this->ssm->ssmSyId = $this->std->stdSyId; $this->ssm->ssmCreateDate = date('Y-m-d H:i:s'); $this->ssm->ssmCreateUserId = $this->session->userdata('UsLogin'); $this->ssm->ssmUpdateDate = date('Y-m-d H:i:s'); $this->ssm->ssmUpdateUserId = $this->session->userdata('UsLogin'); $this->ssm->insert(); } } // end if } // end for
$this->confirmCalGrade(); }
// ##### start ลงทะเบียนและส่งเกรดย้อนหลัง function showBackRegistAndSendGrade() { $this->load->model($this->config->item("rg_folder").'mo_rg_term','tm');
$this->contents['acY'] = $this->session->userdata('acY'); $this->contents['tmId'] = $this->session->userdata('tmId'); $this->contents['rs_tm'] = $this->tm->get_options('','','','n');
$this->output($this->config->item("rg_folder")."v_showBackRegistAndSendGrade"); } function addBackRegistAndSendGrade() { $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<div class="error">','</div>'); $this->form_validation->set_rules('stdCode',' ','trim|required|integer|is_natural_no_zero|xss_clean'); $this->form_validation->set_rules('acY',' ','trim|integer|callback_checkAdY|xss_clean'); $this->form_validation->set_rules('tmId',' ','trim|required|xss_clean'); $this->form_validation->set_rules('syId',' ','callback_checkSyId');
if($this->form_validation->run() == true) { $this->backRegistAndSendGrade_input(); } else { $this->showBackRegistAndSendGrade(); } } function backRegistAndSendGrade_input() { $this->load->model($this->config->item("rg_folder").'mo_rg_student','std'); $this->load->model($this->config->item("rg_folder").'mo_rg_studentsummary','ssm'); $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_courseopen','co'); $this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd'); $this->load->model($this->config->item("rg_folder").'mo_rg_grade','grd');
$stdCode = $this->input->post('stdCode'); $acY = $this->input->post('acY'); $tmId = $this->input->post('tmId'); $syId = $this->input->post('syId');
$this->sy->syId = $syId; $this->contents['qu_sy'] = $this->sy->get_by_key();
$this->tm->tmId = $tmId; $this->contents['qu_tm'] = $this->tm->get_by_key();
$this->contents['acY'] = $acY;
$this->ssm->ssmStdId = $stdCode; $this->ssm->ssmTmId = $tmId; $this->ssm->ssmAcY = $acY; $this->contents['qu_ssm'] = $this->ssm->get_by_key();
$con_qu_std = array('stdCode' => $stdCode, 'stdGenStatus' => 'Y', 'stdSstId' => 1); $qu_std = $this->std->qryStdJoinCurPfSySsm($con_qu_std,'',''); $i = 0; $arr = array(); if($qu_std->num_rows()) { $this->contents['qu_std'] = $qu_std; $con_rs_grd = array('grdGtpId' => $qu_std->row()->curGtpId); $this->contents['rs_grd'] = $this->grd->get_options($con_rs_grd,'','','y');
// curId IS NOT NULL $con_rs_co = array('coCurId' => $qu_std->row()->stdCurId, 'coSyId' => $syId, 'coTmId' => $tmId, 'coAcY' => $acY); $rs_co = $this->co->qryCoJoinCrs($con_rs_co,''); if($rs_co->num_rows()) { foreach($rs_co->result() as $row_co) { $con_qu_rd = array('rdCoId' => $row_co->coId, 'rdAcY' => $acY, 'rdTmId' => $tmId, 'rdStdId' => $qu_std->row()->stdId); $qu_rd = $this->rd->qryRd($con_qu_rd,'','');
$arr[$i]['co'] = $row_co; $arr[$i]['rd'] = $qu_rd;
$i++; } }
// curId IS NULl $con_rs_co2 = array('coCurId' => 'NULL', 'coAcY' => $acY, 'coTmId' => $tmId, 'cofCurId' => $qu_std->row()->stdCurId); $rs_co2 = $this->co->qryCoJoinCofCrs($con_rs_co2,''); if($rs_co2->num_rows()) { foreach($rs_co2->result() as $row_co2) { $con_qu_rd = array('rdCoId' => $row_co2->coId, 'rdAcY' => $acY, 'rdTmId' => $tmId, 'rdStdId' => $qu_std->row()->stdId); $qu_rd = $this->rd->qryRd($con_qu_rd,'','');
$arr[$i]['co'] = $row_co2; $arr[$i]['rd'] = $qu_rd;
$i++; } }
$con_creditAttempt = array('rdStdId' => $qu_std->row()->stdId, 'rdAcY' => $acY, 'rdTmId' => $tmId); $this->contents['creditAttempt'] = $this->rd->getCreditAttempt($con_creditAttempt); } else { $con_std = array('stdCode' => $stdCode); $this->contents['std'] = $this->std->qryStdJoinPfSst($con_std,'',''); } $this->contents['arr'] = $arr;
$this->output($this->config->item("rg_folder")."v_addBackRegistAndSendGrade"); } function processBackRegistAndSendGrade() { $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<div class="error">','</div>');
$cnt = $this->input->post('cnt'); for($num=0; $num<$cnt; $num++) { //if($this->input->post('chk'.$num)=='Y') { $this->form_validation->set_rules('rdGrade'.$num,' ','trim|xss_clean'); //} }
if($this->form_validation->run() == true) { $this->load->model($this->config->item("rg_folder").'mo_rg_regist','rg'); $this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd'); $this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co');
$stdId = $this->input->post('stdId'); $stdCode = $this->input->post('stdCode'); $curId = $this->input->post('curId'); $syId = $this->input->post('syId'); $acY = $this->input->post('acY'); $tmId = $this->input->post('tmId');
for($i=0; $i<$cnt; $i++) { if($this->input->post('chk'.$i)=='Y' && $this->input->post('rdGrade'.$i)!='') {
// ทำการลงทะเบียน $this->rg->rgStdId = $stdId; $this->rg->rgTmId = $tmId; $this->rg->rgAcY = $acY; $this->rg->rgSeq = 1; $qu_rg = $this->rg->get_by_key();
if($qu_rg->num_rows()==0) { $con_rgSeq = array('rgStdId' => $stdId, 'rgAcY' => $acY, 'rgTmId' => $tmId); $this->rg->rgStdId = $stdId; $this->rg->rgTmId = $tmId; $this->rg->rgAcY = $acY; $this->rg->rgSeq = $this->rg->getNextSeq($con_rgSeq); $this->rg->rgSubmitType = 'B'; $this->rg->rgStatus = 'N'; $this->rg->rgCurId = $curId; $this->rg->rgSyId = $syId; $this->rg->rgCreateDate = date('Y-m-d H:i:s'); $this->rg->rgCreateUserId = $this->session->userdata('UsLogin'); $this->rg->rgUpdateDate = date('Y-m-d H:i:s'); $this->rg->rgUpdateUserId = $this->session->userdata('UsLogin'); $this->rg->insert(); }
$flg = 0; $this->rd->rdAcY = $acY; $this->rd->rdStdId = $stdId; $this->rd->rdTmId = $tmId; $this->rd->rdCoId = $this->input->post('coId'.$i); $this->rd->rdSeq = 1; $this->rd->get_by_key(TRUE); $qu_rd = $this->rd->get_by_key();
// ทำการลงทะเบียนรายวิชา if($qu_rd->num_rows()==0) { $this->rd->rdAcY = $acY; $this->rd->rdStdId = $stdId; $this->rd->rdTmId = $tmId; $this->rd->rdCoId = $this->input->post('coId'.$i); $this->rd->rdSeq = $this->rg->rgSeq; $this->rd->rdCreditAttempt = $this->input->post('creditAttempt'.$i); $this->rd->rdSection = $this->input->post('coSection'.$i); $this->rd->rdGrade = $this->input->post('rdGrade'.$i); $this->rd->rdDocNo = ''; $this->rd->rdCredit1 = $this->input->post('credit1'.$i); $this->rd->rdCredit2 = $this->input->post('credit2'.$i); $this->rd->rdNoCalGPA = 'N'; $this->rd->rdAllowPr = 'N'; $this->rd->rdCdId1 = $this->input->post('cdId1'.$i); $this->rd->rdCdId2 = $this->input->post('cdId2'.$i); $this->rd->rdUpdateDate = date('Y-m-d H:i:s'); $this->rd->rdUpdateUserId = $this->session->userdata('UsLogin'); $this->rd->insert();
$flg = 1; } else { $this->rd->rdGrade = $this->input->post('rdGrade'.$i); $this->rd->rdUpdateDate = date('Y-m-d H:i:s'); $this->rd->rdUpdateUserId = $this->session->userdata('UsLogin'); $this->rd->update(); }
// อัพเดทที่นั่งของรายวิชาที่เปิดสอน $this->co->coId = $this->input->post('coId'.$i); $this->co->get_by_key(TRUE); if($flg) { $this->co->coNumSeatReg += 1; } $this->co->coSendGradeStatus = 'Y'; $this->co->coDeclareStatus = 'Y'; $this->co->update(); } else { $this->rd->rdStdId = $stdId; $this->rd->rdAcY = $acY; $this->rd->rdTmId = $tmId; $this->rd->rdSeq = 1; $this->rd->rdCoId = $this->input->post('coId'.$i); $this->rd->get_by_key(); $qu_rd = $this->rd->get_by_key();
// ลบรายวิชาที่เคยลงทะเบียน if($qu_rd->num_rows()) { $this->rd->delete();
// อัพเดทที่นั่งของรายวิชาที่เปิดสอน $this->co->coId = $this->input->post('coId'.$i); $this->co->get_by_key(TRUE); $this->co->coNumSeatReg -= 1; $this->co->update(); }
// ลบการลงทะเบียน เมื่อไม่มีรายวิชาลงทะเบียนเหลืออยู่ $con_rd = array('rdStdId' => $stdId, 'rdAcY' => $acY, 'rdTmId' => $tmId, 'rdSeq' => 1); $rs_rd = $this->rd->qryRd($con_rd); if($rs_rd->num_rows()==0) { $this->rg->rgStdId = $stdId; $this->rg->rgAcY = $acY; $this->rg->rgTmId = $tmId; $this->rg->rgSeq = 1; $this->rg->delete(); } } } $this->backRegistAndSendGrade_input(); } else { $this->backRegistAndSendGrade_input(); } } // ##### end ลงทะเบียนและส่งเกรดย้อนหลัง
/* ##### start จัดการกองทุนกู้ยืม */ function showAllowSendGrade() { $this->load->model($this->config->item("rg_folder").'mo_rg_term','tm');
$this->contents['rs_tm'] = $this->tm->get_options('','','','n');
$this->contents['acY'] = $this->session->userdata('acY'); $this->contents['tm'] = $this->session->userdata('tmId');
$this->output($this->config->item("rg_folder")."v_showAllowSendGrade"); } function addAllowSendGrade() { $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<div class="error">','</div>'); $this->form_validation->set_rules('curName',' ','trim|xss_clean'); $this->form_validation->set_rules('curId',' ','trim|required|xss_clean'); $this->form_validation->set_rules('stdTmIdAdmit',' ','trim|xss_clean'); $this->form_validation->set_rules('adY',' ','trim|required|xss_clean'); $this->form_validation->set_rules('acY',' ','callback_checkAcY2'); $this->form_validation->set_rules('tmId',' ','trim|required|xss_clean');
if($this->form_validation->run() == true) { $this->asg_input(); } else { $this->showAllowSendGrade(); } } function asg_input() { $this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur'); $this->load->model($this->config->item("rg_folder").'mo_rg_term','tm'); $this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
$curId = $this->input->post('curId'); $adY = $this->input->post('adY'); $acY = $this->input->post('acY'); $tmId = $this->input->post('tmId');
$this->contents['acY'] = $acY; $this->contents['adY'] = $adY;
$this->cur->curId = $curId; $this->contents['qu_cur'] = $this->cur->get_by_key();
$this->tm->tmId = $tmId; $this->contents['qu_tm'] = $this->tm->get_by_key();
$con_rs_std = array('stdCurId' => $curId, 'stdAdY' => $adY); $ord_rs_std = array('stdCode' => 'ASC'); $this->contents['rs_std'] = $this->std->qryStdJoinPfAsg($con_rs_std, $ord_rs_std);
$this->output($this->config->item("rg_folder")."v_addAllowSendGrade"); } function asg_insert_update() { $this->load->model($this->config->item("rg_folder").'mo_rg_allowsendgrade','asg');
$cnt = $this->input->post('cnt'); $curId = $this->input->post('curId'); $acY = $this->input->post('acY'); $adY = $this->input->post('adY'); $tmId = $this->input->post('tmId');
$con_rs_asg = array('asgAcY' => $acY, 'asgTmId' => $tmId); $rs_asg = $this->asg->qryAsg($con_rs_asg,'','');
$this->db->trans_begin(); if($rs_asg->num_rows()) { foreach($rs_asg->result() as $row_asg) { $this->asg->asgStdId = $row_asg->asgStdId; $this->asg->asgTmId = $tmId; $this->asg->asgAcY = $acY; $this->asg->delete(); } }
for($i=0; $i<$cnt; $i++) { if($this->input->post('chk'.$i)=='Y') { $this->asg->asgStdId = $this->input->post('stdId'.$i); $this->asg->asgAcY = $acY; $this->asg->asgTmId = $tmId; $this->asg->insert(); } }
if($this->db->trans_status() === false) $this->db->trans_rollback(); else $this->db->trans_commit();
$this->asg_input(); } /* ##### end จัดการกองทุนกู้ยืม */
function std_showResStudy() { $this->load->model($this->config->item("rg_folder").'mo_rg_student','std'); $this->load->model($this->config->item("rg_folder").'mo_rg_studentsummary','ssm'); $this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd'); $this->load->model($this->config->item("rg_folder").'mo_rg_regist','rg');
$stdCode = $this->input->post('stdCode') ? $this->input->post('stdCode') : $this->session->userdata('UsPsCode');
$con_qu_std = array('stdCode' => $stdCode, 'stdGenStatus' => 'Y' ); $qu_std = $this->std->qryStd($con_qu_std); if ($qu_std->num_rows()) { $forceAssess = $this->forceAssess(); if ($forceAssess) { $row_std = $qu_std->row();
$con_qu_std = array('stdId' => $row_std->stdId); $this->contents['qu_std'] = $this->std->qryStdJoinSdtPfCurSySstElv($con_qu_std);
$i = 0; $arr = array(); $con_rs_ssm = array('ssmStdId' => $row_std->stdId); $rs_ssm = $this->ssm->qrySsm($con_rs_ssm); foreach ($rs_ssm->result() as $row_ssm) { $con_rs_ssm = array('ssmStdId' => $row_std->stdId , 'ssmTmId' => $row_ssm->ssmTmId , 'ssmAcY' => $row_ssm->ssmAcY ); $arr[$i]['qu_ssm'] = $this->ssm->qrySsmJoinTm($con_rs_ssm); $con_rs_rd = array('rdStdId' => $row_std->stdId, 'rdAcY' => $row_ssm->ssmAcY, 'rdTmId' => $row_ssm->ssmTmId ); $arr[$i]['rs_rd'] = $this->rd->qryRdJoinCoCrs($con_rs_rd); $con_qu_rg = array('rgStdId' => $row_std->stdId, 'rgAcY' => $row_ssm->ssmAcY, 'rgTmId' => $row_ssm->ssmTmId, 'rgStatus' => 'K' ); $qu_rg = $this->rg->qryRg($con_qu_rg); if ($qu_rg->num_rows()) { $arr[$i]['kssFlag'] = "** รักษาสถานภาพการเป็นนักศึกษา **"; }
$arr[$i]['sumCrAt'] = $this->rd->getSumCrAtByStdIdAcYTmId($row_std->stdId, $row_ssm->ssmAcY, $row_ssm->ssmTmId);
$i++; } $this->contents['rs'] = $arr; } } else { $this->contents['err_msg'] = "** ไม่ปรากฏรหัสนักศึกษาดังกล่าวในฐานข้อมูล **"; }
$this->output($this->config->item("rg_folder")."v_std_showResStudy"); }
/* ##### start callback function ##### */ /*function checkAcY($str){ if($str=='') { $this->form_validation->set_message('checkAcY','กรุณาป้อน%s'); return false; } else if(strlen($str)!=4) { $this->form_validation->set_message('checkAcY','%sจะต้องเท่ากับ 4 หลัก'); return false; } else if($str==0) { $this->form_validation->set_message('checkAcY','%sจะต้องมากกว่า 0'); return false; } else { return true; } } function checkAdY($str) { if($str=='') { $this->form_validation->set_message('checkAdY','กรุณาป้อน%s'); return false; } else if(strlen($str)!=4) { $this->form_validation->set_message('checkAdY','%sจะต้องเท่ากับ 4 หลัก'); return false; } else if($str==0) { $this->form_validation->set_message('checkAdY','%sจะต้องมากกว่า 0'); return false; } else { return true; } } function checkAcY2($str) { if($str=='') { $this->form_validation->set_message('checkAcY2','กรุณาป้อน%s'); return false; } else if(strlen($str)!=4) { $this->form_validation->set_message('checkAcY2','%sจะต้องเท่ากับ 4 หลัก'); return false; } else if($str==0) { $this->form_validation->set_message('checkAcY2','%sจะต้องมากกว่า 0'); return false; }
if($str >= $this->input->post('adY')) { return true; } else { $this->form_validation->set_message('checkAcY2','%sจะต้องมากกว่าหรือเท่ากับปีการศึกษาที่เข้า'); return false; } }*/ /* ##### end callback function ##### */ } ?>
|