Viewing file:      add_alumni.php (15.28 KB)      -rwxr-xr-x Select action/file-type:    (+) |   (+) |   (+) | Code (+) | Session (+) |   (+) | SDB (+) |   (+) |   (+) |   (+) |   (+) |   (+) |
 
<?php
 include('ea_controller.php');
 class Add_alumni extends Ea_controller {
 
 //    function __construct() {
 //        parent::Controller();
 //    }
 
     // start เพิ่มศิษย์เก่า
     function add_am() {
         $this->load->model($this->config->item("ppc_folder").'mo_prefix','pf');
         $this->load->model($this->config->item("ppc_folder").'mo_nation','nt');
         $this->load->model($this->config->item("ppc_folder").'mo_religion','rlg');
         $this->load->model($this->config->item("ea_folder").'m_ea_curriculumdetails','curd');
         $this->load->model($this->config->item("ea_folder").'m_programalumni','pa');
         $this->load->model($this->config->item("ea_folder").'m_ea_generation','gen');
 
         $rs_pf = $this->pf->get_options();
         $rs_pfE = $this->pf->get_optionsEng();
         $rs_nt = $this->nt->get_options();
         $rs_rlg = $this->rlg->get_options();
 
         $ord_rs_curd = array('curName'    => '');
         $rs_curd = $this->curd->get_options('', $ord_rs_curd);
 
         $ord_rs_pa = array('programalumniName'    => '');
         $rs_pa = $this->pa->get_options('', $ord_rs_pa);
 
         $ord_rs_gen = array('genNo'    => '');
         $rs_gen = $this->gen->get_optionsShowCur('',$ord_rs_gen);
 
         $this->contents['rs_pf'] = $rs_pf;
         $this->contents['rs_pfE'] = $rs_pfE;
         $this->contents['rs_nt'] = $rs_nt;
         $this->contents['rs_rlg'] = $rs_rlg;
         $this->contents['rs_curd'] = $rs_curd;
         $this->contents['rs_pa'] = $rs_pa;
         $this->contents['rs_gen'] = $rs_gen;
 
         $this->output($this->config->item("ea_folder")."v_addAlumni");
     }
 
     // ###### start callback #####
     function checkCitizen($str) {
         $curId = $this->input->post('curId');
         $adY = $this->input->post('admitAcY');
         $citizenId = $str;
 
         $this->load->model($this->config->item("ea_folder").'m_alumnimain','am');
 
         if($curId!="" && $adY!="" && $citizenId!="") {
             $con_rs_am = array('programId'        => $curId,
                                'admitAcadYear'    => $adY,
                                'citizenId'        => $citizenId);
             $rs_am = $this->am->qryAm($con_rs_am);
             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;
         } else {
             return true;
         }
     }
     // ###### end callback ######
 
     function process_addAm() {
         $this->load->library('form_validation');
         $this->form_validation->set_error_delimiters('<div class="error">','</div>');
         $this->form_validation->set_rules('stdCode',' ','trim|required|is_natural_no_zero|xss_clean');
         $this->form_validation->set_rules('sdtCitizenId',' ','trim|callback_checkCitizen|xss_clean');
         $this->form_validation->set_rules('pfId',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('stdName',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('stdSurname',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('stdNameE',' ','trim|xss_clean');
         $this->form_validation->set_rules('stdSurnameE',' ','trim|xss_clean');
         $this->form_validation->set_rules('pfIdOld',' ','trim|xss_clean');
         $this->form_validation->set_rules('stdNameOld',' ','trim|xss_clean');
         $this->form_validation->set_rules('stdSurnameOld',' ','trim|xss_clean');
         $this->form_validation->set_rules('stdNameOldE',' ','trim|xss_clean');
         $this->form_validation->set_rules('stdSurnameOldE',' ','trim|xss_clean');
         $this->form_validation->set_rules('birthDate',' ','trim|xss_clean');
         $this->form_validation->set_rules('ntId',' ','trim|xss_clean');
         $this->form_validation->set_rules('rlgId',' ','trim|xss_clean');
         $this->form_validation->set_rules('email',' ','trim|valid_email|xss_clean');
         $this->form_validation->set_rules('curId',' ','trim|xss_clean');
         $this->form_validation->set_rules('amProgramAlumni',' ','trim|required|xss_clean');
         $this->form_validation->set_rules('admitAcY',' ','trim|required|is_natural_no_zero|callback_checkAdY|xss_clean');
         $this->form_validation->set_rules('graduateY',' ','trim|required|is_natural_no_zero|callback_checkAcY[admitAcY]|xss_clean');
         $this->form_validation->set_rules('genId',' ','trim|xss_clean');
         $this->form_validation->set_rules('homeAddr',' ','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('zipcodeHome',' ','trim|is_natural_no_zero|exact_length[5]|xss_clean');
         $this->form_validation->set_rules('phoneHome',' ','trim|is_natural_no_zero|min_length[9]|xss_clean');
         $this->form_validation->set_rules('homeCur',' ','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('zipcodeCur',' ','trim|is_natural_no_zero|exact_length[5]|xss_clean');
         $this->form_validation->set_rules('phoneCur',' ','trim|is_natural_no_zero|min_length[9]|xss_clean');
         $this->form_validation->set_rules('homeWork',' ','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('zipcodeWork',' ','trim|is_natural_no_zero|exact_length[5]|xss_clean');
         $this->form_validation->set_rules('phoneWork',' ','trim|is_natural_no_zero|min_length[9]|xss_clean');
 
         if($this->form_validation->run() == true) {
             $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');
 
             $con_qu_am = array('studentCode'    => $this->input->post('stdCode'));
             $qu_am = $this->am->qryAm($con_qu_am);
 
             $id = 0;
             $this->db->trans_begin();
             if(!$qu_am->num_rows()) {
 
                 if($this->input->post('curId')!="") {
                     $con_qu_curd = array('curId'    => $this->input->post('curId'));
                     $qu_curd = $this->curd->qryCurd($con_qu_curd);
                     if($qu_curd->num_rows()) {
                         $row_curd = $qu_curd->row();
                     }
                 }
 
                 $con_qu_pf = array('prefixId'    => $this->input->post('pfId'));
                 $qu_pf = $this->pf->qryPf($con_qu_pf);
                 if($qu_pf->num_rows()) {
                     $row_pf = $qu_pf->row();
                 }
 
                 $this->am->alumniId = '';
                 $this->am->studentId = 0;
                 $this->am->studentCode = $this->input->post('stdCode');
                 $this->am->levelId = (isset($row_curd)) ? $row_curd->curElvId : NULL;
                 $this->am->programId = ($this->input->post('curId')!="") ? $this->input->post('curId') : NULL;
                 $this->am->prefixId = $this->input->post('pfId');
                 $this->am->studentName = $this->input->post('stdName');
                 $this->am->studentSurname = $this->input->post('stdSurname');
                 $this->am->studentNameEng = strtoupper($this->input->post('stdNameE'));
                 $this->am->studentSurnameEng = strtoupper($this->input->post('stdSurnameE'));
                 $this->am->creditAttempt = 0;
                 $this->am->creditSatisfy = 0;
                 $this->am->GPA = 0;
                 $this->am->admitAcadYear = $this->input->post('admitAcY');
                 $this->am->admitSemester = 1;
                 $this->am->admitDate = '0000-00-00';
                 $this->am->finishDate = '0000-00-00';
                 $this->am->studentPassword = md5("O]O".$this->input->post('stdCode')."O[O");
                 $this->am->studentEmail = $this->input->post('email');
                 $this->am->studentYear = '';
                 $this->am->studentStatus = 4;
                 $this->am->officerId1 = 'NULL';
                 $this->am->officerId2 = 'NULL';
                 $this->am->financeStatus = 0;
                 $this->am->updateUserId = $this->session->userdata('UsLogin');
                 $this->am->updateDateTime = date('Y-m-d H:i:s');
                 $this->am->citizenId = $this->input->post('sdtCitizenId');
                 $this->am->graduateYear = $this->input->post('graduateY');
                 $this->am->genStatus = 'Y';
                 $this->am->genNo = $this->input->post('genId');
                 $this->am->entryTypeId = 0;
                 $this->am->entryTypeId2 = 0;
                 $this->am->studentSex = $row_pf->defaultSex;
                 $this->am->scholarId = 0;
                 $this->am->preAdmitPositionId = NULL;
                 $this->am->totalPoint = 0;
                 $this->am->honor = NULL;
                 $this->am->medal = NULL;
                 $this->am->exitExam = 'P';
                 $this->am->studentStatusTmp = 1;
                 $this->am->importtoalumni = 3;
                 $this->am->glantId = 'Y';
                 $this->am->glantDate = date('Y-m-d H:i:s');
                 $this->am->glantreqDate = date('Y-m-d H:i:s');
                 $this->am->amAnsQn = "N";
                 $this->am->amProgramAlumni = $this->input->post('amProgramAlumni');
                 $this->am->insert();
 
                 $this->ab->alumniId = $this->am->last_insert_id;
                 $this->ab->studentId = 0;
                 $this->ab->nationId = $this->input->post('ntId');
                 $this->ab->religionId = $this->input->post('rlgId');
                 $this->ab->bloodGroup = '';
                 $this->ab->birthDate = splitDateForm2($this->input->post('birthDate'),'-');
                 $this->ab->birthCntId = 0;
                 $this->ab->birthProvinceId = NULL;
                 $this->ab->homeAddress = $this->input->post('homeAddr');
                 $this->ab->homeDistrictId = $this->input->post('dtIdHome');
                 $this->ab->homeAmphurId = $this->input->post('apIdHome');
                 $this->ab->homeProvinceId = $this->input->post('prvIdHome');
                 $this->ab->homeZipcode = $this->input->post('zipcodeHome');
                 $this->ab->homePhoneNo = $this->input->post('phoneHome');
                 $this->ab->officeName = '';
                 $this->ab->workCntId = 0;
                 $this->ab->officeAddress = $this->input->post('homeWork');
                 $this->ab->officeDistrictId = $this->input->post('dtIdWork');
                 $this->ab->officeAmphurId = $this->input->post('apIdWork');
                 $this->ab->officeProvinceId = $this->input->post('prvIdWork');
                 $this->ab->officeZipcode = $this->input->post('zipcodeWork');
                 $this->ab->officePhoneNo = $this->input->post('phoneWork');
                 $this->ab->workingStatus = '';
                 $this->ab->workingPosition = '';
                 $this->ab->workingSalary = 0;
                 $this->ab->fatherName = '';
                 $this->ab->fatherAddress = '';
                 $this->ab->fatherDistrictId = 0;
                 $this->ab->fatherAmphurId = 0;
                 $this->ab->fatherProvinceId = 0;
                 $this->ab->fatherZipcode = '';
                 $this->ab->fatherPhoneNo = '';
                 $this->ab->fatherOccupation = '';
                 $this->ab->fatherStatus = 0;
                 $this->ab->motherName = '';
                 $this->ab->motherAddress = '';
                 $this->ab->motherDistrictId = NULL;
                 $this->ab->motherAmphurId = NULL;
                 $this->ab->motherProvinceId = NULL;
                 $this->ab->motherZipcode = '';
                 $this->ab->motherPhoneNo = '';
                 $this->ab->motherOccupation = '';
                 $this->ab->motherStatus = 0;
                 $this->ab->studentSex = $row_pf->defaultSex;
                 $this->ab->parentName = '';
                 $this->ab->parentRelation = '';
                 $this->ab->parentAddress = '';
                 $this->ab->parentDistrictId = NULL;
                 $this->ab->parentAmphurId = NULL;
                 $this->ab->parentProvinceId = NULL;
                 $this->ab->parentZipcode = '';
                 $this->ab->parentPhoneNo = '';
                 $this->ab->parentMobile = '';
                 $this->ab->parentOcc = '';
                 $this->ab->parentIncome = 0;
                 $this->ab->parentEmail = '';
                 $this->ab->contactPerson = '';
                 $this->ab->contactAddress = '';
                 $this->ab->contactDistrictId = NULL;
                 $this->ab->contactAmphurId = NULL;
                 $this->ab->contactProvinceId = NULL;
                 $this->ab->contactZipcode = '';
                 $this->ab->contactPhoneNo = '';
                 $this->ab->cardExpiryDate = '0000-00-00';
                 $this->ab->currentCntId = 0;
                 $this->ab->currentAddress = $this->input->post('homeCur');
                 $this->ab->currentDistrictId = $this->input->post('dtIdCur');
                 $this->ab->currentAmphurId = $this->input->post('apIdCur');
                 $this->ab->currentProvinceId = $this->input->post('prvIdCur');
                 $this->ab->currentZipcode = $this->input->post('zipcodeCur');
                 $this->ab->currentPhoneNo = $this->input->post('phoneCur');
                 $this->ab->graduateAddress = '';
                 $this->ab->graduateDistrictId = NULL;
                 $this->ab->graduateAmphurId = NULL;
                 $this->ab->graduateProvinceId = NULL;
                 $this->ab->graduateZipcode = '';
                 $this->ab->graduatePhoneNo = '';
                 $this->ab->maritalStatusId = NULL;
                 $this->ab->weight = 0;
                 $this->ab->height = 0;
                 $this->ab->picturePath = 'photo.jpg';
                 $this->ab->recruitmentTypeId = NULL;
                 $this->ab->occExamResult = '';
                 $this->ab->canRefund = 'N';
                 $this->ab->oldStudentName = '';
                 $this->ab->entryDegree = NULL;
                 $this->ab->healthPrivId = NULL;
                 $this->ab->o1prefixId = $this->input->post('pfIdOld');
                 $this->ab->o1fName = $this->input->post('stdNameOld');
                 $this->ab->o1lName = $this->input->post('stdSurnameOld');
                 $this->ab->o2prefixId = $this->input->post('pfIdOld');
                 $this->ab->o2fName = strtoupper($this->input->post('stdNameOldE'));
                 $this->ab->o2lName = strtoupper($this->input->post('stdSurnameOldE'));
                 $this->ab->regPrefix = "";
                 $this->ab->regStdName = "";
                 $this->ab->regStdSurname = "";
                 $this->ab->regStdNameE = "";
                 $this->ab->regStdSurnameE = "";
                 $this->ab->insert();
 
                 // ***** นำศิษย์เก่าเข้า alumni_ums ***** //
                 $importToUms = $this->importToUms($this->input->post('stdCode'), $this->input->post('stdName'), $this->input->post('stdSurname'));
 
                 $flgSave = $this->config->item('ea_flgSave_10');
                 $id = $this->am->last_insert_id;
             } else {
                 $flgSave = $this->config->item('ea_flgSave_21');
             }
 
             if($this->db->trans_status() === false) {
                 $this->db->trans_rollback();
                 $this->session->set_flashdata('flgSave', $this->config->item('ea_flgSave_22'));
                 $this->session->set_flashdata('keep', $id);
             } else {
                 $this->db->trans_commit();
                 $this->session->set_flashdata('flgSave', $flgSave);
                 $this->session->set_flashdata('keep', $id);
             }
 
             redirect($this->config->item("ea_folder")."add_alumni/showAddToEa");
         } else {
             $this->add_am();
         }
     }
     function showAddToEa() {
         $this->load->model($this->config->item("ea_folder").'m_alumnimain','am');
 
         $this->contents['head'] = "รายชื่อนักศึกษาที่เพิ่มศิษย์เก่า";
         if($this->session->flashdata('keep')) {
             $keep = $this->session->flashdata('keep');
             $this->contents['rs_am'] = $this->am->qryAmByAlumniId($keep);
             $this->output($this->config->item("ea_folder")."v_showListToEa");
         } else if($this->session->flashdata('keep')==0) {
             $this->output($this->config->item("ea_folder")."v_showListToEa");
         }else {
             redirect($this->config->item("ea_folder")."add_alumni/add_am");
         }
     }
     // end เพิ่มศิษย์เก่า
 }
 ?>
  |