Viewing file:      info_alumni.php (32.41 KB)      -rwxr-xr-x Select action/file-type:    (+) |   (+) |   (+) | Code (+) | Session (+) |   (+) | SDB (+) |   (+) |   (+) |   (+) |   (+) |   (+) |
 
<?php
 include('ea_controller.php');
 class Info_alumni extends Ea_controller {
 
 //    function __construct() {
 //        parent::Controller();
 //    }
 
     // ###### start callback #####
     function checkCitizen($str) {
         $this->load->model($this->config->item("ea_folder").'m_alumnimain','am');
 
         $alumniId = $this->input->post('alumniId');
         $citizenId = $str;
 
         $this->am->alumniId = $alumniId;
         $this->am->get_by_key(TRUE);
 
         $rs_am = $this->am->qryCitizenIdNotAmId($this->am->programId,$this->am->admitAcadYear,$citizenId,$alumniId);
 
         if($citizenId=='') {
             return true;
         } else if($citizenId!='' && checkFomatIdCard($citizenId)==false) {
             $this->form_validation->set_message('checkCitizen', '%sไม่ถูกต้อง');
             return false;
         } else if($rs_am->num_rows()){
             $this->form_validation->set_message('checkCitizen', '%sซ้ำ');
             return false;
         } else
             return true;
     }
     function checkBloodGroup($str) {
         $bloodGroup = $str;
 
         if($bloodGroup=="") {
             return true;
         } else if($bloodGroup=="A" || $bloodGroup=="B" || $bloodGroup=="AB" || $bloodGroup=="O") {
             return true;
         } else if($bloodGroup=="a" || $bloodGroup=="b" || $bloodGroup=="ab" || $bloodGroup=="o") {
             return true;
         } else {
             $this->form_validation->set_message('checkBloodGroup', '%sไม่ถูกต้อง');
             return false;
         }
     }
     // ###### end callback ######
 
     function main_infoAm($tab=0, $alumniId=0) {
         $this->load->model($this->config->item("ea_folder").'m_alumnimain','am');
         $this->load->model($this->config->item("ea_folder").'m_alumnibio','ab');
         $this->load->model($this->config->item("ea_folder").'m_ea_curriculumdetails','curd');
         $this->load->model($this->config->item("ppc_folder").'mo_prefix','pf');
 
         $tab = ($this->input->post('tab')) ? $this->input->post('tab') : $tab;
         $alumniId = ($this->input->post('alumniId')) ? $this->input->post('alumniId') : $alumniId;
 
         $con_qu_am = array('am.alumniId'    => $alumniId);
         $qu_am = $this->am->qryAmJoinAbPf($con_qu_am);
 
         // หาระดับการศึกษา
         if($qu_am->num_rows()) {
             $con_qu_curd = array('curId'    => $qu_am->row()->programId);
             $qu_curd = $this->curd->qryCurd($con_qu_curd);
             $this->contents['qu_curd'] = $qu_curd;
         }
         // จบการหาระดับการศึกษา
 
         if($tab==1) {
             $this->load->model($this->config->item("ppc_folder").'mo_nation','nt');
             $this->load->model($this->config->item("ppc_folder").'mo_religion','rlg');
 
             $data['qu_am'] = $qu_am;
             $data['tab'] = $tab;
 
             $con_qu_regName = array('am.alumniId'    => $alumniId);
             $data['qu_regName'] = $this->ab->qryRegName($con_qu_regName);
 
             $ord_rs_nt = array('nationName'    => '');
             $data['rs_nt'] = $this->nt->get_options('',$ord_rs_nt);
             $data['rs_rlg'] = $this->rlg->get_options();
 
             $this->contents['v'] = $this->load->view($this->config->item('ea_folder').'v_infoAm_1',$data,TRUE);
         } else if($tab==2) {
             $this->load->model($this->config->item("ppc_folder").'mo_country','cnt');
 
             $data['qu_am'] = $qu_am;
             $data['tab'] = $tab;
             $data['rs_cnt'] = $this->cnt->get_options();
 
             $con_qu_homeAddr =  array('alumniId'    => $alumniId);
             $data['qu_homeAddr'] = $this->ab->qryHomeAddr($con_qu_homeAddr);
 
             $con_qu_curAddr =  array('alumniId'    => $alumniId);
             $data['qu_curAddr'] = $this->ab->qryCurAddr($con_qu_curAddr);
 
             $con_qu_workAddr = array('alumniId'    => $alumniId);
             $data['qu_workAddr'] = $this->ab->qryWorkAddr($con_qu_workAddr);
 
             $this->contents['v'] = $this->load->view($this->config->item('ea_folder').'v_infoAm_2',$data,TRUE);
         } else if($tab==3) {
             $this->load->model($this->config->item("ea_folder").'m_hiswork','hw');
 
             $data['alumniId'] = $alumniId;
             $data['tab'] = $tab;
 
             $con_rs_hw = array('alumniId'    => $alumniId);
             $data['rs_hw'] = $this->hw->qryHw($con_rs_hw);
 
             // ******* update ****** //
             $seqId = $this->input->post('seqId');
             $edit_alumniId = $this->input->post('alumniId');
 
             $this->hw->seqId = $seqId;
             $this->hw->alumniId = $edit_alumniId;
             $data['qu_hw'] = $this->hw->get_by_key();
             // ******* end update ****** //
 
             $this->contents['v'] = $this->load->view($this->config->item('ea_folder').'v_infoAm_3',$data,TRUE);
         } else if($tab==4) {
             $this->load->model($this->config->item("ea_folder").'m_majoredu','maj');
             $this->load->model($this->config->item("ea_folder").'m_leveledu','lev');
             $this->load->model($this->config->item("ea_folder").'m_ea_hiseducation','hed');
 
             $data['alumniId'] = $alumniId;
             $data['tab'] = $tab;
 
             $ord_rs_maj = array('majoreduName'    => '');
             $data['rs_maj'] = $this->maj->get_options('',$ord_rs_maj);
 
             $ord_rs_lev = array('leveleduName'    => '');
             $data['rs_lev'] = $this->lev->get_options('',$ord_rs_lev);
 
             $con_rs_hed = array('hedAlumniId'    => $alumniId);
             $data['rs_hed'] = $this->hed->qryHedJoinLevEduMaj($con_rs_hed);
 
             // ******* update ****** //
             $hedSeqId = $this->input->post('seqId');
             $hedAlumniId = $this->input->post('alumniId');
 
             $con_qu_hed = array('hedSeqId'        => $hedSeqId,
                                 'hedAlumniId'    => $hedAlumniId);
             $data['qu_hed'] = $this->hed->qryHedJoinLevEduMaj($con_qu_hed);
             // ******* end update ****** //
 
             $this->contents['v'] = $this->load->view($this->config->item('ea_folder').'v_infoAm_4',$data,TRUE);
         } else if($tab==5) {
             $this->load->model($this->config->item("ea_folder").'m_typeaward','ta');
             $this->load->model($this->config->item("ea_folder").'m_levelaward','levAw');
             $this->load->model($this->config->item("ea_folder").'m_hisaward','ha');
 
             $data['alumniId'] = $alumniId;
             $data['tab'] = $tab;
 
             $data['rs_ta'] = $this->ta->get_options();
             $data['rs_levAw'] = $this->levAw->get_options();
 
             $con_rs_ha = array('ha.alumniId'    => $alumniId);
             //$data['rs_ha'] = $this->ha->qryHaJoinTaLevAw($con_rs_ha);
             $data['rs_ha'] = $this->ha->qryHaJoinTaLaAmPf($con_rs_ha);
 
             // ******* update ****** //
             $haSeqId = $this->input->post('seqId');
             $haAlumniId = $alumniId;
 
             $this->ha->seqId = $haSeqId;
             $this->ha->alumniId = $haAlumniId;
             $data['qu_ha'] = $this->ha->get_by_key();
             // ******* end update ****** //
 
             $this->contents['v'] = $this->load->view($this->config->item('ea_folder').'v_infoAm_5',$data,TRUE);
         }
 
         $this->contents['qu_am'] = $qu_am;
         $this->contents['tab'] = $tab;
         $this->contents['alumniId'] = $alumniId;
 
         $this->output($this->config->item("ea_folder")."v_mainInfoAm");
     }
 
     function process_infoAm_1() {
         $this->load->model($this->config->item("ea_folder").'m_alumnimain','am');
 
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<div class="error">','</div>');
         $this->form_validation->set_rules('prefixId',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('prefixName',' ','trim|xss_clean');
         $this->form_validation->set_rules('studentName',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('studentSurname',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('prefixNameEng',' ','trim|xss_clean');
         $this->form_validation->set_rules('studentNameEng',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('studentSurnameEng',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('citizenId',' ','trim|xss_clean|callback_checkCitizen');
         $this->form_validation->set_rules('birthDate',' ','trim|xss_clean');
         $this->form_validation->set_rules('bloodGroup',' ','trim|callback_checkBloodGroup|xss_clean');
         $this->form_validation->set_rules('nationId',' ','trim|xss_clean');
         $this->form_validation->set_rules('religionId',' ','trim|xss_clean');
         $this->form_validation->set_rules('studentEmail',' ','trim|valid_email|xss_clean');
         $this->form_validation->set_rules('picturePath',' ','trim|xss_clean');
         $this->form_validation->set_rules('alumniId',' ','trim|xss_clean');
         $this->form_validation->set_rules('tab',' ','trim|xss_clean');
 
         $alumniId = $this->input->post('alumniId');
         $tab = $this->input->post('tab');
 
         $this->am->alumniId = $alumniId;
         $this->am->get_by_key(TRUE);
 
         /* ####### อัพโหลดรูปนักศึกษา ######## */
         $config['upload_path'] = $this->config->item('ea_upload_pictureStd');
         $config['allowed_types'] = 'jpg';
         $config['max_width'] = $this->config->item('ea_allowed_width');
         $config['max_height'] = $this->config->item('ea_allowed_height');
         $config['max_size']    = $this->config->item('ea_upload_size');
         $this->load->library('upload');
         foreach($_FILES as $key => $value) {
             if($_FILES['picturePath']['name']!=""){
                 if(file_exists($this->config->item('ea_upload_pictureStd').$this->am->studentCode.".jpg")) {
                     rename ($this->config->item('ea_upload_pictureStd').$this->am->studentCode.".jpg", $this->config->item('ea_upload_pictureStd').$this->am->studentCode."_old.jpg");
                 }
 
                 $config['file_name'] = $this->am->studentCode;
                 $this->upload->initialize($config);
                 if ($this->upload->do_upload($key)){
                     if(file_exists($this->config->item('ea_upload_pictureStd').$this->am->studentCode."_old.jpg")) {
                         unlink($this->config->item('ea_upload_pictureStd').$this->am->studentCode."_old.jpg");
                     }
 
                     $data = array('upload_data' => $this->upload->data());
                     $path = $data['upload_data']['file_name'];
                 } else {
                     if(file_exists($this->config->item('ea_upload_pictureStd').$this->am->studentCode."_old.jpg")) {
                         rename ($this->config->item('ea_upload_pictureStd').$this->am->studentCode."_old.jpg", $this->config->item('ea_upload_pictureStd').$this->am->studentCode.".jpg");
                     }
 
                     $error = array('error' => $this->upload->display_errors());
                     $this->form_validation->set_rules('picturePath', trim($error['error']), 'callback_checkupload');
                 }
             }
         }
         /* ####### จบอัพโหลดรูปนักศึกษา ######## */
 
         if($this->form_validation->run() == true) {
             $this->load->model($this->config->item("ea_folder").'m_alumnibio','ab');
 
             $prefixId = $this->input->post('prefixId');
             $studentName = $this->input->post('studentName');
             $studentSurname = $this->input->post('studentSurname');
             $studentNameEng = strtoupper($this->input->post('studentNameEng'));
             $studentSurnameEng = strtoupper($this->input->post('studentSurnameEng'));
             $citizenId = $this->input->post('citizenId');
             $birthDate = splitDateForm2($this->input->post('birthDate'),'-');
             $bloodGroup = strtoupper($this->input->post('bloodGroup'));
             $nationId = $this->input->post('nationId');
             $religionId = $this->input->post('religionId');
             $studentEmail = $this->input->post('studentEmail');
 
             $this->db->trans_begin();
             $this->am->prefixId = $prefixId;
             $this->am->studentName = $studentName;
             $this->am->studentSurname = $studentSurname;
             $this->am->studentNameEng = $studentNameEng;
             $this->am->studentSurnameEng = $studentSurnameEng;
             $this->am->citizenId = $citizenId;
             $this->am->studentEmail = $studentEmail;
             $this->am->updateUserId = $this->session->userdata('UsLogin');
             $this->am->updateDateTime = date('Y-m-d H:i:s');
             $this->am->glantreqDate = date('Y-m-d H:i:s');
             $this->am->update();
 
             $this->ab->alumniId = $alumniId;
             $this->ab->get_by_key(TRUE);
             $this->ab->birthDate = $birthDate;
             $this->ab->bloodGroup = $bloodGroup;
             $this->ab->nationId = $nationId;
             $this->ab->religionId = $religionId;
             $this->ab->studentEmail = $studentEmail;
             $this->ab->picturePath = isset($config['file_name']) ? $config['file_name'].'.jpg' : $this->ab->picturePath;
             $this->ab->update();
 
             if($this->db->trans_status() === false) {
                 $this->db->trans_rollback();
             } else {
                 $this->db->trans_commit();
             }
 
             redirect($this->config->item("ea_folder")."info_alumni/main_infoAm/$tab/$alumniId");
         } else {
             $this->main_infoAm();
         }
     }
 
     function process_infoAm_2() {
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<div class="error">','</div>');
         $this->form_validation->set_rules('homeAddress',' ','trim|xss_clean');
         $this->form_validation->set_rules('dtNameHome',' ','trim|xss_clean');
         $this->form_validation->set_rules('dtIdHome',' ','trim|xss_clean');
         $this->form_validation->set_rules('apNameHome',' ','trim|xss_clean');
         $this->form_validation->set_rules('apIdHome',' ','trim|xss_clean');
         $this->form_validation->set_rules('prvNameHome',' ','trim|xss_clean');
         $this->form_validation->set_rules('prvIdHome',' ','trim|xss_clean');
         $this->form_validation->set_rules('homeZipcode',' ','trim|is_natural_no_zero|exact_length[5]|xss_clean');
         $this->form_validation->set_rules('homePhoneNo',' ','trim|is_natural_no_zero|min_length[9]|xss_clean');
 
         $this->form_validation->set_rules('cur_cntChk',' ','trim|xss_clean');
         $this->form_validation->set_rules('currentAddress',' ','trim|xss_clean');
         $this->form_validation->set_rules('dtNameCur',' ','trim|xss_clean');
         $this->form_validation->set_rules('dtIdCur',' ','trim|xss_clean');
         $this->form_validation->set_rules('apNameCur',' ','trim|xss_clean');
         $this->form_validation->set_rules('apIdCur',' ','trim|xss_clean');
         $this->form_validation->set_rules('prvNameCur',' ','trim|xss_clean');
         $this->form_validation->set_rules('prvIdCur',' ','trim|xss_clean');
         $this->form_validation->set_rules('currentZipcode',' ','trim|is_natural_no_zero|exact_length[5]|xss_clean');
         $this->form_validation->set_rules('currentPhoneNo',' ','trim|is_natural_no_zero|min_length[9]|xss_clean');
         $this->form_validation->set_rules('exCntAddr',' ','trim|xss_clean');
         $this->form_validation->set_rules('currentCntId',' ','trim|xss_clean');
         $this->form_validation->set_rules('work_cntChk',' ','trim|xss_clean');
         $this->form_validation->set_rules('officeAddress',' ','trim|xss_clean');
         $this->form_validation->set_rules('dtNameWork',' ','trim|xss_clean');
         $this->form_validation->set_rules('dtIdWork',' ','trim|xss_clean');
         $this->form_validation->set_rules('apNameWork',' ','trim|xss_clean');
         $this->form_validation->set_rules('apIdWork',' ','trim|xss_clean');
         $this->form_validation->set_rules('prvNameWork',' ','trim|xss_clean');
         $this->form_validation->set_rules('prvIdWork',' ','trim|xss_clean');
         $this->form_validation->set_rules('officeZipcode',' ','trim|is_natural_no_zero|exact_length[5]|xss_clean');
         $this->form_validation->set_rules('officePhoneNo',' ','trim|is_natural_no_zero|min_length[9]|xss_clean');
         $this->form_validation->set_rules('ex_workCntAddr',' ','trim|xss_clean');
         $this->form_validation->set_rules('workCntId',' ','trim|xss_clean');
 
         $this->form_validation->set_rules('alumniId',' ','trim|xss_clean');
         $this->form_validation->set_rules('tab',' ','trim|xss_clean');
 
         $alumniId = $this->input->post('alumniId');
         $tab = $this->input->post('tab');
 
         if($this->form_validation->run() == true) {
             $this->db->trans_begin();
             $this->load->model($this->config->item("ea_folder").'m_alumnibio','ab');
             $this->load->model($this->config->item("ea_folder").'m_alumnimain','am');
 
             $this->ab->alumniId = $alumniId;
             $this->ab->get_by_key(TRUE);
 
             $homeAddress = $this->input->post('homeAddress');
             $dtIdHome = $this->input->post('dtIdHome');
             $apIdHome = $this->input->post('apIdHome');
             $prvIdHome = $this->input->post('prvIdHome');
             $homeZipcode = $this->input->post('homeZipcode');
             $homePhoneNo = $this->input->post('homePhoneNo');
 
             $cur_cntChk = $this->input->post('cur_cntChk');
             $currentAddress = $this->input->post('currentAddress');
             $dtIdCur = $this->input->post('dtIdCur');
             $apIdCur = $this->input->post('apIdCur');
             $prvIdCur = $this->input->post('prvIdCur');
             $currentZipcode = $this->input->post('currentZipcode');
             $currentPhoneNo = $this->input->post('currentPhoneNo');
             $exCntAddr = $this->input->post('exCntAddr');
             $currentCntId = $this->input->post('currentCntId');
 
             $work_cntChk = $this->input->post('work_cntChk');
             $officeAddress = $this->input->post('officeAddress');
             $dtIdWork = $this->input->post('dtIdWork');
             $apIdWork = $this->input->post('apIdWork');
             $prvIdWork = $this->input->post('prvIdWork');
             $officeZipcode = $this->input->post('officeZipcode');
             $officePhoneNo = $this->input->post('officePhoneNo');
             $ex_workCntAddr = $this->input->post('ex_workCntAddr');
             $workCntId = $this->input->post('workCntId');
 
             $this->ab->homeAddress = $homeAddress;
             $this->ab->homeDistrictId = $dtIdHome;
             $this->ab->homeAmphurId = $apIdHome;
             $this->ab->homeProvinceId = $prvIdHome;
             $this->ab->homeZipcode = $homeZipcode;
             $this->ab->homePhoneNo = $homePhoneNo;
 
             if($cur_cntChk=='I') {            // ที่อยู่ปัจจุบัน: ในประเทศ
                 $this->ab->currentCntId = 0;
                 $this->ab->currentAddress = $currentAddress;
                 $this->ab->currentDistrictId = $dtIdCur;
                 $this->ab->currentAmphurId = $apIdCur;
                 $this->ab->currentProvinceId = $prvIdCur;
                 $this->ab->currentZipcode = $currentZipcode;
                 $this->ab->currentPhoneNo = $currentPhoneNo;
             } else if($cur_cntChk=='E')    {    // ที่อยู่ปัจจุบัน: นอกประเทศ
                 $this->ab->currentCntId = $currentCntId;
                 $this->ab->currentAddress = $exCntAddr;
                 $this->ab->currentDistrictId = NULL;
                 $this->ab->currentAmphurId = NULL;
                 $this->ab->currentProvinceId = NULL;
                 $this->ab->currentZipcode = NULL;
                 $this->ab->currentPhoneNo = NULL;
             }
 
             if($work_cntChk=='I') {            // ที่อยู่ที่ทำงาน: ในประเทศ
                 $this->ab->workCntId = 0;
                 $this->ab->officeAddress = $officeAddress;
                 $this->ab->officeDistrictId = $dtIdWork;
                 $this->ab->officeAmphurId = $apIdWork;
                 $this->ab->officeProvinceId = $prvIdWork;
                 $this->ab->officeZipcode = $officeZipcode;
                 $this->ab->officePhoneNo = $officePhoneNo;
             } else if($work_cntChk=='E') {    // ที่อยู่ที่ทำงาน: นอกประเทศ
                 $this->ab->workCntId = $workCntId;
                 $this->ab->officeAddress = $ex_workCntAddr;
                 $this->ab->officeDistrictId = NULL;
                 $this->ab->officeAmphurId = NULL;
                 $this->ab->officeProvinceId = NULL;
                 $this->ab->officeZipcode = NULL;
                 $this->ab->officePhoneNo = NULL;
             }
 
             $this->ab->update();
 
             $this->am->alumniId = $alumniId;
             $this->am->get_by_key(TRUE);
             $this->am->glantreqDate = date('Y-m-d H:i:s');
             $this->am->update();
 
             if($this->db->trans_status() === false) {
                 $this->db->trans_rollback();
             } else {
                 $this->db->trans_commit();
             }
 
             redirect($this->config->item("ea_folder")."info_alumni/main_infoAm/$tab/$alumniId");
         } else {
             $this->main_infoAm();
         }
     }
 
     function process_infoAm_3() {
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<div class="error">','</div>');
         $this->form_validation->set_rules('companyNameT',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('companyNameE',' ','trim|xss_clean');
         $this->form_validation->set_rules('companyAddr',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('companyPosition',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('companyStartDate',' ','trim|xss_clean');
 
         if($this->input->post('fDate')=='F') {
             $this->form_validation->set_rules('companyEndDate',' ','trim|callback_checkFrDate[companyStartDate]|xss_clean');
         }
 
         $this->form_validation->set_rules('fDate',' ','trim|xss_clean');
         $this->form_validation->set_rules('seqId',' ','trim|xss_clean');
         $this->form_validation->set_rules('hwId',' ','trim|xss_clean');
         $this->form_validation->set_rules('tab',' ','trim|xss_clean');
         $this->form_validation->set_rules('alumniId',' ','trim|xss_clean');
 
         $tab = $this->input->post('tab');
         $alumniId = $this->input->post('alumniId');
 
         if($this->form_validation->run() == true) {
             $this->load->model($this->config->item("ea_folder").'m_hiswork','hw');
 
             $seqId = $this->input->post('seqId');
             $alumniId_hwId = $this->input->post('hwId');
             $companyNameT = $this->input->post('companyNameT');
             $companyNameE = $this->input->post('companyNameE');
             $companyAddr = $this->input->post('companyAddr');
             $companyPosition = $this->input->post('companyPosition');
             $companyAdmidPosYear = $this->input->post('companyAdmidPosYear');
             $companyStartDate = splitDateForm2($this->input->post('companyStartDate'),'-');
             $companyEndDate = splitDateForm2($this->input->post('companyEndDate'),'-');
             $fDate = $this->input->post('fDate');
 
             $this->hw->seqId = $seqId;
             $this->hw->alumniId = $alumniId_hwId;
             $qu_hw = $this->hw->get_by_key();
 
             $this->db->trans_begin();
             if($qu_hw->num_rows()==0) {
                 // insert to HisWork
 
                 $con_rs_hw = array('alumniId'            => $this->input->post('alumniId'),
                                    'companyNameT'        => $companyNameT,
                                    'companyPosition'    => $companyPosition,
                                    'companyStartDate'    => $companyStartDate);
                 $rs_hw = $this->hw->qryHw($con_rs_hw);
                 if($rs_hw->num_rows()==0) {
                     $con_seqId = array('alumniId'    => $alumniId);
 
                     $this->hw->seqId = $this->hw->getNextSeq($con_seqId);
                     $this->hw->alumniId = $alumniId;
                     $this->hw->companyNameT = $companyNameT;
                     $this->hw->companyNameE = $companyNameE;
                     $this->hw->companyAddr = $companyAddr;
                     $this->hw->companyPosition = $companyPosition;
                     $this->hw->companyAdmidPosYear = $companyAdmidPosYear;
                     $this->hw->companyStartDate = $companyStartDate;
                     if($fDate=='P') {            // ทำงานถึงปัจจุบัน
                         $this->hw->companyEndDate = '0000-00-00';
                     } else if($fDate=='F') {    // ระบุวันที่สิ้นสุดตำแหน่ง
                         $this->hw->companyEndDate = $companyEndDate;
                     }
 
                     $this->hw->hwUserId = $this->session->userdata('UsLogin');
                     $this->hw->hwUserUpdate = date('Y-m-d H:i:s');
                     $this->hw->insert();
                 }
             } else {
                 // update to Hiswork
 
                 $rs_hw = $this->hw->qryHwNotSeqIdAndAmId($companyNameT,$companyPosition,$companyStartDate,$seqId,$alumniId);
                 if($rs_hw->num_rows()==0) {
 
                     $this->hw->companyNameT = $companyNameT;
                     $this->hw->companyNameE = $companyNameE;
                     $this->hw->companyAddr = $companyAddr;
                     $this->hw->companyPosition = $companyPosition;
                     $this->hw->companyAdmidPosYear = $companyAdmidPosYear;
                     $this->hw->companyStartDate = $companyStartDate;
                     
                     if($fDate=='P') {            // ทำงานถึงปัจจุบัน
                         $this->hw->companyEndDate = '0000-00-00';
                     } else if($fDate=='F') {    // ระบุวันที่สิ้นสุดตำแหน่ง
                         $this->hw->companyEndDate = $companyEndDate;
                     }
                     $this->hw->hwUserId = $this->session->userdata('UsLogin');
                     $this->hw->hwUserUpdate = date('Y-m-d H:i:s');
                     $this->hw->update();
                 }
             }
 
             if($this->db->trans_status() === false) {
                 $this->db->trans_rollback();
             } else {
                 $this->db->trans_commit();
             }
 
             redirect($this->config->item("ea_folder")."info_alumni/main_infoAm/$tab/$alumniId");
         } else {
             $this->main_infoAm();
         }
     }
 
     function process_deleteInfoAm_3() {
         $this->load->model($this->config->item("ea_folder").'m_hiswork','hw');
 
         $seqId = $this->input->post('seqId');
         $alumniId = $this->input->post('alumniId');
         $tab = $this->input->post('tab');
 
         $this->db->trans_begin();
         $this->hw->seqId = $seqId;
         $this->hw->alumniId = $alumniId;
         $this->hw->delete();
 
         if($this->db->trans_status() === false) {
             $this->db->trans_rollback();
         } else {
             $this->db->trans_commit();
         }
 
         redirect($this->config->item("ea_folder")."info_alumni/main_infoAm/$tab/$alumniId");
     }
 
     function process_infoAm_4() {
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<div class="error">','</div>');
         $this->form_validation->set_rules('hedDegree',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('hedMajId',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('hedLevelId',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('educationName',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('hedEduId',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('hedStartDate',' ','trim|xss_clean');
 
         if($this->input->post('fDate')=='F') {
             $this->form_validation->set_rules('hedFinishDate',' ','trim|callback_checkFrDate[hedStartDate]|xss_clean');
         }
 
         $this->form_validation->set_rules('fDate',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('alumniId',' ','trim|xss_clean');
         $this->form_validation->set_rules('tab',' ','trim|xss_clean');
         $this->form_validation->set_rules('hedSeqId',' ','trim|xss_clean');
         $this->form_validation->set_rules('hedAlumniId',' ','trim|xss_clean');
 
         $alumniId = $this->input->post('alumniId');
         $tab = $this->input->post('tab');
 
         if($this->form_validation->run() == true) {
             $this->load->model($this->config->item("ea_folder").'m_ea_hiseducation','hed');
 
             $hedSeqId = $this->input->post('hedSeqId');
             $hedAlumniId = $this->input->post('hedAlumniId');
             $hedDegree = $this->input->post('hedDegree');
             $hedMajId = $this->input->post('hedMajId');
             $hedLevelId = $this->input->post('hedLevelId');
             $hedEduId = $this->input->post('hedEduId');
             $hedStartDate = splitDateForm2($this->input->post('hedStartDate'),'-');
             $hedFinishDate = splitDateForm2($this->input->post('hedFinishDate'),'-');
             $fDate = $this->input->post('fDate');
 
             $this->hed->hedSeqId = $hedSeqId;
             $this->hed->hedAlumniId = $hedAlumniId;
             $qu_hed = $this->hed->get_by_key();
 
             $this->db->trans_begin();
             if($qu_hed->num_rows()==0) {
                 $con_rs_hed = array('hedDegree'        => $hedDegree,
                                     'hedMajId'        => $hedMajId,
                                     'hedLevelId'    => $hedLevelId,
                                     'hedEduId'        => $hedEduId);
                 $rs_hed = $this->hed->qryHed($con_rs_hed);
                 if($rs_hed->num_rows()==0) {
                     $con_hedSeqId = array('hedAlumniId'    => $alumniId);
                     $this->hed->hedSeqId = $this->hed->getNextSeq($con_hedSeqId);
                     $this->hed->hedAlumniId = $alumniId;
                     $this->hed->hedDegree = $hedDegree;
                     $this->hed->hedLevelId = $hedLevelId;
                     $this->hed->hedEduId = $hedEduId;
                     $this->hed->hedMajId = $hedMajId;
                     $this->hed->hedStartDate = $hedStartDate;
 
                     if($fDate=='P') {            // เรียนถึงปัจจุบัน
                         $this->hed->hedFinishDate = '0000-00-00';
                     } else if($fDate=='F') {    // ระบุวันที่สิ้นสุดการเรียน
                         $this->hed->hedFinishDate = $hedFinishDate;
                     }
 
                     $this->hed->hedUserId = $this->session->userdata('UsLogin');
                     $this->hed->hedUserUpdate = date('Y-m-d H:i:s');
                     $this->hed->insert();
                 }
 
             } else {
                 $rs_hed = $this->hed->qryHedNotSeqIdAndAmId($hedDegree,$hedLevelId,$hedEduId,$hedMajId,$hedStartDate,$hedSeqId,$hedAlumniId);
                 if($rs_hed->num_rows()==0) {
                     $this->hed->hedDegree = $hedDegree;
                     $this->hed->hedLevelId = $hedLevelId;
                     $this->hed->hedEduId = $hedEduId;
                     $this->hed->hedMajId = $hedMajId;
                     $this->hed->hedStartDate = $hedStartDate;
 
                     if($fDate=='P') {            // เรียนถึงปัจจุบัน
                         $this->hed->hedFinishDate = '0000-00-00';
                     } else if($fDate=='F') {    // ระบุวันที่สิ้นสุดการเรียน
                         $this->hed->hedFinishDate = $hedFinishDate;
                     }
 
                     $this->hed->hedUserId = $this->session->userdata('UsLogin');
                     $this->hed->hedUserUpdate = date('Y-m-d H:i:s');
                     $this->hed->update();
                 }
             }
 
             if($this->db->trans_status() === false) {
                 $this->db->trans_rollback();
             } else {
                 $this->db->trans_commit();
             }
 
             redirect($this->config->item("ea_folder")."info_alumni/main_infoAm/$tab/$alumniId");
         } else {
             $this->main_infoAm();
         }
     }
 
     function process_deleteInfoAm_4() {
         $this->load->model($this->config->item("ea_folder").'m_ea_hiseducation','hed');
 
         $alumniId = $this->input->post('alumniId');
         $hedSeqId = $this->input->post('seqId');
         $tab = $this->input->post('tab');
 
         $this->db->trans_begin();
         $this->hed->hedAlumniId = $alumniId;
         $this->hed->hedSeqId = $hedSeqId;
         $this->hed->delete();
 
         if($this->db->trans_status() === false) {
             $this->db->trans_rollback();
         } else {
             $this->db->trans_commit();
         }
 
         redirect($this->config->item("ea_folder")."info_alumni/main_infoAm/$tab/$alumniId");
     }
 
     function process_infoAm_5() {
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<div class="error">','</div>');
         $this->form_validation->set_rules('awardNameT',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('awardNameE',' ','trim|xss_clean');
         $this->form_validation->set_rules('awardCompany',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('receiveDate',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('typeAwardId',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('levelAwardId',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('tab',' ','trim|xss_clean');
         $this->form_validation->set_rules('alumniId',' ','trim|xss_clean');
         $this->form_validation->set_rules('seqId',' ','trim|xss_clean');
         $this->form_validation->set_rules('ha_alumniId',' ','trim|xss_clean');
 
         $alumniId = $this->input->post('alumniId');
         $tab = $this->input->post('tab');
         
         if($this->form_validation->run() == true) {
             $this->load->model($this->config->item("ea_folder").'m_hisaward','ha');
         
             $seqId = $this->input->post('seqId');
             $ha_alumniId = $this->input->post('ha_alumniId');
             $awardNameT = $this->input->post('awardNameT');
             $awardNameE = $this->input->post('awardNameE');
             $awardCompany = $this->input->post('awardCompany');
             $typeAwardId = $this->input->post('typeAwardId');
             $levelAwardId = $this->input->post('levelAwardId');
             $receiveDate = splitDateForm2($this->input->post('receiveDate'),'-');
 
             $this->ha->seqId = $seqId;
             $this->ha->alumniId = $ha_alumniId;
             $qu_ha = $this->ha->get_by_key();
 
             $this->db->trans_begin();
             if($qu_ha->num_rows()==0) {
                 $con_rs_ha = array('alumniId'        => $alumniId,
                                    'awardNameT'        => $awardNameT,
                                    'awardNameE'        => $awardNameE,
                                    'awardCompany'    => $awardCompany,
                                    'typeAwardId'    => $typeAwardId,
                                    'receiveDate'    => $receiveDate);
                 $rs_ha = $this->ha->qryHa($con_rs_ha);
                 if($rs_ha->num_rows()==0) {
                     $con_seqId = array('alumniId'    => $alumniId);
                     $this->ha->seqId = $this->ha->getNextSeq($con_seqId);
                     $this->ha->alumniId = $alumniId;
                     $this->ha->awardNameT = $awardNameT;
                     $this->ha->awardNameE = $awardNameE;
                     $this->ha->awardCompany = $awardCompany;
                     $this->ha->typeAwardId = $typeAwardId;
                     $this->ha->levelAwardId = $levelAwardId;
                     $this->ha->receiveDate = $receiveDate;
                     $this->ha->haUserId = $this->session->userdata('UsLogin');
                     $this->ha->haUserUpdate = date('Y-m-d H:i:s');
                     $this->ha->insert();
                 }
             } else {
                 $rs_ha = $this->ha->qryHaNotSeqIdAndAmId($awardNameT,$awardCompany,$typeAwardId,$levelAwardId,$receiveDate,$seqId,$ha_alumniId);
                 if($rs_ha->num_rows()==0) {
                     $this->ha->awardNameT = $awardNameT;
                     $this->ha->awardNameE = $awardNameE;
                     $this->ha->awardCompany = $awardCompany;
                     $this->ha->typeAwardId = $typeAwardId;
                     $this->ha->levelAwardId = $levelAwardId;
                     $this->ha->receiveDate = $receiveDate;
                     $this->ha->haUserId = $this->session->userdata('UsLogin');
                     $this->ha->haUserUpdate = date('Y-m-d H:i:s');
                     $this->ha->update();
                 }
             }
 
             if($this->db->trans_status() === false) {
                 $this->db->trans_rollback();
             } else {
                 $this->db->trans_commit();
             }
 
             redirect($this->config->item("ea_folder")."info_alumni/main_infoAm/$tab/$alumniId");
         } else {
             $this->main_infoAm();
         }
     }
 
     function process_deleteInfoAm_5() {
         $this->load->model($this->config->item("ea_folder").'m_hisaward','ha');
 
         $alumniId = $this->input->post('alumniId');
         $tab = $this->input->post('tab');
         $seqId = $this->input->post('seqId');
 
         $this->db->trans_begin();
         $this->ha->alumniId = $alumniId;
         $this->ha->seqId = $seqId;
         $this->ha->delete();
 
         if($this->db->trans_status() === false) {
             $this->db->trans_rollback();
         } else {
             $this->db->trans_commit();
         }
 
         redirect($this->config->item("ea_folder")."info_alumni/main_infoAm/$tab/$alumniId");
     }
 }
 ?>
  |