Viewing file: student.php (75.12 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include("rg_controller.php");
class student extends Rg_controller {
// function __construct() {
// parent::__construct();
// }
function checkCitizen($str) {
$curId = $this->input->post('curId');
$adY = $this->input->post('adY');
$stdId = $this->input->post('stdId');
$citizen = $str;
$this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
if($stdId=='') { //---[กรณีเพิ่มใหม่]
$con_rs_std = array('stdCurId' => $curId,
'stdAdY' => $adY,
'sdtCitizenId' => $citizen);
$rs_std = $this->std->qryStdByCurId($con_rs_std);
} else { //---[กรณีอัพเดท]
$rs_std = $this->std->qryStdByCitizenIdJoinSdt($curId,$adY,$citizen,$stdId);
}
if($rs_std->num_rows() && $citizen!='') {
$this->form_validation->set_message('checkCitizen', '%sซ้ำ');
return false;
} else if($citizen!='') {
if(strlen($citizen)!=13 || checkCitizen($citizen)==false) {
$this->form_validation->set_message('checkCitizen', '%sไม่ถูกต้อง');
return false;
} else
return true;
} else
return true;
}
// ##### end callback function
// ##### start std
function std_show() {
$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_termconfig','tmc');
$con_rs_cur = array('curStatus' => 'Y');
$this->contents['rs_cur'] = $this->cur->get_options($con_rs_cur);
$this->contents['rs_tm'] = $this->tm->get_options('','','','n');
$ord_rs_tmc = array('tmcAcY' => 'DESC');
$this->contents['rs_tmc'] = $this->tmc->get_optionsGroupAcY('n',$ord_rs_tmc);
$this->contents['acY'] = $this->session->userdata('acY');
$this->contents['tmId'] = $this->session->userdata('tmId');
$this->output($this->config->item("rg_folder")."v_showStudent");
}
function std_search() {
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="error">','</div>');
$this->form_validation->set_rules('curId',' ','trim|required|is_natural_no_zero|xss_clean');
$this->form_validation->set_rules('tmId',' ','trim|xss_clean');
$this->form_validation->set_rules('adY',' ','trim|xss_clean');
if($this->form_validation->run() == true) {
$this->load->model($this->config->item("rg_folder").'mo_rg_generation','gen');
$this->load->model($this->config->item("rg_folder").'mo_rg_termconfig','tmc');
$this->load->model($this->config->item("rg_folder").'mo_rg_term','tm');
$this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur');
$this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
$curId = $this->input->post('curId');
$tmId = $this->input->post('tmId');
$adY = $this->input->post('adY');
$con_rs_cur = array('curStatus' => 'Y');
$this->contents['rs_cur'] = $this->cur->get_options($con_rs_cur);
$this->contents['rs_tm'] = $this->tm->get_options('','','','n');
$ord_rs_tmc = array('tmcAcY' => 'DESC');
$this->contents['rs_tmc'] = $this->tmc->get_optionsGroupAcY('n',$ord_rs_tmc);
$this->contents['acY'] = $this->session->userdata('acY');
$this->contents['tmId'] = $this->session->userdata('tmId');
//---[ส่วนข้างบนแสดงส่วนค้นหา]
$con_qu_gen = array('genCurId' => $curId,
'genTmId' => $tmId,
'genAcY' => $adY);
$qu_gen = $this->gen->qryGen($con_qu_gen);
if($qu_gen->num_rows()) {
$this->contents['qu_gen'] = $qu_gen;
} else {
$this->contents['flgmsg'] = "** ไม่สามารถเพิ่มนักศึกษาได้ ต้องทำการเพิ่มข้อมูลรุ่นก่อน ที่เมนูข้อมูลพื้นฐานของระบบ -> ข้อมูลรุ่น **";
}
$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();
$this->contents['adY'] = $adY;
$con_genStatus = array('stdCurId' => $curId,
'stdAdY' => $adY);
$this->contents['genStatus'] = $this->std->qryStdGroupStdGenStatus($con_genStatus);
$con_rs_std = array('stdCurId' => $curId,
'stdAdY' => $adY);
$ord_rs_std = array('stdCode' => '',
'stdName' => '',
'stdSurname' => '');
$this->contents['rs_std'] = $this->std->qryStdJoinPfSoPrvEt($con_rs_std,$ord_rs_std);
//---[จบ แสดงส่วนค้นหา]
$this->output($this->config->item("rg_folder")."v_showStudent");
} else {
$this->std_show();
}
}
function std_add() {
$this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
$this->load->model($this->config->item("rg_folder").'mo_rg_studentdetails','sdt');
$this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur');
$this->load->model($this->config->item("ppc_folder").'mo_prefix','pf');
$this->load->model($this->config->item("rg_folder").'mo_rg_preadmit','pa');
$this->load->model($this->config->item("rg_folder").'mo_rg_healthprivilege','hp');
$this->load->model($this->config->item("rg_folder").'mo_rg_term','tm');
$this->load->model($this->config->item("rg_folder").'mo_rg_entrytype','et');
$this->load->model($this->config->item("rg_folder").'mo_rg_studentstatus','sst');
$this->load->model($this->config->item("rg_folder").'mo_rg_financestatus','fs');
$this->load->model($this->config->item("rg_folder").'mo_rg_termconfig','tmc');
$this->contents['rs_pf'] = $this->pf->get_options();
$this->contents['rs_pa'] = $this->pa->get_options();
$this->contents['rs_hp'] = $this->hp->get_options();
$this->contents['rs_et'] = $this->et->get_options('','','','n');
$stdId = $this->input->post('stdId');
$curId = $this->input->post('curId');
$tmId = $this->input->post('tmId');
$adY = $this->input->post('adY');
$genId = isset($this->type) ? $this->genId : $this->input->post('genId');
$addSpe = $this->input->post('addSpe');
$type = (isset($this->type) || $this->input->post('type')) ? 'T' : '';
$stdAdmitDate = (isset($this->stdAdmitDate)) ? $this->stdAdmitDate : $this->input->post('admitDate');
$con_qu_cur = array('curId' => $curId);
$this->contents['qu_cur'] = $this->cur->qryCurJoinElv($con_qu_cur);
//---[สำหับนักศึกษาปี 1 เข้าใหม่]
$this->sst->sstId = 1;
$this->contents['qu_sst'] = $this->sst->get_by_key();
$this->fs->fsId = 1;
$this->contents['qu_fs'] = $this->fs->get_by_key();
$con_genStatus = array('stdCurId' => $curId,
'stdAdY' => $adY);
$genStatus = $this->std->qryStdGroupStdGenStatus($con_genStatus);
if($genStatus=='Y') {
$con_stdCode = array('stdCurId' => $curId,
'stdAdY' => $adY);
$this->contents['stdCode'] = $this->std->GetNextStdCode($con_stdCode);
}
//---[จบ สำหรับนักศึกษาปี 1 เข้าใหม่]
$this->tm->tmId = $tmId;
$this->contents['qu_tm'] = $this->tm->get_by_key();
$this->contents['tmcFrDate'] = ($type=='T') ? $stdAdmitDate : $this->tmc->getMinToDateByAcY($adY);
$this->contents['tmcToDate'] = $this->tmc->getMaxToDateByAcY($adY);
$this->contents['adY'] = $adY;
$this->contents['genId'] = $genId;
$this->contents['addSpe'] = $addSpe;
$this->contents['type'] = $type;
// กรณีอัพเดท
if($stdId!='') {
$this->contents['qu_std'] = $this->std->qryStdMB($stdId);
}
$con_qu_so = array('stdId' => $stdId);
$this->contents['qu_so'] = $this->std->qryStdPfSoPrv($con_qu_so);
$this->contents['qu_parent'] = $this->sdt->qryAddrOfParentJoinDtApPrv($stdId);
$this->output($this->config->item("rg_folder")."v_addStudent");
}
function std_insert_update() {
$chkStdCode = $this->input->post('chkStdCode');
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="error">','</div>');
$this->form_validation->set_rules('stdId',' ','trim|xss_clean');
$this->form_validation->set_rules('stdCode',' ','trim|xss_clean');
$this->form_validation->set_rules('stdPfId',' ','trim|required|xss_clean');
$this->form_validation->set_rules('stdName',' ','trim|required|xss_clean');
$this->form_validation->set_rules('stdSurname',' ','trim|required|xss_clean');
$this->form_validation->set_rules('chkStdCode',' ', 'trim|xss_clean');
if($chkStdCode=='Y') {
$this->form_validation->set_rules('sdtCitizenId','เลขที่บัตรประจำตัวประชาชน','trim|integer|required|callback_checkCitizen|xss_clean');
} else {
$this->form_validation->set_rules('sdtCitizenId','เลขที่บัตรประจำตัวประชาชน','trim|integer|callback_checkCitizen|xss_clean');
}
$this->form_validation->set_rules('curId',' ','trim|required|xss_clean');
$this->form_validation->set_rules('curName',' ','trim|xss_clean');
$this->form_validation->set_rules('levelId',' ','trim|required|xss_clean');
$this->form_validation->set_rules('levelName',' ','trim|xss_clean');
$this->form_validation->set_rules('genId',' ','trim|required|xss_clean');
$this->form_validation->set_rules('sdtPfIdParent',' ','trim|xss_clean');
$this->form_validation->set_rules('sdtParentName',' ','trim|xss_clean');
$this->form_validation->set_rules('sdtParentSurname',' ','trim|xss_clean');
$this->form_validation->set_rules('sdtParentRelationship',' ','trim|xss_clean');
$this->form_validation->set_rules('sdtParentAddr',' ','trim|xss_clean');
$this->form_validation->set_rules('dtNameParent',' ','trim|xss_clean');
$this->form_validation->set_rules('sdtDtIdParent',' ','trim|xss_clean');
$this->form_validation->set_rules('apNameParent',' ','trim|xss_clean');
$this->form_validation->set_rules('sdtApIdParent',' ','trim|xss_clean');
$this->form_validation->set_rules('prvNameParent',' ','trim|xss_clean');
$this->form_validation->set_rules('sdtPrvIdParent',' ','trim|xss_clean');
$this->form_validation->set_rules('sdtParentPostCode',' ','trim|integer|min_length[5]|xss_clean');
$this->form_validation->set_rules('sdtParentPhoneNo',' ','trim|integer|min_length[9]|max_length[10]|xss_clean');
$this->form_validation->set_rules('sdtParentMobileNo',' ','trim|integer|min_length[10]|max_length[10]|xss_clean');
$this->form_validation->set_rules('sdtParentEmail',' ','trim|xss_clean');
$this->form_validation->set_rules('sdtParentOccupation',' ','trim|xss_clean');
$this->form_validation->set_rules('sdtParentIncome',' ','trim|integer|xss_clean');
$this->form_validation->set_rules('adY',' ','trim|xss_clean');
$this->form_validation->set_rules('tmCode',' ','trim|xss_clean');
$this->form_validation->set_rules('tmId',' ','trim|xss_clean');
$this->form_validation->set_rules('stdAdmitDate',' ','trim|xss_clean');
$this->form_validation->set_rules('admitDate',' ','trim|xss_clean');
$this->form_validation->set_rules('stdGraduateDate',' ','trim|xss_clean');
$this->form_validation->set_rules('syCode',' ','trim|xss_clean');
$this->form_validation->set_rules('syId',' ','trim|xss_clean');
$this->form_validation->set_rules('stdEtId',' ','trim|xss_clean');
$this->form_validation->set_rules('soName',' ','trim|xss_clean');
$this->form_validation->set_rules('stdSoId',' ','trim|required|xss_clean');
$this->form_validation->set_rules('prvNameSo',' ','trim|xss_clean');
$this->form_validation->set_rules('sstName',' ','trim|xss_clean');
$this->form_validation->set_rules('sstId',' ','trim|xss_clean');
$this->form_validation->set_rules('fsName',' ','trim|xss_clean');
$this->form_validation->set_rules('fsId',' ','trim|xss_clean');
$this->form_validation->set_rules('stdPaId',' ','trim|xss_clean');
$this->form_validation->set_rules('sdtCanRefund',' ','trim|xss_clean');
$this->form_validation->set_rules('sdtHpId',' ','trim|xss_clean');
$this->form_validation->set_rules('type',' ','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_studentdetails','sdt');
$this->load->model($this->config->item("ppc_folder").'mo_prefix','pf');
$stdId = $this->input->post('stdId');
$stdCode = $this->input->post('stdCode');
$stdPfId = $this->input->post('stdPfId');
$stdName = $this->input->post('stdName');
$stdSurname = $this->input->post('stdSurname');
$sdtCitizenId = $this->input->post('sdtCitizenId');
$curId = $this->input->post('curId');
$stdGenId = $this->input->post('genId');
$sdtPfIdParent = ($this->input->post('sdtPfIdParent')=="") ? NULL : $this->input->post('sdtPfIdParent');
$sdtParentName = $this->input->post('sdtParentName');
$sdtParentSurname = $this->input->post('sdtParentSurname');
$sdtParentRelationship = $this->input->post('sdtParentRelationship');
$sdtParentAddr = $this->input->post('sdtParentAddr');
$sdtDtIdParent = ($this->input->post('sdtDtIdParent')=="") ? NULL : $this->input->post('sdtDtIdParent');
$sdtApIdParent = ($this->input->post('sdtApIdParent')=="") ? NULL : $this->input->post('sdtApIdParent');
$sdtPrvIdParent = ($this->input->post('sdtPrvIdParent')=="") ? NULL : $this->input->post('sdtPrvIdParent');
$sdtParentPostCode = $this->input->post('sdtParentPostCode');
$sdtParentPhoneNo = $this->input->post('sdtParentPhoneNo');
$sdtParentMobileNo = $this->input->post('sdtParentMobileNo');
$sdtParentEmail = $this->input->post('sdtParentEmail');
$sdtParentOccupation = $this->input->post('sdtParentOccupation');
$adY = $this->input->post('adY');
$tmId = $this->input->post('tmId');
$stdAdmitDate = $this->input->post('stdAdmitDate');
$admitDate = $this->input->post('admitDate');
$syId = $this->input->post('syId');
$stdEtId = $this->input->post('stdEtId');
$stdSoId = $this->input->post('stdSoId');
$stdSstId = $this->input->post('sstId');
$stdFsId = ($this->input->post('fsId')=="") ? NULL : $this->input->post('fsId');
$stdPaId = ($this->input->post('stdPaId')=="") ? NULL : $this->input->post('stdPaId');
$sdtCanRefund = $this->input->post('sdtCanRefund');
$sdtHpId = ($this->input->post('sdtHpId')=="") ? NULL : $this->input->post('sdtHpId');
$sdtParentIncome = $this->input->post('sdtParentIncome');
$type = $this->input->post('type');
$this->pf->prefixId = $stdPfId;
$this->pf->get_by_key(TRUE);
$this->db->trans_begin();
if($stdId=='') {
$this->std->stdId = '';
$this->std->stdCode = ($stdCode) ? $stdCode : NULL;
$this->std->stdName = $stdName;
$this->std->stdNameE = '';
$this->std->stdSurname = $stdSurname;
$this->std->stdSurnameE = '';
$this->std->stdCreditAttempt = 0;
$this->std->stdCreditSatisfy = 0 ;
$this->std->stdGPA = 0;
$this->std->stdAdY = $adY;
$this->std->stdAdmitDate = $admitDate;
$this->std->stdGraduateY = 0;
$this->std->stdGraduateDate = '0000-00-00';
$this->std->stdTotalPoint = 100;
$this->std->stdExitExam = 'N';
$this->std->stdHonor = '';
$this->std->stdMedal = '';
$this->std->stdGenStatus = ($chkStdCode=='Y') ? 'Y' : 'N';
$this->std->stdPfId = $stdPfId;
$this->std->stdCurId = $curId;
$this->std->stdTmIdAdmit = $tmId;
$this->std->stdSyId = $syId;
$this->std->stdSstId = $stdSstId;
$this->std->stdGenId = $stdGenId;
$this->std->stdEtId = $stdEtId;
$this->std->stdEt2Id = ($type=='T') ? 2 : 1; // 2: รับโอน, 1: รับตรง
$this->std->stdPaId = ($stdPaId=='') ? NULL : $stdPaId;
$this->std->stdSoId = $stdSoId;
$this->std->stdFsId = $stdFsId;
$this->std->stdSstIdTmp = 1;;
$this->std->stdUpdateDate = date('Y-m-d H:i:s');
$this->std->stdUpdateUsLogin = $this->session->userdata('UsLogin');
$this->std->insert();
$this->sdt->sdtStdId = $this->std->last_insert_id();
$this->sdt->sdtOldName = '';
$this->sdt->sdtSex = trim(strtoupper($this->pf->defaultSex));
$this->sdt->sdtCitizenId = $sdtCitizenId;
$this->sdt->sdtBirthDate = '0000-00-00';
$this->sdt->sdtBloodGroup = '';
$this->sdt->sdtCardExpireDate = '0000-00-00';
$this->sdt->sdtEmail = '';
$this->sdt->sdtWeight = '';
$this->sdt->sdtHeight = '';
$this->sdt->sdtPicturePath = 'photo.jpg';
$this->sdt->sdtCanRefund = $sdtCanRefund;
$this->sdt->sdtOccExamResult = '';
$this->sdt->sdtHomeAddr = '';
$this->sdt->sdtHomePostCode = '';
$this->sdt->sdtHomePhoneNo = '';
$this->sdt->sdtCurrentAddr = '';
$this->sdt->sdtCurrentPostCode = '';
$this->sdt->sdtCurrentPhoneNo = '';
$this->sdt->sdtWorkName = '';
$this->sdt->sdtWorkAddr = '';
$this->sdt->sdtWorkPostCode = '';
$this->sdt->sdtWorkPhoneNo = '';
$this->sdt->sdtWorkPosition = '';
$this->sdt->sdtWorkSalary = '';
$this->sdt->sdtWorkStatus = '';
$this->sdt->sdtFatherName = '';
$this->sdt->sdtFatherSurname = '';
$this->sdt->sdtFatherAddr = '';
$this->sdt->sdtFatherPostCode = '';
$this->sdt->sdtFatherPhoneNo = '';
$this->sdt->sdtFatherOccupation = '';
$this->sdt->sdtFatherStatus = '';
$this->sdt->sdtMotherName = '';
$this->sdt->sdtMotherSurname = '';
$this->sdt->sdtMotherAddr = '';
$this->sdt->sdtMotherPostCode = '';
$this->sdt->sdtMotherPhoneNo = '';
$this->sdt->sdtMotherOccupation = '';
$this->sdt->sdtMotherStatus = '';
$this->sdt->sdtParentName = $sdtParentName;
$this->sdt->sdtParentSurname = $sdtParentSurname;
$this->sdt->sdtParentRelationship = $sdtParentRelationship;
$this->sdt->sdtParentAddr = $sdtParentAddr;
$this->sdt->sdtParentPostCode = $sdtParentPostCode;
$this->sdt->sdtParentPhoneNo = $sdtParentPhoneNo;
$this->sdt->sdtParentMobileNo = $sdtParentMobileNo;
$this->sdt->sdtParentEmail = $sdtParentEmail;
$this->sdt->sdtParentOccupation = $sdtParentOccupation;
$this->sdt->sdtParentIncome = $sdtParentIncome;
$this->sdt->sdtContactName = '';
$this->sdt->sdtContactAddr = '';
$this->sdt->sdtContactPostCode = '';
$this->sdt->sdtContactPhoneNo = '';
$this->sdt->sdtGraduateAddr = '';
$this->sdt->sdtGraduatePostCode = '';
$this->sdt->sdtGraduatePhoneNo = '';
$this->sdt->sdtPrvIdBirth = NULL;
$this->sdt->sdtCntId = NULL;
$this->sdt->sdtNtId = NULL;
$this->sdt->sdtRlgId = NULL;
$this->sdt->sdtMsId = NULL;
$this->sdt->sdtRtId = NULL;
$this->sdt->sdtHpId = NULL;
$this->sdt->sdtPfIdParent = $sdtPfIdParent;
$this->sdt->sdtDtIdHome = NULL;
$this->sdt->sdtApIdHome = NULL;
$this->sdt->sdtPrvIdHome = NULL;
$this->sdt->sdtDtIdCurrent = NULL;
$this->sdt->sdtApIdCurrent = NULL;
$this->sdt->sdtPrvIdCurrent = NULL;
$this->sdt->sdtDtIdWork = NULL;
$this->sdt->sdtApIdWork = NULL;
$this->sdt->sdtPrvIdWork = NULL;
$this->sdt->sdtDtIdFather = NULL;
$this->sdt->sdtApIdFather = NULL;
$this->sdt->sdtPrvIdFather = NULL;
$this->sdt->sdtDtIdMother = NULL;
$this->sdt->sdtApIdMother = NULL;
$this->sdt->sdtPrvIdMother = NULL;
$this->sdt->sdtDtIdParent = $sdtDtIdParent;
$this->sdt->sdtApIdParent = $sdtApIdParent;
$this->sdt->sdtPrvIdParent = $sdtPrvIdParent;
$this->sdt->sdtDtIdContact = NULL;
$this->sdt->sdtApIdContact = NULL;
$this->sdt->sdtPrvIdContact = NULL;
$this->sdt->sdtDtIdGraduate = NULL;
$this->sdt->sdtApIdGraduate = NULL;
$this->sdt->sdtPrvIdGraduate = NULL;
$this->sdt->sdtEdgIdPre = NULL;
$this->sdt->insert();
} else {
$this->std->stdId = $stdId;
$this->std->get_by_key(TRUE);
$this->std->stdPfId = $stdPfId;
$this->std->stdName = $stdName;
$this->std->stdSurname = $stdSurname;
$this->std->stdEtId = $stdEtId;
$this->std->stdSoId = $stdSoId;
$this->std->stdPaId = ($stdPaId) ? $stdPaId : NULL;
$this->std->update();
$this->sdt->sdtStdId = $stdId;
$this->std->get_by_key(TRUE);
$this->sdt->sdtCitizenId = $sdtCitizenId;
$this->sdt->sdtPfIdParent = $sdtPfIdParent;
$this->sdt->sdtParentName = $sdtParentName;
$this->sdt->sdtParentSurname = $sdtParentSurname;
$this->sdt->sdtParentRelationship = $sdtParentRelationship;
$this->sdt->sdtParentAddr = $sdtParentAddr;
$this->sdt->sdtDtIdParent = $sdtDtIdParent;
$this->sdt->sdtApIdParent = $sdtApIdParent;
$this->sdt->sdtDtIdParent = $sdtDtIdParent;
$this->sdt->sdtPrvIdParent = $sdtPrvIdParent;
$this->sdt->sdtParentPostCode = $sdtParentPostCode;
$this->sdt->sdtParentPhoneNo = $sdtParentPhoneNo;
$this->sdt->sdtParentMobileNo = $sdtParentMobileNo;
$this->sdt->sdtParentEmail = $sdtParentEmail;
$this->sdt->sdtParentOccupation = $sdtParentOccupation;
$this->sdt->sdtParentIncome = $sdtParentIncome;
$this->sdt->sdtCanRefund = $sdtCanRefund;
$this->sdt->sdtHpId = $sdtHpId;
$this->sdt->update();
}
if($this->db->trans_status() === false) {
$this->db->trans_rollback();
} else {
$this->db->trans_commit();
}
if(!$type)
redirect($this->config->item("rg_folder").'student/std_show');
else
redirect($this->config->item("rg_folder").'student/std_showTSt');
} else {
$this->std_add();
}
}
function std_delete() {
$this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
$this->load->model($this->config->item("rg_folder").'mo_rg_studentdetails','sdt');
$stdId = $this->input->post('stdId');
$this->std->stdId = $stdId;
$this->sdt->sdtStdId = $stdId;
$this->sdt->delete();
$this->std->delete();
if($this->db->trans_status() === false) {
$this->db->trans_rollback();
$this->session->set_flashdata('msg', 41);
} else {
$this->db->trans_commit();
$this->session->set_flashdata('msg', 30);
}
redirect($this->config->item("rg_folder")."student/std_show");
}
// ##### start บันทึกนักศึกษาเทียบเท่า/เทียบโอน
function std_showTSt() {
$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');
$con_rs_cur = array('curStatus' => 'Y');
$ord_rs_cur = array('curName' => '');
$this->contents['rs_cur'] = $this->cur->get_options($con_rs_cur,$ord_rs_cur,'','y');
$this->contents['rs_tm'] = $this->tm->get_options('','','','n');
$this->contents['rs_sy'] = $this->sy->get_options('','','','n');
$this->output($this->config->item("rg_folder")."v_showTransferStd");
}
function std_addTst() {
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="error">','</div>');
$this->form_validation->set_rules('curId',' ','trim|required|xss_clean');
$this->form_validation->set_rules('adY',' ','trim|required|callback_checkAdY|xss_clean');
$this->form_validation->set_rules('tmId',' ','trim|required|xss_clean');
$this->form_validation->set_rules('syId',' ','callback_checkSy');
$this->form_validation->set_rules('stdAdmitDate',' ','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_generation','gen');
$curId = $this->input->post('curId');
$adY = $this->input->post('adY');
$tmId = $this->input->post('tmId');
$syId = $this->input->post('syId');
$stdAdmitDate = splitDateForm2($this->input->post('stdAdmitDate'),'-');
$con_rs_std = array('stdCurId' => $curId,
'stdAdY' => $adY,
'stdGenStatus' => 'Y');
$rs_std = $this->std->qryStd($con_rs_std);
// เทียบโอนได้ต่อเมื่อหลักสูตรที่เลือกถูกสร้างรุ่น และสถานะการสร้างรหัสเป็น Y
if($rs_std->num_rows()) {
$con_qu_gen = array('genCurId' => $curId,
'genTmId' => $tmId,
'genAcY' => $adY);
$qu_gen = $this->gen->qryGen($con_qu_gen);
$this->type = 'T';
$this->stdAdmitDate = $stdAdmitDate;
$this->genId = $qu_gen->row()->genId;
$this->std_add();
} else {
$this->std_showNoTst();
}
} else {
$this->std_showTSt();
}
}
function std_showNoTst() {
$this->output($this->config->item("rg_folder")."v_showNoTst");
}
// ##### end บันทึกนักศึกษาเทียบเท่า/เทียบโอน
// ##### สร้างรหัสนักศึกษาแบบอัตโนมัติ
function std_beforeGenCode() {
$this->output($this->config->item("rg_folder")."v_beforeGenStudentCode");
}
function std_showStdCode() {
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="error">','</div>');
$this->form_validation->set_rules('curId',' ','trim|required|xss_clean');
$this->form_validation->set_rules('curName',' ','trim|xss_clean');
$this->form_validation->set_rules('tmIdAdmit',' ','trim|required|xss_clean');
$this->form_validation->set_rules('stdAdY',' ','trim|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_curriculum','cur');
$this->load->model($this->config->item("rg_folder").'mo_rg_prefix','pf');
$curId = $this->input->post('curId');
$stdAdY = $this->input->post('stdAdY');
$tmIdAdmit = $this->input->post('tmIdAdmit');
$this->contents['stdAdY'] = $stdAdY;
$this->contents['tmIdAdmit'] = $tmIdAdmit;
$this->cur->curId = $curId;
$this->contents['qu_cur'] = $this->cur->get_by_key();
$con_rs_std = array('stdCurId' => $curId,
'stdAdY' => $stdAdY,
'stdTmIdAdmit' => $tmIdAdmit);
$this->contents['rs_std'] = $this->std->qryStdPfSoPrv($con_rs_std,'','');
$this->output($this->config->item("rg_folder")."v_genStudentCode");
} else
$this->std_beforeGenCode();
}
function std_genStdCode() {
$this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur');
$this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
$this->load->model($this->config->item("rg_folder").'mo_rg_config','cfg');
$curId = $this->input->post('curId');
$stdAdY = $this->input->post('stdAdY');
$tmIdAdmit = $this->input->post('tmIdAdmit');
$curCcId = $this->input->post('curCcId');
$this->contents['curId'] = $curId;
$this->contents['stdAdY'] = $stdAdY;
$this->contents['tmIdAdmit'] = $tmIdAdmit;
$this->contents['curCcId'] = $curCcId;
$this->cur->curId = $curId;
$this->contents['qu_cur'] = $this->cur->get_by_key();
$con_rs_std = array('stdCurId' => $curId,
'stdAdY' => $stdAdY,
'stdTmIdAdmit' => $tmIdAdmit);
$ord_rs_std = array('stdName' => '',
'stdSurname' => '');
$rs_std = $this->std->qryStdPfSoPrv($con_rs_std,$ord_rs_std);
$qu_cfg = $this->cfg->qryCfg();
$cfgClgCode = $qu_cfg->row()->cfgClgCode;
$cfgGenStdCodePlace = $this->cfg->cfgGenStdCodePlace();
$cfgGenStdCodeCurriculum = $this->cfg->cfgGenStdCodeCurriculum($curId,$curCcId);
//$maxStdCode = substr($stdAdY, -2).$cfgClgCode.substr('0'.$curCcId, -2).substr('001', -3);
$maxStdCode = substr($stdAdY, -2).$cfgGenStdCodePlace->row()->clgAddr.$cfgGenStdCodePlace->row()->clgPhoneNo.$cfgGenStdCodeCurriculum->row()->ccCode.substr('001', -3);
$this->contents['rs_std'] = $rs_std;
$this->contents['maxStdCode'] = $maxStdCode;
$this->output($this->config->item("rg_folder")."v_afterGenStudentCode");
}
function std_processGenStdCode() {
$this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur');
$this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
$this->load->model($this->config->item("rg_folder").'mo_rg_config','cfg');
$curId = $this->input->post('curId');
$stdAdY = $this->input->post('stdAdY');
$tmIdAdmit = $this->input->post('tmIdAdmit');
$curCcId = $this->input->post('curCcId');
$qu_cfg = $this->cfg->qryCfg();
$cfgClgCode = $qu_cfg->row()->cfgClgCode;
$con_rs_std = array('stdCurId' => $curId,
'stdAdY' => $stdAdY,
'stdTmIdAdmit' => $tmIdAdmit);
$ord_rs_std = array('stdName' => '',
'stdSurname' => '');
$rs_std = $this->std->qryStdPfSoPrv($con_rs_std,$ord_rs_std);
$cfgGenStdCodePlace = $this->cfg->cfgGenStdCodePlace();
$cfgGenStdCodeCurriculum = $this->cfg->cfgGenStdCodeCurriculum($curId,$curCcId);
$i = 1;
if($rs_std->num_rows()) {
$flgmsg = 0;
$this->db->trans_begin();
foreach($rs_std->result() as $row_std) {
$this->std->stdId = $row_std->stdId;
$this->std->get_by_key(TRUE);
//$this->std->stdCode = substr($stdAdY, -2).$cfgClgCode.substr('0'.$curCcId, -2).substr('00'.$i, -3);
$this->std->stdCode = substr($stdAdY, -2).$cfgGenStdCodePlace->row()->clgAddr.$cfgGenStdCodePlace->row()->clgPhoneNo.$cfgGenStdCodeCurriculum->row()->ccCode.substr('00'.$i, -3);
$this->std->stdGenStatus = 'Y';
$this->std->stdUpdateDate = date('Y-m-d H:i:s');
$this->std->stdUpdateUsLogin = $this->session->userdata('UsLogin');
$this->std->update();
$flgmsg = 10;
$i++;
}
if($this->db->trans_status() === false) {
$this->db->trans_rollback();
} else {
$this->db->trans_commit();
}
}
redirect($this->config->item("rg_folder")."student/std_beforeGenCode");
}
//---[]--- จบสร้างรหัสนักศึกษาแบบอัตโนมัติ
//---[]--- สร้างรหัสนักศึกษาแบบกำหนดเอง
function std_beforeSetCode() {
$this->contents['setCode'] = 'Y';
$this->output($this->config->item("rg_folder")."v_beforeGenStudentCode");
}
function std_setStdCode() {
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="error">','</div>');
$this->form_validation->set_rules('curId',' ','trim|required|xss_clean');
$this->form_validation->set_rules('curName',' ','trim|xss_clean');
$this->form_validation->set_rules('tmIdAdmit',' ','trim|required|xss_clean');
$this->form_validation->set_rules('stdAdY',' ','trim|required|xss_clean');
if($this->form_validation->run() == true)
$this->std_showSetStdCode();
else
$this->std_beforeSetCode();
}
function std_showSetStdCode() {
$this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
$this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur');
$curId = $this->input->post('curId');
$stdAdY = $this->input->post('stdAdY');
$tmIdAdmit = $this->input->post('tmIdAdmit');
$this->contents['curId'] = $curId;
$this->contents['stdAdY'] = $stdAdY;
$this->contents['tmIdAdmit'] = $tmIdAdmit;
$this->contents['msg'] = (isset($this->msg)) ? 'กำหนดรัหสนักศึกษาซ้ำ' : '';
$this->cur->curId = $curId;
$this->contents['qu_cur'] = $this->cur->get_by_key();
$con_rs_std = array('stdCurId' => $curId,
'stdAdY' => $stdAdY,
'stdTmIdAdmit' => $tmIdAdmit);
$ord_rs_std = array('stdName' => '',
'stdSurname' => '');
$this->contents['rs_std'] = $this->std->qryStdPfSoPrv($con_rs_std,$ord_rs_std);
$this->output($this->config->item("rg_folder")."v_setStudentCode");
}
function std_processSetStdCode() {
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="error">','</div>');
$this->form_validation->set_rules('curId',' ','trim|required|xss_clean');
$this->form_validation->set_rules('curName',' ','trim|xss_clean');
$this->form_validation->set_rules('curCcId',' ','trim|required|xss_clean');
$this->form_validation->set_rules('stdAdY',' ','trim|required|xss_clean');
$this->form_validation->set_rules('tmIdAdmit',' ','trim|required|xss_clean');
$this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
$msg = 1;
$tmp = 0;
$curId = $this->input->post('curId');
$curCcId = $this->input->post('curCcId');
$stdAdY = $this->input->post('stdAdY');
$tmIdAdmit = $this->input->post('tmIdAdmit');
$cnt = $this->input->post('cnt');
$this->std->db->trans_begin();
$con_rs_std = array('stdCurId' => $curId,
'stdAdY' => $stdAdY);
$this->std->upDateStd($con_rs_std);
for($i=0; $i<$cnt; $i++) {
$this->form_validation->set_rules('stdCode'.$i,' ','trim|required|is_natural_no_zero|xss_clean');
if($tmp==0) {
$con_qu_std = array('stdCode' => $this->input->post('stdCode'.$i));
$qu_std = $this->std->qryStd($con_qu_std);
if(!$qu_std->num_rows()) {
$this->std->stdId = $this->input->post('stdId'.$i);
$this->std->get_by_key(TRUE);
$this->std->stdCode = $this->input->post('stdCode'.$i);
$this->std->stdUpdateDate = date('Y-m-d H:i:s');
$this->std->stdUpdateUsLogin = $this->session->userdata('UsLogin');
$this->std->update();
} else {
$this->load->vars(array("code" => 'รหัสซ้ำ', "num" => $i));
$tmp = 1;
}
}
}
if($this->form_validation->run() == true && $tmp==0) {
$this->std->db->trans_commit();
$this->std_afterSetStdCode();
} else {
$this->std->db->trans_rollback();
$this->std_showSetStdCode();
}
}
function std_afterSetStdCode() {
$this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
$this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur');
$curId = $this->input->post('curId');
$stdAdY = $this->input->post('stdAdY');
$tmIdAdmit = $this->input->post('tmIdAdmit');
$this->contents['curId'] = $curId;
$this->contents['stdAdY'] = $stdAdY;
$this->contents['tmIdAdmit'] = $tmIdAdmit;
$this->cur->curId = $curId;
$this->contents['qu_cur'] = $this->cur->get_by_key();
$con_rs_std = array('stdCurId' => $curId,
'stdAdY' => $stdAdY,
'stdTmIdAdmit' => $tmIdAdmit);
$ord_rs_std = array('stdName' => '',
'stdSurname' => '');
$this->contents['rs_std'] = $this->std->qryStdPfSoPrv($con_rs_std,$ord_rs_std);
$this->output($this->config->item("rg_folder")."v_afterSetStudentCode");
}
function std_processAfterSetStdCode() {
$this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
$cnt = $this->input->post('cnt');
$flgmsg = 1;
$this->std->db->trans_begin();
for($i=0; $i<$cnt; $i++) {
$this->std->stdId = $this->input->post('stdId'.$i);
$this->std->get_by_key(TRUE);
$this->std->stdCode = $this->input->post('stdCode'.$i);
$this->std->stdGenStatus = 'Y';
$this->std->stdUpdateDate = date('Y-m-d H:i:s');
$this->std->stdUpdateUsLogin = $this->session->userdata('UsLogin');
$this->std->update();
$flgmsg = 10;
}
if($this->std->db->trans_status() === false) {
$this->std->db->trans_rollback();
} else {
$this->std->db->trans_commit();
}
redirect($this->config->item("rg_folder")."student/std_beforeSetCode");
}
//---[]--- จบสร้างรหัสนักศึกษาแบบกำหนดเอง
// ##### บันทึกรายวิชาเทียบเท่า/เทียบโอน
function std_showTstCo() {
$this->output($this->config->item("rg_folder")."v_showTransferCo");
}
function std_addTstCo() {
$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_courseopen','co');
$this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd');
$this->load->model($this->config->item("rg_folder").'mo_rg_acadconfig','ac');
$this->load->model($this->config->item("rg_folder").'mo_rg_grade','grd');
$ac = $this->ac->get_by_key(TRUE);
$this->contents['acCPTransferClass'] = $this->ac->acCPTransferClass;
$this->contents['acY'] = $this->session->userdata('acY');
$this->contents['tmId'] = $this->session->userdata('tmId');
$con_qu_std = array('stdCode' => $this->input->post('stdCode'),
'stdSstId' => 1,
'stdEt2Id' => 2);
$qu_std = $this->std->qryPfCurSyTm($con_qu_std);
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');
// หารายวิชา
$rs_co = $this->co->qryCoByCoSectionIs1ANDCoCurId($qu_std->row()->stdCurId);
$arr = array();
$i = 1;
if($rs_co->num_rows()) {
foreach($rs_co->result() as $row) {
// มีการลงทะเบียนหรือัง
$con_qu_rd = array('rdStdId' => $qu_std->row()->stdId,
'rdAcY' => $row->coAcY,
'rdTmId' => $row->coTmId,
'rdCoId' => $row->coId);
$qu_rd = $this->rd->qryRd($con_qu_rd,'', '');
$flgRd = ($qu_rd->num_rows()==0) ? 0 : 1;
$con_qu_rs = array('coId' => $row->coId);
$arr[$i]['qu_crs'] = $this->co->qryCoJoinCrs($con_qu_rs,'',''); // หารายวิชา
$arr[$i]['flgRd'] = $flgRd; // flag การลงทะเบียน
$arr[$i]['qu_rd'] = $qu_rd; // หาการลงทะเบียนเรียน
$i++;
}
}
// หาผลรวมของหน่วยกิตที่นักศึกษาลงทะเบียนเรียนแล้ว
$con_sumCredit = array('rdStdId' => $qu_std->row()->stdId);
$this->contents['sumCredit'] = $this->rd->getCreditAttempt($con_sumCredit,'');
$this->contents['arr'] = $arr;
} else
$this->contents['err_msg'] = "** ไม่ปรากฏรหัสนักศึกษาเทียบเท่า/เทียบโอนดังกล่าวในฐานข้อมูล **";
$this->output($this->config->item("rg_folder")."v_showTransferCo");
} else
$this->std_showTstCo();
}
function std_processTstCo() {
$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_acadconfig','ac');
$this->ac->get_by_key(TRUE);
$acCPTransferClass = $this->ac->acCPTransferClass; // check CP
$this->db->trans_begin();
for($i=1; $i<=$this->input->post('cnt'); $i++) {
$this->rg->rgStdId = $this->input->post('stdId');
$this->rg->rgTmId = $this->input->post('tm'.$i);
$this->rg->rgAcY = $this->input->post('acY'.$i);
$this->rg->rgSeq = 1;
$qu_rg = $this->rg->get_by_key();
// กรณีที่ยังไม่มีการลงทะเบียนเรียนในเทอมที่ต้องการ ให้ทำการลงทะเบียนก่อน
if($qu_rg->num_rows()==0) {
$this->rg->rgStdId = $this->input->post('stdId');
$this->rg->rgTmId = $this->input->post('tm'.$i);
$this->rg->rgAcY = $this->input->post('acY'.$i);
$con_rgSeq = array('rgStdId' => $this->input->post('stdId'),
'rgAcY' => $this->input->post('tm'.$i),
'rgTmId' => $this->input->post('acY'.$i));
$this->rg->rgSeq = $this->rg->getNextSeq($con_rgSeq); // not complete
$this->rg->rgSubmitType = 'B';
$this->rg->rgStatus = 'T';
$this->rg->rgCurId = $this->input->post('curId');
$this->rg->rgSyId = $this->input->post('sy'.$i);
$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();
}
// บันทึก/แก้ไขข้อมูลในตาราง rg_RegistDetails
if($this->input->post('order'.$i)=='Y' && $this->input->post('rdGrade'.$i)) {
$this->rd->rdAcY = $this->input->post('acY'.$i);
$this->rd->rdStdId = $this->input->post('stdId');
$this->rd->rdTmId = $this->input->post('tm'.$i);
$this->rd->rdCoId = $this->input->post('coId'.$i);
$this->rd->rdSeq = $this->input->post('sequence'.$i);
$qu_rd = $this->rd->get_by_key();
// อัพเดทเกรดใน rg_RegistDetails
if($qu_rd->num_rows()) {
$this->rd->get_by_key(TRUE);
$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();
}
// บันทึกเกรดใน rg_RegistDetails
else {
$this->rd->rdAcY = $this->input->post('acY'.$i);
$this->rd->rdStdId = $this->input->post('stdId');
$this->rd->rdTmId = $this->input->post('tm'.$i);
$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 = 0;
$this->rd->rdGrade = $this->input->post('rdGrade'.$i);
$this->rd->rdDocNo = ($this->rd->rdDocNo!=NULL) ? $this->input->post('rdDocNo') : '';
$this->rd->rdCredit1 = $this->input->post('credit1'.$i);
$this->rd->rdCredit2 = $this->input->post('credit2'.$i);
$this->rd->rdNoCalGPA = ($this->rd->rdNoCalGPA!=NULL) ? $this->rd->rdNoCalGPA : 'N';
$this->rd->rdAllowPr = ($this->rd->rdAllowPr!=NULL) ? $this->rd->rdAllowPr : 'N';
$this->rd->rdCdId1 = $this->input->post('coCdId1'.$i);
$this->rd->rdCdId2 = $this->input->post('coCdId2'.$i);
$this->rd->rdUpdateDate = date('Y-m-d H:i:s');
$this->rd->rdUpdateUserId = $this->session->userdata('UsLogin');
$this->rd->insert();
}
} else {
// Delete rg_RegistDetails
$this->rd->rdStdId = $this->input->post('stdId');
$this->rd->rdAcY = $this->input->post('acY'.$i);
$this->rd->rdTmId = $this->input->post('tm'.$i);
$this->rd->rdSeq = $this->input->post('sequence'.$i);
$this->rd->rdCoId = $this->input->post('coId'.$i);
$qu_rd = $this->rd->get_by_key();
if($qu_rd->num_rows()) {
$this->rd->delete();
}
// Delete rg_Regist
$con_qu_rd = array('rdStdId' => $this->input->post('stdId'),
'rdAcY' => $this->input->post('acY'.$i),
'rdTmId' => $this->input->post('tm'.$i),
'rdSeq' => $this->input->post('sequence'.$i));
$qu_rd = $this->rd->qryRd($con_qu_rd,'','');
if($qu_rd->num_rows()==0) { // เอา rg_RegistDetails ออกมาแล้ว
$this->rg->rgStdId = $this->input->post('stdId');
$this->rg->rgAcY = $this->input->post('acY'.$i);
$this->rg->rgTmId = $this->input->post('tm'.$i);
$this->rg->rgSeq = $this->input->post('sequence'.$i);
$qu_rg = $this->rg->get_by_key();
if($qu_rg->num_rows()) {
$this->rg->delete();
}
}
}
}
if($this->db->trans_status() === false) {
$this->db->trans_rollback();
} else {
$this->db->trans_commit();
}
$this->std_addTstCo();
}
// ##### จบบันทึกรายวิชาเทียบเท่า/เทียบโอน
// ##### ข้อมูลการทำกิจกรรมรายหลักสูตร
function std_showAc() {
$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_curriculum','cur');
$this->contents['tm'] = $this->session->userdata('tmId');
$this->contents['acY'] = $this->session->userdata('acY');
$this->contents['rs_tm'] = $this->tm->get_options('','','','n');
$this->contents['rs_sy'] = $this->sy->get_options('','','','n');
$con_rs_cur = array('curStatus' => 'Y');
$ord_rs_cur = array('curName' => '');
$this->contents['rs_cur'] = $this->cur->get_options_allCur($con_rs_cur,$ord_rs_cur,'',"ทุกหลักสูตร");
$this->output($this->config->item("rg_folder")."v_showStudentActivity", $this->session->flashdata('msg'));
}
function std_addAc() {
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="error">','</div>');
$this->form_validation->set_rules('sacName',' ','trim|required|xss_clean');
$this->form_validation->set_rules('sacAcY',' ','trim|callback_checkAdY|callback_checkPreAdY|is_natural_no_zero|xss_clean');
$this->form_validation->set_rules('sacTmId',' ','trim|required|xss_clean');
$this->form_validation->set_rules('sacSyId',' ','trim|required|xss_clean');
$this->form_validation->set_rules('sacFrDate','วันที่เข้าร่วม','trim|callback_checkFrDate[sacToDate]|xss_clean');
$this->form_validation->set_rules('sacToDate','วันที่สิ้นสุด','trim|xss_clean');
$this->form_validation->set_rules('curId',' ','trim|xss_clean');
if($this->form_validation->run() == true) {
$this->std_addStdAc();
} else {
$this->std_showAc();
}
}
function std_addStdAc() {
$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_studentactivity','sac');
$sacName = $this->input->post('sacName');
$sacFrDate = $this->input->post('sacFrDate');
$sacToDate = $this->input->post('sacToDate');
$sacAcY = $this->input->post('sacAcY');
$sacTmId = $this->input->post('sacTmId');
$sacSyId = $this->input->post('sacSyId');
$curId = $this->input->post('curId');
$this->contents['sacName'] = $sacName;
$this->contents['sacFrDate'] = $sacFrDate;
$this->contents['sacToDate'] = $sacToDate;
$this->contents['sacAcY'] = $sacAcY;
$this->contents['sacTmId'] = $sacTmId;
$this->contents['sacSyId'] = $sacSyId;
if($curId==0) {
$con_rs_cur = array('stdGenStatus' => 'Y',
'curStatus' => 'Y');
} else {
$con_rs_cur = array('stdCurId' => $this->input->post('curId'),
'stdGenStatus' => 'Y',
'curStatus' => 'Y');
}
$rs_cur = $this->std->qryStdGroupStdCurId($con_rs_cur);
$arr = array();
$i = 0; //ตัวนับจำนวนหลักสูตร
$order = 0; // ตัวนับจำนวนนักศึกษา
if($rs_cur->num_rows()) {
foreach($rs_cur->result() as $rowCur) {
$con_rs_std = array('stdCurId' => $rowCur->stdCurId);
$ord_rs_std = array('stdCode' => '');
$rs_std = $this->std->qryStdJoinPf($con_rs_std,$ord_rs_std,'');
$arr[$i]['curId'] = $rowCur->stdCurId;
$arr[$i]['curName'] = $rowCur->curName;
$arr[$i]['std'] = $rs_std;
foreach($rs_std->result() as $rowStd) {
// หาข้อมูลนักศึกษาแบบรายภาค และตรวจสอบสถานะ
$this->ssm->ssmStdId = $rowStd->stdId;
$this->ssm->ssmTmId = $this->input->post('sacTmId');
$this->ssm->ssmAcY = $this->input->post('sacAcY');
$qu_ssm = $this->ssm->get_by_key();
if(($qu_ssm->num_rows() && $qu_ssm->row()->ssmSstId==1) || ($qu_ssm->num_rows()==0 && $this->input->post('sacAcY')>=$rowStd->stdAdY && $rowStd->stdSstId==1)) {
// หาว่ามีการทำกิจกรรมแล้วหรือยัง
$con_qu_sac = array('sacStdId' => $rowStd->stdId,
'sacName' => $this->input->post('sacName'),
'sacAcY' => $this->input->post('sacAcY'),
'sacFrDate' => splitDateDb2($this->input->post('sacFrDate')),
'sacToDate' => splitDateDb2($this->input->post('sacToDate')),
'sacSyId' => $this->input->post('sacSyId'),
'sacTmId' => $this->input->post('sacTmId'));
$qu_sac = $this->sac->qrySac($con_qu_sac,'','');
$arr[$i][$order]['sac'] = ($qu_sac->num_rows()) ? 1 : 0;
} //end if
else {
$arr[$i][$order]['sac'] = 0;
}
$order++;
} // end foreach
$i++;
} // end foreach
} //end if
$this->contents['arr'] = $arr;
$this->output($this->config->item("rg_folder")."v_addStudentActivity");
}
function std_processAddAc() {
$this->load->model($this->config->item("rg_folder").'mo_rg_studentactivity','sac');
$flgmsg = 0;
$this->db->trans_begin();
for($i=0; $i<$this->input->post('cnt'); $i++) {
$con_qu_sac = array('sacStdId' => $this->input->post('stdId'.$i),
'sacName' => $this->input->post('sacName'),
'sacAcY' => $this->input->post('sacAcY'),
'sacFrDate' => $this->input->post('sacFrDate'),
'sacToDate' => $this->input->post('sacToDate'),
'sacSyId' => $this->input->post('sacSyId'),
'sacTmId' => $this->input->post('sacTmId'));
$qu_sac = $this->sac->qrySac($con_qu_sac,'','');
// ถ้าเจอการทำกิจกรรมของนักศึกษาให้ทำการลบก่อน
if($qu_sac->num_rows()) {
if($this->input->post('order'.$i)!='Y') {
$this->sac->sacSeq = $qu_sac->row()->sacSeq;
$this->sac->sacStdId = $this->input->post('stdId'.$i);
$this->sac->delete();
$flgmsg = 10;
}
} else { // ถ้าไม่เจอการทำกิจกรรมให้บันทึกใหม่
if($this->input->post('order'.$i)=='Y') {
$this->sac->sacSeq = $this->sac->getNextSacSeqBySacStdId($this->input->post('stdId'.$i));
$this->sac->sacStdId = $this->input->post('stdId'.$i);
$this->sac->sacName = $this->input->post('sacName');
$this->sac->sacAcY = $this->input->post('sacAcY');
$this->sac->sacFrDate = $this->input->post('sacFrDate');
$this->sac->sacToDate = $this->input->post('sacToDate');
$this->sac->sacPosition = '';
$this->sac->sacSyId = $this->input->post('sacSyId');
$this->sac->sacTmId = $this->input->post('sacTmId');
$this->sac->insert();
$flgmsg = 10;
}
}
} // end for
if($this->db->trans_status() === false) {
$this->db->trans_rollback();
$this->session->set_flashdata('msg', '0');
} else {
$this->db->trans_commit();
$this->session->set_flashdata('msg', $flgmsg);
}
redirect($this->config->item("rg_folder")."student/std_showAc");
}
// ##### จบข้อมูลการทำกิจกรรมรายหลักสูตร
// ##### กำหนดคะแนนความประพฤติ
function std_genTTPoint() {
$this->output($this->config->item("rg_folder")."v_genTotalPoint");
}
function std_processGenTTPoint() {
$this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
$this->load->model($this->config->item("rg_folder").'mo_rg_studentbehavior','sbe');
$stdSstIdStr = ('1,2,3');
$acY_R = $this->session->userdata('acY_R');
$rs_std = $this->std->qryStdByStdSstIdStr($stdSstIdStr);
foreach($rs_std->result() as $row) {
$this->std->stdId = $row->stdId;
$this->std->get_by_key(TRUE);
$this->std->stdTotalPoint = 100;
$this->std->stdUpdateDate = date('Y-m-d H:i:s');
$this->std->stdUpdateUsLogin = $this->session->userdata('UsLogin');
$con_qu_sbe = array('sbeStdId' => $row->stdId,
'sbeAcY' => $acY_R);
$qu_sbe = $this->sbe->qrySbe($con_qu_sbe,'','');
/* เช็คจาก rg_StudentBehavior ว่าต้องกำหนดปีละครั้งหรือไม่ */
if($qu_sbe->num_rows()==0) {
$this->std->update();
}
}
$this->output($this->config->item("rg_folder")."v_processGenTotalPoint");
}
// ##### จบกำหนดคะแนนความประพฤติ
// ##### start crs
function crs_insert_update() {
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<font color="red">','</font>');
$this->form_validation->set_rules('crsCode',' ','trim|required|xss_clean');
$this->form_validation->set_rules('crsCodeE',' ','trim|required|xss_clean');
$this->form_validation->set_rules('crsName',' ','trim|required|xss_clean');
$this->form_validation->set_rules('crsNameE',' ','trim|required|xss_clean');
$this->form_validation->set_rules('crsAbbr',' ','trim|xss_clean');
$this->form_validation->set_rules('crsAbbrE',' ','trim|xss_clean');
$this->form_validation->set_rules('crsDescription',' ','trim|xss_clean');
$this->form_validation->set_rules('crsDescriptionE',' ','trim|xss_clean');
$this->form_validation->set_rules('crsCreditTotal',' ','trim|required|integer|xss_clean');
$this->form_validation->set_rules('crsPeriod1',' ','trim|required|integer|xss_clean');
$this->form_validation->set_rules('crsPeriod2',' ','trim|required|integer|xss_clean');
$this->form_validation->set_rules('crsPeriod3',' ','trim|required|integer|xss_clean');
$this->form_validation->set_rules('crsShowLabInTS',' ','trim|required|xss_clean');
$this->form_validation->set_rules('crsStatus',' ','trim|xss_clean');
$this->form_validation->set_rules('crsCdId',' ','trim|required|xss_clean');
for($i=2; $i<=5; $i++) {
$this->form_validation->set_rules('crsId'.$i,' ','trim|xss_clean');
$this->form_validation->set_rules('crsName'.$i,' ','trim|xss_clean');
$this->form_validation->set_rules('prcAndOr'.$i,' ','trim|xss_clean');
}
if($this->form_validation->run() == true) {
$this->db->trans_begin();
$this->load->model($this->config->item("rg_folder").'m_rg_course','crs');
$this->load->model($this->config->item("rg_folder").'m_rg_precourse','prc');
$this->crs->crsId = $this->input->post('crsId');
$this->crs->crsCode = $this->input->post('crsCode');
$this->crs->crsCodeE = $this->input->post('crsCodeE');
$this->crs->crsName = $this->input->post('crsName');
$this->crs->crsNameE = $this->input->post('crsNameE');
$this->crs->crsAbbr = $this->input->post('crsAbbr');
$this->crs->crsAbbrE = $this->input->post('crsAbbrE');
$this->crs->crsDescription = $this->input->post('crsDescription');
$this->crs->crsDescriptionE = $this->input->post('crsDescriptionE');
$this->crs->crsCreditTotal = $this->input->post('crsCreditTotal');
$this->crs->crsCredit1 = $this->input->post('crsPeriod1');
$this->crs->crsCredit2 = $this->input->post('crsCreditTotal') - $this->input->post('crsPeriod1');
$this->crs->crsPeriod1 = $this->input->post('crsPeriod1');
$this->crs->crsPeriod2 = $this->input->post('crsPeriod2');
$this->crs->crsPeriod3 = $this->input->post('crsPeriod3');
$this->crs->crsUnit = $this->input->post('crsCreditTotal').'('.$this->input->post('crsPeriod1').'-'.$this->input->post('crsPeriod2').'-'.$this->input->post('crsPeriod3').')';
$this->crs->crsShowLabInTS = $this->input->post('crsShowLabInTS');
$this->crs->crsStatus = $this->input->post('crsStatus') ? $this->input->post('crsStatus') : '';
$this->crs->crsCdId = $this->input->post('crsCdId');
$this->crs->crsUpdateDate = date('Y-m-d H:i:s');
$this->crs->crsUpdateUserId = $this->session->userdata("UsLogin");
if($this->input->post('crsId') == 0) {
$this->crs->crsCreateDate = date('Y-m-d H:i:s');
$this->crs->crsCreateUserId = $this->session->userdata("UsLogin");
$this->crs->insert();
}
else
$this->crs->update();
$prcCrsId = $this->input->post('crsId') ? $this->input->post('crsId') : $this->crs->last_insert_id();
$rs_prc = $this->prc->qryByCrsId($prcCrsId);
foreach($rs_prc->result() as $row)
$this->prc->delete($row->prcCrsId, $row->prcPrCrsId);
for($i=2; $i<=5; $i++) {
$qu_prc1 = $this->prc->getByKey($prcCrsId, $this->input->post('crsId'.$i));
$qu_prc2 = $this->prc->getByKey($prcCrsId, $this->input->post('crsId'.($i+1)));
$this->prc->prcCrsId = $prcCrsId;
$this->prc->prcPrCrsId = $this->input->post('crsId'.$i);
$this->prc->prcAndOr = ($this->input->post('crsId'.($i+1)) && $qu_prc2->num_rows()==0 && $this->input->post('crsId'.$i)<>$this->input->post('crsId'.($i+1))) ? $this->input->post('prcAndOr'.$i) : '';
$this->prc->prcSeq = $this->prc->getNextSeqByCrsId($prcCrsId);
if($i == 2) {
if($this->input->post('crsId'.$i) && $qu_prc1->num_rows()==0) {
$this->prc->insert();
$flag = 1;
}
else
$flag = 0;
}
else {
if($this->input->post('crsId'.$i) && $qu_prc1->num_rows()==0 && $flag) {
$this->prc->insert();
$flag = 1;
}
else
$flag = 0;
}
}
if($this->db->trans_status() === false)
$this->db->trans_rollback();
else
$this->db->trans_commit();
redirect($this->config->item("rg_folder")."curriculum/crs_show");
}
else
$this->crs_input();
}
// ##### end crs
// ##### ปรับปรุงชั้นปี เมนูนี้ยังไม่เปิดใช้ not complete
function adjustPassSt() {
if($this->input->post('stdCode')) {
$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_regist','rg');
$std = $this->std->qryStdByCodeStStatus($this->input->post('stdCode'), ('1,2'));
if($std->num_rows()) {
$con_qu_std = array('stdId' => $std->row()->stdId);
$this->contents['qu_std'] = $this->std->qryStdJoinPfCurSySstElv($con_qu_std,'','');
$this->contents['acY'] = $this->ssm->getMaxAcYByStdId($std->row()->stdId);
$this->contents['tm'] = $this->ssm->getMaxTmIdByStdIdAcY($std->row()->stdId, $this->contents['acY']);
$con_qu_ssm = array('ssmStdId' => $std->row()->stdId,
'ssmTmId' => $this->contents['tm'],
'ssmAcY' => $this->contents['acY']);
$this->contents['qu_ssm'] = $this->ssm->qrySsm($con_qu_ssm,'','');
$acY = $this->contents['acY'];
for($acY=$std->row()->stdAdY; $acY<=$this->session->userdata('acY_R'); $acY++) {
$tm = $this->ssm->getMaxTmIdByStdIdAcY($std->row()->stdId, $acY);
} //end for
} //end if
} //end if
$this->output($this->config->item("rg_folder")."v_adjustPassSt");
}
// ##### ปรับปรุงชั้นปี
// ##### ปรับปรุงสถานะนักศึกษาตามหลักสูตร
function searchStdUpSstCur() {
$this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur');
$this->load->model($this->config->item("rg_folder").'mo_rg_studyyear','sy');
$con_rs_cur = array('curStatus' => 'Y');
$ord_rs_cur = array('curName' => '');
$this->contents['rs_cur'] = $this->cur->get_options($con_rs_cur,$ord_rs_cur);
$this->contents['rs_sy'] = $this->sy->get_options('','','','n');
$this->output($this->config->item("rg_folder")."v_searchStudentUpStatusCur");
}
function editStdUpSstCur() {
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="error">','</div>');
$this->form_validation->set_rules('curId',' ','trim|required|xss_clean');
$this->form_validation->set_rules('syId',' ','trim|xss_clean');
if($this->form_validation->run() == true) {
$this->upSstCur();
} else {
$this->searchStdUpSstCur();
}
}
function upSstCur() {
$this->load->model($this->config->item("rg_folder").'mo_rg_studyyear','sy');
$this->load->model($this->config->item("rg_folder").'mo_rg_studentstatus','sst');
$this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
$this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur');
$curId = $this->input->post('curId');
$syId = $this->input->post('syId');
$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();
$sstId = ("2,3,4,7,8,9");
$this->contents['rs_sst'] = $this->sst->get_optionsNotSstId($sstId);
$con_rs_std = array('stdCurId' => $curId,
'stdSyId' => $syId);
$ord_rs_std = array('stdCode' => '');
$this->contents["rs_std"] = $this->std->qryStdJoinPfSst($con_rs_std,$ord_rs_std);
$this->output($this->config->item("rg_folder")."v_editStudentStatusCur");
}
function processStdUpSstCur() {
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="error">','</div>');
$this->form_validation->set_rules('stdSstId',' ','trim|required|xss_clean');
$cnt = $this->input->post('cnt');
for($i=0; $i<$cnt; $i++) {
$this->form_validation->set_rules('chkbox'.$i,' ','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_studentsummary','ssm');
$flgmsg = 0;
$this->db->trans_begin();
for($i=0; $i<$cnt; $i++) {
if($this->input->post('chkbox'.$i)=='Y') {
$this->std->stdId = $this->input->post('stdId'.$i);
$this->std->get_by_key(TRUE);
$this->std->stdSstId = $this->input->post('stdSstId');
$this->std->stdUpdateDate = date('Y-m-d H:i:s');
$this->std->stdUpdateUsLogin = $this->session->userdata('UsLogin');
$this->std->update();
$this->ssm->ssmStdId = $this->input->post('stdId'.$i);
$this->ssm->ssmTmId = $this->session->userdata('tmId');
$this->ssm->ssmAcY = $this->session->userdata('acY');
$this->ssm->get_by_key(TRUE);
$ssm = $this->ssm->get_by_key();
if($ssm->num_rows()) {
$this->ssm->ssmSstId = $this->input->post('stdSstId');
$this->ssm->ssmUpdateDate = date('Y-m-d H:i:s');
$this->ssm->ssmUpdateUserId = $this->session->userdata('UsLogin');
$this->ssm->update();
$flgmsg = 10;
} else {
$this->ssm->ssmStdId = $this->input->post('stdId'.$i);
$this->ssm->ssmTmId = $this->session->userdata('tmId');
$this->ssm->ssmAcY = $this->session->userdata('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 = '0000-00-00';
$this->ssm->ssmPassStatus = 0;
$this->ssm->ssmSstId = $this->input->post('stdSstId');
$this->ssm->ssmSstIdApproveSpe = NULL;
$this->ssm->ssmSyId = $this->std->calSyByStdIdAndAcY($this->input->post('stdId'.$i), $this->session->userdata('acY'));
$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
if($this->db->trans_status() === false) {
$this->db->trans_rollback();
} else {
$this->db->trans_commit();
}
redirect($this->config->item("rg_folder")."student/searchStdUpSstCur");
} else {
$this->upSstCur();
}
}
// ##### จบปรับปรุงสถานะนักศึกษาตามหลักสูตร
// ##### ปรับปรุงสถานะนักศึกษารายนักศึกษา
function std_searchStdUpSst() {
$this->output($this->config->item("rg_folder")."v_searchStudentUpStatusStd");
}
function std_showStdUpSst() {
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="error">','</div>');
$this->form_validation->set_rules('curId',' ','trim|required|xss_clean');
$this->form_validation->set_rules('curName',' ','trim|xss_clean');
$this->form_validation->set_rules('adY',' ','trim|required|xss_clean');
$this->form_validation->set_rules('tmIdAdmit',' ','trim|required|xss_clean');
$this->form_validation->set_rules('syId',' ','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_curriculum','cur');
$adY = $this->input->post('adY');
$curId = $this->input->post('curId');
$syId = $this->input->post('syId');
$tmIdAdmit = $this->input->post('tmIdAdmit');
$con_rs_std = array('stdAdY' => $adY,
'stdCurId' => $curId);
$this->contents['rs_std'] = $this->std->qryStdPfSoPrv($con_rs_std);
$this->cur->curId = $curId;
$this->contents['qu_cur'] = $this->cur->get_by_key();
$this->contents['curId'] = $curId;
$this->contents['adY'] = $adY;
$this->contents['tmIdAdmit'] = $tmIdAdmit;
$this->contents['syId'] = $syId;
$this->output($this->config->item("rg_folder")."v_showStudentUpStatusStd");
} else {
$this->std_searchStdUpSst();
}
}
function std_editStdUpSst() {
$this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
$this->load->model($this->config->item("rg_folder").'mo_rg_studentdetails','sdt');
$this->load->model($this->config->item("rg_folder").'mo_rg_studentstatus','sst');
$stdId = $this->input->post('stdId');
$this->contents['qu_std'] = $this->std->qryStdMB($stdId);
$con_qu_sdt = array('sdtStdId' => $stdId);
$this->contents['qu_sdt'] = $this->sdt->qrySdtJoinPfDtApPrv($con_qu_sdt);
$sstId = ('2,3,4,7,8,9');
$this->contents['rs_sst'] = $this->sst->get_optionsNotSstId($sstId,'');
$this->output($this->config->item("rg_folder")."v_editStudentStatus");
}
function std_processStdUpSst() {
$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->db->trans_begin();
$this->std->stdId = $this->input->post('stdId');
$this->std->get_by_key(TRUE);
$this->std->stdSstId = $this->input->post('stdSstId');
$this->std->stdUpdateDate = date('Y-m-d H:i:s');
$this->std->stdUpdateUsLogin = $this->session->userdata('UsLogin');
$this->std->update();
$this->ssm->ssmStdId = $this->input->post('stdId');
$this->ssm->ssmTmId = $this->session->userdata('tmId');
$this->ssm->ssmAcY = $this->session->userdata('acY');
$this->ssm->get_by_key(TRUE);
$ssm = $this->ssm->get_by_key();
if($ssm->num_rows()) {
$this->ssm->ssmSstId = $this->input->post('stdSstId');
$this->ssm->ssmUpdateDate = date('Y-m-d H:i:s');
$this->ssm->ssmUpdateUserId = $this->session->userdata('UsLogin');
$this->ssm->update();
} else { // กรณี insert
$this->ssm->ssmStdId = $this->input->post('stdId');
$this->ssm->ssmTmId = $this->session->userdata('tmId'); //เทอมที่ล็อกอิน
$this->ssm->ssmAcY = $this->session->userdata('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 = '0000-00-00';
$this->ssm->ssmPassStatus = '';
$this->ssm->ssmSstId = $this->input->post('stdSstId');
$this->ssm->ssmSstIdApproveSpe = NULL;
$this->ssm->ssmSyId = $this->std->calSyByStdIdAndAcY($this->input->post('stdId'), $this->session->userdata('acY'));
$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();
}
if($this->db->trans_status() === false) {
$this->db->trans_rollback();
$this->contents['flgSuccess'] = "กระบวนการปรับปรุงสถานะนักศึกษารหัส ".$this->std->stdCode." ไม่สำเร็จ";
} else {
$this->db->trans_commit();
$this->contents['flgSuccess'] = "กระบวนการปรับปรุงสถานะนักศึกษารหัส ".$this->std->stdCode." สำเร็จ";
}
$this->std_editStdUpSst();
}
// ##### จบปรับปรุงสถานะนักศึกษารายนักศึกษา
// ##### คืนสภาพนักศึกษา
function std_searchStdStatus() {
$this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
$this->load->model($this->config->item("rg_folder").'mo_rg_studentsummary','ssm');
if($this->input->post('stdCode')) {
$std = $this->std->qryStdByCodeStStatus($this->input->post('stdCode'),('2,7,8,9'));
if($std->num_rows()) {
$con_qu_std = array('stdId' => $std->row()->stdId);
$this->contents['qu_std'] = $this->std->qryStdJoinPfCurSySstElv($con_qu_std,'','');
$this->contents['stdCode'] = $this->input->post('stdCode');
} else {
$this->contents['flgShow'] = "** กรุณาตรวจสอบรหัสนักศึกษาอีกครั้ง **";
}
}
// start processStdStatus
// note: อัพเดทต้องทั้ง rg_Student, rg_StudentSummary เสมอ
$this->db->trans_begin();
if($this->input->post('add2')) {
$this->ssm->ssmStdId = $this->input->post('stdId');
$this->ssm->ssmTmId = $this->input->post('tm');
$this->ssm->ssmAcY = $this->input->post('acY');
$this->ssm->get_by_key(TRUE);
$ssm = $this->ssm->get_by_key();
if($ssm->num_rows()) {
$this->ssm->ssmSstId = 1; // สถานะกำลังศึกษาอยู่
$this->ssm->ssmApprover = $this->input->post('ssmApprover');
$this->ssm->ssmRefNo = $this->input->post('ssmRefNo');
$this->ssm->ssmApproveDate = splitDateDb2($this->input->post('ssmApproveDate'),"-");
$this->ssm->ssmUpdateDate = date('Y-m-d H:i:s');
$this->ssm->ssmUpdateUserId = $this->session->userdata('UsLogin');
$this->ssm->ssmSstIdApproveSpe = $this->input->post('apprveSpe');
$this->ssm->update();
$this->std->stdId = $this->input->post('stdId');
$this->std->get_by_key(TRUE);
$this->std->stdSstId = 1; // สถานะกำลังศึกษาอยู่
$this->std->stdUpdateDate = date('Y-m-d H:i:s');
$this->std->stdUpdateUsLogin = $this->session->userdata('UsLogin');
$this->std->update();
$this->contents['flgSuccess'] = "กระบวนการคืนสภาพนักศึกษารหัส ".$this->input->post('stdCode')." เสร็จสิ้น";
} else {
$this->contents['flgSuccess'] = "กระบวนการคืนสภาพนักศึกษารหัส ".$this->input->post('stdCode')." ไม่สำเร็จ<br />กรุณาล็อกอินไปยังภาคการศึกษาที่ต้องการคืนสภาพ";
}
}
if($this->db->trans_status() === false)
$this->db->trans_rollback();
else
$this->db->trans_commit();
// end processStdStatus
$this->output($this->config->item("rg_folder")."v_searchStudReStatus");
}
// ##### จบคืนสภาพนักศึกษา
function tc_showSdt() {
$this->load->model($this->config->item("rg_folder").'mo_rg_person','prs');
$this->load->model($this->config->item("rg_folder").'mo_rg_adviser','adv');
$this->load->model($this->config->item("rg_folder").'mo_rg_classteacher','ctc');
$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_student','std');
$personId = $this->session->userdata('UsPsCode');
$acY = $this->session->userdata('acY');
$con_qu_prs = array('prsUsId' => $personId);
$qu_prs = $this->prs->qryPrsJoinPPC($con_qu_prs);
if ($qu_prs->num_rows()) {
$this->contents['qu_prs'] = $qu_prs;
$row_prs = $qu_prs->row();
/*
$con_rs_adv = array('advPrsId' => $row_prs->prsId,
'advAcY' => $acY,
'stdSstId' => 1
);
$ord_rs_adv = array('stdCode' => 'ASC');
$this->contents['rs_adv'] = $this->adv->qryAdvJoinStd($con_rs_adv, $ord_rs_adv); */
$con_rs_adv = array('advPrsId' => $row_prs->prsId,
'stdSstId' => 1
);
$ord_rs_adv = array('stdCode' => 'ASC');
$this->contents['rs_adv'] = $this->adv->qryAdvJoinStdLastAcY($con_rs_adv, $ord_rs_adv);
$stStatus = '1, 2, 3';
$i = 0;
$arr = array();
$con_rs_ctc = array('ctcPrsId' => $row_prs->prsId,
'ctcAcY' => $acY
);
$rs_ctc = $this->ctc->qryCtc($con_rs_ctc);
foreach ($rs_ctc->result() as $row_ctc) {
$this->cur->curId = $row_ctc->ctcCurId;
$arr[$i]['qu_cur'] = $this->cur->get_by_key();
$this->sy->syId = $row_ctc->ctcSyId;
$arr[$i]['qu_sy'] = $this->sy->get_by_key();
$j = 0;
$rs_std = $this->std->qryStdByCurIdSyIdSstIdStr($row_ctc->ctcCurId, $row_ctc->ctcSyId, $stStatus);
foreach ($rs_std->result() as $row_std) {
$con_qu_std = array('stdId' => $row_std->stdId);
$arr[$i][$j]['qu_std'] = $this->std->qryStdJoinPf($con_qu_std);
$j++;
}
$i++;
}
$this->contents['rs2'] = $arr;
$this->output($this->config->item("rg_folder")."v_tc_showSdt");
} else {
$msg = "ท่านไม่มีสิทธิ์ในเมนูนี้";
$this->session->set_flashdata('msg', $msg);
redirect($this->config->item("rg_folder")."msg/err_msg");
}
}
// ##### 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 {
$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($qu_tmc->num_rows()) {
return true;
} else {
$this->form_validation->set_message('checkAcY','%sไม่ถูกต้อง');
return false;
}
}
}
function checkToDate($str) {
$sacFrDate = splitDateDb2($this->input->post('sacFrDate'));
$sacToDate = splitDateDb2($str);
if($sacFrDate <= $sacToDate) {
return true;
} else {
$this->form_validation->set_message('checkToDate','%sไม่ถูกต้อง');
return false;
}
}
// ##### end callback_function
}
?>
|