Viewing file:      news.php (3.4 KB)      -rwxr-xr-x Select action/file-type:    (+) |   (+) |   (+) | Code (+) | Session (+) |   (+) | SDB (+) |   (+) |   (+) |   (+) |   (+) |   (+) |
 
<?php
 include('ea_controller.php');
 class News extends Ea_controller {
 
 //    function __construct() {
 //        parent::Controller();
 //    }
 
     // ##### start ta
     function ns_input() {
         $this->load->model($this->config->item("ea_folder").'mo_news','ns');
 
         $this->ns->nsId = $this->input->post('nsId');
         $this->contents['qu_ns'] = $this->ns->get_by_key();
         
         $this->contents['rs_ns'] = $this->ns->qryNs('','','');
         //echo $this->db->last_query();
 
         $this->output($this->config->item("ea_folder")."v_addNews", $this->session->flashdata('msg'));
     }
     function ns_search() {
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<font color="red">','</font>');
         $this->form_validation->set_rules('topicsearch','คำค้น','trim|required|xss_clean');
 
         if($this->form_validation->run() == true) {
             $this->load->model($this->config->item("ea_folder").'mo_news','ns');
 
             $topicsearch = $this->input->post('topicsearch');
 
             $con_rs_ns = array('nsTopic'    => $topicsearch);
             $this->contents['rs_ns'] = $this->ns->qryNs_2($con_rs_ns,'','');
 
             $this->output($this->config->item("ea_folder")."v_addNews");
         } else {
             $this->ns_input();
         }
     }
     function ns_insert_update() {
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<font color="red">','</font>');
         $this->form_validation->set_rules('nsId',' ','trim|xss_clean');
         $this->form_validation->set_rules('nsTopic','ชื่อหัวข้อ','trim|required|xss_clean');
         $this->form_validation->set_rules('nsDesc','รายละเอียด','trim|required|xss_clean');
 
         $flgmsg = 0;
         if($this->form_validation->run() == true) {
             $this->load->model($this->config->item("ea_folder").'mo_news','ns');
 
             $con_rs_ns = array('nsTopic'    => $this->input->post('nsTopic'),
                                'nsDesc'        => $this->input->post('nsDesc'),
                                'nsDate'        => splitDateForm2($this->input->post('nsDate'),'-'),
                                'nsUserId'    => $this->session->userdata('UsID'));
             $rs_ns = $this->ns->qryNs($con_rs_ns,'','');
             //echo $this->db->last_query();
 
             if(!$rs_ns->num_rows()) {
 
                 $this->ns->nsTopic = $this->input->post('nsTopic');
                 $this->ns->nsDesc = $this->input->post('nsDesc');
                 $this->ns->nsDate = splitDateForm2($this->input->post('nsDate'),'-');
                 $this->ns->nsUserId = $this->session->userdata('UsID');
 
 
                 if($this->input->post('nsId')=='') {
                     $this->ns->nsId = '';
                     $this->ns->insert();
                     //echo $this->db->last_query();
                     $flgmsg = 1;
                 } else {
                     $this->ns->nsId = $this->input->post('nsId');
                     $this->ns->update();
                     //echo $this->db->last_query();
                     $flgmsg = 1;
                 }
                 
             }
             $this->session->set_flashdata('msg', 2);
 
             if($this->db->trans_status() === false) {
                 $this->db->trans_rollback();
                 if($flgmsg)
                     $this->session->set_flashdata('msg', 2);
                 } else {
                 $this->db->trans_commit();
                 if($flgmsg)
                     $this->session->set_flashdata('msg', 1);
             }
             redirect($this->config->item("ea_folder")."news/ns_input");
         } else {
             $this->ns_input();
         }
     }
     function ns_delete() {
         $this->load->model($this->config->item("ea_folder").'mo_news','ns');
 
         $this->ns->nsId = $this->input->post('nsId');
         $this->ns->delete();
         $this->session->set_flashdata('msg', 3);
         redirect($this->config->item("ea_folder")."news/ns_input");
     }
     // ##### end ta
 
 
     
 }
 ?>
  |