Viewing file: timeqn.php (3.23 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include('ea_controller.php');
class Timeqn extends Ea_controller {
// function __construct() {
// parent::Controller();
// }
function showTimeQn() {
$this->load->model($this->config->item("ea_folder").'m_alumnimain','am');
$this->load->model($this->config->item("ea_folder").'m_timeqn','tq');
// ##### เพิ่มปีจบเอง ######
$showTb = $this->input->post('showTb');
$add_graduateY = $this->input->post('add_graduateY');
if($add_graduateY==1 || $showTb==1) {
$this->contents['showTb'] = 1;
}
// ##### จบเพิ่มปีจบเอง ######
// ##### แก้ไข ######
$seqId = $this->input->post('seqId');
$this->tq->seqId = $seqId;
$this->contents['qu_tq'] = $this->tq->get_by_key();
// ##### จบแก้ไข ######
$ord_rs_tq = array('graduateY' => 'DESC');
$this->contents['rs_tq'] = $this->tq->qryTq('',$ord_rs_tq);
$this->contents['rs_graduateY'] = $this->am->get_optionsDistinctGraduateY();
$this->output($this->config->item("ea_folder")."v_showTimeQn");
}
function processTimeQn() {
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="error">','</div>');
$this->form_validation->set_rules('graduateY',' ','trim|required|callback_checkAdY|is_natural_no_zero|xss_clean');
$this->form_validation->set_rules('startDate',' ','trim|xss_clean');
$this->form_validation->set_rules('endDate',' ','trim|callback_checkFrDate[startDate]|xss_clean');
$this->form_validation->set_rules('seqId',' ','trim|xss_clean');
$this->form_validation->set_rules('showTb',' ','trim|xss_clean');
if($this->form_validation->run() == true) {
$this->load->model($this->config->item("ea_folder").'m_timeqn','tq');
$graduateY = $this->input->post('graduateY');
$startDate = splitDateForm2($this->input->post('startDate'),'-');
$endDate = splitDateForm2($this->input->post('endDate'),'-');
$seqId = $this->input->post('seqId');
$con_qu_tm = array('graduateY' => $graduateY);
$qu_tm = $this->tq->qryTq($con_qu_tm);
if($qu_tm->num_rows()==0) {
$this->tq->seqId = '';
$this->tq->graduateY = $graduateY;
$this->tq->startDate = $startDate;
$this->tq->endDate = $endDate;
$this->tq->tqUserId = $this->session->userdata('UsLogin');
$this->tq->tqUserUpdate = date('Y-m-d H:i:s');
$this->tq->insert();
} else {
$this->tq->seqId = $seqId;
$this->tq->graduateY = $graduateY;
$this->tq->startDate = $startDate;
$this->tq->endDate = $endDate;
$this->tq->tqUserId = $this->session->userdata('UsLogin');
$this->tq->tqUserUpdate = date('Y-m-d H:i:s');
$this->tq->update();
}
redirect($this->config->item("ea_folder")."timeqn/showTimeQn");
} else {
$this->showTimeQn();
}
}
function deleteTimeQn() {
$this->load->model($this->config->item("ea_folder").'m_timeqn','tq');
$seqId = $this->input->post('seqId');
$this->db->trans_begin();
$this->tq->seqId = $seqId;
$this->tq->delete();
if($this->db->trans_status() === false) {
$this->db->trans_rollback();
} else {
$this->db->trans_commit();
}
redirect($this->config->item("ea_folder")."timeqn/showTimeQn");
}
}
?>
|