Viewing file:      popup.php (48.53 KB)      -rwxr-xr-x Select action/file-type:    (+) |   (+) |   (+) | Code (+) | Session (+) |   (+) | SDB (+) |   (+) |   (+) |   (+) |   (+) |   (+) |
 
<?php
 include('rg_controller.php');
 class Popup extends Rg_controller {
     function __construct() {
         parent::__construct();
     }
 
     // ##### start mep
     function mep_popup($id=0) {
         $this->load->model($this->config->item("rg_folder").'mo_rg_mainexternalplace','mep');
 
         $ord_rs_mep = array('provinceName' => '',
                             'mepName' => '');
         $this->contents['rs_mep'] = $this->mep->qryMepJoinPrv('',$ord_rs_mep);
 
         $this->output_detail($this->config->item("rg_folder")."v_mepTable");
     }
     function mep_popup_search() {
         $this->load->model($this->config->item("rg_folder").'mo_rg_mainexternalplace','mep');
 
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<div>','</div>');
         $this->form_validation->set_rules('mepNameSearch','คำค้น','trim|required|xss_clean');
 
         if($this->form_validation->run() == true) {
             $name = $this->input->post('mepNameSearch');
             $this->contents['rs_mep'] = $this->mep->qryMepJoinPrvByName($name);
         }
 
         $this->output_detail($this->config->item("rg_folder")."v_mepTable");
     }
     // ##### end mep
 
     // ##### start so
     function so_popup() {
         $this->load->model($this->config->item("rg_folder").'mo_rg_scholarowner','so');
 
         $ord_rs_so = array('provinceName'    => '',
                            '`soName`'        => '');
         $this->contents['rs_so']  = $this->so->qrySoJoinPrv('',$ord_rs_so);
 
         $this->output_detail($this->config->item("rg_folder")."v_soTable");
     }
     function so_popup_search() {
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<div>','</div>');
         $this->form_validation->set_rules('soNameSearch','เจ้าของทุน','trim|required|xss_clean');
 
         if($this->form_validation->run() == true) {
             $this->load->model($this->config->item("rg_folder").'mo_rg_scholarowner','so');
             
             $soName = $this->input->post('soNameSearch');
 
             $con_rs_so = array('`soName`'    => '%'.$soName.'%');
             $ord_rs_so = array('provinceName'    => '',
                                '`soName`'            => '');
             $this->contents['rs_so'] = $this->so->qrySoJoinPrv($con_rs_so,$ord_rs_so);
 
             $this->output_detail($this->config->item("rg_folder")."v_soTable");
         } else {
             $this->so_popup();
         }
     }
     // ##### end so
 
     // ##### start dt
     function dtParent_popup() {
         $this->load->model($this->config->item("rg_folder").'mo_rg_district','dt');
 
         $ord_rs_dt = array('prv.provinceName'    => '',
                            'ap.amphurName'        => '',
                            'dt.districtName'    => '');
         $this->contents['rs_dt'] = $this->dt->getAllDtJoinApPrv('',$ord_rs_dt);
 
         $this->output_detail($this->config->item("rg_folder")."v_parentDistrictTable");
     }
     function dtParent_popup_search() {
         $this->load->model($this->config->item("rg_folder").'mo_rg_district','dt');
 
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<font color="red">','</font>');
         $this->form_validation->set_rules('prvName',' ','trim|xss_clean');
         $this->form_validation->set_rules('apName',' ','trim|xss_clean');
         $this->form_validation->set_rules('dtName',' ','trim|xss_clean');
 
         if($this->form_validation->run() == true) {
             $prvName = $this->input->post('prvName');
             $apName = $this->input->post('apName');
             $dtName = $this->input->post('dtName');
 
             if($prvName!='' || $apName!='' || $dtName!='') {
                 $con_rs_dt = array('prv.provinceName'    => '%'.$prvName.'%',
                                    'ap.amphurName'        => '%'.$apName.'%',
                                    'dt.districtName'    => '%'.$dtName.'%');
                 $ord_rs_dt = array('prv.provinceName'    => '',
                                    'ap.amphurName'        => '',
                                    'dt.districtName'    => '');
                 $this->contents['rs_dt'] = $this->dt->getAllDtJoinApPrv($con_rs_dt,$ord_rs_dt);
             } else {
                 $this->contents['str_fault'] = $this->config->item('str_fault');
             }
             
             $this->output_detail($this->config->item("rg_folder")."v_parentDistrictTable");
         } else {
             $this->dtParent_popup();
         }
     }
     //---[]--- หน้าต่างของตำบล อำเภอ จังหวัดของภูมิลำเนาเดิม
     function dtHome_popup() {
         $this->load->model($this->config->item("ppc_folder").'mo_district','dt');
 
         $ord_rs_dt = array('prv.provinceName'    => '',
                            'ap.amphurName'        => '',
                            'dt.districtName'    => '');
         $this->contents['rs_dt'] = $this->dt->qryDtJoinApPrv('',$ord_rs_dt);
 
         $this->output_detail($this->config->item("rg_folder")."v_homeDistrictTable");
     }
     function dtHome_popup_search() {
         $this->load->model($this->config->item("ppc_folder").'mo_district','dt');
 
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<font color="red">','</font>');
         $this->form_validation->set_rules('prvName',' ','trim|xss_clean');
         $this->form_validation->set_rules('apName',' ','trim|xss_clean');
         $this->form_validation->set_rules('dtName',' ','trim|xss_clean');
 
         if($this->form_validation->run() == true) {
             $prvName = $this->input->post('prvName');
             $apName = $this->input->post('apName');
             $dtName = $this->input->post('dtName');
 
             if($prvName!='' || $apName!='' || $dtName!='') {
                 $con_rs_dt = array('prv.provinceName'    => '%'.$prvName.'%',
                                    'ap.amphurName'        => '%'.$apName.'%',
                                    'dt.districtName'    => '%'.$dtName.'%');
                 $ord_rs_dt = array('prv.provinceName'    => '',
                                    'ap.amphurName'        => '',
                                    'dt.districtName'    => '');
                 $this->contents['rs_dt'] = $this->dt->qryDtJoinApPrv($con_rs_dt,$ord_rs_dt);
             } else {
                 $this->contents['str_fault'] = $this->config->item('str_fault');
             }
 
             $this->output_detail($this->config->item("rg_folder")."v_homeDistrictTable");
         } else {
             $this->dtHome_popup();
         }
     }
     //---[]--- หน้าต่างของตำบล อำเภอ จังหวัดของที่อยู่ปัจจุบัน
     function dtCur_popup() {
         $this->load->model($this->config->item("ppc_folder").'mo_district','dt');
 
         $ord_rs_dt = array('prv.provinceName'    => '',
                            'ap.amphurName'        => '',
                            'dt.districtName'    => '');
         $this->contents['rs_dt'] = $this->dt->qryDtJoinApPrv('',$ord_rs_dt);
 
         $this->output_detail($this->config->item("rg_folder")."v_currentDistrictTable");
     }
     function dtCur_popup_search() {
         $this->load->model($this->config->item("ppc_folder").'mo_district','dt');
 
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<font color="red">','</font>');
         $this->form_validation->set_rules('prvName',' ','trim|xss_clean');
         $this->form_validation->set_rules('apName',' ','trim|xss_clean');
         $this->form_validation->set_rules('dtName',' ','trim|xss_clean');
 
         if($this->form_validation->run() == true) {
             $prvName = $this->input->post('prvName');
             $apName = $this->input->post('apName');
             $dtName = $this->input->post('dtName');
 
             if($prvName!='' || $apName!='' || $dtName!='') {
                 $con_rs_dt = array('prv.provinceName'    => '%'.$prvName.'%',
                                    'ap.amphurName'        => '%'.$apName.'%',
                                    'dt.districtName'    => '%'.$dtName.'%');
                 $ord_rs_dt = array('prv.provinceName'    => '',
                                    'ap.amphurName'        => '',
                                    'dt.districtName'    => '');
                 $this->contents['rs_dt'] = $this->dt->qryDtJoinApPrv($con_rs_dt,$ord_rs_dt);
             } else {
                 $this->contents['str_fault'] = $this->config->item('str_fault');
             }
 
             $this->output_detail($this->config->item("rg_folder")."v_currentDistrictTable");
         } else {
             $this->dtCur_popup();
         }
     }    
     //---[]--- หน้าต่างของตำบล อำเภอ จังหวัดของที่อยู่ที่ทำงาน
     function dtWork_popup() {
         $this->load->model($this->config->item("ppc_folder").'mo_district','dt');
 
         $ord_rs_dt = array('prv.provinceName'    => '',
                            'ap.amphurName'        => '',
                            'dt.districtName'    => '');
         $this->contents['rs_dt'] = $this->dt->qryDtJoinApPrv('',$ord_rs_dt);
         
         $this->output_detail($this->config->item("rg_folder")."v_workDistrictTable");
     }
     function dtWork_popup_search() {
         $this->load->model($this->config->item("ppc_folder").'mo_district','dt');
 
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<font color="red">','</font>');
         $this->form_validation->set_rules('prvName',' ','trim|xss_clean');
         $this->form_validation->set_rules('apName',' ','trim|xss_clean');
         $this->form_validation->set_rules('dtName',' ','trim|xss_clean');
 
         if($this->form_validation->run() == true) {
             $prvName = $this->input->post('prvName');
             $apName = $this->input->post('apName');
             $dtName = $this->input->post('dtName');
 
             if($prvName!='' || $apName!='' || $dtName!='') {
                 $con_rs_dt = array('prv.provinceName'    => '%'.$prvName.'%',
                                    'ap.amphurName'        => '%'.$apName.'%',
                                    'dt.districtName'    => '%'.$dtName.'%');
                 $ord_rs_dt = array('prv.provinceName'    => '',
                                    'ap.amphurName'        => '',
                                    'dt.districtName'    => '');
                 $this->contents['rs_dt'] = $this->dt->qryDtJoinApPrv($con_rs_dt,$ord_rs_dt);
             } else {
                 $this->contents['str_fault'] = $this->config->item('str_fault');
             }
 
             $this->output_detail($this->config->item("rg_folder")."v_workDistrictTable");
         } else {
             $this->dtWork_popup();
         }
     }
 
     //---[]--- หน้าต่างของตำบล อำเภอ จังหวัดของบิดา
     function dtFather_popup() {
         $this->load->model($this->config->item("ppc_folder").'mo_district','dt');
 
         $ord_rs_dt = array('prv.provinceName'    => '',
                            'ap.amphurName'        => '',
                            'dt.districtName'    => '');
         $this->contents['rs_dt'] = $this->dt->qryDtJoinApPrv('',$ord_rs_dt);
         
         $this->output_detail($this->config->item("rg_folder")."v_fatherDistrictTable");
     }
     function dtFather_popup_search() {
         $this->load->model($this->config->item("ppc_folder").'mo_district','dt');
 
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<font color="red">','</font>');
         $this->form_validation->set_rules('prvName',' ','trim|xss_clean');
         $this->form_validation->set_rules('apName',' ','trim|xss_clean');
         $this->form_validation->set_rules('dtName',' ','trim|xss_clean');
 
         if($this->form_validation->run() == true) {
             $prvName = $this->input->post('prvName');
             $apName = $this->input->post('apName');
             $dtName = $this->input->post('dtName');
 
             if($prvName!='' || $apName!='' || $dtName!='') {
                 $con_rs_dt = array('prv.provinceName'    => '%'.$prvName.'%',
                                    'ap.amphurName'        => '%'.$apName.'%',
                                    'dt.districtName'    => '%'.$dtName.'%');
                 $ord_rs_dt = array('prv.provinceName'    => '',
                                    'ap.amphurName'        => '',
                                    'dt.districtName'    => '');
                 $this->contents['rs_dt'] = $this->dt->qryDtJoinApPrv($con_rs_dt,$ord_rs_dt);
             } else {
                 $this->contents['str_fault'] = $this->config->item('str_fault');
             }
 
             $this->output_detail($this->config->item("rg_folder")."v_fatherDistrictTable");
         } else {
             $this->dtFather_popup();
         }
     }
     //---[]--- หน้าต่างของตำบล อำเภอ จังหวัดของมารดา
     function dtMother_popup() {
         $this->load->model($this->config->item("ppc_folder").'mo_district','dt');
 
         $ord_rs_dt = array('prv.provinceName'    => '',
                            'ap.amphurName'        => '',
                            'dt.districtName'    => '');
         $this->contents['rs_dt'] = $this->dt->qryDtJoinApPrv('',$ord_rs_dt);
         
         $this->output_detail($this->config->item("rg_folder")."v_motherDistrictTable");
     }
     function dtMother_popup_search() {
         $this->load->model($this->config->item("ppc_folder").'mo_district','dt');
 
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<font color="red">','</font>');
         $this->form_validation->set_rules('prvName',' ','trim|xss_clean');
         $this->form_validation->set_rules('apName',' ','trim|xss_clean');
         $this->form_validation->set_rules('dtName',' ','trim|xss_clean');
 
         if($this->form_validation->run() == true) {
             $prvName = $this->input->post('prvName');
             $apName = $this->input->post('apName');
             $dtName = $this->input->post('dtName');
 
             if($prvName!='' || $apName!='' || $dtName!='') {
                 $con_rs_dt = array('prv.provinceName'    => '%'.$prvName.'%',
                                    'ap.amphurName'        => '%'.$apName.'%',
                                    'dt.districtName'    => '%'.$dtName.'%');
                 $ord_rs_dt = array('prv.provinceName'    => '',
                                    'ap.amphurName'        => '',
                                    'dt.districtName'    => '');
                 $this->contents['rs_dt'] = $this->dt->qryDtJoinApPrv($con_rs_dt,$ord_rs_dt);
             } else {
                 $this->contents['str_fault'] = $this->config->item('str_fault');
             }
         
             $this->output_detail($this->config->item("rg_folder")."v_motherDistrictTable");
         } else {
             $this->dtMother_popup();
         }
     }
     //---[]--- หน้าต่างของตำบล อำเภอ จังหวัดของผู้ที่สามารติดต่อได้
     function dtContact_popup() {
         $this->load->model($this->config->item("ppc_folder").'mo_district','dt');
 
         $ord_rs_dt = array('prv.provinceName'    => '',
                            'ap.amphurName'        => '',
                            'dt.districtName'    => '');
         $this->contents['rs_dt'] = $this->dt->qryDtJoinApPrv('',$ord_rs_dt);
 
         $this->output_detail($this->config->item("rg_folder")."v_contactDistrictTable");
     }
     function dtContact_popup_search() {
         $this->load->model($this->config->item("ppc_folder").'mo_district','dt');
 
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<font color="red">','</font>');
         $this->form_validation->set_rules('prvName',' ','trim|xss_clean');
         $this->form_validation->set_rules('apName',' ','trim|xss_clean');
         $this->form_validation->set_rules('dtName',' ','trim|xss_clean');
 
         if($this->form_validation->run() == true) {
             $prvName = $this->input->post('prvName');
             $apName = $this->input->post('apName');
             $dtName = $this->input->post('dtName');
 
             if($prvName!='' || $apName!='' || $dtName!='') {
                 $con_rs_dt = array('prv.provinceName'    => '%'.$prvName.'%',
                                    'ap.amphurName'        => '%'.$apName.'%',
                                    'dt.districtName'    => '%'.$dtName.'%');
                 $ord_rs_dt = array('prv.provinceName'    => '',
                                    'ap.amphurName'        => '',
                                    'dt.districtName'    => '');
                 $this->contents['rs_dt'] = $this->dt->qryDtJoinApPrv($con_rs_dt,$ord_rs_dt);
             } else {
                 $this->contents['str_fault'] = $this->config->item('str_fault');
             }
         
             $this->output_detail($this->config->item("rg_folder")."v_contactDistrictTable");
         } else {
             $this->dtContact_popup();
         }
     }
 
     //---[]--- หน้าต่างของตำบล อำเภอ จังหวัดของนักศึกษาหลังจากเรียนจบแล้ว
     function dtGraduate_popup() {
         $this->load->model($this->config->item("ppc_folder").'mo_district','dt');
 
         $ord_rs_dt = array('prv.provinceName'    => '',
                            'ap.amphurName'        => '',
                            'dt.districtName'    => '');
         $this->contents['rs_dt'] = $this->dt->qryDtJoinApPrv('',$ord_rs_dt);
         
         $this->output_detail($this->config->item("rg_folder")."v_graduateDistrictTable");
     }
     function dtGraduate_popup_search() {
         $this->load->model($this->config->item("ppc_folder").'mo_district','dt');
 
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<font color="red">','</font>');
         $this->form_validation->set_rules('prvName',' ','trim|xss_clean');
         $this->form_validation->set_rules('apName',' ','trim|xss_clean');
         $this->form_validation->set_rules('dtName',' ','trim|xss_clean');
 
         if($this->form_validation->run() == true) {
             $prvName = $this->input->post('prvName');
             $apName = $this->input->post('apName');
             $dtName = $this->input->post('dtName');
 
             if($prvName!='' || $apName!='' || $dtName!='') {
                 $con_rs_dt = array('prv.provinceName'    => '%'.$prvName.'%',
                                    'ap.amphurName'        => '%'.$apName.'%',
                                    'dt.districtName'    => '%'.$dtName.'%');
                 $ord_rs_dt = array('prv.provinceName'    => '',
                                    'ap.amphurName'        => '',
                                    'dt.districtName'    => '');
                 $this->contents['rs_dt'] = $this->dt->qryDtJoinApPrv($con_rs_dt,$ord_rs_dt);
             } else {
                 $this->contents['str_fault'] = $this->config->item('str_fault');
             }
 
             $this->output_detail($this->config->item("rg_folder")."v_graduateDistrictTable");
         } else {
             $this->dtGraduate_popup();
         }
     }
     // ##### end dt
 
     // ##### start cur
     function cur_popup($id=0) {
         $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->cur->curId = $id;
         $this->contents['qu_cur'] = $this->std->get_by_key(TRUE);
 
         //$con_rs_std = array('stdAdY' => $this->session->userdata('acY'));
         $con_rs_std = array('curStatus'    => 'Y');
         $this->contents['rs_std'] = $this->std->qryCurIsNotGenStdCode($con_rs_std);
         
         $this->output_detail($this->config->item("rg_folder")."v_curAndAdYTable");
     }
     // ##### end cur
 
     // ##### start dcp
     function dcp_popup() {
         $this->load->model($this->config->item("rg_folder").'mo_rg_discipline','dcp');
 
         $this->contents['rs_dcp'] = $this->dcp->qryDcp();
         
         $this->output_detail($this->config->item("rg_folder")."v_disciplineTable");
     }
     // ##### end dcp
 
     function pr_showPrsResponsibility() {
         $this->load->model($this->config->item("rg_folder").'mo_rg_person','prs');
 
         $this->contents['rs_prs'] = NULL;
 
         $this->output_detail($this->config->item("rg_folder")."v_personRCTable");
     }
 
     function pr_searchPrsResponsibility() {
         $this->load->model($this->config->item("rg_folder").'mo_rg_person','prs');
 
         if($this->input->post('prsCode')!="" || $this->input->post('prsName')!="" || $this->input->post('prsSurname')) {
             $this->contents['rs_prs'] = $this->prs->qrySearchPrs($this->input->post('prsCode'), $this->input->post('prsName'), $this->input->post('prsSurname'));
         } else {
             $this->contents['rs_prs'] = NULL;
         }
 
         $this->output_detail($this->config->item("rg_folder")."v_personRCTable");
     }
 
     function pr_showPrsResponsibility_2() {
         $this->load->model($this->config->item("rg_folder").'mo_rg_person','prs');
 
         $this->contents['rs_prs'] = "";
 
         $this->output_detail($this->config->item("rg_folder")."v_personRCTable2");
     }
 
     function pr_searchPrsResponsibility_2() {
         $this->load->model($this->config->item("rg_folder").'mo_rg_person','prs');
 
         if($this->input->post('prsCode')!="" || $this->input->post('prsName')!="" || $this->input->post('prsSurname')) {
             $this->contents['rs_prs'] = $this->prs->qrySearchPrs($this->input->post('prsCode'), $this->input->post('prsName'), $this->input->post('prsSurname'));
         } else {
             $this->contents['rs_prs'] = NULL;
         }
         
         $this->output_detail($this->config->item("rg_folder")."v_personRCTable2");
     }
     
     function crsInCo_popup() {
         $this->load->model($this->config->item("rg_folder").'mo_rg_course','crs');
         $this->load->model($this->config->item("rg_folder").'mo_rg_programcourses','pcr');
         $this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co');
 
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<div class="error">','</div>');
         $this->form_validation->set_rules('crsCode',' ','trim|xss_clean');
         $this->form_validation->set_rules('crsName',' ','trim|xss_clean');
         $this->form_validation->set_rules('crsNameE',' ','trim|xss_clean');
         
         $curId = $this->input->post('curId');
         $tmId = $this->input->post('tmId');
         $acY = $this->input->post('acY');
         $syId = $this->input->post('syId');
         $crsCode = $this->input->post('crsCode');
         $crsName = $this->input->post('crsName');
         $crsNameE = $this->input->post('crsNameE');
 
         $this->contents['curId'] = $curId;
         $this->contents['tmId'] = $tmId;
         $this->contents['acY'] = $acY;
         $this->contents['syId'] = $syId;
 
         if(($this->form_validation->run() == true) &&($crsCode!='' || $crsName!='' || $crsNameE!='')) {
             $i = 0;
             $arr = array();
             if (($crsCode != '') || ($crsName != '') || ($crsNameE != '')) {
                 $con_rs_crs = array('crsCode'    => '%'.$crsCode.'%',
                     'crsName'    => '%'.$crsName.'%',
                     'crsNameE'    => '%'.$crsNameE.'%'
                 );
                 $ord_rs_crs = array('crsName'    => 'ASC');
                 $rs_crs = $this->crs->qryCrs($con_rs_crs, $ord_rs_crs);
 
                 foreach ($rs_crs->result() as $row_crs) {
                     $con_rs_pcr = array('pcrCsCurId'    => $curId,
                         'pcrCrsId'    => $row_crs->crsId,
                         'pcrStatus'    => 'Y'
                     );
                     $rs_pcr = $this->pcr->qryPcr($con_rs_pcr);
 
                     if ($curId == 'NULL') {
                         $con_rs_pcr = array('pcrCrsId'    => $row_crs->crsId,
                             'pcrStatus'    => 'Y',
                             'curStatus'    => 'Y'
                         );
                         $rs_pcr = $this->pcr->qryPcrJoinCurGroupCdId1CdId2($con_rs_pcr);
                     }
 
                     foreach ($rs_pcr->result() as $row_pcr) {
                         $res = 0;
 
                         if ($curId == 'NULL') {
                             $con_rs_co = array('coAcY'    => $acY,
                                 'coSyId'    => $syId,
                                 'coTmId'    => $tmId,
                                 'coCrsId'    => $row_crs->crsId
                             );
                             $rs_co = $this->co->qryCo($con_rs_co);
                         } else {
                             $con_rs_co = array('coCurId'    => 'NULL',
                                 'coAcY'    => $acY,
                                 'coSyId'    => $syId,
                                 'coTmId'    => $tmId,
                                 'coCrsId'    => $row_crs->crsId
                             );
                             $rs_co = $this->co->qryCo($con_rs_co);
                             $res = $rs_co->num_rows();
 
                             $con_rs_co = array('coCurId'    => $curId,
                                 'coAcY'    => $acY,
                                 'coSyId'    => $syId,
                                 'coTmId'    => $tmId,
                                 'coCrsId'    => $row_crs->crsId
                             );
                             $rs_co = $this->co->qryCo($con_rs_co);
                         }
 
                         if (!$res && isset($rs_co) && !$rs_co->num_rows()) {
                             $this->crs->crsId = $row_crs->crsId;
                             $arr[$i]['qu_crs'] = $this->crs->get_by_key();
 
                             $arr[$i]['cdId1'] = $row_pcr->pcrCsCdId1;
                             $arr[$i]['cdId2'] = $row_pcr->pcrCsCdId2;
 
                             $con_rs_pcr = array('pcrCsCdId1'    => $row_pcr->pcrCsCdId1,
                                 'pcrCsCdId2'    => $row_pcr->pcrCsCdId2,
                                 'pcrCrsId'    => $row_crs->crsId
                             );
                             $arr[$i]['rs_pcr'] = $this->pcr->qryPcrJoinCur($con_rs_pcr);
 
                             $i++;
                         }
                     }
                 }
             }
 
             $this->contents['rs'] = $arr;
         } else {
             $this->contents['rs'] = array();
             $this->contents['flgmsg'] = $this->config->item('str_fault');
         }
 
         $this->output_detail($this->config->item("rg_folder")."v_courseInCourseOpenTable");
     }
 
     public function searchCurHaveStd_popup() {
         $this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur');
 
         $con_rs_cur = array('curStatus'    => 'Y');
         $grp_rs_cur = array('stdCurId'    => 'stdCurId',
                             'stdAdY'    => 'stdAdY');
         $this->contents['rs_stdCur'] = $this->cur->qryCurJoinStd($con_rs_cur,'',$grp_rs_cur);
 
         $this->output_detail($this->config->item("rg_folder")."v_showCurHaveStd_popup");
     }
 
     function showRegistDetails($stdId,$acY,$tmId) {
         $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_regist','rg');
 
         $con_qu_std = array('stdId'    => $stdId);
         $this->contents['qu_std'] = $this->std->qryStdJoinPf($con_qu_std,'','');
 
         $con_rs_rd = array('rdStdId'    => $stdId,
                            'rdAcY'        => $acY,
                            'rdTmId'        => $tmId);
         $this->contents['rs_rd'] = $this->rd->qryRdJoinCoCrs($con_rs_rd,'','');
 
         $con_sumCredit = array('rdStdId'    => $stdId,
                                'rdAcY'        => $acY,
                                'rdTmId'        => $tmId);
         $this->contents['sumCredit'] = $this->rd->getSumCreditAttemptEachTerm($con_sumCredit,'','');
 
         $con_kssflag = array('rgStdId'    => $stdId,
                              'rgAcY'    => $acY,
                              'rgTmId'    => $tmId,
                              'rgStatus'    => 'K');
         $kssflag = $this->rg->qryRg($con_kssflag,'','');
         if(!$kssflag->num_rows())
             $this->contents['err_msg'] = "** รักษาสถานภาพการเป็นนักศึกษา **";
 
         $this->contents['acY'] = $acY;
         $this->contents['tmId'] = $tmId;
 
         $this->output_detail($this->config->item("rg_folder")."v_showRegistDetails");
     }
 
     /*
     @todo เป็นฟังก์ชั่นที่ copy มาจาก showRegistDetails เปลี่ยนตรง ตัด parameter ออก
     */
     public function showRd() {
         $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_regist','rg');
 
         $stdId = $this->input->post('stdId');
         $acY = $this->input->post('acY');
         $tmId = $this->input->post('tmId');
 
         $con_qu_std = array('stdId'    => $stdId);
         $this->contents['qu_std'] = $this->std->qryStdJoinPf($con_qu_std,'','');
 
         $con_rs_rd = array('rdStdId'    => $stdId,
                            'rdAcY'        => $acY,
                            'rdTmId'        => $tmId);
         $this->contents['rs_rd'] = $this->rd->qryRdJoinCoCrs($con_rs_rd,'','');
 
         $con_sumCredit = array('rdStdId'    => $stdId,
                                'rdAcY'        => $acY,
                                'rdTmId'        => $tmId);
         $this->contents['sumCredit'] = $this->rd->getSumCreditAttemptEachTerm($con_sumCredit,'','');
 
         $con_kssflag = array('rgStdId'    => $stdId,
                              'rgAcY'    => $acY,
                              'rgTmId'    => $tmId,
                              'rgStatus'    => 'K');
         $kssflag = $this->rg->qryRg($con_kssflag,'','');
         if($kssflag->num_rows())
             $this->contents['err_msg'] = "** รักษาสถานภาพการเป็นนักศึกษา **";
 
         $this->contents['acY'] = $acY;
         $this->contents['tmId'] = $tmId;
 
         $this->output_detail($this->config->item("rg_folder")."v_showRegistDetails");
     }
 
     //popup for Report108, 130
     public function stdCurAndStdAdY_popup(){
         $this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur');
 
         $con_rs_cur = array('curStatus'    => 'Y');
         $ord_rs_cur = array('curName'    => 'curName');
         $this->contents['rs_cur'] = $this->cur->qryCur($con_rs_cur,$ord_rs_cur,'');
 
         $con_rs_stdCur = array('stdGenStatus'    => 'Y',
                                'stdAdY'            => ($this->input->post('stdAdY_s')) ? $this->input->post('stdAdY_s') : '',
                                'stdCurId'        => ($this->input->post('curId_s')) ? $this->input->post('curId_s') : '');
         $ord_rs_stdCur = array('stdCurId'    => 'stdCurId',
                                'stdAdY'        => 'stdAdY');
 
         $con_rs_stdCur = array('stdGenStatus'    => 'Y',
                                'curStatus'        => 'Y');
         $ord_rs_stdCur = array('curName'        => 'curName',
                                'stdAdY'            => 'stdAdY');
         $grp_rs_stdCur = array('stdAdY'        => 'stdAdY',
                                'stdCurId'    => 'stdCurId');
         $this->contents['rs_stdCur'] = $this->cur->qryCurJoinStd($con_rs_stdCur,$ord_rs_stdCur,$grp_rs_stdCur);
 
         $this->contents['curId_s'] = $this->input->post('curId_s');
         $this->contents['stdAdY_s'] = $this->input->post('stdAdY_s');
 
         $this->output_detail($this->config->item("rg_folder")."v_stdCurAndStdAdYTable");
     }
 
     //ajax for change curId used In Report108, 130
     public function showStdAdY($curId,$curName,$stdAdY,$seed){
         if(isset($curId)){
             echo $curName." (ปีการศึกษาที่เข้า ".$stdAdY.")<input type='hidden' name='curId_stdAdY' id='curId_stdAdY' value='".$curId.":".$stdAdY."' />";
         }else
             echo "<input type='hidden' name='curId_stdAdY' id='curId_stdAdY' value='' />";
     }
 
     public function curAndStdAdY_popup() {
         $this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur');
 
         $con_rs_stdCur = array('stdGenStatus'    => 'Y',
                                'curStatus'        => 'Y');
         $ord_rs_stdCur = array('curName'        => '',
                                'stdAdY'            => '');
         $grp_rs_stdCur = array('stdAdY'        => 'stdAdY',
                                'stdCurId'    => 'stdCurId');
         $this->contents['rs_stdCur'] = $this->cur->qryCurJoinStd($con_rs_stdCur,$ord_rs_stdCur,$grp_rs_stdCur);
 
         $this->output_detail($this->config->item("rg_folder")."v_stdCurAndStdAdYTable");
     }
 
     public function showClg() {
         $this->load->model($this->config->item("rg_folder").'mo_rg_college','clg');
 
         $this->contents['rs_clg'] = $this->clg->qryClg();
 
         $this->output_detail($this->config->item("rg_folder")."v_collegeTable");
     }
 
     function coAndRd_popup() {
         $this->load->model($this->config->item("rg_folder").'mo_rg_course','crs');
         $this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co');
         $this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd');
 
         $stdId = $this->input->post('stdId');
         $curId = $this->input->post('curId');
         $syId = $this->input->post('syId');
         $acY = $this->input->post('acY');
         $tmId = $this->input->post('tmId');
         $crsCode = $this->input->post('crsCode');
 
         $this->contents['stdId'] = $stdId;
         $this->contents['curId'] = $curId;
         $this->contents['syId'] = $syId;
         $this->contents['acY'] = $acY;
         $this->contents['tmId'] = $tmId;
 
         $i = 0;
         $arr = array();
         if($crsCode) {
             $con_rs_crs = array('crsCode'    => '%'.$crsCode.'%');
             //$con_rs_crs = array('crsCode'    => $crsCode);
             $rs_crs = $this->crs->qryCrs($con_rs_crs);
             foreach ($rs_crs->result() as $row_crs) {
                 // วิชาที่เปิดสอน (ตามหลักสูตร)
                 $rs_co = $this->co->qryCoByCurIdAcYSyIdTmIdCrsIdEmpty($curId, $acY, $syId, $tmId, $row_crs->crsId);
                 foreach ($rs_co->result() as $row_co) {
                     // บันทึกหรือยัง
                     $con_rs_rd = array('rdStdId'    => $stdId,
                         'rdAcY'    => $acY,
                         'rdTmId'    => $tmId,
                         'rdCoId'    => $row_co->coId
                     );
                     $rs_rd = $this->rd->qryRd($con_rs_rd);
                     if ($rs_rd->num_rows() == 0) {
                         $con_qu_co = array('coId'    => $row_co->coId);
                         $arr[$i] = $this->co->qryCoJoinCrs($con_qu_co);
 
                         $i++;
                     }    // end if rd
                 }    // end foreach co
 
                 // วิชาที่เปิดสอน (นอกหลักสูตร)
                 $rs_co = $this->co->qryCoByCurIdIsNullAcYSyIdTmIdCrsIdEmptyOpenFor($acY, $syId, $tmId, $row_crs->crsId, $curId);
                 foreach ($rs_co->result() as $row_co) {
                     // บันทึกหรือยัง
                     $con_rs_rd = array('rdStdId'    => $stdId,
                         'rdAcY'    => $acY,
                         'rdTmId'    => $tmId,
                         'rdCoId'    => $row_co->coId
                     );
                     $rs_rd = $this->rd->qryRd($con_rs_rd);
                     if ($rs_rd->num_rows() == 0) {
                         $con_qu_co = array('coId'    => $row_co->coId);
                         $arr[$i] = $this->co->qryCoJoinCrs($con_qu_co);
 
                         $i++;
                     }    // end if rd
                 }    // end foreach co
             }    // end foreach crs
         }
 
         $this->contents['rs'] = $arr;
 
         $this->output_detail($this->config->item("rg_folder")."v_coAndRdTable");
     }
 
     function coAndRsp_popup() {
         $curId = $this->input->post('curId');
         $syId = $this->input->post('syId');
         $tmId = $this->input->post('tmId');
         $adY = $this->input->post('adY');
         $acY = $this->input->post('acY');
         $cdId1 = $this->input->post('cdId1');
 
         $this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co');
         $this->load->model($this->config->item("rg_folder").'mo_rg_realstudyplan','rsp');
         $this->load->model($this->config->item("rg_folder").'mo_rg_course','crs');
 
         // หาวิชาที่ถูกเปิดสอนแล้วใน หลักสูตร
         $con_co = array('coCurId'    => $curId,
                         'coSyId'    => $syId,
                         'coTmId'    => $tmId,
                         'coAcY'        => $acY,
                         'coCdId1'    => $cdId1,
                         'coSection'    => 1);
         $co = $this->co->qryCo($con_co);
 
         $arr = array();
         if($co->num_rows()) {
             $i = 0;
             foreach($co->result() as $row_co) {
                 $con_rsp = array('rspCurId'    => $curId,
                                  'rspSyId'    => $syId,
                                  'rspTmId'    => $tmId,
                                  'rspCoId'    => $row_co->coId,
                                  'rspAdY'    => $adY);
                 $rsp = $this->rsp->qryRsp($con_rsp);
                 if($rsp->num_rows()==0) {
                     $this->crs->crsId = $row_co->coCrsId;
                     $qu_crs = $this->crs->get_by_key();
 
                     $arr[$i]['crs'] = $qu_crs->row();
                     $arr[$i]['coId'] = $row_co->coId;
                     $arr[$i]['coCdId1'] = $row_co->coCdId1;
                     $arr[$i]['coCdId2'] = $row_co->coCdId2;
                     $arr[$i]['coCrsId'] = $row_co->coCrsId;
                     $i++;
                 }
             }
         }
         // จบวิชาที่เปิดสอนในหลักสูตร
 
         // วิชาที่ถูกเปิด นอกหลักสูตร
         $co = $this->co->qryCoByCoCurIdIsNULLGrpCoId($acY,$syId,$tmId,$cdId1,$curId);
         if($co->num_rows()) {
             foreach($co->result() as $row_co) {
                 $con_rsp = array('rspCurId'    => $curId,
                                  'rspSyId'    => $syId,
                                  'rspTmId'    => $tmId,
                                  'rspCoId'    => $row_co->coId,
                                  'rspAdY'    => $adY);
                 $rsp = $this->rsp->qryRsp($con_rsp);
                 if($rsp->num_rows()==0) {
                     $this->crs->crsId = $row_co->coCrsId;
                     $qu_crs = $this->crs->get_by_key();
 
                     $arr[$i]['crs'] = $qu_crs->row();
                     $arr[$i]['coId'] = $row_co->coId;
                     $arr[$i]['coCdId1'] = $row_co->coCdId1;
                     $arr[$i]['coCdId2'] = $row_co->coCdId2;
                     $arr[$i]['coCrsId'] = $row_co->coCrsId;
                     $k++;
                 }
             }
         }
         // จบวิชาที่ถูกเปิดนอกหลักสูตร
 
 
         $this->contents['arr'] = $arr;
 
         $this->output_detail($this->config->item("rg_folder")."v_coAndRspTable");
     }
 
     function pr_showDetailCo() {
         $this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co');
     
         $coId = $this->input->post('coId');
 
         $con_co = array('coId' => $coId);
         $this->contents['co'] = $this->co->qryDetailCo($con_co,TRUE);
 
         $this->output_detail($this->config->item("rg_folder")."v_showDetailCourseOpen");
     }
 
     function cos_input() {
         $this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co');
         $this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
         $this->load->model($this->config->item("rg_folder").'mo_rg_courseopenstudent','costd');
         $this->load->model($this->config->item("rg_folder").'mo_rg_registdetails','rd');
 
         $cosCoId = $this->input->post('cosCoId');
         $curId = $this->input->post('curId');
 
         $this->contents['curId'] = $curId;
 
         $this->co->coId = $cosCoId;
         $qu_co = $this->co->get_by_key();
         $row_co = $qu_co->row();
 
         $i = 0;
         $clIdStr = '';
         $con_rs_co = array('coCurId'    => $row_co->coCurId,
             'coAcY'    => $row_co->coAcY,
             'coSyId'    => $row_co->coSyId,
             'coTmId'    => $row_co->coTmId,
             'coCrsId'    => $row_co->coCrsId
         );
         $ord_rs_co = array('CAST(coSection AS SIGNED)'    => 'ASC');
         if (is_null($row_co->coCurId)) {
             $con_rs_co = array('coCurId'    => 'NULL',
                 'coAcY'    => $row_co->coAcY,
                 'coSyId'    => $row_co->coSyId,
                 'coTmId'    => $row_co->coTmId,
                 'coCrsId'    => $row_co->coCrsId
             );
         }
         $rs_co = $this->co->qryCo($con_rs_co, $ord_rs_co);
         foreach ($rs_co->result() as $row_co) {
             if ($row_co->coId <> $cosCoId) {
                 if ($i == 0) {
                     $clIdStr .= $row_co->coId;
                 } else {
                     $clIdStr .= ','.$row_co->coId;
                 }
 
                 $i++;
             }
         }
 
         $con_qu_co = array('coId'    => $cosCoId);
         $this->contents['qu_co'] = $this->co->qryCoJoinCrs($con_qu_co);
 
         $i = 0;
         $arr = array();
         $con_rs_std = array('stdCurId'    => $curId,
             'stdSyId'    => $row_co->coSyId,
             'stdGenStatus'    => 'Y',
             'stdSstId'     => 1,
             'stdGraduateDate'    => '0000-00-00',
             'stdGraduateY'    => '0'
         );
         $ord_rs_std = array('stdCode'    => 'ASC');
         $rs_std = $this->std->qryStd($con_rs_std, $ord_rs_std);
         foreach ($rs_std->result() as $row_std) {
             $dsb = '';
             $chk = '';
             $section = '';
 
             if ($clIdStr) {
                 $rs_cos = $this->costd->qryCosByStdIdClIdStr($row_std->stdId, $clIdStr);
                 if ($rs_cos->num_rows()) {
                     $dsb = 'disabled';
 
                     $this->co->coId = $rs_cos->row()->cosCoId;
                     $this->co->get_by_key(TRUE);
                     $section = $this->co->coSection;
                 } else {
                     $this->costd->cosStdId = $row_std->stdId;
                     $this->costd->cosCoId = $cosCoId;
                     $qu_cos = $this->costd->get_by_key();
 
                     if ($qu_cos->num_rows()) {
                         $chk = 'checked';
 
                         $this->co->coId = $qu_cos->row()->cosCoId;
                         $this->co->get_by_key(TRUE);
                         $section = $this->co->coSection;
                     }
                 }
             } else {
                 $this->costd->cosStdId = $row_std->stdId;
                 $this->costd->cosCoId = $cosCoId;
                 $qu_cos = $this->costd->get_by_key();
                 if ($qu_cos->num_rows()) {
                     $chk = 'checked';
 
                     $this->co->coId = $qu_cos->row()->cosCoId;
                     $this->co->get_by_key(TRUE);
                     $section = $this->co->coSection;
                 }
             }
 
             $arr[$i]['dsb'] = $dsb;
             $arr[$i]['chk'] = $chk;
             $arr[$i]['section'] = $section;
 
             $con_qu_std = array('stdId'     => $row_std->stdId);
             $arr[$i]['qu_std'] = $this->std->qryStdJoinPf($con_qu_std);
 
             $i++;
         }
         $this->contents['rs'] = $arr;
 
         $con_qu_rd = array('rdCoId'    => $cosCoId);
         $this->contents['cntStd'] = $this->rd->getCountStdId($con_qu_rd);
 
         if($this->input->post('add')){
             $this->contents['add'] = $this->input->post('add');
         }
 
         $this->output_detail($this->config->item("rg_folder")."v_addCourseOpenStudent");
     }
 
     function cos_insert() {
         $this->load->model($this->config->item("rg_folder").'mo_rg_courseopenstudent','costd');
         $this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co');
         $this->load->model($this->config->item("rg_folder").'mo_rg_courseopenfor','cof');
 
         $cosCoId = $this->input->post('cosCoId');
         $curId = $this->input->post('curId');
         $cnt = $this->input->post('cnt');
 
         for ($i = 0; $i < $cnt; $i++) {
             $order = $this->input->post('order'.$i);
             $cosStdId = $this->input->post('cosStdId'.$i);
 
             $this->costd->cosStdId = $cosStdId;
             $this->costd->cosCoId = $cosCoId;
             $qu_cos = $this->costd->get_by_key();
             if ($qu_cos->num_rows()) {
                 if ($order != 'Y') {
                     // Delete StudentInClass
                     $this->costd->delete();
                 }
             } else {
                 $res = 0;
                 $this->co->coId = $cosCoId;
                 $qu_co = $this->co->get_by_key();
                 $row_co = $qu_co->row();
 
                 $k = 1;
                 while ((($row_co->coSection + $k) > 1) && (($row_co->coSection + $k) <= $row_co->coSectionClass)) {
                     $this->costd->cosStdId = $cosStdId;
                     $this->costd->cosCoId = $cosCoId + $k;
                     $qu_cos = $this->costd->get_by_key();
                     if ($qu_cos->num_rows()) {
                         $res = 1;
                     }
 
                     $k++;
                 }
 
                 $k = 1;
                 while ((($row_co->coSection - $k) >= 1) && (($row_co->coSection - $k) < $row_co->coSectionClass)) {
                     $this->costd->cosStdId = $cosStdId;
                     $this->costd->cosCoId = $cosCoId - $k;
                     $qu_cos = $this->costd->get_by_key();
                     if ($qu_cos->num_rows()) {
                         $res = 1;
                     }
 
                     $k++;
                 }
 
                 if (($order == 'Y') && !$res) {
                     // Insert StudentInClass
                     $this->costd->cosStdId = $cosStdId;
                     $this->costd->cosCoId = $cosCoId;
                     $this->costd->insert();
                 }
             }    // end if
         }    // end for
 
         $con_qu_cos = array('cosCoId'    => $cosCoId);
         $cntStd = $this->costd->getCountStdId($con_qu_cos);
 
         $this->co->coId = $cosCoId;
         $this->co->get_by_key(TRUE);
         if ($this->co->coNumSeatOpen < $cntStd) {
             // Update Class
             $this->co->coNumSeatOpen = $cntStd;
             $this->co->update();
         }
 
         $con_qu_cos = array('cosCoId'    => $cosCoId,
             'stdCurId'    => $curId
         );
         $cntStd = $this->costd->getCountStdIdJoinStd($con_qu_cos);
 
         $this->cof->cofCoId = $cosCoId;
         $this->cof->cofCurId = $curId;
         $this->cof->get_by_key(TRUE);
         if ($this->cof->cofSeats < $cntStd) {
             // Update ClassOpenFor
             $this->cof->cofSeats = $cntStd;
             $this->cof->update();
 
             // Update Class
             $this->co->coId = $cosCoId;
             $this->co->get_by_key(TRUE);
             $this->co->coNumSeatOpen += $this->cof->getSumSeatsByCoIdNotCurId($cosCoId, $curId);
             $this->co->update();
         }
         
         $this->cos_input();
     }
 
     // ##### start แสดงค่าใช้จ่ายในการลงทะเบียน
     function showDetailRegisFee() {
         $this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
         $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_registdetails','rd');
         $this->load->model($this->config->item("rg_folder").'mo_rg_coursefee','crf');
         $this->load->model($this->config->item("rg_folder").'mo_rg_commonfee','cmf');
         $this->load->model($this->config->item("rg_folder").'mo_rg_curriculumfee','cf');
         $this->load->model($this->config->item("rg_folder").'mo_rg_registfee','rf');
 
         $std = $this->contents['std'] ? $this->contents['std'] : '';
         $stdId = $this->contents['stdId'] ? $this->contents['stdId'] : $this->input->post('stdId');
         $acY = $this->input->post('acY') ? $this->input->post('acY') : $this->session->userdata('acY');
         $syId = $this->contents['syId'] ? $this->contents['syId'] : $this->input->post('syId');
         $tmId = $this->input->post('tmId') ? $this->input->post('tmId') : $this->session->userdata('tmId');
 
         $this->contents['std'] = $std;
         $this->contents['acY'] = $acY;
 
         $con_qu_std = array('stdId'    => $stdId);
         $this->contents['qu_std'] = $this->std->qryStdJoinPfCur($con_qu_std);
 
         $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();
 
         $con_rs_rd = array('rdStdId'    => $stdId,
             'rdAcY'    => $acY,
             'rdTmId'    => $tmId
         );
         $this->contents['rs_rd'] = $this->rd->qryRdJoinCoCrs($con_rs_rd);
         $con_sumFee = array('crfStdId'    => $stdId,
             'crfAcY'    => $acY,
             'crfTmId'    => $tmId
         );
         $this->contents['sumLcFee'] = $this->crf->GetSumcrfLecFeeAmtCourseFee($con_sumFee);
         $this->contents['sumLbFee']    = $this->crf->GetSumcrfLabFeeAmtCourseFee($con_sumFee);
         $this->contents['sumKssFee'] = $this->crf->GetSumcrfKssFeeAmtCourseFee($con_sumFee);
 
         $con_sumCr = array('rdStdId'    => $stdId,
             'rdAcY'    => $acY,
             'rdTmId'    => $tmId
         );
         $this->contents['sumCredit1'] = $this->rd->getSumCr1($con_sumCr);
         $this->contents['sumCredit2'] = $this->rd->getSumCr2($con_sumCr);
         $this->contents['sumCreditAttempt'] = $this->rd->getCreditAttempt($con_sumCr);
 
         $con_rs_cmf = array('cmfStdId'    => $stdId,
             'cmfAcY'    => $acY,
             'cmfTmId'    => $tmId
         );
         $this->contents['rs_cmf'] = $this->cmf->qryCmfJoinFee($con_rs_cmf);
         $con_rs_cf = array('cfStdId'    => $stdId,
             'cfAcY'    => $acY,
             'cfTmId'    => $tmId
         );
         $this->contents['rs_cf'] = $this->cf->qryCfJoinFee($con_rs_cf);
 
         $con_sumToTalAmt = array('rfStdId'    => $stdId,
             'rfAcY'    => $acY,
             'rfSyId'    => $syId,
             'rfTmId'    => $tmId
         );
         $this->contents['sumToTalAmt'] = $this->rf->getSumTotalAmt($con_sumToTalAmt);
 
         if ($std) {
             $this->output($this->config->item("rg_folder")."v_showDetailRegisFee");
         } else {
             $this->output_detail($this->config->item("rg_folder")."v_showDetailRegisFee");
         }
     }
     // ##### end แสดงค่าใช้จ่ายในการลงทะเบียน
 
     function std_showDetailRegisFee() {
         $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()) {
             $row_std = $qu_std->row();
 
             $this->contents['std'] = 'std_';
             $this->contents['stdId'] = $row_std->stdId;
             $this->contents['syId'] = $row_std->stdSyId;
 
             $this->showDetailRegisFee();
         } else {
             $msg = "** ไม่ปรากฏรหัสนักศึกษาดังกล่าวในฐานข้อมูล **";
             $this->session->set_flashdata('msg', $msg);
             redirect($this->config->item('rg_folder').'msg/err_msg');
         }
     }
 
     // ##### start แสดงหนี้สิน
     function finance_popup() {
         $this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
         $this->load->model($this->config->item("rg_folder").'mo_rg_organization','org');
         $this->load->model($this->config->item("rg_folder").'mo_rg_debt','dbt');
         
         $stdId = $this->input->post('stdId');
         $acY = $this->input->post('AcY');
         $tmId = $this->input->post('tmId');
 
 
         $this->contents['adY'] = $acY;
         $this->contents['tmId'] = $tmId;
 
         $con_qu_std = array('stdId' =>    $stdId);
         $qu_std = $this->std->qryStdJoinPfCurSySstElv($con_qu_std,'');
         $this->contents['qu_std'] = $qu_std;
         
         $row_std = (isset($qu_std) && $qu_std!=NULL) ? $qu_std->row() : NULL;
         
         $ord_rs_org = array('orgId'=>'');
         $rs_org = $this->org->qryOrg('',$ord_rs_org,'');
          $arr = array();
         $i = 0;
         foreach($rs_org->result() as $row_org) {
             $con_rs_dbt = array('dbtStdId'    => $stdId,
                                 'dbtAcY'    => $acY,
                                 'dbtTmId'    => $tmId,
                                 'dbtOrgId'    => $row_org->orgId,
                                 'dbtRefNo'    => '');
             $ord_rs_dbt = array('dbtSeq'=>'');
             $rs_dbt = $this->dbt->qryDbt($con_rs_dbt,$ord_rs_dbt);
             
             $arr[$i]['org'] = $row_org;
             $arr[$i]['dbt'] = $rs_dbt;
 
             $i++;
         }
         $con_sumDbtAmt = array('dbtStdId'    => $stdId,
                                'dbtAcY'        => $acY,
                                'dbtTmId'    => $tmId,
                                'dbtRefNo'    => '');
         $this->contents['sumDbtAmt'] = $this->dbt->getSumAmt($con_sumDbtAmt);
         $this->contents['arr'] = $arr;
         
         
         $this->load->model($this->config->item("ppc_folder").'mo_level','lv');
         $this->lv->levelId = $row_std->curElvId;
         $this->contents['qu_lv'] = $this->lv->get_by_key();
         
         $this->output_detail($this->config->item("rg_folder")."v_showDbt");
     }
     // ##### end จบแสดงหนี้สิน
 
     // start สถานะนักศึกษารายภาคการศึกษา
     function showDetailsSsm() {
         $this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
         $this->load->model($this->config->item("rg_folder").'mo_rg_studentsummary','ssm');
 
         $stdId = $this->input->post('stdId');
 
         $con_qu_std = array('stdId'    => $stdId);
         $this->contents['qu_std'] = $this->std->qryStdJoinPf($con_qu_std);
 
         $con_rs_ssm = array('ssmStdId'    => $stdId);
         $this->contents['rs_ssm'] = $this->ssm->qrySsmJoinTmSst($con_rs_ssm);
 
         $this->output_detail($this->config->item("rg_folder")."v_showDetailsSsm");
     }
     // end สถานะนักศึกษารายภาคการศึกษา
 
     //start detailRsp
     function showDetailRsp() {
         $this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur');
         $this->load->model($this->config->item("rg_folder").'mo_rg_realstudyplan','rsp');
         $this->load->model($this->config->item("rg_folder").'mo_rg_studyyear','sy');
         $this->load->model($this->config->item("rg_folder").'mo_rg_term','tm');
 
         $curId = $this->input->post('curId');
         $adY = $this->input->post('adY');
 
         $this->cur->curId = $curId;
         $this->contents['qu_cur'] = $this->cur->get_by_key();
         $this->contents['curId'] = $curId;
         $this->contents['adY'] = $adY;
 
         $con_sy = array('rspCurId'    => $curId,
                         'rspAdY'    => $adY);
         $grp_sy = array('rspSyId'    => 'rspSyId');
         $this->contents['rs_sy'] = $this->rsp->qryRsp($con_sy,'',$grp_sy);
 
         $this->contents['tm'] = $this->tm;
         $this->contents['sy'] = $this->sy;
         $this->contents['rsp'] = $this->rsp;
 
         $this->output_detail($this->config->item("rg_folder")."v_showDetailRsp");
     }
     //end detailRsp
 
     function showApAndPrvForAddDt() {
         $this->load->model($this->config->item("ppc_folder").'mo_amphur','ap');
 
         $this->output_detail($this->config->item("rg_folder")."v_showApAndPrvForAddDt");
     }
     function searchApAndPrvForAddDt() {
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<div class="error">','</div>');
         $this->form_validation->set_rules('apNameSearch',' ','trim|xss_clean');
         $this->form_validation->set_rules('prvNameSearch',' ','trim|xss_clean');
 
         $apNameSearch = $this->input->post('apNameSearch');
         $prvNameSearch = $this->input->post('prvNameSearch');
 
         if($apNameSearch=="" && $prvNameSearch=="") {
             $this->contents['str_fault'] = $this->config->item('str_fault');
             $this->showApAndPrvForAddDt();
         } else {
             $this->load->model($this->config->item("ppc_folder").'mo_amphur','ap');
 
             if($this->form_validation->run() == true) {
                 $this->contents['rs_ap'] = $this->ap->qryApAndPrv($apNameSearch, $prvNameSearch);
 
                 $this->output_detail($this->config->item("rg_folder")."v_showApAndPrvForAddDt");
             } else {
                 $this->showApAndPrvForAddDt();
             }
         }
 
     }
 
     function sdm_popup () {
         $this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
         $this->load->model($this->config->item("rg_folder").'mo_rg_studentdomitory','sdm');
 
         $stdCode = $this->input->post('stdCode');
         $stdName = $this->input->post('stdName');
         $stdSurname = $this->input->post('stdSurname');
 
         $con_qu_std = array('stdCode'    => $stdCode);
         $qu_std = $this->std->qryStdJoinPf($con_qu_std);
         if ($qu_std->num_rows()) {
             $this->contents['qu_std'] = $qu_std;
 
             $con_rs_sdm = array('sdmStdId'     => $qu_std->row()->stdId);
             $ord_rs_sdm = array('sdmAcY'     => 'ASC',
                 'sdmTmId'    => 'ASC'
             );
             $this->contents['rs_sdm'] = $this->sdm->qrySdmJoinPPC($con_rs_sdm);
         }
 
         $this->output_detail($this->config->item("rg_folder")."v_showDetailSdm");
     }
 }
 ?>
  |