Viewing file: checkregis.php (18.67 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include('rg_controller.php');
class Checkregis extends Rg_controller {
// function __construct() {
// parent::__construct();
// }
function prc_check() {
$this->load->model($this->config->item("rg_folder").'mo_rg_term','tm');
$this->load->model($this->config->item("rg_folder").'mo_rg_studyyear','sy');
$acY = $this->session->userdata('acY');
$tmId = $this->session->userdata('tmId');
$this->contents['acY'] = $acY;
$this->contents['tmId'] = $tmId;
$ord_rs_tm = array('tmCode' => 'ASC');
$this->contents['rs_tm'] = $this->tm->get_options('', $ord_rs_tm);
$ord_rs_sy = array('syCode' => 'ASC');
$this->contents['rs_sy'] = $this->sy->get_options('', $ord_rs_sy);
$this->output($this->config->item("rg_folder")."v_checkPreCourse");
}
function prc_show() {
$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_student','std');
$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_precourse','prc');
$this->load->model($this->config->item("rg_folder").'mo_rg_course','crs');
$this->load->model($this->config->item("rg_folder").'mo_rg_registfee','rf');
$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('adY',' ','trim|required|xss_clean');
$this->form_validation->set_rules('stdTmIdAdmit',' ','trim|xss_clean');
$this->form_validation->set_rules('acY',' ','trim|required|checkAcY|xss_clean');
$this->form_validation->set_rules('tmId',' ','trim|xss_clean');
$this->form_validation->set_rules('syId',' ','trim|required|xss_clean');
if($this->form_validation->run() == true) {
$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');
$this->cur->curId = $curId;
$qu_cur = $this->cur->get_by_key();
if ($qu_cur->num_rows()) {
$this->contents['qu_cur'] = $qu_cur;
}
$this->contents['adY'] = $adY;
$this->sy->syId = $syId;
$qu_sy = $this->sy->get_by_key();
if ($qu_sy->num_rows()) {
$this->contents['qu_sy'] = $qu_sy;
}
$this->contents['acY'] = $acY;
$this->tm->tmId = $tmId;
$qu_tm = $this->tm->get_by_key();
if ($qu_tm->num_rows()) {
$this->contents['qu_tm'] = $qu_tm;
}
$i = 0;
$arr = array();
$con_rs_std = array('stdCurId' => $curId,
'stdAdY' => $adY
);
$ord_rs_std = array('stdCode' => 'ASC');
$rs_std = $this->std->qryStd($con_rs_std, $ord_rs_std);
foreach ($rs_std->result() as $row_std) {
$con_rs_rd = array('rdStdId' => $row_std->stdId,
'rdAcY' => $acY,
'rdTmId' => $tmId
);
$rs_rd = $this->rd->qryRd($con_rs_rd);
foreach ($rs_rd->result() as $row_rd) {
$con_qu_std = array('stdId' => $row_std->stdId);
$arr[$i]['qu_std'] = $this->std->qryStdJoinPf($con_qu_std);
$arr[$i]['rdSeq'] = $row_rd->rdSeq;
$arr[$i]['rdAllowPr'] = $row_rd->rdAllowPr;
$con_qu_co = array('coId' => $row_rd->rdCoId);
$qu_co = $this->co->qryCoJoinCrs($con_qu_co);
$arr[$i]['qu_co'] = $qu_co;
$row_co = $qu_co->row();
$k = 0;
$flag1 = 1;
$crs = array();
$op = array();
$con_rs_prc = array('prcCrsId' => $row_co->coCrsId);
$ord_rs_prc = array('prcSeq' => 'ASC');
$rs_prc = $this->prc->qryPrc($con_rs_prc, $ord_rs_prc);
foreach ($rs_prc->result() as $row_prc) {
$crs[$k] = $row_prc->prcPrCrsId;
$op[$k] = $row_prc->prcAndOr;
$k++;
}
$flag1 = 0;
for ($ndex = 0; $ndex < count($crs); $ndex++) {
if ($ndex == 0) {
$rs_rd = $this->rd->qryRdByStdIdAcYTmIdCrsId($row_std->stdId, $acY, $tmId, $crs[$ndex]);
$flag1 = $rs_rd->num_rows();
}
if (isset($op[$ndex]) && $op[$ndex]) {
$rs_rd = $this->rd->qryRdByStdIdAcYTmIdCrsId($row_std->stdId, $acY, $tmId, $crs[$ndex+1]);
$flag2 = $rs_rd->num_rows();
if ($op[$ndex] == 'A') {
if ($flag1 && $flag2) {
$flag1 = 1;
} else {
$flag1 = 0;
}
} else if ($op[$ndex] == 'O') {
if ($flag1 || $flag2) {
$flag1 = 1;
} else {
$flag1 = 0;
}
}
} // end if
} // end for
if (!$flag1) {
// Prerequisite Names
$prNames = '';
for ($ndex = 0; $ndex < count($crs); $ndex++) {
$this->crs->crsId = $crs[$ndex];
$qu_crs = $this->crs->get_by_key();
if ($ndex == 0) {
$prNames = $qu_crs->row()->crsCode;
} else {
$prNames .= ', '.$qu_crs->row()->crsCode;
}
}
$arr[$i]['prNames'] = $prNames;
$con_rs_rf = array('rfStdId' => $row_std->stdId,
'rfAcY' => $acY,
'rfTmId' => $tmId
);
$arr[$i]['rs_rf'] = $this->rf->qryRf($con_rs_rf);
$i++;
} // end if flag1
} // end foreach rs_rd
} // end foreach rs_std
$this->contents['rs'] = $arr;
$this->output($this->config->item("rg_folder")."v_showPreCourse");
} else
$this->prc_check();
}
function rd_updateAllowPr() {
$this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd');
$cnt = $this->input->post('cnt');
$acY = $this->input->post('acY');
$tmId = $this->input->post('tmId');
$rdStdId = $this->input->post('rdStdId');
$rdSeq = $this->input->post('rdSeq');
$rdCoId = $this->input->post('rdCoId');
$rdAllowPr = $this->input->post('rdAllowPr');
for ($i = 0; $i < $cnt; $i++) {
$this->rd->rdStdId = $rdStdId[$i];
$this->rd->rdAcY = $acY;
$this->rd->rdTmId = $tmId;
$this->rd->rdSeq = $rdSeq[$i];
$this->rd->rdCoId = $rdCoId[$i];
$this->rd->get_by_key(TRUE);
$this->rd->rdUpdateDateTime = date('Y-m-d H:i:s');
$this->rd->rdUpdateUserId = $this->session->userdata('UsLogin');
$this->rd->rdAllowPr = (isset($rdAllowPr[$i]) && ($rdAllowPr[$i] == 'Y')) ? $rdAllowPr[$i] : 'N';
$this->rd->update();
}
redirect($this->config->item('rg_folder').'checkregis/prc_check');
}
// ##### start ตรวจสอบรายวิชาที่ลงทะเบียนเรียน
function checkRegistDetails() {
$this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
$this->load->model($this->config->item("rg_folder").'mo_rg_term','tm');
$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_registwithdraw','rw');
$std = $this->contents['std'] ? $this->contents['std'] : '';
$stdCode = $this->contents['stdCode'] ? $this->contents['stdCode'] : $this->input->post('stdCode');
$acY = $this->input->post('acY') ? $this->input->post('acY') : $this->session->userdata('acY');
$tmId = $this->input->post('tmId') ? $this->input->post('tmId') : $this->session->userdata('tmId');
$this->contents['std'] = $std;
if ($stdCode) {
$this->contents['stdCode'] = $stdCode;
$con_qu_std = array('stdCode' => $stdCode,
'stdGenStatus' => 'Y'
);
$qu_std = $this->std->qryStdJoinPfCurSySstElv($con_qu_std);
if ($qu_std->num_rows()) {
$this->contents['qu_std'] = $qu_std;
$row_std = $qu_std->row();
$this->contents['acY'] = $acY;
$this->contents['tmId'] = $tmId;
$this->tm->tmId = $tmId;
$this->contents['qu_tm'] = $this->tm->get_by_key();
$con_rs_rgAcY = array('rgStdId' => $row_std->stdId);
$this->contents['rs_rgAcY'] = $this->rg->get_optionsGroupAcY($con_rs_rgAcY, 'y');
$con_rs_rgTmId = array('rgStdId' => $row_std->stdId,
'rgAcY' => $acY
);
$this->contents['rs_rgTmId'] = $this->rg->get_optionsGroupTmId($con_rs_rgTmId, 'y');
$con_rs_rd = array('rdStdId' => $row_std->stdId,
'rdAcY' => $acY,
'rdTmId' => $tmId
);
$this->contents['rs_rd'] = $this->rd->qryRdJoinCoCrsRg($con_rs_rd);
$con_rs_rw = array('rwStdId' => $row_std->stdId,
'rwAcY' => $acY,
'rwTmId' => $tmId
);
$this->contents['rs_rw'] = $this->rw->qryRwJoinCoCrsRg($con_rs_rw);
$con_qu_rg = array('rgStdId' => $row_std->stdId,
'rgAcY' => $acY,
'rgTmId' => $tmId,
'rgStatus' => 'K'
);
$qu_rg = $this->rg->qryRg($con_qu_rg);
if ($qu_rg->num_rows()) {
$this->contents['kssFlag'] = "** รักษาสถานภาพการเป็นนักศึกษา **";
}
$con_qu_rd = array('rdStdId' => $row_std->stdId,
'rdAcY' => $acY,
'rdTmId' => $tmId
);
$this->contents['sumCrAt'] = $this->rd->getSumCrAt($con_qu_rd);
} else {
$this->contents['err_msg'] = "** ไม่ปรากฏรหัสนักศึกษาดังกล่าวในฐานข้อมูล **";
}
}
$this->output($this->config->item("rg_folder")."v_checkRegistDetails");
}
function std_checkRegistDetails() {
$this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
$stdCode = $this->session->userdata('UsPsCode');
$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['std'] = 'std_';
$this->contents['stdCode'] = $stdCode;
$this->checkRegistDetails();
} else {
$msg = "** ไม่ปรากฏรหัสนักศึกษาดังกล่าวในฐานข้อมูล **";
$this->session->set_flashdata('msg', $msg);
redirect($this->config->item('rg_folder').'msg/err_msg');
}
}
// function changeTm($acY, $stdId) {
// $this->load->model($this->config->item("rg_folder").'mo_rg_regist','rg');
//
// $con_rs_rgTmId = array('rgAcY' => $acY,
// 'rgStdId' => $stdId);
// $data['rs_rgTmId'] = $this->rg->get_optionsGroupTmId($con_rs_rgTmId, 'y');
//
// echo $this->load->view($this->config->item("rg_folder")."v_showTm", $data, TRUE);
// }
//
// function showRd($stdId='', $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_regist','rg');
// $this->load->model($this->config->item("rg_folder").'mo_rg_registwithdraw','rw');
//
// $data['qu_cfg'] = $this->cfg->qryCfg('','','','');
//
// $con_rs_rd = array('rdStdId' => $stdId,
// 'rdAcY' => $acY,
// 'rdTmId' => $tmId);
// $rs_rd = $this->rd->qryRdJnCrsOpCrs($con_rs_rd,'','');
//
// $i = 0;
// $arr = array();
// // หารายวิชาที่ลงทะเบียนเรียน
// if($rs_rd->num_rows()) {
// foreach($rs_rd->result() as $row_rd) {
// $this->rg->rgStdId = $stdId;
// $this->rg->rgTmId = $row_rd->rdTmId;
// $this->rg->rgAcY = $row_rd->rdAcY;
// $this->rg->rgSeq = $row_rd->rdSeq;
// $qu_rg = $this->rg->get_by_key();
//
// $arr[$i]['crs'] = $row_rd;
// $arr[$i]['rg'] = $qu_rg->row();
// $arr[$i]['flg'] = 0;
// //สถานะการลงทะเบียนเรียน
// // N: ปกติ
// // L: สาย
// // A: เพิ่มถอนปกติ
//
// $i++;
//
// }
// }
//
// // หารายวิชาที่ถอนการลงทะเบียน
// $con_rs_rw = array('rwStdId' => $stdId,
// 'rwAcY' => $acY,
// 'rwTmId' => $tmId);
// $rs_rw = $this->rw->qryRwJoinCoCrs($con_rs_rw,'','');
// if($rs_rw->num_rows()) {
// foreach($rs_rw->result() as $row_rw) {
// $this->rg->rgStdId = $stdId;
// $this->rg->rgTmId = $row_rw->rwTmId;
// $this->rg->rgAcY = $row_rw->rwAcY;
// $this->rg->rgSeq = $row_rw->rwSeq;
// $qu_rg = $this->rg->get_by_key();
//
// $arr[$i]['crs'] = $row_rw;
// $arr[$i]['rg'] = $qu_rg->row();
// $arr[$i]['flg'] = 1;
//
// $i++;
// }
// }
//
// // หาเทอมรักษาสภาพ
// $con_qu_kss = array('rgStdId' => $stdId,
// 'rgAcY' => $acY,
// 'rgTmId' => $tmId,
// 'rgStatus' => 'K');
// $qu_kss = $this->rg->qryRg($con_qu_kss,'','');
// if($qu_kss->num_rows()) {
// $data['flg_kss'] = "** รักษาสถานภาพการเป็นนักศึกษา **";
// }
//
// $con_sumCreditAttempt = array('rdStdId' => $stdId,
// 'rdAcY' => $acY,
// 'rdTmId' => $tmId);
// $data['sumCreditAttempt'] = $this->rd->getCreditAttempt($con_sumCreditAttempt);
// $data['arr'] = $arr;
//
// echo $this->load->view($this->config->item("rg_folder")."v_checkRegistDetailsRow", $data, TRUE);
// }
// ##### end ตรวจสอบรายวิชาที่ลงทะเบียนเรียน
// ##### start ตรวจสอบค่าลงทะเบียนเรียน
function showRegisFee() {
$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_student','std');
$this->load->model($this->config->item("rg_folder").'mo_rg_registfee','rf');
$this->load->model($this->config->item("rg_folder").'mo_rg_payment','py');
$curId = $this->input->post('curId');
$adY = $this->input->post('adY');
$acY = $this->input->post('acY');
$syId = $this->input->post('syId');
$tmId = $this->input->post('tmId');
$this->cur->curId = $curId;
$this->contents['qu_cur'] = $this->cur->get_by_key();
$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['adY'] = $adY;
$this->contents['acY'] = $acY;
$con_rs_std = array('stdCurId' => $curId,
'stdAdY' => $adY);
$ord_rs_std = array('stdCode' => '');
$rs_std = $this->std->qryStdJoinPf($con_rs_std,$ord_rs_std,'');
//echo "<pre>"; print_r($rs_std);
$arr = array();
$i = 0;
if($rs_std->num_rows()) {
foreach($rs_std->result() as $rowStd) {
$con_sumTotalAmt = array('rfStdId' => $rowStd->stdId,
'rfAcY' => $acY,
'rfSyId' => $syId,
'rfTmId' => $tmId);
$con_sumBalance = array('rfStdId' => $rowStd->stdId,
'rfAcY' => $acY,
'rfSyId' => $syId,
'rfTmId' => $tmId);
$con_sumLateFine = array('rfStdId' => $rowStd->stdId,
'rfAcY' => $rowStd->stdId,
'rfSyId' => $syId,
'rfTmId' => $tmId,
'pmLateStatus' => 'Y');
$arr[$i]['std'] = $rowStd;
$arr[$i]['sumTotalAmt'] = $this->rf->getSumTotalAmt($con_sumTotalAmt);
$arr[$i]['sumBalance'] = $this->rf->getSumBalance($con_sumBalance);
$arr[$i]['sumLateFine'] = $this->py->getSumLateFine($con_sumLateFine);
$i++;
}
}
$this->contents['arr'] = $arr;
$con_Tt = array('rfAcY' => $acY,
'rfSyId' => $syId,
'rfTmId' => $tmId,
'rfCurId' => $curId);
$con_Lf = array('rfAcY' => $acY,
'rfSyId' => $syId,
'rfTmId' => $tmId,
'pmLateStatus' => 'Y');
$this->contents['sumTt'] = $this->rf->getSumTotalAmt($con_Tt);
$this->contents['sumBl'] = $this->rf->getSumBalance($con_Tt);
$this->contents['sumLf'] = $this->py->getSumLateFine($con_Lf);
$this->output($this->config->item("rg_folder")."v_showRegisFee");
}
function checkRegistFee() {
$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->contents['rs_tm'] = $this->tm->get_options('', '', '', 'y');
$this->contents['acY'] = $this->session->userdata('acY');
$this->contents['tm'] = $this->session->userdata('tmId');
$this->output($this->config->item("rg_folder")."v_checkRegistFee");
}
function showRegistFee() {
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<font color="red">','</font>');
$this->form_validation->set_rules('curId','ชื่อหลักสูตร','trim|required|xss_clean');
$this->form_validation->set_rules('curName','ชื่อหลักสูตร','trim|required|xss_clean');
$this->form_validation->set_rules('stdTmIdAdmit','ปีการศึกษาที่เข้า','trim|required|xss_clean');
$this->form_validation->set_rules('adY','ปีการศึกษาที่เข้า','trim|required|xss_clean');
$this->form_validation->set_rules('tmId','ภาคการศึกษา','trim|required|xss_clean');
$this->form_validation->set_rules('acY','ปีการศึกษา','callback_checkAcY');
$this->form_validation->set_rules('syId','ชั้นปีนักศึกษา','trim|required|xss_clean');
if($this->form_validation->run() == true) {
$this->showRegisFee();
} else {
$this->checkRegistFee();
}
}
// ##### end ตรวจสอบค่าลงทะเบียนเรียน
// ##### start callback function
function checkAcY($str) {
$this->load->model($this->config->item("rg_folder").'mo_rg_termconfig','tmc');
$con_qu_tmc = array('tmcAcY' => $str);
$qu_tmc = $this->tmc->qryTmc($con_qu_tmc,'','');
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;
}
if($qu_tmc->num_rows()) {
if($qu_tmc->row()->tmcAcY >= $this->input->post('adY')) {
return true;
} else {
$this->form_validation->set_message('checkAcY','%sจะต้องมากกว่าหรือเท่ากับปีการศึกษาที่เข้า');
return false;
}
} else {
$this->form_validation->set_message('checkAcY','%sไม่ถูกต้อง');
return false;
}
}
// ##### end callback function
}
?>
|