Viewing file: studenthis.php (20.3 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include("rg_controller.php");
class studenthis extends Rg_controller {
// function __construct() {
// parent::__construct();
// }
// ##### start stdMBHis
function std_showHis() {
$this->output($this->config->item("rg_folder")."v_searchStudentHis");
}
function std_searchHis() {
$stdCode = $this->input->post('stdCode');
$stdName = $this->input->post('stdName');
$stdSurname = $this->input->post('stdSurname');
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<font color="red">','</font>');
$this->form_validation->set_rules('stdCode',' ','trim|xss_clean');
$this->form_validation->set_rules('stdName',' ','trim|xss_clean');
$this->form_validation->set_rules('stdSurname',' ','trim|xss_clean');
if($this->form_validation->run() == true) {
if($stdCode!='' || $stdName!='' || $stdSurname!='') {
$this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
$con_rs_std = array('stdCode' => '%'.$stdCode.'%',
'stdName' => '%'.$stdName.'%',
'stdSurname' => '%'.$stdSurname.'%');
$this->contents['rs_std'] = $this->std->qryStdJoinPfCurSySstElv($con_rs_std);
} else {
$this->contents['str_fault'] = $this->config->item('str_fault');
}
$this->output($this->config->item("rg_folder")."v_searchStudentHis");
} else {
$this->std_showHis();
}
}
function std_editStdMBHis($tb=0, $id=0) {
$this->load->model($this->config->item("rg_folder").'mo_rg_config','cfg');
$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_studyyear','sy');
$tab = $this->input->post('tab')=='' ? ($tb==0 ? 1 : $tb) : $this->input->post('tab');
$stdId = $this->input->post('stdId')=="" ? $id : $this->input->post('stdId');
$data['tab'] = $tab;
$data['stdId'] = $stdId;
$data['qu_cfg'] = $this->cfg->qryCfg();
$data['acY'] = $this->session->userdata('acY');
$data['tmId'] = $this->session->userdata('tmId');
$ord_rs_term = array('tmName' => '');
$rs_tm = $this->tm->get_options('',$ord_rs_term,'','n');
$ord_rs_sy = array('syName' => '');
$rs_sy = $this->sy->get_options('',$ord_rs_sy,'','n');
$con_std = array('stdId' => $stdId);
$std = $this->std->qryStd($con_std);
if($tab==1) {
$this->load->model($this->config->item("rg_folder").'mo_rg_studenteduhis','seh');
$this->load->model($this->config->item("ppc_folder").'mo_level','elv');
$this->load->model($this->config->item("ppc_folder").'mo_province','prv');
$ord_rs_elv = array('levelName' => '');
$data['rs_elv'] = $this->elv->get_options('',$ord_rs_elv);
$ord_rs_prv = array('provinceName' => '');
$data['rs_prv'] = $this->prv->get_options('',$ord_rs_prv);
$con_rs_seh = array('sehStdId' => $stdId);
$data['rs_seh'] = $this->seh->qrySehJoinStdPrv($con_rs_seh);
$data['qu_std'] = $std;
$this->contents['v'] = $this->load->view($this->config->item('rg_folder').'v_editStdMBHis1',$data,TRUE);
} else if($tab==2) {
$this->load->model($this->config->item("rg_folder").'mo_rg_studentactivity','sac');
$this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
$data['rs_tm'] = $rs_tm;
$data['rs_sy'] = $rs_sy;
$con_rs_sac = array('sacStdId' => $stdId);
$ord_rs_sac = array('sacAcY' => 'DESC',
'sacTmId' => 'ASC');
$data['rs_sac'] = $this->sac->qrySacJoinTmSy($con_rs_sac,$ord_rs_sac);
$data['qu_std'] = $std;
$this->contents['v'] = $this->load->view($this->config->item('rg_folder').'v_editStdMBHis2',$data,TRUE);
} else if($tab==3) {
$this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
$this->load->model($this->config->item("rg_folder").'mo_rg_studentabsent','sab');
$data['rs_sy'] = $rs_sy;
$con_rs_sab = array('sabStdId' => $stdId);
$ord_rs_sab = array('sabAcY' => 'DESC',
'sabFrDate' => 'ASC');
$data['rs_sab'] = $this->sab->qrySabJoinSy($con_rs_sab,$ord_rs_sab);
$con_qu_std = array('stdId' => $stdId);
$data['qu_std'] = $std;
$opt = array();
$opt[1] = "ลาป่วย";
$opt[2] = "ลากิจ";
$opt[3] = "ขาดเรียน";
$data['rs_absentCause'] = $opt;
$this->contents['v'] = $this->load->view($this->config->item('rg_folder').'v_editStdMBHis3',$data,TRUE);
} else if($tab==4) {
$this->load->model($this->config->item("rg_folder").'mo_rg_studentbehavior','sbe');
$data['rs_tm'] = $rs_tm;
$data['qu_std'] = $std;
$con_rs_sbe = array('sbeStdId' => $stdId);
$data['rs_sbe'] = $this->sbe->qrySbeJoinTmDcp($con_rs_sbe);
$this->contents['v'] = $this->load->view($this->config->item('rg_folder').'v_editStdMBHis4',$data,TRUE);
}
$this->contents['tab'] = $tab;
$this->contents['qu_std'] = $this->std->qryStdMB($stdId);
$this->output($this->config->item("rg_folder")."v_editStdMBHis", $this->session->flashdata('msg'));
}
function std_insertStdMBHis1() {
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="error">','</div>');
$this->form_validation->set_rules('tab',' ','trim|required|xss_clean');
$this->form_validation->set_rules('stdId',' ','trim|required|xss_clean');
$this->form_validation->set_rules('sehElvId',' ','trim|required|xss_clean');
$this->form_validation->set_rules('sehInstitutionName',' ','trim|required|xss_clean');
$this->form_validation->set_rules('sehInstitutionNameE',' ','trim|required|xss_clean');
$this->form_validation->set_rules('sehPrvId',' ','trim|required|xss_clean');
$this->form_validation->set_rules('sehGraduateY',' ','trim|callback_checkAdY|callback_checkHisAdY|is_natural_no_zero|required|xss_clean');
$this->form_validation->set_rules('sehGPA',' ','trim|callback_checkGPA|required|xss_clean');
if($this->form_validation->run() == true) {
$this->load->model($this->config->item("rg_folder").'mo_rg_studenteduhis','seh');
$tab = $this->input->post('tab');
$stdId = $this->input->post('stdId');
$sehElvId = $this->input->post('sehElvId');
$sehInstitutionName = $this->input->post('sehInstitutionName');
$sehInstitutionNameE = $this->input->post('sehInstitutionNameE');
$sehPrvId = $this->input->post('sehPrvId');
$sehGraduateY = $this->input->post('sehGraduateY');
$sehGPA = $this->input->post('sehGPA');
$this->seh->sehStdId = $stdId;
$this->seh->sehElvId = $sehElvId;
$rs_seh = $this->seh->get_by_key();
$flgmsg = 0;
$this->db->trans_begin();
if(!$rs_seh->num_rows()) {
$this->seh->sehStdId = $stdId;
$this->seh->sehElvId = $sehElvId;
$this->seh->sehInstitutionName = $sehInstitutionName;
$this->seh->sehInstitutionNameE = $sehInstitutionNameE;
$this->seh->sehPrvId = $sehPrvId;
$this->seh->sehGraduateY = $sehGraduateY;
$this->seh->sehGPA = $sehGPA;
$this->seh->insert();
$flgmsg = 10;
}
$this->session->set_flashdata('msg', 21);
if($this->db->trans_status() === false) {
$this->db->trans_rollback();
if($flgmsg)
$this->session->set_flashdata('msg', $flgmsg);
} else {
$this->db->trans_commit();
if($flgmsg)
$this->session->set_flashdata('msg', $flgmsg);
}
redirect($this->config->item("rg_folder")."studenthis/std_editStdMBHis/$tab/$stdId");
} else {
$this->std_editStdMBHis();
}
}
function std_insertStdMBHis2() {
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="error">','</div>');
$this->form_validation->set_rules('tab',' ','trim|required|xss_clean');
$this->form_validation->set_rules('stdId',' ','trim|required|xss_clean');
$this->form_validation->set_rules('stdAdY',' ','trim|required|xss_clean');
$this->form_validation->set_rules('sacTmId',' ','trim|required|xss_clean');
$this->form_validation->set_rules('sacAcY',' ','trim|callback_checkAdY|callback_checkHisAdY|is_natural_no_zero|required|xss_clean');
$this->form_validation->set_rules('sacSyId',' ','trim|xss_clean');
$this->form_validation->set_rules('sacName',' ','trim|required|xss_clean');
$this->form_validation->set_rules('sacPosition',' ','trim|required|xss_clean');
$this->form_validation->set_rules('sacFrDate','วันที่เข้าร่วม','trim|callback_checkFrDate[sacToDate]|callback_checkHisDate[sacAcY]|xss_clean');
$this->form_validation->set_rules('sacToDate','วันที่สิ้นสุด','trim|callback_checkHisDate[sacAcY]|xss_clean');
if($this->form_validation->run() == true) {
$this->load->model($this->config->item("rg_folder").'mo_rg_studentactivity','sac');
$tab = $this->input->post('tab');
$stdId = $this->input->post('stdId');
$sacTmId = $this->input->post('sacTmId');
$sacAcY = $this->input->post('sacAcY');
$sacSyId = $this->input->post('sacSyId');
$sacName = $this->input->post('sacName');
$sacPosition = $this->input->post('sacPosition');
$sacFrDate = splitDateForm2($this->input->post('sacFrDate'),'-');
$sacToDate = splitDateForm2($this->input->post('sacToDate'),'-');
$con_rs_sac = array('sacStdId' => $stdId,
'sacTmId' => $sacTmId,
'sacAcY' => $sacAcY,
'sacSyId' => $sacSyId,
'sacName' => $sacName,
'sacFrDate' => $sacFrDate,
'sacToDate' => $sacToDate);
$rs_sac = $this->sac->qrySac($con_rs_sac);
$flgmsg = 0;
$this->db->trans_begin();
if(!$rs_sac->num_rows()) {
$this->sac->sacSeq = $this->sac->getNextSacSeqBySacStdId($stdId);
$this->sac->sacStdId = $stdId;
$this->sac->sacName = $sacName;
$this->sac->sacAcY = $sacAcY;
$this->sac->sacFrDate = $sacFrDate;
$this->sac->sacToDate = $sacToDate;
$this->sac->sacPosition = $sacPosition;
$this->sac->sacSyId = $sacSyId;
$this->sac->sacTmId = $sacTmId;
$this->sac->insert();
$flgmsg = 10;
}
$this->session->set_flashdata('msg', 21);
if($this->db->trans_status() === false) {
$this->db->trans_rollback();
if($flgmsg)
$this->session->set_flashdata('msg', $flgmsg);
} else {
$this->db->trans_commit();
if($flgmsg)
$this->session->set_flashdata('msg', $flgmsg);
}
redirect($this->config->item("rg_folder")."studenthis/std_editStdMBHis/$tab/$stdId");
} else {
$this->std_editStdMBHis();
}
}
function std_insertStdMBHis3() {
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="error">','</div>');
$this->form_validation->set_rules('tab',' ','trim|required|xss_clean');
$this->form_validation->set_rules('stdId',' ','trim|required|xss_clean');
$this->form_validation->set_rules('stdAdY',' ','trim|required|xss_clean');
$this->form_validation->set_rules('sabAcY',' ','trim|callback_checkAdY|callback_checkHisAdY|is_natural_no_zero|required|xss_clean');
$this->form_validation->set_rules('sabSyId',' ','trim|xss_clean');
$this->form_validation->set_rules('sabCause',' ','trim|xss_clean');
$this->form_validation->set_rules('sabFrDate','วันที่เริ่ม','trim|callback_checkFrDate[sabToDate]|callback_checkHisDate[sabAcY]|xss_clean');
$this->form_validation->set_rules('sabToDate','วันที่สิ้นสุด','trim|callback_checkHisDate[sabAcY]|callback_checkBetweenDate|xss_clean');
if($this->form_validation->run() == true) {
$this->load->model($this->config->item("rg_folder").'mo_rg_studentabsent','sab');
$tab = $this->input->post('tab');
$stdId = $this->input->post('stdId');
$sabAcY = $this->input->post('sabAcY');
$sabSyId = $this->input->post('sabSyId');
$sabCause = $this->input->post('sabCause');
$sabFrDate = splitDateForm2($this->input->post('sabFrDate'),'-');
$sabToDate = splitDateForm2($this->input->post('sabToDate'),'-');
$con_rs_sab = array('sabStdId' => $stdId,
'sabAcY' => $sabAcY,
'sabSyId' => $sabSyId,
'sabFrDate' => $sabFrDate,
'sabToDate' => $sabToDate);
$rs_sab = $this->sab->qrySab($con_rs_sab);
$date = $this->sab->qryBetWeenDateNotSabStdId($sabFrDate,$sabToDate,$stdId);
$flgmsg = 0;
$this->db->trans_begin();
if(!$rs_sab->num_rows() && !$date->num_rows()) {
$this->sab->sabSeq = $this->sab->getNextSabSeqBySabStdId($stdId);
$this->sab->sabStdId = $stdId;
$this->sab->sabFrDate = $sabFrDate;
$this->sab->sabToDate = $sabToDate;
$this->sab->sabFrDate = $sabFrDate;
$this->sab->sabAcY = $sabAcY;
$this->sab->sabCause = $sabCause;
$this->sab->sabSyId = $sabSyId;
$this->sab->insert();
$flgmsg = 10;
}
$this->session->set_flashdata('msg', 21);
if($this->db->trans_status() === false) {
$this->db->trans_rollback();
if($flgmsg)
$this->session->set_flashdata('msg', $flgmsg);
} else {
$this->db->trans_commit();
if($flgmsg)
$this->session->set_flashdata('msg', $flgmsg);
}
redirect($this->config->item("rg_folder")."studenthis/std_editStdMBHis/$tab/$stdId");
} else {
$this->std_editStdMBHis();
}
}
function std_insertStdMBHis4() {
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="error">','</div>');
$this->form_validation->set_rules('tab',' ','trim|required|xss_clean');
$this->form_validation->set_rules('stdId',' ','trim|required|xss_clean');
$this->form_validation->set_rules('stdAdY',' ','trim|required|xss_clean');
$this->form_validation->set_rules('sbeAcY','ปีการศึกษา (พ.ศ.)','trim|callback_checkAdY|callback_checkHisAdY|is_natural_no_zero|required|xss_clean');
$this->form_validation->set_rules('sbeTmId','ภาคการศึกษา','trim|xss_clean');
$this->form_validation->set_rules('sbeDescription','รายละเอียด','trim|required|xss_clean');
$this->form_validation->set_rules('dcpName',' ','trim|xss_clean');
$this->form_validation->set_rules('sbeDcpId','ระดับคะแนนและคะแนนที่ตัด','trim|required|xss_clean');
$this->form_validation->set_rules('sbeCutPoint',' ','trim|xss_clean');
$this->form_validation->set_rules('sbeRecordDate','วันที่เกิดเหตุ','trim|callback_checkSbeFrDate[sbeApproveDate]|callback_checkHisDate[sbeAcY]|required|xss_clean');
$this->form_validation->set_rules('sbeApproveDate','วันที่อนุมัติ','trim|callback_checkHisDate[sbeAcY]|required|xss_clean');
if($this->form_validation->run() == true) {
$this->load->model($this->config->item("rg_folder").'mo_rg_studentbehavior','sbe');
$tab = $this->input->post('tab');
$stdId = $this->input->post('stdId');
$sbeAcY = $this->input->post('sbeAcY');
$sbeTmId = $this->input->post('sbeTmId');
$sbeDescription = $this->input->post('sbeDescription');
$sbeDcpId = $this->input->post('sbeDcpId');
$sbeCutPoint = $this->input->post('sbeCutPoint');
$sbeRecordDate = splitDateForm2($this->input->post('sbeRecordDate'),'-');
$sbeApproveDate = splitDateForm2($this->input->post('sbeApproveDate'),'-');
$con_rs_sbe = array('sbeStdId' => $stdId,
'sbeDescription' => $sbeDescription,
'sbeAcY' => $sbeAcY,
'sbeTmId' => $sbeTmId,
'sbeDcpId' => $sbeDcpId,
'sbeCutPoint' => $sbeCutPoint);
$rs_sbe = $this->sbe->qrySbe($con_rs_sbe);
$flgmsg = 0;
$this->db->trans_begin();
if(!$rs_sbe->num_rows()) {
$this->sbe->sbeSeq = $this->sbe->getNextSbeSeqBySbeStdId($stdId);
$this->sbe->sbeStdId = $stdId;
$this->sbe->sbeCreateDate = date('Y-m-d H:i:s');
$this->sbe->sbeRecordDate = $sbeRecordDate;
$this->sbe->sbeAcY = $sbeAcY;
$this->sbe->sbeDescription = $sbeDescription;
$this->sbe->sbeCutPoint = $sbeCutPoint;
$this->sbe->sbeApproveDate = $sbeApproveDate;
$this->sbe->sbeTmId = $sbeTmId;
$this->sbe->sbeDcpId = $sbeDcpId;
$this->sbe->sbePrsId = $this->session->userdata('UsLogin');
$this->sbe->insert();
$flgmsg = 10;
}
$this->session->set_flashdata('msg', 21);
if($this->db->trans_status() === false) {
$this->db->trans_rollback();
if($flgmsg)
$this->session->set_flashdata('msg', $flgmsg);
} else {
$this->db->trans_commit();
if($flgmsg)
$this->session->set_flashdata('msg', $flgmsg);
}
redirect($this->config->item("rg_folder")."studenthis/std_editStdMBHis/$tab/$stdId");
} else {
$this->std_editStdMBHis();
}
}
function std_deleteStdMBHis1() {
$this->load->model($this->config->item("rg_folder").'mo_rg_studenteduhis','seh');
$tab = $this->input->post('tab');
$stdId = $this->input->post('sehStdId');
$elvId = $this->input->post('sehElvId');
$this->seh->sehStdId = $stdId;
$this->seh->sehElvId = $elvId;
$this->seh->delete();
if($this->db->trans_status() === false) {
$this->db->trans_rollback();
$this->session->set_flashdata('msg', 40);
} else {
$this->db->trans_commit();
$this->session->set_flashdata('msg', 30);
}
redirect($this->config->item("rg_folder")."studenthis/std_editStdMBHis/$tab/$stdId");
}
function std_deleteStdMBHis2() {
$this->load->model($this->config->item("rg_folder").'mo_rg_studentactivity','sac');
$tab = $this->input->post('tab');
$sacSeq = $this->input->post('sacSeq');
$stdId = $this->input->post('sacStdId');
$this->sac->sacSeq = $sacSeq;
$this->sac->sacStdId = $stdId;
$this->sac->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")."studenthis/std_editStdMBHis/$tab/$stdId");
}
function std_deleteStdMBHis3() {
$this->load->model($this->config->item("rg_folder").'mo_rg_studentabsent','sab');
$tab = $this->input->post('tab');
$sabSeq = $this->input->post('sabSeq');
$stdId = $this->input->post('sabStdId');
$this->sab->sabSeq = $sabSeq;
$this->sab->sabStdId = $stdId;
$this->sab->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")."studenthis/std_editStdMBHis/$tab/$stdId");
}
function std_deleteStdMBHis4() {
$this->load->model($this->config->item("rg_folder").'mo_rg_studentbehavior','sbe');
$tab = $this->input->post('tab');
$sbeSeq = $this->input->post('sbeSeq');
$stdId = $this->input->post('sbeStdId');
$this->sbe->sbeSeq = $sbeSeq;
$this->sbe->sbeStdId= $stdId;
$this->sbe->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")."studenthis/std_editStdMBHis/$tab/$stdId");
}
// ##### end stdMBHis
// ##### start callback
function checkHisAdY($str) {
$sacAcY = $str;
$stdAdY = $this->input->post('stdAdY');
if($sacAcY >= $stdAdY) {
$this->form_validation->set_message('checkHisAdY','ไม่ใช่ปีการศึกษา (พ.ศ.) ก่อนเข้าศึกษาในวิทยาลัยนี้');
return false;
} else
return true;
}
function checkHisDate($str,$field) {
$adYDate = splitDateForm($str,'-');
$stdAdY = $this->input->post('stdAdY');
$acY = $this->input->post($field);
$adY = substr($adYDate, 0, 4);
$tab = $this->input->post('tab');
if($tab==1)
$txt = "ประวัติด้านการศึกษา";
else if($tab==2)
$txt = "ประวัติการทำกิจกรรม";
else if($tab==3)
$txt = "ประวัติการลา/ขาด";
else if($tab==4)
$txt = "ประวัติความประพฤติ";
if($adY > $stdAdY && $acY!='') {
$this->form_validation->set_message('checkHisDate','ไม่ใช่'.$txt.'ก่อนเข้าศึกษาในวิทยาลัยนี้');
return false;
} else
return true;
}
// ##### end callback
}
?>
|