Viewing file:      bdppc.php (44.57 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 bdppc extends Rg_controller {
 
 //    function __construct() {
 //        parent::__construct();
 //    }
 
     // ##### start elv
     function lev_input($search=0) {
         $this->load->model($this->config->item("ppc_folder").'mo_level','lev');
 
         if($search==0) {
             $ord_rs_lev = array('levelName'    => 'ASC');
             $this->contents['rs_lev'] = $this->lev->qryLev('', $ord_rs_lev);
         }
 
         $elvId = $this->input->post('elvId');
         $this->lev->levelId = $elvId;
         $this->contents['qu_elv'] = $this->lev->get_by_key();
 
         //$this->output($this->config->item("rg_folder")."v_showLevel");
         $this->output($this->config->item("rg_folder")."v_addEduLevel", $this->session->flashdata('msg'));
     }
     function lev_insert_update() {
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<div class="error">','</div>');
         $this->form_validation->set_rules('elvName',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('elvNameE',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('elvAbbr',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('elvAbbrE',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('elvId',' ','trim|xss_clean');
 
         if ($this->form_validation->run() == true) {
             $this->load->model($this->config->item("ppc_folder").'mo_level','lev');
 
             $elvName = $this->input->post('elvName');
             $elvNameE = $this->input->post('elvNameE');
             $elvAbbr = $this->input->post('elvAbbr');
             $elvAbbrE = $this->input->post('elvAbbrE');
             $elvId = $this->input->post('elvId');
 
             $this->lev->levelId = $elvId;
             $qu_lev = $this->lev->get_by_key();
 
             $this->lev->db->trans_begin();
             if($qu_lev->num_rows()) {
                 $con_rs_lev = array('levelName'    => $elvName,
                                     'levelAbbr'    => $elvAbbr);
                 $rs_lev = $this->lev->qryLevNotId($con_rs_lev, $elvId);
                 if(!$rs_lev->num_rows()) {
                     $this->lev->levelId = $elvId;
                     $this->lev->get_by_key(TRUE);
                     if (class_exists('Ver_query')) {
                         Ver_query::setOldVal($this->lev, $this->config->item('ppc_dbname').'.Level');
                     }
 
                     $this->lev->levelName = $elvName;
                     $this->lev->levelNameEng = $elvNameE;
                     $this->lev->levelAbbr = $elvAbbr;
                     $this->lev->levelAbbrEng = $elvAbbrE;
                     $this->lev->update();
                     if (class_exists('Ver_query')) {
                         Ver_query::saveQuery($this->lev, $this->lev->db->last_query(), $this->config->item('ver_ppc_id'));
                     }
                     
                     $flgmsg = 10;
                 } else {
                     $flgmsg = 21;
                 }
             } else {
                 $con_rs_lev = array('levelName'    => $elvName,
                                     'levelAbbr'    => $elvAbbr);
                 $rs_lev = $this->lev->qryLev($con_rs_lev);
                 if(!$rs_lev->num_rows()) {
                     if (class_exists('Ver_query')) {
                         Ver_query::setOldVal($this->lev, $this->config->item('ppc_dbname').'.Level');
                     }
                     
                     $this->lev->levelId = "";
                     $this->lev->levelName = $elvName;
                     $this->lev->levelNameEng = $elvNameE;
                     $this->lev->levelAbbr = $elvAbbr;
                     $this->lev->levelAbbrEng = $elvAbbrE;
                     $this->lev->pbriId = "";
                     $this->lev->insert();
 
                     if (class_exists('Ver_query')) {
                         Ver_query::saveQuery($this->lev, $this->lev->db->last_query(), $this->config->item('ver_ppc_id'));
                     }
 
                     $flgmsg = 10;
                 } else {
                     $flgmsg = 21;
                 }
             }
 
             if ($this->lev->db->trans_status() === false) {
                 $this->lev->db->trans_rollback();
                 $flgmsg = 20;
                 $this->session->set_flashdata('msg', $flgmsg);
             } else {
                 $this->lev->db->trans_commit();
                 $this->session->set_flashdata('msg', $flgmsg);
             }
 
             redirect($this->config->item("rg_folder")."bdppc/lev_input");
         } else {
             $this->lev_input();
         }
     }
     function lev_search() {
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<font color="red">','</font>');
         $this->form_validation->set_rules('levNameSearch',' ','trim|required|xss_clean');
 
         if($this->form_validation->run() == true) {
             $this->load->model($this->config->item("ppc_folder").'mo_level','lev');
 
             $levNameSearch = $this->input->post('levNameSearch');
             
             $con_rs_lev = array('levelName'    => '%'.$levNameSearch.'%');
             $ord_rs_lev = array('levelName'    => '');
             $this->contents['rs_lev'] = $this->lev->qryLev($con_rs_lev, $ord_rs_lev);
 
             $opt = array();
             $opt[''] = 'ไม่ระบุ';
             $opt['M'] = 'ชาย';
             $opt['F'] = 'หญิง';
             $this->contents['gender'] = $opt;
 
             $this->output($this->config->item("rg_folder")."v_addEduLevel");
         } else {
             $this->lev_input(1);
         }
     }
     function lev_detail() {
         $this->load->model($this->config->item("ppc_folder").'mo_level','lev');
 
         $elvId = $this->input->post('elvId');
         $this->lev->levelId = $elvId;
         $this->contents['qu_elv'] = $this->lev->get_by_key();
 
         $this->output_detail($this->config->item("rg_folder")."v_detailEduLevel");
     }
     function lev_delete() {
         $this->load->model($this->config->item("ppc_folder").'mo_level','lev');
 
         $elvId = $this->input->post('elvId');
 
         $this->lev->db->trans_begin();
         $this->lev->levelId = $elvId;
         if (class_exists('Ver_query')) {
             Ver_query::setOldVal($this->lev, $this->config->item('ppc_dbname').'.Level');
         }
 
         $this->lev->delete();
         if (class_exists('Ver_query')) {
             Ver_query::saveQuery($this->lev, $this->lev->db->last_query(), $this->config->item('ver_ppc_id'));
         }
 
         if ($this->lev->db->trans_status() === false) {
             $this->lev->db->trans_rollback();
             $this->session->set_flashdata('msg', 41);
         } else {
             $this->lev->db->trans_commit();
             $this->session->set_flashdata('msg', 30);
         }
 
         redirect($this->config->item("rg_folder")."bdppc/lev_input");
     }
     function lev_print() {
         $this->load->model($this->config->item("ppc_folder").'mo_level','lev');
 
         $ord_rs_lev = array('levelName'    => '');
         $data['rs_lev'] = $this->lev->qryLev('',$ord_rs_lev);
         $data['UsName'] = $this->session->userdata('UsName');
 
         $this->load->view($this->config->item("rg_folder")."v_printLevel", $data);
     }
     // ##### end elv
 
     // ##### start pf
     function pf_input($search=0) {
         $this->load->model($this->config->item("ppc_folder").'mo_prefix','pf');
 
         if($search==0) {
             //$ord_rs_pf = array('prefixNameFull'    => '');
             //$this->contents['rs_pf'] = $this->pf->qryPf('',$ord_rs_pf);
             $this->contents['rs_pf'] = $this->pf->qryPf();
         }
 
         $pfId = $this->input->post('pfId');
         $this->pf->prefixId = $pfId;
         $this->contents['qu_pf'] = $this->pf->get_by_key();
 
         $opt = array();
         $opt[''] = 'ไม่ระบุ';
         $opt['M'] = 'ชาย';
         $opt['F'] = 'หญิง';
         $this->contents['gender'] = $opt;
 
         //$this->output($this->config->item("rg_folder")."v_showPrefix");
         $this->output($this->config->item("rg_folder")."v_addPrefix", $this->session->flashdata('msg'));
     }
     function pf_insert_update() {
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<div class="error">','</div>');
         $this->form_validation->set_rules('pfName',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('pfNameE',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('pfNameAbbr',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('pfNameAbbrE',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('pfGender',' ','trim|xss_clean');
         $this->form_validation->set_rules('pfId',' ','trim|xss_clean');
 
         if ($this->form_validation->run() == true) {
             $this->load->model($this->config->item("ppc_folder").'mo_prefix','pf');
 
             $pfName = $this->input->post('pfName');
             $pfNameE = $this->input->post('pfNameE');
             $pfNameAbbr = $this->input->post('pfNameAbbr');
             $pfNameAbbrE = $this->input->post('pfNameAbbrE');
             $pfGender = $this->input->post('pfGender');
             $pfId = $this->input->post('pfId');
 
             $this->pf->prefixId = $pfId;
             $qu_pf = $this->pf->get_by_key();
             $this->pf->db->trans_begin();
             if($qu_pf->num_rows()) {
                 $con_rs_pf = array('prefixNameFull'    => $pfName,
                                    'prefixName'        => $pfNameAbbr);
                 $rs_pf = $this->pf->qryPfNotId($con_rs_pf, $pfId);
                 if(!$rs_pf->num_rows()) {
                     $this->pf->prefixId = $pfId;
                     $this->pf->get_by_key(TRUE);
                     if (class_exists('Ver_query')) {
                         Ver_query::setOldVal($this->pf, $this->config->item('ppc_dbname').'.Prefix');
                     }
 
                     $this->pf->prefixNameFull = $pfName;
                     $this->pf->prefixName = $pfNameAbbr;
                     $this->pf->prefixNameEngFull = $pfNameE;
                     $this->pf->prefixNameEng = $pfNameAbbrE;
                     $this->pf->defaultSex = $pfGender;
                     $this->pf->update();
                     if (class_exists('Ver_query')) {
                         Ver_query::saveQuery($this->pf, $this->pf->db->last_query(), $this->config->item('ver_ppc_id'));
                     }
                     
                     $flgmsg = 10;
                 } else {
                     $flgmsg = 21;
                 }
             } else {
                 $con_rs_pf = array('prefixNameFull'    => $pfName,
                                    'prefixName'        => $pfNameAbbr);
                 $rs_pf = $this->pf->qryPf($con_rs_pf);
                 if(!$rs_pf->num_rows()) {
                     if (class_exists('Ver_query')) {
                         Ver_query::setOldVal($this->pf, $this->config->item('ppc_dbname').'.Prefix');
                     }
                     
                     $this->pf->prefixId = "";
                     $this->pf->prefixNameFull = $pfName;
                     $this->pf->prefixName = $pfNameAbbr;
                     $this->pf->prefixNameEngFull = $pfNameE;
                     $this->pf->prefixNameEng = $pfNameAbbrE;
                     $this->pf->defaultSex = $pfGender;
                     $this->pf->pbriId = "";
                     $this->pf->insert();
 
                     if (class_exists('Ver_query')) {
                         Ver_query::saveQuery($this->pf, $this->pf->db->last_query(), $this->config->item('ver_ppc_id'));
                     }
 
                     $flgmsg = 10;
                 } else {
                     $flgmsg = 21;
                 }
             }
 
             if ($this->pf->db->trans_status() === false) {
                 $this->pf->db->trans_rollback();
                 $flgmsg = 20;
                 $this->session->set_flashdata('msg', $flgmsg);
             } else {
                 $this->pf->db->trans_commit();
                 $this->session->set_flashdata('msg', $flgmsg);
             }
 
             redirect($this->config->item("rg_folder")."bdppc/pf_input");
         } else {
             $this->pf_input();
         }
     }
     function pf_search() {
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<font color="red">','</font>');
         $this->form_validation->set_rules('pfNameSearch',' ','trim|required|xss_clean');
 
         if($this->form_validation->run() == true) {
             $this->load->model($this->config->item("ppc_folder").'mo_prefix','pf');
 
             $pfNameSearch = $this->input->post('pfNameSearch');
             
             $this->contents['rs_pf'] = $this->pf->qryPfLikePfNameFullAndPfName($pfNameSearch, $pfNameSearch);
 
             $opt = array();
             $opt[''] = 'ไม่ระบุ';
             $opt['M'] = 'ชาย';
             $opt['F'] = 'หญิง';
             $this->contents['gender'] = $opt;
 
             $this->output($this->config->item("rg_folder")."v_addPrefix");
         } else {
             $this->pf_input(1);
         }
     }
     function pf_delete() {
         $this->load->model($this->config->item("ppc_folder").'mo_prefix','pf');
 
         $pfId = $this->input->post('pfId');
 
         $this->pf->db->trans_begin();
         $this->pf->prefixId = $pfId;
         if (class_exists('Ver_query')) {
             Ver_query::setOldVal($this->pf, $this->config->item('ppc_dbname').'.Prefix');
         }
 
         $this->pf->delete();
         if (class_exists('Ver_query')) {
             Ver_query::saveQuery($this->pf, $this->pf->db->last_query(), $this->config->item('ver_ppc_id'));
         }
 
         if ($this->pf->db->trans_status() === false) {
             $this->pf->db->trans_rollback();
             $this->session->set_flashdata('msg', 41);
         } else {
             $this->pf->db->trans_commit();
             $this->session->set_flashdata('msg', 30);
         }
 
         redirect($this->config->item("rg_folder")."bdppc/pf_input");
     }
     function pf_detail() {
         $this->load->model($this->config->item("ppc_folder").'mo_prefix','pf');
 
         $pfId = $this->input->post('pfId');
 
         $this->pf->prefixId = $pfId;
         $this->contents['qu_pf'] = $this->pf->get_by_key();
         
         $this->output_detail($this->config->item("rg_folder")."v_detailPrefix");
     }
     function pf_print() {
         $this->load->model($this->config->item("ppc_folder").'mo_prefix','pf');
 
         $data['rs_pf'] = $this->pf->qryPf();
         $data['UsName'] = $this->session->userdata('UsName');
 
         $this->load->view($this->config->item("rg_folder")."v_printPrefixppc", $data);
     }
     // ##### end pf
 
     // ##### start nt
     function nt_input($search=0) {
         $this->load->model($this->config->item("ppc_folder").'mo_nation','nt');
 
         if($search==0) {
             $ord_rs_nt = array('nationName'    => '');
             $this->contents['rs_nt'] = $this->nt->qryNt('',$ord_rs_nt);
         }
 
         $ntId = $this->input->post('ntId');
         $this->nt->nationId = $ntId;
         $this->contents['qu_nt'] = $this->nt->get_by_key();
         
         //$this->output($this->config->item("rg_folder")."v_showNation");
         $this->output($this->config->item("rg_folder")."v_addNation", $this->session->flashdata('msg'));
     }
     function nt_insert_update() {
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<div class="error">','</div>');
         $this->form_validation->set_rules('ntName',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('ntNameE',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('ntId',' ','trim|xss_clean');
 
         if ($this->form_validation->run() == true) {
             $this->load->model($this->config->item("ppc_folder").'mo_nation','nt');
 
             $ntName = $this->input->post('ntName');
             $ntNameE = $this->input->post('ntNameE');
             $ntId = $this->input->post('ntId');
 
             $this->nt->nationId = $ntId;
             $qu_nt = $this->nt->get_by_key();
             $this->nt->db->trans_begin();
             if($qu_nt->num_rows()) {
                 $rs_nt = $this->nt->qryNtNotId($ntName, $ntId);
                 if(!$rs_nt->num_rows()) {
                     $this->nt->nationId = $ntId;
                     $this->nt->get_by_key(TRUE);
                     if (class_exists('Ver_query')) {
                         Ver_query::setOldVal($this->nt, $this->config->item('ppc_dbname').'.Nation');
                     }
 
                     $this->nt->nationName = $ntName;
                     $this->nt->nationNameEng = $ntNameE;
                     $this->nt->update();
                     if (class_exists('Ver_query')) {
                         Ver_query::saveQuery($this->nt, $this->nt->db->last_query(), $this->config->item('ver_ppc_id'));
                     }
                     
                     $flgmsg = 10;
                 } else {
                     $flgmsg = 21;
                 }
             } else {
                 $con_rs_nt = array('nationName'    => $ntName);
                 $rs_nt = $this->nt->qryNt($con_rs_nt);
                 if(!$rs_nt->num_rows()) {
                     if (class_exists('Ver_query')) {
                         Ver_query::setOldVal($this->nt, $this->config->item('ppc_dbname').'.Nation');
                     }
                     
                     $this->nt->nationId = '';
                     $this->nt->nationName =  $ntName;
                     $this->nt->nationNameEng =  $ntNameE;
                     $this->nt->pbriId = '';
                     $this->nt->insert();
 
                     if (class_exists('Ver_query')) {
                         Ver_query::saveQuery($this->nt, $this->nt->db->last_query(), $this->config->item('ver_ppc_id'));
                     }
 
                     $flgmsg = 10;
                 } else {
                     $flgmsg = 21;
                 }
             }
 
             if ($this->nt->db->trans_status() === false) {
                 $this->nt->db->trans_rollback();
                 $flgmsg = 20;
                 $this->session->set_flashdata('msg', $flgmsg);
             } else {
                 $this->nt->db->trans_commit();
                 $this->session->set_flashdata('msg', $flgmsg);
             }
 
             redirect($this->config->item("rg_folder")."bdppc/nt_input");
         } else {
             $this->nt_input();
         }
     }
     function nt_search() {
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<font color="red">','</font>');
         $this->form_validation->set_rules('ntNameSearch',' ','trim|required|xss_clean');
 
         if($this->form_validation->run() == true) {
             $this->load->model($this->config->item("ppc_folder").'mo_nation','nt');
 
             $ntNameSearch = $this->input->post('ntNameSearch');
             
             $con_rs_nt = array('nationName'    => '%'.$ntNameSearch.'%');
             $ord_rs_nt = array('nationName'    => '');
             $this->contents['rs_nt'] = $this->nt->qryNt($con_rs_nt,$ord_rs_nt);
 
             $this->output($this->config->item("rg_folder")."v_addNation");
         } else {
             $this->nt_input(1);
         }
     }
     function nt_delete() {
         $this->load->model($this->config->item("ppc_folder").'mo_nation','nt');
 
         $ntId = $this->input->post('ntId');
 
         $this->nt->db->trans_begin();
         $this->nt->nationId = $ntId;
         if (class_exists('Ver_query')) {
             Ver_query::setOldVal($this->nt, $this->config->item('ppc_dbname').'.Nation');
         }
 
         $this->nt->delete();
         if (class_exists('Ver_query')) {
             Ver_query::saveQuery($this->nt, $this->nt->db->last_query(), $this->config->item('ver_ppc_id'));
         }
 
         if ($this->nt->db->trans_status() === false) {
             $this->nt->db->trans_rollback();
             $this->session->set_flashdata('msg', 41);
         } else {
             $this->nt->db->trans_commit();
             $this->session->set_flashdata('msg', 30);
         }
 
         redirect($this->config->item("rg_folder")."bdppc/nt_input");
     }
     function nt_print() {
         $this->load->model($this->config->item("ppc_folder").'mo_nation','nt');
 
         $ord_rs_nt = array('nationName'    => '');
         $data['rs_nt'] = $this->nt->qryNt('',$ord_rs_nt);
         $data['UsName'] = $this->session->userdata('UsName');
 
         $this->load->view($this->config->item("rg_folder")."v_printNationppc", $data);
     }
     // ##### end nt
 
     // ##### start rlg
     function rlg_input($search=0) {
         $this->load->model($this->config->item("ppc_folder").'mo_religion','rlg');
 
         if($search==0) {
             $ord_rs_rlg = array('religionName'    => '');
             $this->contents['rs_rlg'] = $this->rlg->qryRlg('',$ord_rs_rlg);
         }
 
         $rlgId = $this->input->post('rlgId');
         $this->rlg->religionId = $rlgId;
         $this->contents['qu_rlg'] = $this->rlg->get_by_key();
 
         //$this->output($this->config->item("rg_folder")."v_showReligion");
         $this->output($this->config->item("rg_folder")."v_addReligion", $this->session->flashdata('msg'));
     }
     function rlg_insert_update() {
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<div class="error">','</div>');
         $this->form_validation->set_rules('rlgName',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('rlgNameE',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('rlgId',' ','trim|xss_clean');
 
         if ($this->form_validation->run() == true) {
             $this->load->model($this->config->item("ppc_folder").'mo_religion','rlg');
 
             $rlgName = $this->input->post('rlgName');
             $rlgNameE = $this->input->post('rlgNameE');
             $rlgId = $this->input->post('rlgId');
 
             $this->rlg->religionId = $rlgId;
             $qu_rlg = $this->rlg->get_by_key();
             $this->rlg->db->trans_begin();
             if($qu_rlg->num_rows()) {
                 $rs_rlg = $this->rlg->qryRlgNotId($rlgName, $rlgId);
                 if(!$rs_rlg->num_rows()) {
                     $this->rlg->religionId = $rlgId;
                     $this->rlg->get_by_key(TRUE);
                     if (class_exists('Ver_query')) {
                         Ver_query::setOldVal($this->rlg, $this->config->item('ppc_dbname').'.Religion');
                     }
 
                     $this->rlg->religionName = $rlgName;
                     $this->rlg->religionNameEng = $rlgNameE;
                     $this->rlg->update();
                     if (class_exists('Ver_query')) {
                         Ver_query::saveQuery($this->rlg, $this->rlg->db->last_query(), $this->config->item('ver_ppc_id'));
                     }
                     
                     $flgmsg = 10;
                 } else {
                     $flgmsg = 21;
                 }
             } else {
                 $con_rs_rlg = array('religionName'    => $rlgName);
                 $rs_rlg = $this->rlg->qryRlg($con_rs_rlg);
                 if(!$rs_rlg->num_rows()) {
                     if (class_exists('Ver_query')) {
                         Ver_query::setOldVal($this->rlg, $this->config->item('ppc_dbname').'.Religion');
                     }
                     
                     $this->rlg->religionId = '';
                     $this->rlg->religionName = $rlgName;
                     $this->rlg->religionNameEng = $rlgNameE;
                     $this->rlg->pbriId = '';
                     $this->rlg->insert();
 
                     if (class_exists('Ver_query')) {
                         Ver_query::saveQuery($this->rlg, $this->rlg->db->last_query(), $this->config->item('ver_ppc_id'));
                     }
 
                     $flgmsg = 10;
                 } else {
                     $flgmsg = 21;
                 }
             }
 
             if ($this->rlg->db->trans_status() === false) {
                 $this->rlg->db->trans_rollback();
                 $flgmsg = 20;
                 $this->session->set_flashdata('msg', $flgmsg);
             } else {
                 $this->rlg->db->trans_commit();
                 $this->session->set_flashdata('msg', $flgmsg);
             }
 
             redirect($this->config->item("rg_folder")."bdppc/rlg_input");
         } else {
             $this->rlg_input();
         }
     }
     function rlg_search() {
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<font color="red">','</font>');
         $this->form_validation->set_rules('rlgNameSearch',' ','trim|required|xss_clean');
 
         if($this->form_validation->run() == true) {
             $this->load->model($this->config->item("ppc_folder").'mo_religion','rlg');
 
             $rlgNameSearch = $this->input->post('rlgNameSearch');
             
             $con_rs_rlg = array('religionName'    => '%'.$rlgNameSearch.'%');
             $ord_rs_rlg = array('religionName'    => '');
             $this->contents['rs_rlg'] = $this->rlg->qryRlg($con_rs_rlg,$ord_rs_rlg);
 
             $this->output($this->config->item("rg_folder")."v_addReligion");
         } else {
             $this->rlg_input(1);
         }
     }
     function rlg_delete() {
         $this->load->model($this->config->item("ppc_folder").'mo_religion','rlg');
 
         $rlgId = $this->input->post('rlgId');
 
         $this->rlg->db->trans_begin();
         $this->rlg->religionId = $rlgId;
         if (class_exists('Ver_query')) {
             Ver_query::setOldVal($this->rlg, $this->config->item('ppc_dbname').'.Religion');
         }
 
         $this->rlg->delete();
         if (class_exists('Ver_query')) {
             Ver_query::saveQuery($this->rlg, $this->rlg->db->last_query(), $this->config->item('ver_ppc_id'));
         }
 
         if ($this->rlg->db->trans_status() === false) {
             $this->rlg->db->trans_rollback();
             $this->session->set_flashdata('msg', 41);
         } else {
             $this->rlg->db->trans_commit();
             $this->session->set_flashdata('msg', 30);
         }
 
         redirect($this->config->item("rg_folder")."bdppc/rlg_input");
     }
     function rlg_print() {
         $this->load->model($this->config->item("ppc_folder").'mo_religion','rlg');
 
         $ord_rs_rlg = array('religionName'    => '');
         $data['rs_rlg'] = $this->rlg->qryRlg('',$ord_rs_rlg);
         $data['UsName'] = $this->session->userdata('UsName');
 
         $this->load->view($this->config->item("rg_folder")."v_printReligionppc", $data);
     }
     // ##### end rlg
 
     // ##### start prv
     function prv_input($search=0) {
         $this->load->model($this->config->item("ppc_folder").'mo_province','prv');
 
         $prvId = $this->input->post('prvId');
         $this->prv->provinceId = $prvId;
         $this->contents['qu_prv'] = $this->prv->get_by_key();
 
         if($search==0) {
             $ord_rs_prv = array('provinceName'    => '');
             $this->contents['rs_prv'] = $this->prv->qryPrv('',$ord_rs_prv);
         }
 
         //$this->output($this->config->item("rg_folder")."v_showProvince");
         $this->output($this->config->item("rg_folder")."v_addProvince", $this->session->flashdata('msg'));
     }
     function prv_insert_update() {
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<div class="error">','</div>');
         $this->form_validation->set_rules('prvName',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('prvNameE',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('prvId',' ','trim|xss_clean');
 
         if ($this->form_validation->run() == true) {
             $this->load->model($this->config->item("ppc_folder").'mo_province','prv');
 
             $prvName = $this->input->post('prvName');
             $prvNameE = $this->input->post('prvNameE');
             $prvId = $this->input->post('prvId');
 
             $this->prv->provinceId = $prvId;
             $qu_prv = $this->prv->get_by_key();
             $this->prv->db->trans_begin();
             if($qu_prv->num_rows()) {
                 $rs_prv = $this->prv->qryPrvNotId($prvName, $prvId);
                 if(!$rs_prv->num_rows()) {
                     $this->prv->provinceId = $prvId;
                     $this->prv->get_by_key(TRUE);
                     if (class_exists('Ver_query')) {
                         Ver_query::setOldVal($this->prv, $this->config->item('ppc_dbname').'.Province');
                     }
 
                     $this->prv->provinceName = $prvName;
                     $this->prv->provinceNameEng = $prvNameE;
                     $this->prv->update();
                     if (class_exists('Ver_query')) {
                         Ver_query::saveQuery($this->prv, $this->prv->db->last_query(), $this->config->item('ver_ppc_id'));
                     }
                     
                     $flgmsg = 10;
                 } else {
                     $flgmsg = 21;
                 }
             } else {
                 $con_rs_prv = array('provinceName'    => $prvName);
                 $rs_prv = $this->prv->qryPrv($con_rs_prv);
                 if(!$rs_prv->num_rows()) {
                     if (class_exists('Ver_query')) {
                         Ver_query::setOldVal($this->prv, $this->config->item('ppc_dbname').'.Province');
                     }
                     $this->prv->provinceId = '';
                     $this->prv->provinceName = $prvName;
                     $this->prv->provinceNameEng = $prvNameE;
                     $this->prv->pbriId = '';
                     $this->prv->insert();
                     if (class_exists('Ver_query')) {
                         Ver_query::saveQuery($this->prv, $this->prv->db->last_query(), $this->config->item('ver_ppc_id'));
                     }
 
                     $flgmsg = 10;
                 } else {
                     $flgmsg = 21;
                 }
             }
 
             if ($this->prv->db->trans_status() === false) {
                 $this->prv->db->trans_rollback();
                 $flgmsg = 20;
                 $this->session->set_flashdata('msg', $flgmsg);
             } else {
                 $this->prv->db->trans_commit();
                 $this->session->set_flashdata('msg', $flgmsg);
             }
 
             redirect($this->config->item("rg_folder")."bdppc/prv_input");
         } else {
             $this->prv_input();
         }
     }
     function prv_search() {
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<font color="red">','</font>');
         $this->form_validation->set_rules('prvNameSearch',' ','trim|required|xss_clean');
 
         if($this->form_validation->run() == true) {
             $this->load->model($this->config->item("ppc_folder").'mo_province','prv');
 
             $prvNameSearch = $this->input->post('prvNameSearch');
             
             $con_rs_prv = array('provinceName'    => '%'.$prvNameSearch.'%');
             $ord_rs_prv = array('provinceName'    => '');
             $this->contents['rs_prv'] = $this->prv->qryPrv($con_rs_prv,$ord_rs_prv);
 
             //$this->output($this->config->item("rg_folder")."v_showProvince");
             $this->output($this->config->item("rg_folder")."v_addProvince");
         } else {
             $this->prv_input(1);
         }
     }
     function prv_print() {
         $this->load->model($this->config->item("ppc_folder").'mo_province','prv');
 
         $ord_rs_prv = array('provinceName'    => '');
         $data['rs_prv'] = $this->prv->qryPrv('',$ord_rs_prv);
         $data['UsName'] = $this->session->userdata('UsName');
 
         $this->load->view($this->config->item("rg_folder")."v_printProvinceppc", $data);
     }
     function prv_delete() {
         $this->load->model($this->config->item("ppc_folder").'mo_province','prv');
 
         $prvId = $this->input->post('prvId');
 
         $this->prv->db->trans_begin();
         $this->prv->provinceId = $prvId;
         if (class_exists('Ver_query')) {
             Ver_query::setOldVal($this->prv, $this->config->item('ppc_dbname').'.Province');
         }
 
         $this->prv->delete();
         if (class_exists('Ver_query')) {
             Ver_query::saveQuery($this->prv, $this->prv->db->last_query(), $this->config->item('ver_ppc_id'));
         }
 
         if ($this->prv->db->trans_status() === false) {
             $this->prv->db->trans_rollback();
             $this->session->set_flashdata('msg', 41);
         } else {
             $this->prv->db->trans_commit();
             $this->session->set_flashdata('msg', 30);
         }
 
         redirect($this->config->item("rg_folder")."bdppc/prv_input");
     }
     // ##### end prv
 
     // ##### start ap
     function ap_input() {
         $this->load->model($this->config->item("ppc_folder").'mo_amphur','ap');
         $this->load->model($this->config->item("ppc_folder").'mo_province','prv');
 
         $ord_rs_prv = array('provinceName'    => '');
         $this->contents['rs_prv'] = $this->prv->get_options('',$ord_rs_prv);
         $this->contents['character'] = thaiCharacter();
 
         $apId = $this->input->post('apId');
         $this->ap->amphurId = $apId;
         $this->contents['qu_ap'] = $this->ap->get_by_key();
         
         //$this->output($this->config->item("rg_folder")."v_showAmphur");
         $this->output($this->config->item("rg_folder")."v_addAmphur", $this->session->flashdata('msg'));
     }
     function ap_insert_update() {
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<div class="error">','</div>');
         $this->form_validation->set_rules('apId',' ','trim|xss_clean');
         $this->form_validation->set_rules('apName',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('apNameE',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('provinceId',' ','trim|required|xss_clean');
 
         if ($this->form_validation->run() == true) {
             $this->load->model($this->config->item("ppc_folder").'mo_amphur','ap');
             $this->load->model($this->config->item("ppc_folder").'mo_province','prv');
 
             $flgmsg = 0;
             $this->ap->db->trans_begin();
 
             $apId = $this->input->post('apId');
             $apName = $this->input->post('apName');
             $apNameE = $this->input->post('apNameE');
             $apPrvId = $this->input->post('provinceId');
 
             $this->ap->amphurId = $apId;
             $qu_ap = $this->ap->get_by_key();
 
             $con_rs_ap = array('amphurName'    => $apName,
                                'provinceId'    => $apPrvId);
             if($qu_ap->num_rows()) {
                 $rs_ap = $this->ap->qryApNotId($con_rs_ap,$apId);
                 if(!$rs_ap->num_rows()) {
                     $this->ap->amphurId = $apId;
                     $this->ap->get_by_key(TRUE);
                     if (class_exists('Ver_query')) {
                         Ver_query::setOldVal($this->ap, $this->config->item('ppc_dbname').'.Amphur');
                     }
 
                     $this->ap->amphurName = $apName;
                     $this->ap->amphurNameEng = $apNameE;
                     $this->ap->provinceId = $apPrvId;
                     $this->ap->update();
                     if (class_exists('Ver_query')) {
                         Ver_query::saveQuery($this->ap, $this->ap->db->last_query(), $this->config->item('ver_ppc_id'));
                     }
 
                     $flgmsg = 10;
                 } else {
                     $flgmsg = 21;
                 }
             } else {
                 $rs_ap = $this->ap->qryAp($con_rs_ap);
                 if(!$rs_ap->num_rows()) {
                     if (class_exists('Ver_query')) {
                         Ver_query::setOldVal($this->ap, $this->config->item('ppc_dbname').'.Amphur');
                     }
 
                     $this->ap->amphurId = '';
                     $this->ap->amphurName = $apName;
                     $this->ap->amphurNameEng = $apNameE;
                     $this->ap->provinceId = $apPrvId;
                     $this->ap->used = '';
                     $this->ap->pbriId = '';
                     $this->ap->insert();
                     if (class_exists('Ver_query')) {
                         Ver_query::saveQuery($this->ap, $this->ap->db->last_query(), $this->config->item('ver_ppc_id'));
                     }
 
                     $flgmsg = 10;
                 } else {
                     $flgmsg = 21;
                 }
             }
 
             $this->session->set_flashdata('msg', $flgmsg);
 
             if($this->ap->db->trans_status() === false) {
                 $this->ap->db->trans_rollback();
                 $this->session->set_flashdata('msg', $flgmsg);
             } else {
                 $this->ap->db->trans_commit();
                 $this->session->set_flashdata('msg', $flgmsg);
             }
 
             redirect($this->config->item("rg_folder")."bdppc/ap_input");
         } else {
             $this->ap_input();
         }
     }
     function ap_search() {
         $this->load->model($this->config->item("ppc_folder").'mo_amphur','ap');
         $this->load->model($this->config->item("ppc_folder").'mo_province','prv');
 
         $character = $this->input->post('character');
         $prv = $this->input->post('prv');
         $nameSearch = $this->input->post('nameSearch');
 
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<div class="error">','</div>');
         $this->form_validation->set_rules('character',' ','trim|xss_clean');
         $this->form_validation->set_rules('prv',' ','trim|xss_clean');
         $this->form_validation->set_rules('nameSearch',' ','trim|xss_clean');
 
         if($character=="" && $prv=="" && $nameSearch=="") {
             $this->contents['str_fault'] = $this->config->item('str_fault');
             $this->ap_input();
         } else {
             if ($this->form_validation->run() == true) {
                 $this->contents['character'] = thaiCharacter();
                 
                 $ord_rs_prv = array('provinceName'    => '');
                 $this->contents['rs_prv'] = $this->prv->get_options('', $ord_rs_prv);
 
                 if($character) {
                     $this->contents['rs_ap'] = $this->ap->qryApByCharacterAndPrvId($character, $prv);
                 } else {
                     if($prv) {
                         $con_rs_ap = array('amphurName'        => '%'.$nameSearch.'%',
                                            'ap.provinceId'    => $prv);
                     } else {
                         $con_rs_ap = array('amphurName'    => '%'.$nameSearch.'%');
                     }
 
                     $ord_rs_ap = array('prv.provinceName'    => '',
                                        'amphurName'            => '');
                     $this->contents['rs_ap'] = $this->ap->qryApJoinPrv($con_rs_ap,$ord_rs_ap);
                 }
 
                 $this->output($this->config->item("rg_folder")."v_addAmphur");
             } else {
                 $this->ap_input();
             }
         }        
     }
     function ap_delete() {
         $this->load->model($this->config->item("ppc_folder").'mo_amphur','ap');
 
         $apId = $this->input->post('apId');
 
         $this->ap->db->trans_begin();
         $this->ap->amphurId = $apId;
         if (class_exists('Ver_query')) {
             Ver_query::setOldVal($this->ap, $this->config->item('ppc_dbname').'.Amphur');
         }
 
         $this->ap->delete();
         if (class_exists('Ver_query')) {
             Ver_query::saveQuery($this->ap, $this->ap->db->last_query(), $this->config->item('ver_ppc_id'));
         }
 
         if($this->ap->db->trans_status() === false) {
             $this->ap->db->trans_rollback();
             $this->session->set_flashdata('msg', 41);
         } else {
             $this->ap->db->trans_commit();
             $this->session->set_flashdata('msg', 30);
         }
 
         redirect($this->config->item("rg_folder")."bdppc/ap_input");
     }
     function ap_print() {
         $this->load->model($this->config->item("ppc_folder").'mo_amphur','ap');
         
         $ord_rs_ap = array('provinceName'    => '',
                            'amphurName'        => '');
         $data['rs_ap'] = $this->ap->qryApJoinPrv('',$ord_rs_ap);
         $data['UsName'] = $this->session->userdata('UsName');
 
         $this->load->view($this->config->item("rg_folder")."v_printAmphurppc", $data);
     }
     // ##### end ap
 
     // ##### start dt
     function dt_input() {
         $this->load->model($this->config->item("ppc_folder").'mo_district','dt');
         $this->load->model($this->config->item("ppc_folder").'mo_province','prv');
 
         $ord_rs_prv = array('provinceName'    => '');
         $this->contents['rs_prv'] = $this->prv->get_options('',$ord_rs_prv);
         $this->contents['character'] = thaiCharacter();
 
         $dtId = $this->input->post('dtId');
         $con_qu_dt = array('districtId'    => $dtId);
         $this->contents['qu_dt'] = $this->dt->qryDtJoinApPrv($con_qu_dt);
 
         //$this->output($this->config->item("rg_folder")."v_showDistrict");
         $this->output($this->config->item("rg_folder")."v_addDistrict", $this->session->flashdata('msg'));
     }
     function dt_insert_update() {
         $this->load->model($this->config->item("ppc_folder").'mo_district','dt');
 
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<div class="error">','</div>');
         $this->form_validation->set_rules('dtName',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('dtNameE',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('amphurName',' ','trim|xss_clean');
         $this->form_validation->set_rules('amphurId',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('provinceName',' ','trim|xss_clean');
         $this->form_validation->set_rules('provinceId',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('dtId',' ','trim|xss_clean');
 
         if($this->form_validation->run() == true) {
             $flgmsg = 0;
             $this->dt->db->trans_begin();
 
             $dtName = $this->input->post('dtName');
             $dtNameE = $this->input->post('dtNameE');
             $amphurId = $this->input->post('amphurId');
             $provinceId = $this->input->post('provinceId');
             $dtId = $this->input->post('dtId');
 
             $this->dt->districtId = $dtId;
             $qu_dt = $this->dt->get_by_key();
             if($qu_dt->num_rows()) {
                 $con_rs_dt = array('districtName'    => $dtName,
                                    'amphurId'        => $amphurId,
                                    'provinceId'        => $provinceId);
                 $rs_dt = $this->dt->qryDtNotId($con_rs_dt,$dtId);
                 if(!$rs_dt->num_rows()) {
                     $this->dt->districtId = $dtId;
                     $this->dt->get_by_key(TRUE);
                     if (class_exists('Ver_query')) {
                         Ver_query::setOldVal($this->dt, $this->config->item('ppc_dbname').'.District');
                     }
 
                     $this->dt->districtName = $dtName;
                     $this->dt->districtNameEng = $dtNameE;
                     $this->dt->amphurId = $amphurId;
                     $this->dt->provinceId = $provinceId;
                     $this->dt->update();
                     if (class_exists('Ver_query')) {
                         Ver_query::saveQuery($this->dt, $this->dt->db->last_query(), $this->config->item('ver_ppc_id'));
                     }
 
                     $flgmsg = 10;
                 } else {
                     $flgmsg = 21;
                 }
             } else {
                 $con_rs_dt = array('districtName'    => $dtName,
                                    'amphurId'        => $amphurId,
                                    'provinceId'        => $provinceId);
                 $rs_dt = $this->dt->qryDt($con_rs_dt);
                 if(!$rs_dt->num_rows()) {
                     if (class_exists('Ver_query')) {
                         Ver_query::setOldVal($this->dt, $this->config->item('ppc_dbname').'.District');
                     }
 
                     $this->dt->districtId = "";
                     $this->dt->districtName = $dtName;
                     $this->dt->districtNameEng = $dtNameE;
                     $this->dt->amphurId = $amphurId;
                     $this->dt->provinceId = $provinceId;
                     $this->dt->used = '';
                     $this->dt->pbriId = '';
                     $this->dt->insert();
                     if (class_exists('Ver_query')) {
                         Ver_query::saveQuery($this->dt, $this->dt->db->last_query(), $this->config->item('ver_ppc_id'));
                     }
 
                     $flgmsg = 10;
 
                 } else {
                     $flgmsg = 21;
                 }
             }
 
             $this->session->set_flashdata('msg', $flgmsg);
 
             if($this->dt->db->trans_status() === false) {
                 $this->dt->db->trans_rollback();
                 $flgmsg = 20;
                 $this->session->set_flashdata('msg', $flgmsg);
             } else {
                 $this->dt->db->trans_commit();
                 $this->session->set_flashdata('msg', $flgmsg);
             }
 
             redirect($this->config->item("rg_folder")."bdppc/dt_input");
         } else {
             $this->dt_input();
         }
     }
     function dt_search() {
         $this->load->model($this->config->item("ppc_folder").'mo_district','dt');
         $this->load->model($this->config->item("ppc_folder").'mo_province','prv');
 
         $character = $this->input->post('character');
         $prv = $this->input->post('prv');
         $nameSearch = $this->input->post('nameSearch');
         $nameDtSearch = $this->input->post('nameDtSearch');
 
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<div class="error">','</div>');
         $this->form_validation->set_rules('character',' ','trim|xss_clean');
         $this->form_validation->set_rules('prv',' ','trim|xss_clean');
         $this->form_validation->set_rules('nameSearch',' ','trim|xss_clean');
         $this->form_validation->set_rules('nameDtSearch',' ','trim|xss_clean');
 
         if($character=="" && $prv=="" && $nameSearch=="" && $nameDtSearch=="") {
             $this->contents['str_fault'] = $this->config->item('str_fault');
             $this->dt_input();
         } else {
             if ($this->form_validation->run() == true) {
                 $this->contents['character'] = thaiCharacter();
                 
                 $ord_rs_prv = array('provinceName'    => '');
                 $this->contents['rs_prv'] = $this->prv->get_options('', $ord_rs_prv);
 
                 if($character) {
                     $this->contents['rs_dt'] = $this->dt->qryDtByCharacterAndPrvId($character, $prv);
                 } else {
                     $this->contents['rs_dt'] = $this->dt->qryDtLikeDtNameAndApNameAndPrvId($nameDtSearch, $nameSearch , $prv);
                 }
 
                 $this->output($this->config->item("rg_folder")."v_addDistrict");
             } else {
                 $this->dt_input();
             }
         }        
     }
     function dt_delete() {
         $this->load->model($this->config->item("ppc_folder").'mo_district','dt');
 
         $dtId = $this->input->post('dtId');
 
         $this->dt->db->trans_begin();
         $this->dt->districtId = $dtId;
         if (class_exists('Ver_query')) {
             Ver_query::setOldVal($this->dt, $this->config->item('ppc_dbname').'.District');
         }
 
         $this->dt->delete();
         if (class_exists('Ver_query')) {
             Ver_query::saveQuery($this->dt, $this->dt->db->last_query(), $this->config->item('ver_ppc_id'));
         }
 
         if($this->dt->db->trans_status() === false) {
             $this->dt->db->trans_rollback();
             $this->session->set_flashdata('msg', 41);
         } else {
             $this->dt->db->trans_commit();
             $this->session->set_flashdata('msg', 30);
         }
 
         redirect($this->config->item("rg_folder")."bdppc/dt_input");
     }
     function dt_print() {
         $this->load->model($this->config->item("ppc_folder").'mo_district','dt');
 
         $ord_rs_dt = array('provinceName'    => '',
                            'amphurName'    => '',
                            'districtName'    => '');
         $data['rs_dt'] = $this->dt->qryDtJoinApPrv('',$ord_rs_dt);
         $data['UsName'] = $this->session->userdata('UsName');
 
         $this->load->view($this->config->item("rg_folder")."v_printDistrictppc", $data);
     }
     // ##### end dt
 
     // ##### start cnt
     function cnt_input($search=0) {
         $this->load->model($this->config->item("ppc_folder").'mo_country','cnt');
 
         if($search==0) {
             $ord_rs_cnt = array('countryName'    => '');
             $this->contents['rs_cnt'] = $this->cnt->qryCnt('',$ord_rs_cnt);
         }
 
         $cntId = $this->input->post('cntId');
         $this->cnt->countryId = $cntId;
         $this->contents['qu_cnt'] = $this->cnt->get_by_key();
     
         //$this->output($this->config->item("rg_folder")."v_showCountry");
         $this->output($this->config->item("rg_folder")."v_addCountry", $this->session->flashdata('msg'));
     }
     function cnt_insert_update() {
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<div class="error">','</div>');
         $this->form_validation->set_rules('cntName',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('cntId',' ','trim|xss_clean');
 
         if ($this->form_validation->run() == true) {
             $this->load->model($this->config->item("ppc_folder").'mo_country','cnt');
 
             $cntName = $this->input->post('cntName');
             $cntId = $this->input->post('cntId');
 
             $this->cnt->countryId = $cntId;
             $qu_cnt = $this->cnt->get_by_key();
             $this->cnt->db->trans_begin();
             if($qu_cnt->num_rows()) {
                 $rs_cnt = $this->cnt->qryCntNotId($cntName, $cntId);
                 if(!$rs_cnt->num_rows()) {
                     $this->cnt->countryId = $cntId;
                     $this->cnt->get_by_key(TRUE);
                     if (class_exists('Ver_query')) {
                         Ver_query::setOldVal($this->cnt, $this->config->item('ppc_dbname').'.Country');
                     }
 
                     $this->cnt->countryName = $cntName;
                     $this->cnt->update();
                     if (class_exists('Ver_query')) {
                         Ver_query::saveQuery($this->cnt, $this->cnt->db->last_query(), $this->config->item('ver_ppc_id'));
                     }
                     
                     $flgmsg = 10;
                 } else {
                     $flgmsg = 21;
                 }
             } else {
                 $con_rs_cnt = array('countryName'    => $cntName);
                 $rs_cnt = $this->cnt->qryCnt($con_rs_cnt);
                 if(!$rs_cnt->num_rows()) {
                     if (class_exists('Ver_query')) {
                         Ver_query::setOldVal($this->cnt, $this->config->item('ppc_dbname').'.Country');
                     }
 
                     $this->cnt->countryId = "";
                     $this->cnt->countryName = $cntName;
                     $this->cnt->pbriId = "";
                     $this->cnt->insert();
                     if (class_exists('Ver_query')) {
                         Ver_query::saveQuery($this->cnt, $this->cnt->db->last_query(), $this->config->item('ver_ppc_id'));
                     }
 
                     $flgmsg = 10;
                 } else {
                     $flgmsg = 21;
                 }
             }
 
             if ($this->cnt->db->trans_status() === false) {
                 $this->cnt->db->trans_rollback();
                 $flgmsg = 20;
                 $this->session->set_flashdata('msg', $flgmsg);
             } else {
                 $this->cnt->db->trans_commit();
                 $this->session->set_flashdata('msg', $flgmsg);
             }
 
             redirect($this->config->item("rg_folder")."bdppc/cnt_input");
         } else {
             $this->cnt_input();
         }
     }
     function cnt_search() {
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<font color="red">','</font>');
         $this->form_validation->set_rules('cntNameSearch',' ','trim|required|xss_clean');
 
         if($this->form_validation->run() == true) {
             $this->load->model($this->config->item("ppc_folder").'mo_country','cnt');
 
             $cntNameSearch = $this->input->post('cntNameSearch');
             
             $con_rs_cnt = array('countryName'    => '%'.$cntNameSearch.'%');
             $ord_rs_cnt = array('countryName'    => '');
             $this->contents['rs_cnt'] = $this->cnt->qryCnt($con_rs_cnt,$ord_rs_cnt);
 
             $this->output($this->config->item("rg_folder")."v_addCountry");
         } else {
             $this->cnt_input(1);
         }
     }
     function cnt_delete() {
         $this->load->model($this->config->item("ppc_folder").'mo_Country','cnt');
 
         $cntId = $this->input->post('cntId');
 
         $this->cnt->db->trans_begin();
         $this->cnt->countryId = $cntId;
         if (class_exists('Ver_query')) {
             Ver_query::setOldVal($this->cnt, $this->config->item('ppc_dbname').'.Country');
         }
 
         $this->cnt->delete();
         if (class_exists('Ver_query')) {
             Ver_query::saveQuery($this->cnt, $this->cnt->db->last_query(), $this->config->item('ver_ppc_id'));
         }
 
         if($this->cnt->db->trans_status() === false) {
             $this->cnt->db->trans_rollback();
             $this->session->set_flashdata('msg', 41);
         } else {
             $this->cnt->db->trans_commit();
             $this->session->set_flashdata('msg', 30);
         }
 
         redirect($this->config->item("rg_folder")."bdppc/cnt_input");
     }
     function cnt_print() {
         $this->load->model($this->config->item("ppc_folder").'mo_country','cnt');
         
         $ord_rs_cnt = array('countryName'    => '');
         $data['rs_cnt'] = $this->cnt->qryCnt('',$ord_rs_cnt);
         $data['UsName'] = $this->session->userdata('UsName');
 
         $this->load->view($this->config->item("rg_folder")."v_printCountryppc", $data);
     }
     // ##### end cnt
 }
 ?>
  |