Viewing file: smo_club.php (52.59 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php include('sa_controller.php'); class Smo_club extends Sa_controller {
/** คำอธิบายฟังก์ชั่น: มีไว้สร้างสโมสรใหม่ */ function create_samo() { $data['text'] = 'nothing'; $this->output("v_createSamo", $data); }
/** คำอธิบายฟังก์ชั่น: มีไว้สร้างชมรมใหม่ */ function create_club() { $data['text'] = 'nothing'; $this->output("v_createClub", $data); }
function detail_club(){ $this->load->model($this->config->item('sa_folder').'sa_member_model','mem'); $mem = $this->mem; $this->load->model($this->config->item('sa_folder').'sa_detail_project_model','dt'); $dt = $this->dt; $this->load->model($this->config->item('sa_folder').'sa_co_owner_proj_model','cop'); $cop = $this->cop; $this->load->model($this->config->item('sa_folder').'sa_committee_model','comt'); $com = $this->comt;
$this->load->model($this->config->item('sa_folder').'sa_vehicle_model','veh'); $veh = $this->veh;
$this->load->model($this->config->item('sa_folder').'sa_vehicle_club_model','vc'); $vc = $this->vc; $this->load->model($this->config->item('sa_folder').'sa_person_model','prs'); $prs = $this->prs; $this->load->model($this->config->item('sa_folder').'sa_file_upload_model'); $up = $this->sa_file_upload_model; $this->load->model($this->config->item('sa_folder').'sa_smo_club_model','sc'); $sc = $this->sc; $sc->sc_id = $this->input->post('sc_id'); $sc->get_all_by_key(TRUE); $data['qu_cl'] = $sc; if($this->input->post('sc_id')){ $up->fup_grp = $sc->sc_fup_grp; $data['sc_file'] = $up->getByGroup(); $rs_prs = $prs->selectPersonByAdsJoinPPC($sc->sc_id); $data['sc_prs'] = $rs_prs; } $sc->sc_type = 1; $data['smo'] = $sc->get_optionsByType(); $data['ck_id'] = $this->input->post('sc_id'); // ประเภทกิจกรรม $vc->vc_sc_id = $this->input->post('sc_id');
$data['rs_veh'] = $vc->get_by_sc();
if($this->input->post('sc_parentId') || $this->session->flashdata('sc_parentId')){ $data['sc_parentId'] = ($this->session->flashdata('sc_parentId')) ? $this->session->flashdata('sc_parentId') : $this->input->post('sc_parentId'); $sc->sc_parentId = $data['sc_parentId']; $sc->sc_type = 2; $rs_smo = $sc->get_by_type_PR(); $data['rs_cl'] = $rs_smo; $file = array(); if($rs_smo->num_rows()>0){ foreach ($rs_smo->result() as $row_smo) { $up->fup_grp = $row_smo->sc_fup_grp; $file[$row_smo->sc_id] = $up->getByGroup(); } } $data['file'] = $file; $arr = array(); if ($rs_smo->num_rows() > 0) { foreach ($rs_smo->result() as $row) { $rs_prs = $prs->selectPersonByAdsJoinPPC($row->sc_id); $arr[$row->sc_id] = $rs_prs; } } $data['arr'] = $arr; $pm = array(); if($rs_smo->num_rows()>0){ foreach ($rs_smo->result() as $row_smo) { $rs_mem = $mem->get_by_cond('', '', '', '','', $row_smo->sc_id, '', ''); $num_mem = $rs_mem->num_rows(); $dt->dpj_owner = $row_smo->sc_id; $rs_dt = $dt->getByOwner(); $num_dt = $rs_dt->num_rows(); $cop->cop_sc_id = $row_smo->sc_id; $rs_cop = $cop->getByCop_sc_id(); $num_cop = $rs_cop->num_rows(); $com->cmt_cl_id = $row_smo->sc_id; $rs_com = $com->getByCmt_sc_id(); $num_com = $rs_com->num_rows(); if($num_mem>0 || $num_dt>0 || $num_cop>0 || $num_com>0){ $pm[$row_smo->sc_id] = "N"; }else{ $pm[$row_smo->sc_id] = "Y"; } } }
$data['pm'] = $pm; } $this->output_popup("v_detail_club", $data); }
function club($error = "") { $this->load->model($this->config->item('sa_folder').'sa_member_model','mem'); $mem = $this->mem; $this->load->model($this->config->item('sa_folder').'sa_detail_project_model','dt'); $dt = $this->dt; $this->load->model($this->config->item('sa_folder').'sa_co_owner_proj_model','cop'); $cop = $this->cop; $this->load->model($this->config->item('sa_folder').'sa_committee_model','comt'); $com = $this->comt;
$this->load->model($this->config->item('sa_folder').'sa_vehicle_model','veh'); $veh = $this->veh;
$this->load->model($this->config->item('sa_folder').'sa_vehicle_club_model','vc'); $vc = $this->vc; $this->load->model($this->config->item('sa_folder').'sa_person_model','prs'); $prs = $this->prs; $this->load->model($this->config->item('sa_folder').'sa_file_upload_model'); $up = $this->sa_file_upload_model; $this->load->model($this->config->item('sa_folder').'sa_smo_club_model','sc'); $sc = $this->sc; $sc->sc_id = $this->input->post('sc_id'); $sc->get_by_key(TRUE); $data['qu_cl'] = $sc; if($this->input->post('sc_id')){ $up->fup_grp = $sc->sc_fup_grp; $data['sc_file'] = $up->getByGroup(); $rs_prs = $prs->selectPersonByAdsJoinPPC($sc->sc_id); $data['sc_prs'] = $rs_prs; } $sc->sc_type = 1; $data['smo'] = $sc->get_optionsByType();
if($error!=""){ $data['error'] = $error; } $data['ck_id'] = $this->input->post('sc_id'); // ประเภทกิจกรรม $vc->vc_sc_id = $this->input->post('sc_id');
$data['rs_veh'] = $vc->get_by_sc();
if($this->input->post('sc_parentId') || $this->session->flashdata('sc_parentId')){ $data['sc_parentId'] = ($this->session->flashdata('sc_parentId')) ? $this->session->flashdata('sc_parentId') : $this->input->post('sc_parentId'); $sc->sc_parentId = $data['sc_parentId']; $sc->sc_type = 2; $rs_smo = $sc->get_by_type_PR(); $data['rs_cl'] = $rs_smo; $file = array(); if($rs_smo->num_rows()>0){ foreach ($rs_smo->result() as $row_smo) { $up->fup_grp = $row_smo->sc_fup_grp; $file[$row_smo->sc_id] = $up->getByGroup(); } } $data['file'] = $file; $arr = array(); if ($rs_smo->num_rows() > 0) { foreach ($rs_smo->result() as $row) { $rs_prs = $prs->selectPersonByAdsJoinPPC($row->sc_id); $arr[$row->sc_id] = $rs_prs; } } $data['arr'] = $arr; $pm = array(); if($rs_smo->num_rows()>0){ foreach ($rs_smo->result() as $row_smo) { $rs_mem = $mem->get_by_cond('', '', '', '','', $row_smo->sc_id, '', ''); $num_mem = $rs_mem->num_rows(); $dt->dpj_owner = $row_smo->sc_id; $rs_dt = $dt->getByOwner(); $num_dt = $rs_dt->num_rows(); $cop->cop_sc_id = $row_smo->sc_id; $rs_cop = $cop->getByCop_sc_id(); $num_cop = $rs_cop->num_rows(); $com->cmt_cl_id = $row_smo->sc_id; $rs_com = $com->getByCmt_sc_id(); $num_com = $rs_com->num_rows(); if($num_mem>0 || $num_dt>0 || $num_cop>0 || $num_com>0){ $pm[$row_smo->sc_id] = "N"; }else{ $pm[$row_smo->sc_id] = "Y"; } } }
$data['pm'] = $pm; } $this->output("v_club", $data); }
function add_club() { $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<br><font color="red">','</font>');
$this->form_validation->set_rules('sc_parentId', 'สโมสร', 'trim|callback_checkselect|xss_clean'); $this->form_validation->set_rules('sc_id', '', 'trim|xss_clean'); $this->form_validation->set_rules('sc_name', 'ชื่อชมรม(ไทย)', 'trim|required|xss_clean'); $this->form_validation->set_rules('sc_name_eng', 'ชื่อชมรม(อังกฤษ)', 'trim|xss_clean'); $this->form_validation->set_rules('sc_objective', ' ', 'trim|xss_clean'); $this->form_validation->set_rules('sc_detail', ' ', 'trim|xss_clean'); $this->form_validation->set_rules('sc_min_member', 'จำนวนสมาชิกขั้นต่ำ', 'trim|required|is_natural_no_zero|xss_clean'); $this->form_validation->set_rules('sc_max_member', 'จำนวนสมาชิกสูงสุด', 'trim|required|is_natural_no_zero|xss_clean'); $this->form_validation->set_rules('sc_due', 'ค่าสมาชิกชมรม', 'trim|required|integer|xss_clean'); if ($this->input->post('sc_id')=="") { $this->form_validation->set_rules('wk11_co', 'อาจารย์ประจำชมรม ', 'trim|required|xss_clean'); } $this->form_validation->set_rules('sc_fr_date', 'ปีที่ก่อตั้งชมรม', 'trim|required|xss_clean'); $this->form_validation->set_rules('sc_fr_date', 'ปีที่ก่อตั้งชมรม', 'trim|required|xss_clean'); $this->form_validation->set_rules('up', ' ', 'trim|xss_clean'); $ch_vehicle = 'N'; for ($i=1; $i<$this->input->post('vehicle'); $i++){ $this->form_validation->set_rules('vehicle'.$i, ' ', 'trim|xss_clean'); if ($this->input->post('vehicle'.$i) != ''){ $ch_vehicle = 'Y'; } }
if ($this->form_validation->run() == FALSE || $ch_vehicle == 'N') { if ($ch_vehicle == 'N') { $this->load->vars( array('ch_vehicle' => '<font color="red"> กรุณาเลือกประเภทกิจกรรม </font>')); } $this->club(); //TRUE } else {
$this->load->model($this->config->item('sa_folder').'sa_smo_club_model'); $m = $this->sa_smo_club_model;
$m->sc_id = trim($this->input->post('sc_id')); $m->sc_name = trim($this->input->post('sc_name')); $m->sc_parentId = trim($this->input->post('sc_parentId'));
$query = $m->check_rep_name();
if ($query->num_rows() == 0) { $this->load->model($this->config->item('sa_folder').'sa_vehicle_club_model'); $vc = $this->sa_vehicle_club_model; $this->load->model($this->config->item('sa_folder').'sa_adviser_sc_model'); $ad = $this->sa_adviser_sc_model; $this->load->model($this->config->item('sa_folder').'sa_file_upload_model'); $up = $this->sa_file_upload_model; if ($this->input->post('sc_id')) { $m->sc_id = trim($this->input->post('sc_id')); $m->get_by_key(TRUE); $old_grp = $m->sc_fup_grp; }
$m->sc_name = trim($this->input->post('sc_name')); $m->sc_name_eng = trim($this->input->post('sc_name_eng')); $m->sc_objective = trim($this->input->post('sc_objective')); $m->sc_detail = trim($this->input->post('sc_detail')); $m->sc_min_member = trim($this->input->post('sc_min_member')); $m->sc_max_member = trim($this->input->post('sc_max_member')); $m->sc_due = trim($this->input->post('sc_due')); $m->sc_type = 2; $m->sc_fr_date = trim($this->input->post('sc_fr_date')); $sc->sc_to_date = trim($this->input->post('sc_to_date')); $sc->sc_fup_grp = "NULL";
if ( $this->input->post('sc_id') != '' ) { $m->update(); $sc_id = $m->sc_id; } else { $m->insert(); $sc_id = $m->last_insert_id; } $vc->vc_sc_id = $sc_id; $vc->delete_vehicle_club(); for ($i=1; $i<$this->input->post('vehicle'); $i++){ if ($this->input->post('vehicle'.$i) != ''){ $vc->vc_sc_id = $sc_id; $vc->vc_veh_id = trim($this->input->post('vehicle'.$i)); $vc->insert(); } } if($this->input->post('sc_id')){ $ad->ads_sc_id = $this->input->post('sc_id'); $ad_rs = $ad->getBySc_id(); foreach ($ad_rs->result() as $ad_row) { $ad->ads_id = $ad_row->ads_id; $ad->delete(); } $ad->ads_id = ""; $old = $this->input->post('ote'); for($i=0;$i<count($old);$i++){ $ad->ads_sc_id = $this->input->post('sc_id'); $ad->ads_prs_id = trim($old[$i]);
$ad->insert(); } } $a = explode("###", ($this->input->post('std') ? $this->input->post('std') : $this->input->post('wk11_co'))); foreach ($a as $value) { $v = explode(":", $value); $ad->ads_sc_id = $sc_id; $ad->ads_prs_id = trim($v[0]);
$ad->insert(); }
// Start Up file if(isset($_FILES['fileupload']) && !empty($_FILES['fileupload']['name'])){ $config['upload_path'] = './uploads/esa/doc'; $config['max_size'] = $this->config->item('sa_upload_size'); $config['allowed_types'] = '*'; $config['overwrite'] = TRUE; $config['file_name'] = $sc_id; $this->load->library('upload', $config); if (!$this->upload->do_upload('fileupload')) { $error = array('error' => $this->upload->display_errors()); $this->club($error); }else{ $data = array('upload_data' => $this->upload->data('fileupload')); if ($this->input->post('sc_id')){ $up->fup_grp = $old_grp; $rs_file = $up->getByGroup(); // if($rs_file->num_rows()>0){ // foreach ($rs_file->result() as $row_file) { // unlink('./uploads/esa/doc/'.$row_file->fup_file_name); // } // } $up->deleteByGroup(); } $up->fup_seq = 1; $up->fup_file_name = $data['upload_data']['file_name']; $up->fup_path = 'uploads/esa/doc/'.$data['upload_data']['file_name']; $up->fup_date = date("Y-m-d H:i:s"); $up->fup_user_id = $this->session->userdata('UsID'); $up->fup_grp = ($up->getMaxGroup()->row()->max+1); $up->insert();
$m->sc_id = $sc_id; $m->sc_fup_grp = $up->fup_grp; $m->update(); $this->session->set_flashdata('sc_parentId', $this->input->post('sc_parentId')); redirect($this->config->item('sa_folder').'smo_club/club'); } }else{ $this->session->set_flashdata('sc_parentId', $this->input->post('sc_parentId')); redirect($this->config->item('sa_folder').'smo_club/club'); } //End Up file } else { $this->load->vars(array('error_name' => "<font color='red'><br />ชื่อสโมสรนี้มีอยู่แล้ว</font>")); $this->club(); } } }
function del_club() { $this->db->trans_begin(); $sc_id = $this->input->post('sc_id'); $this->load->model($this->config->item('sa_folder').'sa_file_upload_model'); $up = $this->sa_file_upload_model; $this->load->model($this->config->item('sa_folder').'sa_smo_club_model'); $m = $this->sa_smo_club_model; $this->load->model($this->config->item('sa_folder').'sa_vehicle_club_model'); $vc = $this->sa_vehicle_club_model; $vc->vc_sc_id = $sc_id; $vc->delete_vehicle_club(); $this->load->model($this->config->item('sa_folder').'sa_adviser_sc_model'); $ad = $this->sa_adviser_sc_model; $ad->ads_sc_id = $sc_id; $ad_rs = $ad->getBySc_id(); $this->load->model($this->config->item('sa_folder').'sa_committee_model','cmt'); $cmt= $this->cmt;
foreach ($ad_rs->result() as $ad_row) { $ad->ads_id = $ad_row->ads_id; $ad->delete(); } $cmt->cmt_sc_id = $sc_id; $rs_cmt = $cmt->getByCmt_sc_id(); foreach ($rs_cmt->result() as $row_cmt) { $cmt->cmt_id = $row_cmt->cmt_id; $cmt->delete(); }
$m->sc_id = $sc_id; $m->get_by_key(TRUE); $old_grp = $m->sc_fup_grp; $up->fup_grp = $old_grp; $rs_file = $up->getByGroup(); if($rs_file->num_rows()>0){ foreach ($rs_file->result() as $row_file) { unlink('./uploads/esa/doc/'.$row_file->fup_file_name); } } $up->deleteByGroup(); $m->delete();
if($this->db->trans_status() === false){ $this->db->trans_rollback(); } else { $this->db->trans_commit(); } $this->session->set_flashdata('sc_parentId', $this->input->post('sc_parentId')); redirect($this->config->item('sa_folder').'smo_club/club'); }
function detail_smo(){ $this->load->model($this->config->item('sa_folder').'sa_smo_club_model','sc'); $sc = $this->sc; $this->load->model($this->config->item('sa_folder').'sa_file_upload_model'); $up = $this->sa_file_upload_model; $this->load->model($this->config->item('sa_folder').'sa_member_model','mem'); $mem = $this->mem; $this->load->model($this->config->item('sa_folder').'sa_detail_project_model','dt'); $dt = $this->dt; $this->load->model($this->config->item('sa_folder').'sa_co_owner_proj_model','cop'); $cop = $this->cop; $this->load->model($this->config->item('sa_folder').'sa_committee_model','comt'); $com = $this->comt; $sc->sc_id = $this->input->post('sc_id'); $sc->get_by_key(TRUE); $data['qu_smo'] = $sc; $sc->sc_type = 1; $rs_smo = $sc->get_by_type(); $data['rs_smo'] = $rs_smo; $file = array(); if($rs_smo->num_rows()>0){ foreach ($rs_smo->result() as $row_smo) { $up->fup_grp = $row_smo->sc_fup_grp; $file[$row_smo->sc_id] = $up->getByGroup(); } } $data['file'] = $file; $pm = array(); if($rs_smo->num_rows()>0){ foreach ($rs_smo->result() as $row_smo) { $rs_mem = $mem->get_by_cond('', '', '', '', $row_smo->sc_id, '', '', ''); $num_mem = $rs_mem->num_rows(); $dt->dpj_owner = $row_smo->sc_id; $rs_dt = $dt->getByOwner(); $num_dt = $rs_dt->num_rows(); $cop->cop_sc_id = $row_smo->sc_id; $rs_cop = $cop->getByCop_sc_id(); $num_cop = $rs_cop->num_rows(); $com->cmt_cl_id = $row_smo->sc_id; $rs_com = $com->getByCmt_sc_id(); $num_com = $rs_com->num_rows(); if($num_mem>0 || $num_dt>0 || $num_cop>0 || $num_com>0){ $pm[$row_smo->sc_id] = "N"; }else{ $pm[$row_smo->sc_id] = "Y"; } } }
$data['pm'] = $pm; $this->output_popup("v_detail_smo", $data); }
function smo() { $this->load->model($this->config->item('sa_folder').'sa_smo_club_model','sc'); $sc = $this->sc; $this->load->model($this->config->item('sa_folder').'sa_file_upload_model'); $up = $this->sa_file_upload_model; $this->load->model($this->config->item('sa_folder').'sa_member_model','mem'); $mem = $this->mem; $this->load->model($this->config->item('sa_folder').'sa_detail_project_model','dt'); $dt = $this->dt; $this->load->model($this->config->item('sa_folder').'sa_co_owner_proj_model','cop'); $cop = $this->cop; $this->load->model($this->config->item('sa_folder').'sa_committee_model','comt'); $com = $this->comt; $sc->sc_id = $this->input->post('sc_id'); $sc->get_by_key(TRUE); $data['qu_smo'] = $sc; $sc->sc_type = 1; $rs_smo = $sc->get_by_type(); $data['rs_smo'] = $rs_smo; $file = array(); if($rs_smo->num_rows()>0){ foreach ($rs_smo->result() as $row_smo) { $up->fup_grp = $row_smo->sc_fup_grp; $file[$row_smo->sc_id] = $up->getByGroup(); } } $data['file'] = $file; $pm = array(); if($rs_smo->num_rows()>0){ foreach ($rs_smo->result() as $row_smo) { $rs_mem = $mem->get_by_cond('', '', '', '', $row_smo->sc_id, '', '', ''); $num_mem = $rs_mem->num_rows(); $dt->dpj_owner = $row_smo->sc_id; $rs_dt = $dt->getByOwner(); $num_dt = $rs_dt->num_rows(); $cop->cop_sc_id = $row_smo->sc_id; $rs_cop = $cop->getByCop_sc_id(); $num_cop = $rs_cop->num_rows(); $com->cmt_cl_id = $row_smo->sc_id; $rs_com = $com->getByCmt_sc_id(); $num_com = $rs_com->num_rows(); if($num_mem>0 || $num_dt>0 || $num_cop>0 || $num_com>0){ $pm[$row_smo->sc_id] = "N"; }else{ $pm[$row_smo->sc_id] = "Y"; } } }
$data['pm'] = $pm; $this->output("v_smo", $data); }
function add_smo() { $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<br><font color="red">','</font>');
$this->load->model($this->config->item('sa_folder').'sa_file_upload_model'); $up = $this->sa_file_upload_model; $this->form_validation->set_rules('sc_id', '', 'trim|xss_clean'); $this->form_validation->set_rules('sc_name', 'ชื่อสโมสร', 'trim|required|xss_clean'); $this->form_validation->set_rules('sc_name_eng', ' ', 'trim|xss_clean'); $this->form_validation->set_rules('sc_objective', ' ', 'trim|xss_clean'); $this->form_validation->set_rules('sc_detail', ' ', 'trim|xss_clean'); $this->form_validation->set_rules('sc_fr_date', 'วันที่ก่อตั้งสโมสร', 'trim|required|xss_clean'); $this->form_validation->set_rules('sc_to_date', ' ', 'trim|xss_clean'); $this->form_validation->set_rules('fileupload', ' ', 'trim|xss_clean'); if ($this->form_validation->run() == FALSE) { $this->smo(TRUE); } else { $this->load->model($this->config->item('sa_folder').'sa_smo_club_model'); $sc = $this->sa_smo_club_model; $sc->sc_id = trim($this->input->post('sc_id')); $sc->sc_name = trim($this->input->post('sc_name')); $sc->sc_parentId = 0; $query = $sc->check_rep_name(); if ($query->num_rows() == 0) { if ($this->input->post('sc_id')) { $sc->sc_id = trim($this->input->post('sc_id')); $sc->get_by_key(TRUE); $old_grp = $sc->sc_fup_grp; } $sc->sc_name = trim($this->input->post('sc_name'));//update fern $sc->sc_name_eng = trim($this->input->post('sc_name_eng')); $sc->sc_objective = trim($this->input->post('sc_objective')); $sc->sc_detail = trim($this->input->post('sc_detail')); $sc->sc_fr_date = trim($this->input->post('sc_fr_date')); $sc->sc_to_date = trim($this->input->post('sc_to_date')); $sc->sc_type = 1; $sc->sc_fup_grp = ($this->input->post('sc_id'))? $old_grp:"0"; if ($this->input->post('sc_id')) { $sc->update(); $sc_id = $this->input->post('sc_id'); } else { $sc->insert(); $sc_id = $sc->last_insert_id; } if(isset($_FILES['fileupload']) && !empty($_FILES['fileupload']['name'])){ $config['upload_path'] = './uploads/esa/doc'; $config['max_size'] = $this->config->item('sa_upload_size'); $config['allowed_types'] = '*'; $config['overwrite'] = TRUE; $config['file_name'] = $sc_id; $this->load->library('upload', $config); if (!$this->upload->do_upload('fileupload')) { $sc->sc_id = $this->input->post('sc_id'); $sc->get_by_key(TRUE); $data['qu_smo'] = $sc; if($this->input->post('sc_id')){ $this->load->model($this->config->item('sa_folder').'sa_file_upload_model'); $up = $this->sa_file_upload_model; $up->fup_grp = $sc->sc_fup_grp; $data['rs_file'] = $up->getByGroup(); } $sc->sc_type = 1; $data['rs_smo'] = $sc->get_by_type(); $data['error'] = array('error' => $this->upload->display_errors()); $this->output("v_smo", $data); }else{ if ($this->input->post('sc_id')){ $up->fup_grp = $old_grp; $rs_file = $up->getByGroup(); /*if($rs_file->num_rows()>0){ foreach ($rs_file->result() as $row_file) { unlink('./uploads/esa/doc/'.$row_file->fup_file_name); } }*/ $up->deleteByGroup(); }
$data = array('upload_data' => $this->upload->data('fileupload')); $up->fup_seq = 1; $up->fup_file_name = $data['upload_data']['file_name']; $up->fup_path = 'uploads/esa/doc/'.$data['upload_data']['file_name']; $up->fup_date = date("Y-m-d H:i:s"); $up->fup_user_id = $this->session->userdata('UsID'); $up->fup_grp = ($up->getMaxGroup()->row()->max+1); $up->insert();
$sc->sc_id = $sc_id; $sc->sc_fup_grp = $up->fup_grp; $sc->update();
redirect($this->config->item('sa_folder').'smo_club/smo'); } }else{ redirect($this->config->item('sa_folder').'smo_club/smo'); } } else { $this->load->vars(array('error_name' => "<font color='red'><br />ชื่อสโมสรนี้มีอยู่แล้ว</font>")); $this->smo(TRUE); } } }
function del_smo() { $this->load->model($this->config->item('sa_folder').'sa_smo_club_model','sc'); $sc = $this->sc; $this->load->model($this->config->item('sa_folder').'sa_file_upload_model'); $up = $this->sa_file_upload_model; $this->load->model($this->config->item('sa_folder').'sa_vehicle_club_model'); $vc = $this->sa_vehicle_club_model; $this->load->model($this->config->item('sa_folder').'sa_adviser_sc_model'); $ad = $this->sa_adviser_sc_model; $this->load->model($this->config->item('sa_folder').'sa_committee_model','cmt'); $cmt= $this->cmt; $this->db->trans_begin(); $sc->sc_type = 2; $sc->sc_parentId = trim($this->input->post('sc_id'));; $rs_pr = $sc->get_by_type_PR(); if($rs_pr->num_rows()>0){ foreach ($rs_pr->result() as $row_pr) { $vc->vc_sc_id = $row_pr->sc_id; $vc->delete_vehicle_club(); $ad->ads_sc_id = $row_pr->sc_id; $ad_rs = $ad->getBySc_id(); foreach ($ad_rs->result() as $ad_row) { $ad->ads_id = $ad_row->ads_id; $ad->delete(); } $cmt->cmt_cl_id = $row_pr->sc_id; $rs_cmt = $cmt->getByCmt_sc_id(); foreach ($rs_cmt->result() as $row_cmt) { $cmt->cmt_id = $row_cmt->cmt_id; $cmt->delete(); } $sc->sc_id = $row_pr->sc_id; $sc->get_by_key(TRUE); $old_grp = $sc->sc_fup_grp; $up->fup_grp = $old_grp; $rs_file = $up->getByGroup(); if($rs_file->num_rows()>0){ foreach ($rs_file->result() as $row_file) { unlink('./uploads/esa/doc/'.$row_file->fup_file_name); } } $up->deleteByGroup();
$sc->delete(); } } $sc->sc_id = trim($this->input->post('sc_id')); $sc->get_by_key(TRUE); $old_grp = $sc->sc_fup_grp; $up->fup_grp = $old_grp; $rs_file = $up->getByGroup(); if($rs_file->num_rows()>0){ foreach ($rs_file->result() as $row_file) { unlink('./uploads/esa/doc/'.$row_file->fup_file_name); } } $up->deleteByGroup();
$sc->delete();
if($this->db->trans_status() === false){ $this->db->trans_rollback(); } else { $this->db->trans_commit(); } redirect($this->config->item('sa_folder').'smo_club/smo'); }
function club_pos($cl_id = '') { if($this->session->flashdata('error')){ $error = $this->session->flashdata('error'); $data['error'] = $error; } $cl_id = (isset($error['cmt_id']))? $error['cmt_id']:$this->input->post('cmt_id');
$this->load->model($this->config->item('rg_folder').'mo_rg_termconfig','tmc'); $tmc = $this->tmc; $data['rs_tmc'] = $tmc->get_options();
$this->load->model($this->config->item('sa_folder').'sa_smo_club_model','sc'); $sc = $this->sc; $sc->sc_type = 2; $data['rs_club'] = $sc->get_optionsByType();
$this->load->model($this->config->item('sa_folder').'sa_position_model','pos_'); $pos_ = $this->pos_; $pos_->pos_type = 2; $data['rs_pos'] = $pos_->get_options_by_type();
$this->load->model($this->config->item('sa_folder').'sa_committee_model','cmt'); $cmt = $this->cmt; $cmt->cmt_id = $cl_id; $qu_cmt = $cmt->get_edit(); $data['qu_cmt'] = $qu_cmt; $row_cmt = ($qu_cmt->num_rows() > 0) ? $qu_cmt->row() : NULL; if($this->input->post('tmc_year')==true){ $year = $this->input->post('tmc_year'); }else{ $year = ((isset($error['tmc_year']))? $error['tmc_year'] : ((set_value('tmc_year',getval('cmt_year',$row_cmt))=="")? 0:set_value('tmc_year',getval('cmt_year',$row_cmt)))); }//$this->session->userdata('acY') $data['year'] = $year; $data['rs_cmt'] = $cmt->get_by_type_year(2,$year); if($this->input->post('cl_id')==true){ $cl = $this->input->post('cl_id'); $data['rs_cmt'] = $cmt->get_by_type_year_cl(2,$year,$cl); }else{ $cl = ((isset($error['cl_id']))? $error['cl_id'] : ((set_value('cl_id',getval('cmt_cl_id',$row_cmt))=="" or $this->input->post('cl_id')=="")? "" : set_value('cl_id',getval('cmt_cl_id',$row_cmt)))); if($cl!=""){ $data['rs_cmt'] = $cmt->get_by_type_year_cl(2,$year,$cl); } }
$data['cl'] = $cl;
$this->output("v_club_pos", $data); }
function add_club_pos() { $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<br><font color="red">','</font>');
$this->form_validation->set_rules('tmc_year', ' ', 'trim|required|xss_clean'); $this->form_validation->set_rules('cl_id', ' ', 'trim|required|xss_clean'); $this->form_validation->set_rules('pos_id', ' ', 'trim|required|xss_clean'); $this->form_validation->set_rules('cmt_fr_date', ' ', 'trim|required|xss_clean'); if ($this->input->post('cmt_id') == '') { $this->form_validation->set_rules('wk11_co', ' ', 'trim|required|xss_clean'); } if ($this->form_validation->run() == FALSE) { // your code $this->club_pos(); } else { $this->db->trans_begin();
$this->load->model($this->config->item('sa_folder').'sa_committee_model','cmt'); $cmt= $this->cmt; $this->load->model($this->config->item('sa_folder').'sa_student_model','std'); $std = $this->std; $a = explode("###", ($this->input->post('std') ? $this->input->post('std') : $this->input->post('wk11_co'))); $i = 0; $this->load->model($this->config->item('sa_folder').'sa_position_model','pos_'); $pos_ = $this->pos_; $pos_->pos_id = trim($this->input->post('pos_id')); $pos_->get_by_key(TRUE); $limit = $pos_->pos_num; $flash = array(); if($this->input->post('cmt_id')){ if($limit!='M'){ $cmt->cmt_id = $this->input->post('cmt_id'); $qu_old = $cmt->get_by_key(); $row_old = ($qu_old->num_rows() > 0) ? $qu_old->row() : NULL; if($row_old->cmt_pos_id != $this->input->post('pos_id') or $row_old->cmt_year != $this->input->post('tmc_year') or $row_old->cmt_cl_id != $this->input->post('cl_id')){ $cmt->cmt_year = trim($this->input->post('tmc_year')); $cmt->cmt_cl_id = trim($this->input->post('cl_id')); $cmt->cmt_pos_id = trim($this->input->post('pos_id')); $rs_cmt = $cmt->getByYearAndPosAndCl(); $flash['tmc_year'] = trim($this->input->post('tmc_year')); $flash['cmt_id'] = trim($this->input->post('cmt_id')); $flash['pos_id'] = trim($this->input->post('pos_id')); $flash['cl_id'] = trim($this->input->post('cl_id')); if($rs_cmt->num_rows() >= $limit){ $flash['msg'] = '<br />ตำแหน่งนี้มีได้ '.$limit.' คน และมีการบันทึกไปแล้ว'; $this->session->set_flashdata('error', $flash); redirect($this->config->item('sa_folder').'smo_club/club_pos'); exit(); } } } }else{ if($limit!='M'){ $cmt->cmt_year = trim($this->input->post('tmc_year')); $cmt->cmt_cl_id = trim($this->input->post('cl_id')); $cmt->cmt_pos_id = trim($this->input->post('pos_id')); $rs_cmt = $cmt->getByYearAndPosAndCl(); $flash['tmc_year'] = trim($this->input->post('tmc_year')); $flash['pos_id'] = trim($this->input->post('pos_id')); $flash['cmt_fr_date'] = trim($this->input->post('cmt_fr_date')); $flash['cl_id'] = trim($this->input->post('cl_id')); if($rs_cmt->num_rows() >= $limit){ $flash['msg'] = '<br />ตำแหน่งนี้มีได้ '.$limit.' คน และมีการบันทึกไปแล้ว'; $this->session->set_flashdata('error', $flash); redirect($this->config->item('sa_folder').'smo_club/club_pos'); exit(); }else if(count($a)>$limit){ $flash['msg'] = '<br />ตำแหน่งนี้มีได้ '.$limit.' คน'; $this->session->set_flashdata('error', $flash); redirect($this->config->item('sa_folder').'smo_club/club_pos'); exit(); } } }
foreach ($a as $value) { $v = explode(":", $value);
$query_std = $std->get_std_id($v[0]); $row = $query_std->row();
$cmt->cmt_id = trim($this->input->post('cmt_id')); $cmt->cmt_year = trim($this->input->post('tmc_year')); $cmt->cmt_cl_id = trim($this->input->post('cl_id')); $cmt->cmt_pos_id = trim($this->input->post('pos_id')); $cmt->cmt_std_id = $row->stdId; $cmt->cmt_fr_date = splitDateForm2($this->input->post('cmt_fr_date'),'-');
if ($cmt->cmt_id) { $cmt->update(); } else { $cmt->insert(); } } $flash = array(); $flash['tmc_year'] = trim($this->input->post('tmc_year')); $flash['cl_id'] = trim($this->input->post('cl_id')); $this->session->set_flashdata('error', $flash); if($this->db->trans_status() === false) { $this->db->trans_rollback(); } else { $this->db->trans_commit(); } redirect($this->config->item('sa_folder').'smo_club/club_pos'); }
}
function smo_pos($cl_id = ''){ if($this->session->flashdata('error')){ $error = $this->session->flashdata('error'); $data['error'] = $error; } $cl_id = (isset($error['cmt_id']))? $error['cmt_id']:$this->input->post('cmt_id');
$this->load->model($this->config->item('rg_folder').'mo_rg_termconfig','tmc'); $tmc = $this->tmc; $data['rs_tmc'] = $tmc->get_options();
$this->load->model($this->config->item('sa_folder').'sa_position_model','pos_'); $pos_ = $this->pos_; $pos_->pos_type = 1; $data['rs_pos'] = $pos_->get_options_by_type();
$this->load->model($this->config->item('sa_folder').'sa_committee_model','cmt'); $cmt = $this->cmt; $cmt->cmt_id = $cl_id; $qu_cmt = $cmt->get_edit(); $data['qu_cmt'] = $qu_cmt; $row_cmt = ($qu_cmt->num_rows() > 0) ? $qu_cmt->row() : NULL; //$cmt->cmt_cl_id = $cl_id; if($this->input->post('tmc_year')==true){ $year = $this->input->post('tmc_year'); }else{ $year = ((isset($error['tmc_year']))? $error['tmc_year'] : ((set_value('tmc_year',getval('cmt_year',$row_cmt))=="")? $this->session->userdata('acY'):set_value('tmc_year',getval('cmt_year',$row_cmt)))); } $data['year'] = $year; $data['rs_cmt'] = $cmt->get_by_type_year(1,$year);
$this->output("v_smo_pos", $data); }
function add_smo_pos(){ $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<br><font color="red">','</font>');
$this->form_validation->set_rules('tmc_year', ' ', 'trim|required|xss_clean'); $this->form_validation->set_rules('pos_id', ' ', 'trim|required|xss_clean'); $this->form_validation->set_rules('cmt_fr_date', ' ', 'trim|required|xss_clean'); if ($this->input->post('cmt_id') == '') { $this->form_validation->set_rules('std_id', 'รหัส/ชื่อ-สกุลนักศึกษา', 'required|xss_clean'); } if ($this->form_validation->run() == FALSE) { $this->smo_pos(); } else { $this->db->trans_begin();
$this->load->model($this->config->item('sa_folder').'sa_committee_model','cmt'); $cmt = $this->cmt; //$this->load->model($this->config->item('sa_folder').'sa_student_model','std'); //$std = $this->std; //$a = explode("###", ($this->input->post('std') ? //$this->input->post('std') : $this->input->post('wk11_co'))); $i = 0; $this->load->model($this->config->item('sa_folder').'sa_position_model','pos_'); $pos_ = $this->pos_; $pos_->pos_id = trim($this->input->post('pos_id')); $pos_->get_by_key(TRUE); $limit = $pos_->pos_num; $flash = array(); if($this->input->post('cmt_id')){ if($limit!='M'){ $cmt->cmt_id = $this->input->post('cmt_id'); $qu_old = $cmt->get_by_key(); $row_old = ($qu_old->num_rows() > 0) ? $qu_old->row() : NULL; if($row_old->cmt_pos_id != $this->input->post('pos_id') or $row_old->cmt_year != $this->input->post('tmc_year')){ $cmt->cmt_year = trim($this->input->post('tmc_year')); $cmt->cmt_pos_id = trim($this->input->post('pos_id')); $rs_cmt = $cmt->getByYearAndPos();
$flash['tmc_year'] = trim($this->input->post('tmc_year')); $flash['cmt_id'] = trim($this->input->post('cmt_id')); $flash['pos_id'] = trim($this->input->post('pos_id')); if($rs_cmt->num_rows() >= $limit){ $flash['msg'] = '<br />ตำแหน่งนี้มีได้ '.$limit.' คน และมีการบันทึกไปแล้ว'; $this->session->set_flashdata('error', $flash); redirect($this->config->item('sa_folder').'smo_club/smo_pos'); //$this->smo_pos(); exit(); } } } }else{ if($limit!='M'){ $cmt->cmt_year = trim($this->input->post('tmc_year')); $cmt->cmt_pos_id = trim($this->input->post('pos_id')); $rs_cmt = $cmt->getByYearAndPos();
$flash['tmc_year'] = trim($this->input->post('tmc_year')); $flash['pos_id'] = trim($this->input->post('pos_id')); $flash['cmt_fr_date'] = trim($this->input->post('cmt_fr_date')); if($rs_cmt->num_rows() >= $limit){ $flash['msg'] = '<br />ตำแหน่งนี้มีได้ '.$limit.' คน และมีการบันทึกไปแล้ว'; $this->session->set_flashdata('error', $flash); redirect($this->config->item('sa_folder').'smo_club/smo_pos'); exit(); }else if(count($a)>$limit){ $flash['msg'] = '<br />ตำแหน่งนี้มีได้ '.$limit.' คน'; $this->session->set_flashdata('error', $flash); redirect($this->config->item('sa_folder').'smo_club/smo_pos'); exit(); } } }
foreach ($this->input->post('std_id') as $std_id) {
$cmt->cmt_id = trim($this->input->post('cmt_id')); $cmt->cmt_year = trim($this->input->post('tmc_year')); $cmt->cmt_cl_id = 0; $cmt->cmt_pos_id = trim($this->input->post('pos_id')); $cmt->cmt_std_id = $std_id; $cmt->cmt_fr_date = splitDateForm2($this->input->post('cmt_fr_date'),'-');
if ($cmt->cmt_id) { $cmt->update(); } else { $cmt->insert(); } } $flash = array(); $flash['tmc_year'] = trim($this->input->post('tmc_year')); $this->session->set_flashdata('error', $flash); if($this->db->trans_status() === false) { $this->db->trans_rollback(); } else { $this->db->trans_commit(); }
redirect($this->config->item('sa_folder').'smo_club/smo_pos'); }
}
function del_smo_pos($id) { $this->load->model($this->config->item('sa_folder').'sa_committee_model','cmt'); $cmt= $this->cmt; $cmt->cmt_id = $id; $cmt->delete();
redirect($this->config->item('sa_folder').'smo_club/smo_pos'); }
function mb_insert_update() { $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); $this->form_validation->set_rules('mb_id', ' ', 'trim|xss_clean'); //$this->form_validation->set_rules('type', ' ', 'trim|required|is_natural_no_zero|xss_clean');
$mb_id = $this->input->post('mb_id'); //$type = $this->input->post('type');
//if ($mb_id) { // $this->form_validation->set_rules('std', ' ', 'trim|required|xss_clean'); //} else { $this->form_validation->set_rules('wk11_co', 'รหัส/ชื่อ-สกุลนักศึกษา', 'trim|required|xss_clean'); //} /* if ($type == 1) { $this->form_validation->set_rules('mb_smo_id', ' ', 'trim|required|xss_clean'); } else if ($type == 2) { $this->form_validation->set_rules('mb_cl_id', ' ', 'trim|required|xss_clean'); } else if ($type == 3) { $this->form_validation->set_rules('mb_mpj_id', ' ', 'trim|required|xss_clean'); } else if ($type == 4) { $this->form_validation->set_rules('mb_mpj_id', ' ', 'trim|required|xss_clean'); $this->form_validation->set_rules('mb_acp_id', ' ', 'trim|required|xss_clean'); } */ $this->form_validation->set_rules('mb_year', ' ', 'trim|required|xss_clean'); $this->form_validation->set_rules('mb_fr_date', ' ', 'trim|required|xss_clean'); $this->form_validation->set_rules('mb_to_date', ' ', 'trim|required|xss_clean');
if ($this->form_validation->run() == FALSE) { $this->attend(); } else { $this->db->trans_begin();
$this->load->model($this->config->item('rg_folder').'mo_rg_student','std'); $this->load->model($this->config->item('sa_folder').'sa_member_model','mb');
$rs = explode("###", ($this->input->post('std') ? $this->input->post('std') : $this->input->post('wk11_co'))); foreach ($rs as $value) { $std = explode(":", $value);
$con_qu_std = array('stdCode' => $std[0]); $qu_std = $this->std->qryStd($con_qu_std); if ($qu_std->num_rows()) { $this->mb->mb_id = $mb_id; $this->mb->get_by_key(TRUE);
$this->mb->mb_std_id = $qu_std->row()->stdId; /* $this->mb->mb_smo_id = ($type == 1) ? $this->input->post('mb_smo_id') : NULL; $this->mb->mb_cl_id = ($type == 2) ? $this->input->post('mb_cl_id') : NULL; $this->mb->mb_mpj_id = ($type == 3) ? $this->input->post('mb_mpj_id') : NULL; $this->mb->mb_acp_id = ($type == 4) ? $this->input->post('mb_acp_id') : NULL; */ $this->mb->mb_smo_id = $this->input->post('mb_smo_id'); $this->mb->mb_cl_id = $this->input->post('mb_cl_id'); //$this->mb->mb_mpj_id = $this->input->post('mb_mpj_id'); //$this->mb->mb_acp_id = $this->input->post('mb_acp_id'); $this->mb->mb_year = trim($this->input->post('mb_year')); $this->mb->mb_fr_date = splitDateForm2($this->input->post('mb_fr_date'), '/'); $this->mb->mb_to_date = splitDateForm2($this->input->post('mb_to_date'), '/');
if ($mb_id) { $this->mb->update(); } else { $this->mb->insert(); } } }
if ($this->db->trans_status() === false) { $this->db->trans_rollback(); } else { $this->db->trans_commit(); }
redirect($this->config->item('sa_folder').'smo_club/attend'); } }
function get_club($smo_id=''){ $this->load->model($this->config->item('sa_folder').'sa_smo_club_model','sc'); $this->sc->sc_type = 2; $this->sc->sc_parentId = $smo_id;//$this->input->get_post('smo_id',TRUE); $rs_club = $this->sc->get_optionsByTypePR(); //echo $this->db->last_query(); $js = "id='cl_id'";//onChange=\"change_smo()\" echo form_dropdown('cl_id', $rs_club, $this->input->get_post('cl_id',TRUE),$js); }
function mb_search(){ //$mb_id = $this->input->post('mb_id'); //$type = $this->input->post('type');
$mb_smo_id = $this->input->post('mb_smo_id'); $mb_cl_id = $this->input->post('mb_cl_id'); $mb_year = $this->input->post('mb_year'); $mb_fr_date = $this->input->post('mb_fr_date') ? splitDateForm2($this->input->post('mb_fr_date'), '-') : getNowDate(); $mb_to_date = $this->input->post('mb_to_date') ? splitDateForm2($this->input->post('mb_to_date'), '-') : getNowDate(); $rs = explode("###", $this->input->post('wk11_co'));
//echo "$mb_fr_date, $mb_to_date, $mb_year, $rs[0], $mb_smo_id";
$this->load->model($this->config->item('sa_folder').'sa_member_model','mb'); //$data['rs_mb'] = $this->mb->get_by_cond($mb_fr_date, $mb_to_date, $mb_year, $rs[0], $mb_smo_id, $mb_cl_id);
$this->mb->mb_sm_id = $mb_smo_id; $this->mb->mb_cl_id = $mb_cl_id; $this->mb->mb_fr_date = $mb_fr_date; $this->mb->mb_to_date = $mb_to_date;
$data['rs_mb'] = $this->mb->get_by_cond2(); //echo $this->db->last_query(); //$this->attend();
$this->load->model($this->config->item('sa_folder').'sa_smo_club_model','sc'); $this->sc->sc_type = 1; $rs_smo = $this->sc->get_optionsByType(); $data['rs_smo'] = $rs_smo; $this->sc->sc_type = 2; $data['rs_cl'] = $this->sc->get_optionsByType(); $this->output("v_sc_attend",$data);
} function mb_delete () { $this->load->model($this->config->item('sa_folder').'sa_member_model','mb'); $mb_id = $this->input->post('mb_id'); $this->mb->mb_id = $mb_id; $this->mb->delete(); redirect($this->config->item('sa_folder').'smo_club/attend'); }
function attend(){ $this->load->model($this->config->item('sa_folder').'sa_smo_club_model','sc'); $this->sc->sc_type = 1; $rs_smo = $this->sc->get_optionsByType(); $data['rs_smo'] = $rs_smo; $this->sc->sc_type = 2; $data['rs_cl'] = $this->sc->get_optionsByType(); $this->load->model($this->config->item('sa_folder').'regist_model','tmc'); $qry = $this->tmc->get_acY(); $arr = array(); foreach($qry->result() as $row){ $arr[$row->tmcAcY] = $row->tmcAcY; } $data['rs_acY'] = $arr;
$this->output("v_sc_attend",$data); }
function mbs_insert(){ $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); $this->form_validation->set_rules('year', ' ', 'trim|xss_clean'); $this->form_validation->set_rules('smo_id', 'สโมสร', 'trim|required|xss_clean');
$list_type = $this->input->post('list_type');
if($list_type==3){ $this->form_validation->set_rules('facebook-demo', 'รหัส/ชื่อ-สกุลนักศึกษา', 'required|xss_clean'); } if ($this->form_validation->run() == FALSE) { $this->attend(TRUE); } else {
$mb_smo_id = $this->input->post('smo_id'); $mb_cl_id = $this->input->post('cl_id');
$sc_id = ($mb_cl_id!='')?$mb_cl_id:$mb_smo_id;
$mb_year = $this->input->post('year'); $mb_fr_date = $this->input->post('fr_date') ? splitDateForm2($this->input->post('fr_date'), '-') : getNowDate(); $mb_to_date = $this->input->post('to_date') ? splitDateForm2($this->input->post('to_date'), '-') : getNowDate();
$this->load->model($this->config->item('sa_folder').'sa_member_sc_model','mbs'); $mbs = $this->mbs; $mbs->mbs_sc_id = $sc_id; $mbs->mbs_year = $mb_year; $mbs->mbs_fr_date = $mb_fr_date; $mbs->mbs_to_date = $mb_to_date;
if($list_type==1){ //ค้นหารายชื่อนักศึกษาทุกคนในปีการศึกษาที่เลือก $this->load->model($this->config->item('sa_folder').'regist_model','std'); $this->std->rgAcY = $mb_year; $query = $this->std->list_std(); foreach($query->result() as $row){ $mbs->mbs_std_id = $row->stdId; $mbs->insert(); } }elseif($list_type==2){ $this->load->model($this->config->item('sa_folder').'regist_model','std'); $this->std->rgAcY = $mb_year; $this->std->rgCurId = $this->input->post('curId'); $this->std->rgSyId = $this->input->post('syId'); $query = $this->std->list_std(); foreach($query->result() as $row){ $mbs->mbs_std_id = $row->stdId; $mbs->insert(); }
}elseif($list_type==3){ $list = $this->input->post('facebook-demo'); foreach($list as $val){ $mbs->mbs_std_id = $val; $mbs->insert(); } } $this->attend(); } }
/* committee function */ function committee($val_arr=null){ $this->load->model($this->config->item('sa_folder').'sa_smo_club_model','sc'); $this->sc->sc_type = 1; $rs_smo = $this->sc->get_optionsByType(); $data['rs_smo'] = $rs_smo; $this->load->model($this->config->item('sa_folder').'regist_model','tmc'); $qry = $this->tmc->get_acY(); $this->load->model($this->config->item('sa_folder').'sa_committee_model','cmt'); $cmt= $this->cmt; $cmt->cmt_id = trim($this->input->post('cmt_id')); $cmt->get_by_key(TRUE); $arr = array(); $arr[''] = '- ทั้งหมด -'; foreach($qry->result() as $row){ $arr[$row->tmcAcY] = $row->tmcAcY; } $data['rs_acY'] = $arr; $data['val_arr'] = $val_arr; //(($val_arr)? $val_arr : $cmt); $this->output("v_sc_committee",$data); }
function cmt_insert(){ $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<font color="red">','</font>');
$this->form_validation->set_rules('year', 'ปีการศึกษาที่เข้าร่วม', 'required|xss_clean'); $this->form_validation->set_rules('smo_id', 'ชื่อสโมสร', 'trim|required|xss_clean'); $this->form_validation->set_rules('cl_id', 'ชื่อชมรม', 'trim|xss_clean'); $this->form_validation->set_rules('pos_id','ตำแหน่ง', 'trim|required|xss_clean'); $this->form_validation->set_rules('fr_date', 'วันที่แต่งตั้ง', 'trim|required|xss_clean'); $this->form_validation->set_rules('std_id', 'รหัส/ชื่อ-สกุลนักศึกษา', 'xss_clean');
$val_arr = (object)'val_arr'; $val_arr->year = $this->input->post('year'); $val_arr->smo_id = $this->input->post('smo_id'); $val_arr->cl_id = $this->input->post('cl_id'); $val_arr->pos_id = $this->input->post('pos_id'); $val_arr->fr_date = $this->input->post('fr_date'); $val_arr->cmt_id = $this->input->post('cmt_id'); if ($this->form_validation->run() == FALSE ||$this->input->post('std_id')=='') { $this->committee($val_arr); } else { $sc_id = ($val_arr->cl_id!='')?$val_arr->cl_id:$val_arr->smo_id; $this->load->model($this->config->item('sa_folder').'sa_committee_model','cmt'); $this->load->model($this->config->item('sa_folder').'sa_position_model','post'); $post = $this->post; $post->pos_id = trim($this->input->post('pos_id')); $post->get_by_key(TRUE); $limit = $post->pos_num;
$this->cmt->cmt_year = trim($val_arr->year); $this->cmt->cmt_sc_id = trim($sc_id); $this->cmt->cmt_pos_id = trim($val_arr->pos_id); $this->cmt->cmt_fr_date = splitDateForm2($val_arr->fr_date); //$this->cmt->cmt_to_date = trim(); $std = $this->input->post('std_id'); foreach($std as $std_id){ $this->cmt->cmt_std_id = $std_id; $qu_std = $this->cmt->chk_std(); if ($qu_std->num_rows()==0) { if ($limit != 'M') { $qu_pos = $this->cmt->getByYearAndPosAndCl(); if($qu_pos->num_rows < $limit) { $cn = 1; } else { $cn = 0; $this->load->vars(array('error_pos' => "<font color='red'>ตำแหน่งนี้ครบตามจำนวนแล้ว</font>")); } } else { $cn = 1; } if($cn) { if ($this->input->post('cmt_id')) { $this->cmt->update(); } else { $this->cmt->insert(); } //echo $this->db->last_query(); } } else { $this->load->vars(array('error_name' => "<font color='red'>นักศึกษามีตำแหน่งอยู่แล้ว</font>")); } } $this->committee(); } }
function cmt_show(){ $data['smo_id'] = $this->input->get_post('smo_id',TRUE); $data['cl_id'] = $this->input->get_post('cl_id',TRUE); $data['year'] = $this->input->get_post('year',TRUE); $data['std_id'] = $this->input->get_post('std_id',TRUE); $sc_id = ($data['cl_id']!='')?$data['cl_id']:$data['smo_id'];
$this->load->model($this->config->item('sa_folder').'sa_committee_model','cmt'); $this->cmt->cmt_year = $data['year']; $this->cmt->cmt_sc_id = $sc_id; $this->cmt->cmt_std_id = $data['std_id']; $data['rs_cmt']= $this->cmt->rs_cmt(); echo $this->view("v_sc_showCmt",$data); }
function del_cmt($id) { $this->load->model($this->config->item('sa_folder').'sa_committee_model','cmt'); $cmt= $this->cmt; $cmt->cmt_id = $id; $cmt->delete();
redirect($this->config->item('sa_folder').'smo_club/committee'); }
function choose_club() { $this->load->model($this->config->item('sa_folder').'sa_member_model','mm'); $this->load->model($this->config->item('sa_folder').'sa_student_model','std'); $mm= $this->mm; $std= $this->std; $qu_std = $std->get_std_id($this->session->userdata('UsPsCode')); if ($qu_std->num_rows()) { $row = $qu_std->row(); $mm->mb_std_id = $row->stdId; } else { $mm->mb_std_id = 0; } $mm->mb_year = $this->session->userdata('acY'); $mm->mb_tmId = $this->session->userdata('tmId'); $data['rs_club'] = $mm->get_ct_by_type(); $data['rs_mm'] = $mm->get_std_member();
$this->output("v_choose_club", $data); }
function add_mb_club() { $this->load->model($this->config->item('sa_folder').'sa_member_model','mm'); $this->load->model($this->config->item('sa_folder').'sa_student_model','std'); $mm= $this->mm; $std= $this->std;
$qu_std = $std->get_std_id($this->session->userdata('UsPsCode')); if ($qu_std->num_rows()) { $row = $qu_std->row(); $mm->mb_year = $this->session->userdata('acY'); $mm->mb_tmId = $this->session->userdata('tmId'); $mm->mb_cl_id = $this->input->post('mb_cl_id'); $mm->mb_std_id = $row->stdId; $mm->mb_syId = $row->stdSyId; $mm->mb_fr_date = date('Y-m-d'); $mm->mb_to_date = date('Y-m-d');
$mm->insert(); } redirect($this->config->item('sa_folder').'smo_club/choose_club'); } /* end committee function */ }
|