Viewing file: import23082564.php (49.77 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include('rg_controller.php');
class import extends Rg_controller {
// function __construct() {
// parent::__construct();
// }
public $url = "http://admission.pi.in.th/admission/index.php/admisexport/genXMLToRegisCurl"; //2557=122.155.174.51
// public $url = "http://124.109.2.137/admission/index.php/admisexport/genXMLToRegisCurl";
// public $url = "122.155.12.70:8080/processing/index.php/admisexport/genXMLToRegisCurl";
//----------------------- special function --------------------------------- //
//----[]--- ฟังก์ชั่น check curl
function iscurlinstalled() {
if (in_array('curl', get_loaded_extensions())) {
return true;
}
else{
return false;
}
}
//---[]--- ฟังก์ชั่น check xml
function isxmlinstalled() {
if (in_array('xml', get_loaded_extensions())) {
return true;
}
else{
return false;
}
}
//---[]--- ฟังก์ชั่น check First node
function checkFirstNode($arr) {
$name = 0;
foreach($arr as $key => $val) {
foreach($val as $k => $v) {
if($k=='name') {
$name = $v;
}
}
}
return intval($name);
}
//---[]--- ฟังก์ชั่น check End node
function checkEndNode($arr) {
$end = 0;
foreach($arr as $key => $val) {
foreach($val as $k => $v) {
if($k=='end') {
$end = $v;
}
}
}
return intval($end);
}
//----------------------- end special function ---------------------------- //
function showImportStd() {
//$acY_R = $this->session->userdata('acY_R');
$acY_R = $this->session->userdata('acY');
$this->contents['acY_R'] = $acY_R;
/*----[]---- เช็คสถานะการนำเข้าข้อมูล */
$this->load->model($this->config->item("rg_folder").'mo_rg_realstudentad','stdad');
$con_rs_stdad = '';
// $con_rs_stdad = array('app_year' => $acY_R,
// 'app_result_status' => 'Y');
$rs_stdad = $this->stdad->qryRealStdAd($con_rs_stdad);
//Debug($rs_stdad);
//echo $rs_stdad->num_rows();
//die();
if($rs_stdad->num_rows()) {
$stage = 2;
$con_rs_stdad = array('app_year' => $acY_R,
'curId' => '0',
'app_result_status' => 'Y');
$rs_stdad = $this->stdad->qryRealStdAd($con_rs_stdad); // กำหนดหลักสูตรไม่ครบ
$noGs = $this->stdad->qryBySyNameAndNoGs($acY_R); // ยังไม่สร้างรุ่น
$noStd = $this->stdad->qryStdAdNotInStdAndSdt($acY_R); // ไม่มีข้อมูลใน rg_Student & rg_StudentDetails
//Debug($rs_stdad);
//Debug($noGs);
//Debug($noStd);
if($rs_stdad->num_rows() || $noGs->num_rows()) {
$stage = 3;
} else if($noStd->num_rows()) {
$stage = 5;
} else {
$stage = 4;
}
} else {
$stage = 1;
}
if($stage==1) {
$this->sub_showImportStd();
} else if($stage==2 || $stage==3) {
$this->showAfterAddRealStdAd(); //$this->processMatchingCur();
} else if($stage==5) {
$this->processMatchingCur();
} else {
$this->processConfirmMatchCur();
}
//Debug($this->db->queries);
/*----[]---- จบการเช็คสถานะการนำเข้าข้อมูล */
}
function sub_showImportStd() {
//$acY_R = $this->session->userdata('acY_R');
$acY_R = $this->session->userdata('acY');
$this->contents['acY_R'] = $acY_R;
$this->contents['description'] = "<span class='h'>ขั้นตอนนี้เป็นการนำข้อมูลนักเรียนที่มีสิทธิ์เข้าศึกษาจากระบบ Admission <br />เข้าระบบทะเบียนของวิทยาลัย ประจำปีการศึกษา ".$acY_R."</span>";
$this->output($this->config->item("rg_folder")."v_showImportStd");
}
function showRealStdAd() {
$this->load->helper('logsfile');
$year_th = date('Y') + 543;
$chk_curl = $this->iscurlinstalled();
$chk_xml = $this->isxmlinstalled();
$acY_R = ($this->input->post('acY_R')) ? $this->input->post('acY_R') : $year_th;
$description = "";
if($chk_curl && $chk_xml) {
$this->load->model($this->config->item("rg_folder").'mo_rg_config','cfg');
$this->cfg->get_by_key(TRUE);
//---[]--- start curl function
//$url = "http://admission.pi.in.th/admission/index.php/admisexport/genXMLToRegisCurl";
$xmlStr = $this->cfg->cfgClgCode."|".$acY_R;
//Debug($xmlStr);
//die();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlStr);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
$rs = curl_exec($ch);
//print_r(curl_getinfo($ch));
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
//---[]--- end curl function
if ( $httpcode == 200 ){
SaveXML($rs, 'admission');
SaveXML($acY_R, 'postdata');
//echo $rs;
//die();
$std = simplexml_load_string($rs);
//Debug($std);
//die();
//---[]--- เช็คข้อมูลมาครบหรือไม่
$firstNode = $this->checkFirstNode($std);
$endNode = $this->checkEndNode($std);
if($firstNode==$endNode) {
$this->contents['acY_R'] = $acY_R;
$this->contents['cfgName'] = $this->cfg->cfgClgName;
$this->contents['std'] = $std;
} else {
$this->contents['display_err'] = "<span class='error'>** เกิดความผิดพลาดในการส่งข้อมูลนักศึกษาจากระบบ admission **<br />กรุณากดนำเข้าข้อมูลนักศึกษาใหม่อีกครั้ง</span>";
}
$this->output($this->config->item("rg_folder")."v_showRealStdAd");
}else{
$description.=curl_error($ch);
//print curl_error($ch);
$this->contents['description'] = $description;
$this->contents['acY_R'] = $acY_R;
$this->output($this->config->item("rg_folder")."v_errImportStd");
}
curl_close ($ch);
} else {
$description = "";
if(!$chk_curl) {
$description.= "cURL ";
}
if(!$chk_curl && !$chk_xml) {
$description.= "และ ";
}
if(!$chk_xml) {
$description.= "SimpleXML ";
}
$this->contents['description'] = $description;
$this->contents['acY_R'] = $acY_R;
$this->output($this->config->item("rg_folder")."v_errImportStd");
}
}
function processAddRealStdAd() {
$acY_R = $this->input->post('acY_R');
$this->load->model($this->config->item("rg_folder").'mo_rg_config','cfg');
$this->cfg->get_by_key(TRUE);
//---[]--- start curl function
//$url = "http://admission.pi.in.th/admission/index.php/admisexport/genXMLToRegisCurl";
$xmlStr = $this->cfg->cfgClgCode."|".$acY_R;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlStr);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
$rs = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close ($ch);
//---[]--- end curl function
$std = simplexml_load_string($rs);
//---[]--- เช็คข้อมูลมาครบหรือไม่
$firstNode = $this->checkFirstNode($std);
$endNode = $this->checkEndNode($std);
if($firstNode==$endNode) {
$this->load->model($this->config->item("rg_folder").'mo_rg_realstudentad','stdad');
$this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
$this->load->model($this->config->item("rg_folder").'mo_rg_studentdetails','sdt');
/* ลบ rg_RealStudentDe ที่ยังไม่จับคู่ลักสูตร และยังไม่สร้างรหัส
- rg_RealStudentAd.curId=0
- rg_Student.genStatus=N
&&
- rg_RealStudentAd.curId!=0
- rg_Student.genStatus=N OR genStatus IS NULL
*/
$con_rs_ad = array('app_year' => $acY_R,
'curId' => '0');
$rs_ad = $this->stdad->delStdAd($con_rs_ad);
$rs_addAd = $this->stdad->qryStdAdByCurIdIsNotZeroAndGsIsNOrNullJoinStdSdt();
if($rs_addAd->num_rows()) {
foreach($rs_addAd->result() as $row_addAd) {
$this->std->stdId = $row_addAd->stdId;
$this->std->delete();
$this->sdt->sdtStdId = $row_addAd->stdId;
$this->sdt->delete();
}
}
/* จบลบ rg_RealStudentDe ที่ยังไม่จับคู่ลักสูตร และยังไม่สร้างรหัส */
/*----[]----- start add rg_RealStudenAd */
$i = 0;
$this->db->trans_begin();
foreach($std as $key => $val) {
if($val->app_idcard) { // ตัดหัว-ท้ายออก
$this->stdad->app_year = strval($val->app_year);
$this->stdad->app_idcard = strval($val->app_idcard);
$qu_stdAd = $this->stdad->get_by_key();
if($qu_stdAd->num_rows()==0) {
$this->stdad->app_year = strval($val->app_year);
$this->stdad->app_at_id = intval($val->app_at_id);
$this->stdad->at_name = strval($val->at_name);
$this->stdad->app_type = intval($val->app_type);
$this->stdad->app_sub_type = intval($val->app_sub_type);
$this->stdad->app_pf_id = intval($val->app_pf_id);
$this->stdad->pf_name = strval($val->pf_name);
$this->stdad->app_name = strval($val->app_name);
$this->stdad->app_lname = strval($val->app_lname);
$this->stdad->app_idcard = strval($val->app_idcard);
$this->stdad->app_number = intval($val->app_number);
$this->stdad->ul_email = strval($val->ul_email);
$this->stdad->app_birthday = strval($val->app_birthday);
$this->stdad->app_age = intval($val->app_age);
$this->stdad->app_tall = strval($val->app_tall);
$this->stdad->app_old_name = (strval($val->app_old_name)=='NULL') ? '' : strval($val->app_old_name);
$this->stdad->app_old_lname = (strval($val->app_old_lname)=='NULL') ? '' : strval($val->app_old_lname);
$this->stdad->app_housenum = (strval($val->app_housenum)=='NULL') ? '' : strval($val->app_housenum);
$this->stdad->app_housegrp = (strval($val->app_housegrp)=='NULL') ? '' : strval($val->app_housegrp);
$this->stdad->app_soi = (strval($val->app_soi)=='NULL') ? '' : strval($val->app_soi);
$this->stdad->app_road = (strval($val->app_road)=='NULL') ? '' : strval($val->app_road);
$this->stdad->app_dt_id = intval($val->app_dt_id);
$this->stdad->app_dt_name = strval($val->app_dt_name);
$this->stdad->app_ap_id = intval($val->app_ap_id);
$this->stdad->app_ap_name = strval($val->app_ap_name);
$this->stdad->app_prv_id = intval($val->app_prv_id);
$this->stdad->app_prv_name = strval($val->app_prv_name);
$this->stdad->app_postcode = strval($val->app_postcode);
$this->stdad->app_phone = strval($val->app_phone);
$this->stdad->app_cont_housenum = (strval($val->app_cont_housenum)=='NULL') ? '' : strval($val->app_cont_housenum);
$this->stdad->app_cont_housegrp = (strval($val->app_cont_housegrp)=='NULL') ? '' : strval($val->app_cont_housegrp);
$this->stdad->app_cont_soi = (strval($val->app_cont_soi)=='NULL') ? '' : strval($val->app_cont_soi);
$this->stdad->app_cont_road = (strval($val->app_cont_road)=='NULL') ? '' : strval($val->app_cont_road);
$this->stdad->app_cont_dt_id = intval($val->app_cont_dt_id);
$this->stdad->app_cont_dt_name = (strval($val->app_cont_dt_name)=='NULL') ? '' : strval($val->app_cont_dt_name);
$this->stdad->app_cont_ap_id = intval($val->app_cont_ap_id);
$this->stdad->app_cont_ap_name = (strval($val->app_cont_ap_name)=='NULL') ? '' : strval($val->app_cont_ap_name);
$this->stdad->app_cont_prv_id = intval($val->app_cont_prv_id);
$this->stdad->app_cont_prv_name = (strval($val->app_cont_prv_name)=='NULL') ? '' : strval($val->app_cont_prv_name);
$this->stdad->app_cont_postcode = (strval($val->app_cont_postcode)=='NULL') ? '' : strval($val->app_cont_postcode);
$this->stdad->app_cont_phone = (strval($val->app_cont_phone)=='NULL') ? '' : strval($val->app_cont_phone);
$this->stdad->app_cont_name1 = (strval($val->app_cont_name1)=='NULL') ? '' : strval($val->app_cont_name1);
$this->stdad->app_cont_lname1 = (strval($val->app_cont_lname1)=='NULL') ? '' : strval($val->app_cont_lname1);
$this->stdad->app_cont_phone1 = (strval($val->app_cont_phone1)=='NULL') ? '' : strval($val->app_cont_phone1);
$this->stdad->app_cont_name2 = (strval($val->app_cont_name2)=='NULL') ? '' : strval($val->app_cont_name2);
$this->stdad->app_cont_lname2 = (strval($val->app_cont_lname2)=='NULL') ? '' : strval($val->app_cont_lname2);
$this->stdad->app_cont_phone2 = (strval($val->app_cont_phone2)=='NULL') ? '' : strval($val->app_cont_phone2);
$this->stdad->app_cont_name3 = (strval($val->app_cont_name3)=='NULL') ? '' : strval($val->app_cont_name3);
$this->stdad->app_cont_lname3 = (strval($val->app_cont_lname3)=='NULL') ? '' : strval($val->app_cont_lname3);
$this->stdad->app_cont_phone3 = (strval($val->app_cont_phone3)=='NULL') ? '' : strval($val->app_cont_phone3);
$this->stdad->app_place_interview = intval($val->app_place_interview);
$this->stdad->place_interview = strval($val->place_interview);
$this->stdad->app_score = floatval($val->app_score);
$this->stdad->dt1_ht_id = intval($val->dt1_ht_id);
$this->stdad->ht_name = (strval($val->ht_name)=='NULL') ? '' : strval($val->ht_name);
$this->stdad->dt1_ht_name = (strval($val->dt1_ht_name)=='NULL') ? '' : strval($val->dt1_ht_name);
$this->stdad->dt1_ht_lname = (strval($val->dt1_ht_lname)=='NULL') ? '' : strval($val->dt1_ht_lname);
$this->stdad->dt1_ht_housenum = (strval($val->dt1_ht_housenum)=='NULL') ? '' : strval($val->dt1_ht_housenum);
$this->stdad->dt1_ht_housegrp = (strval($val->dt1_ht_housegrp)=='NULL') ? '' : strval($val->dt1_ht_housegrp);
$this->stdad->dt1_ht_road = (strval($val->dt1_ht_road)=='NULL') ? '' : strval($val->dt1_ht_road);
$this->stdad->dt1_ht_soi = (strval($val->dt1_ht_soi)=='NULL') ? '' : strval($val->dt1_ht_soi);
$this->stdad->dt1_ht_dt_id = intval($val->dt1_ht_dt_id);
$this->stdad->dt1_ht_dt_name = (strval($val->dt1_ht_dt_name)=='NULL') ? '' : strval($val->dt1_ht_dt_name);
$this->stdad->dt1_ht_ap_id = intval($val->dt1_ht_ap_id);
$this->stdad->dt1_ht_ap_name = (strval($val->dt1_ht_ap_name)=='NULL') ? '' : strval($val->dt1_ht_ap_name);
$this->stdad->dt1_ht_prv_id = intval($val->dt1_ht_prv_id);
$this->stdad->dt1_ht_prv_name = (strval($val->dt1_ht_prv_name)=='NULL') ? '' : strval($val->dt1_ht_prv_name);
$this->stdad->dt1_ht_postcode = (strval($val->dt1_ht_postcode)=='NULL') ? '' : strval($val->dt1_ht_postcode);
$this->stdad->dt1_ht_phone = (strval($val->dt1_ht_phone)=='NULL') ? '' : strval($val->dt1_ht_phone);
$this->stdad->dt1_vt_id = intval($val->dt1_vt_id);
$this->stdad->vt_name = (strval($val->vt_name)=='NULL') ? '' : strval($val->vt_name);
$this->stdad->dt1_vt_idcard = (intval($val->dt1_vt_idcard)=='NULL') ? '' : intval($val->dt1_vt_idcard);
$this->stdad->dt1_vt_name = (strval($val->dt1_vt_name)=='NULL') ? '' : strval($val->dt1_vt_name);
$this->stdad->dt1_vt_prv_id = intval($val->dt1_vt_prv_id);
$this->stdad->dt1_vt_prv_name = (strval($val->dt1_vt_prv_name)=='NULL') ? '' : strval($val->dt1_vt_prv_name);
$this->stdad->dt1_scholarship = (strval($val->dt1_scholarship)=='NULL') ? '' : strval($val->dt1_scholarship);
$this->stdad->dt1_childofficial = (strval($val->dt1_childofficial)=='NULL') ? '' : strval($val->dt1_childofficial);
$this->stdad->dt1_year_end = intval($val->dt1_year_end);
$this->stdad->dt1_gpax = floatval($val->dt1_gpax);
$this->stdad->dt21_date_start = strval($val->dt21_date_start);
$this->stdad->dt21_year_end = intval($val->dt21_year_end);
$this->stdad->dt21_gpax = floatval($val->dt21_gpax);
$this->stdad->dt21_vt_level = intval($val->dt21_vt_level);
$this->stdad->vl_name = (strval($val->vl_name)=='NULL') ? '' : strval($val->vl_name);
$this->stdad->dt22_date_start = strval($val->dt22_date_start);
$this->stdad->dt22_post = intval($val->dt22_post);
$this->stdad->pd22_name = (strval($val->pd22_name)=='NULL') ? '' : strval($val->pd22_name);
$this->stdad->dt22_off_idcard = intval($val->dt22_off_idcard);
$this->stdad->dt22_department = (strval($val->dt22_department)=='NULL') ? '' : strval($val->dt22_department);
$this->stdad->dt22_ministry = intval($val->dt22_ministry);
$this->stdad->dt22_ministry_name = (strval($val->dt22_ministry_name)=='NULL') ? '' : strval($val->dt22_ministry_name);
$this->stdad->dt22_year_end = intval($val->dt22_year_end);
$this->stdad->dt22_gpax = floatval($val->dt22_gpax);
$this->stdad->dt23_date_start = strval($val->dt23_date_start);
$this->stdad->dt23_post = intval($val->dt23_post);
$this->stdad->pd23_name = (strval($val->pd23_name)=='NULL') ? '' : strval($val->pd23_name);
$this->stdad->dt23_off_idcard = intval($val->dt23_off_idcard);
$this->stdad->dt23_department = (strval($val->dt23_department)=='NULL') ? '' : strval($val->dt23_department);
$this->stdad->dt23_ministry = intval($val->dt23_ministry);
$this->stdad->dt23_ministry_name = (strval($val->dt23_ministry_name)=='NULL') ? '' : strval($val->dt23_ministry_name);
$this->stdad->dt23_year_end = intval($val->dt23_year_end);
$this->stdad->dt23_gpax = floatval($val->dt23_gpax);
$this->stdad->dt24_date_start = strval($val->dt24_date_start);
$this->stdad->dt24_off_idcard = intval($val->dt24_off_idcard);
$this->stdad->dt24_department = (strval($val->dt24_department)=='NULL') ? '' : strval($val->dt24_department);
$this->stdad->dt24_ministry = intval($val->dt24_ministry);
$this->stdad->dt24_ministry_name = (strval($val->dt24_ministry_name)=='NULL') ? '' : strval($val->dt24_ministry_name);
$this->stdad->dt24_graduate = intval($val->dt24_graduate);
$this->stdad->gd24_name = (strval($val->gd24_name)=='NULL') ? '' : strval($val->gd24_name);
$this->stdad->dt24_year_end = intval($val->dt24_year_end);
$this->stdad->dt24_gpax = floatval($val->dt24_gpax);
$this->stdad->dt25_date_start = strval($val->dt25_date_start);
$this->stdad->dt25_off_idcard = intval($val->dt25_off_idcard);
$this->stdad->dt25_department = (strval($val->dt25_department)=='NULL') ? '' : strval($val->dt25_department);
$this->stdad->dt25_ministry = intval($val->dt25_ministry);
$this->stdad->dt25_ministry_name = (strval($val->dt25_ministry_name)=='NULL') ? '' : strval($val->dt25_ministry_name);
$this->stdad->dt25_graduate = intval($val->dt25_graduate);
$this->stdad->gd25_name = (strval($val->gd25_name)=='NULL') ? '' : strval($val->gd25_name);
$this->stdad->dt25_year_end = intval($val->dt25_year_end);
$this->stdad->dt25_gpax = floatval($val->dt25_gpax);
$this->stdad->dt26_date_start = strval($val->dt26_date_start);
$this->stdad->dt26_off_idcard = intval($val->dt26_off_idcard);
$this->stdad->dt26_department = (strval($val->dt26_department)=='NULL') ? '' : strval($val->dt26_department);
$this->stdad->dt26_ministry = intval($val->dt26_ministry);
$this->stdad->dt26_ministry_name = (strval($val->dt26_ministry_name)=='NULL') ? '' : strval($val->dt26_ministry_name);
$this->stdad->dt26_year_end = intval($val->dt26_year_end);
$this->stdad->dt26_gpax = floatval($val->dt26_gpax);
$this->stdad->itv_prv_id = intval($val->itv_prv_id);
$this->stdad->itv_prv_name = (strval($val->itv_prv_name)=='NULL') ? '' : strval($val->itv_prv_name);
$this->stdad->itv_ap_id = intval($val->itv_ap_id);
$this->stdad->itv_ap_name = (strval($val->itv_ap_name)=='NULL') ? '' : strval($val->itv_ap_name);
$this->stdad->itv_crs_id = intval($val->itv_crs_id);
$this->stdad->crs_name = strval($val->crs_name);
$this->stdad->itv_qt_id = intval($val->itv_qt_id);
$this->stdad->qt_name = strval($val->qt_name);
$this->stdad->itv_clg_id = intval($val->itv_clg_id);
$this->stdad->itv_clg_name = strval($val->itv_clg_name);
$this->stdad->app_result_status = strval($val->app_result_status);
$this->stdad->createUsLogin = $this->session->userdata('UsLogin');
$this->stdad->updateDateTime = date('Y-m-d H:i:s');
$this->stdad->curId = '';
$this->stdad->insert();
} else {
$this->stdad->app_year = strval($val->app_year);
$this->stdad->app_at_id = intval($val->app_at_id);
$this->stdad->at_name = strval($val->at_name);
$this->stdad->app_type = intval($val->app_type);
$this->stdad->app_sub_type = intval($val->app_sub_type);
$this->stdad->app_pf_id = intval($val->app_pf_id);
$this->stdad->pf_name = strval($val->pf_name);
$this->stdad->app_name = strval($val->app_name);
$this->stdad->app_lname = strval($val->app_lname);
$this->stdad->app_idcard = strval($val->app_idcard);
$this->stdad->app_number = intval($val->app_number);
$this->stdad->ul_email = strval($val->ul_email);
$this->stdad->app_birthday = strval($val->app_birthday);
$this->stdad->app_age = intval($val->app_age);
$this->stdad->app_tall = strval($val->app_tall);
$this->stdad->app_old_name = (strval($val->app_old_name)=='NULL') ? '' : strval($val->app_old_name);
$this->stdad->app_old_lname = (strval($val->app_old_lname)=='NULL') ? '' : strval($val->app_old_lname);
$this->stdad->app_housenum = (strval($val->app_housenum)=='NULL') ? '' : strval($val->app_housenum);
$this->stdad->app_housegrp = (strval($val->app_housegrp)=='NULL') ? '' : strval($val->app_housegrp);
$this->stdad->app_soi = (strval($val->app_soi)=='NULL') ? '' : strval($val->app_soi);
$this->stdad->app_road = (strval($val->app_road)=='NULL') ? '' : strval($val->app_road);
$this->stdad->app_dt_id = intval($val->app_dt_id);
$this->stdad->app_dt_name = strval($val->app_dt_name);
$this->stdad->app_ap_id = intval($val->app_ap_id);
$this->stdad->app_ap_name = strval($val->app_ap_name);
$this->stdad->app_prv_id = intval($val->app_prv_id);
$this->stdad->app_prv_name = strval($val->app_prv_name);
$this->stdad->app_postcode = strval($val->app_postcode);
$this->stdad->app_phone = strval($val->app_phone);
$this->stdad->app_cont_housenum = (strval($val->app_cont_housenum)=='NULL') ? '' : strval($val->app_cont_housenum);
$this->stdad->app_cont_housegrp = (strval($val->app_cont_housegrp)=='NULL') ? '' : strval($val->app_cont_housegrp);
$this->stdad->app_cont_soi = (strval($val->app_cont_soi)=='NULL') ? '' : strval($val->app_cont_soi);
$this->stdad->app_cont_road = (strval($val->app_cont_road)=='NULL') ? '' : strval($val->app_cont_road);
$this->stdad->app_cont_dt_id = intval($val->app_cont_dt_id);
$this->stdad->app_cont_dt_name = (strval($val->app_cont_dt_name)=='NULL') ? '' : strval($val->app_cont_dt_name);
$this->stdad->app_cont_ap_id = intval($val->app_cont_ap_id);
$this->stdad->app_cont_ap_name = (strval($val->app_cont_ap_name)=='NULL') ? '' : strval($val->app_cont_ap_name);
$this->stdad->app_cont_prv_id = intval($val->app_cont_prv_id);
$this->stdad->app_cont_prv_name = (strval($val->app_cont_prv_name)=='NULL') ? '' : strval($val->app_cont_prv_name);
$this->stdad->app_cont_postcode = (strval($val->app_cont_postcode)=='NULL') ? '' : strval($val->app_cont_postcode);
$this->stdad->app_cont_phone = (strval($val->app_cont_phone)=='NULL') ? '' : strval($val->app_cont_phone);
$this->stdad->app_cont_name1 = (strval($val->app_cont_name1)=='NULL') ? '' : strval($val->app_cont_name1);
$this->stdad->app_cont_lname1 = (strval($val->app_cont_lname1)=='NULL') ? '' : strval($val->app_cont_lname1);
$this->stdad->app_cont_phone1 = (strval($val->app_cont_phone1)=='NULL') ? '' : strval($val->app_cont_phone1);
$this->stdad->app_cont_name2 = (strval($val->app_cont_name2)=='NULL') ? '' : strval($val->app_cont_name2);
$this->stdad->app_cont_lname2 = (strval($val->app_cont_lname2)=='NULL') ? '' : strval($val->app_cont_lname2);
$this->stdad->app_cont_phone2 = (strval($val->app_cont_phone2)=='NULL') ? '' : strval($val->app_cont_phone2);
$this->stdad->app_cont_name3 = (strval($val->app_cont_name3)=='NULL') ? '' : strval($val->app_cont_name3);
$this->stdad->app_cont_lname3 = (strval($val->app_cont_lname3)=='NULL') ? '' : strval($val->app_cont_lname3);
$this->stdad->app_cont_phone3 = (strval($val->app_cont_phone3)=='NULL') ? '' : strval($val->app_cont_phone3);
$this->stdad->app_place_interview = intval($val->app_place_interview);
$this->stdad->place_interview = strval($val->place_interview);
$this->stdad->app_score = floatval($val->app_score);
$this->stdad->dt1_ht_id = intval($val->dt1_ht_id);
$this->stdad->ht_name = (strval($val->ht_name)=='NULL') ? '' : strval($val->ht_name);
$this->stdad->dt1_ht_name = (strval($val->dt1_ht_name)=='NULL') ? '' : strval($val->dt1_ht_name);
$this->stdad->dt1_ht_lname = (strval($val->dt1_ht_lname)=='NULL') ? '' : strval($val->dt1_ht_lname);
$this->stdad->dt1_ht_housenum = (strval($val->dt1_ht_housenum)=='NULL') ? '' : strval($val->dt1_ht_housenum);
$this->stdad->dt1_ht_housegrp = (strval($val->dt1_ht_housegrp)=='NULL') ? '' : strval($val->dt1_ht_housegrp);
$this->stdad->dt1_ht_road = (strval($val->dt1_ht_road)=='NULL') ? '' : strval($val->dt1_ht_road);
$this->stdad->dt1_ht_soi = (strval($val->dt1_ht_soi)=='NULL') ? '' : strval($val->dt1_ht_soi);
$this->stdad->dt1_ht_dt_id = intval($val->dt1_ht_dt_id);
$this->stdad->dt1_ht_dt_name = (strval($val->dt1_ht_dt_name)=='NULL') ? '' : strval($val->dt1_ht_dt_name);
$this->stdad->dt1_ht_ap_id = intval($val->dt1_ht_ap_id);
$this->stdad->dt1_ht_ap_name = (strval($val->dt1_ht_ap_name)=='NULL') ? '' : strval($val->dt1_ht_ap_name);
$this->stdad->dt1_ht_prv_id = intval($val->dt1_ht_prv_id);
$this->stdad->dt1_ht_prv_name = (strval($val->dt1_ht_prv_name)=='NULL') ? '' : strval($val->dt1_ht_prv_name);
$this->stdad->dt1_ht_postcode = (strval($val->dt1_ht_postcode)=='NULL') ? '' : strval($val->dt1_ht_postcode);
$this->stdad->dt1_ht_phone = (strval($val->dt1_ht_phone)=='NULL') ? '' : strval($val->dt1_ht_phone);
$this->stdad->dt1_vt_id = intval($val->dt1_vt_id);
$this->stdad->vt_name = (strval($val->vt_name)=='NULL') ? '' : strval($val->vt_name);
$this->stdad->dt1_vt_idcard = (intval($val->dt1_vt_idcard)=='NULL') ? '' : intval($val->dt1_vt_idcard);
$this->stdad->dt1_vt_name = (strval($val->dt1_vt_name)=='NULL') ? '' : strval($val->dt1_vt_name);
$this->stdad->dt1_vt_prv_id = intval($val->dt1_vt_prv_id);
$this->stdad->dt1_vt_prv_name = (strval($val->dt1_vt_prv_name)=='NULL') ? '' : strval($val->dt1_vt_prv_name);
$this->stdad->dt1_scholarship = (strval($val->dt1_scholarship)=='NULL') ? '' : strval($val->dt1_scholarship);
$this->stdad->dt1_childofficial = (strval($val->dt1_childofficial)=='NULL') ? '' : strval($val->dt1_childofficial);
$this->stdad->dt1_year_end = intval($val->dt1_year_end);
$this->stdad->dt1_gpax = floatval($val->dt1_gpax);
$this->stdad->dt21_date_start = strval($val->dt21_date_start);
$this->stdad->dt21_year_end = intval($val->dt21_year_end);
$this->stdad->dt21_gpax = floatval($val->dt21_gpax);
$this->stdad->dt21_vt_level = intval($val->dt21_vt_level);
$this->stdad->vl_name = (strval($val->vl_name)=='NULL') ? '' : strval($val->vl_name);
$this->stdad->dt22_date_start = strval($val->dt22_date_start);
$this->stdad->dt22_post = intval($val->dt22_post);
$this->stdad->pd22_name = (strval($val->pd22_name)=='NULL') ? '' : strval($val->pd22_name);
$this->stdad->dt22_off_idcard = intval($val->dt22_off_idcard);
$this->stdad->dt22_department = (strval($val->dt22_department)=='NULL') ? '' : strval($val->dt22_department);
$this->stdad->dt22_ministry = intval($val->dt22_ministry);
$this->stdad->dt22_ministry_name = (strval($val->dt22_ministry_name)=='NULL') ? '' : strval($val->dt22_ministry_name);
$this->stdad->dt22_year_end = intval($val->dt22_year_end);
$this->stdad->dt22_gpax = floatval($val->dt22_gpax);
$this->stdad->dt23_date_start = strval($val->dt23_date_start);
$this->stdad->dt23_post = intval($val->dt23_post);
$this->stdad->pd23_name = (strval($val->pd23_name)=='NULL') ? '' : strval($val->pd23_name);
$this->stdad->dt23_off_idcard = intval($val->dt23_off_idcard);
$this->stdad->dt23_department = (strval($val->dt23_department)=='NULL') ? '' : strval($val->dt23_department);
$this->stdad->dt23_ministry = intval($val->dt23_ministry);
$this->stdad->dt23_ministry_name = (strval($val->dt23_ministry_name)=='NULL') ? '' : strval($val->dt23_ministry_name);
$this->stdad->dt23_year_end = intval($val->dt23_year_end);
$this->stdad->dt23_gpax = floatval($val->dt23_gpax);
$this->stdad->dt24_date_start = strval($val->dt24_date_start);
$this->stdad->dt24_off_idcard = intval($val->dt24_off_idcard);
$this->stdad->dt24_department = (strval($val->dt24_department)=='NULL') ? '' : strval($val->dt24_department);
$this->stdad->dt24_ministry = intval($val->dt24_ministry);
$this->stdad->dt24_ministry_name = (strval($val->dt24_ministry_name)=='NULL') ? '' : strval($val->dt24_ministry_name);
$this->stdad->dt24_graduate = intval($val->dt24_graduate);
$this->stdad->gd24_name = (strval($val->gd24_name)=='NULL') ? '' : strval($val->gd24_name);
$this->stdad->dt24_year_end = intval($val->dt24_year_end);
$this->stdad->dt24_gpax = floatval($val->dt24_gpax);
$this->stdad->dt25_date_start = strval($val->dt25_date_start);
$this->stdad->dt25_off_idcard = intval($val->dt25_off_idcard);
$this->stdad->dt25_department = (strval($val->dt25_department)=='NULL') ? '' : strval($val->dt25_department);
$this->stdad->dt25_ministry = intval($val->dt25_ministry);
$this->stdad->dt25_ministry_name = (strval($val->dt25_ministry_name)=='NULL') ? '' : strval($val->dt25_ministry_name);
$this->stdad->dt25_graduate = intval($val->dt25_graduate);
$this->stdad->gd25_name = (strval($val->gd25_name)=='NULL') ? '' : strval($val->gd25_name);
$this->stdad->dt25_year_end = intval($val->dt25_year_end);
$this->stdad->dt25_gpax = floatval($val->dt25_gpax);
$this->stdad->dt26_date_start = strval($val->dt26_date_start);
$this->stdad->dt26_off_idcard = intval($val->dt26_off_idcard);
$this->stdad->dt26_department = (strval($val->dt26_department)=='NULL') ? '' : strval($val->dt26_department);
$this->stdad->dt26_ministry = intval($val->dt26_ministry);
$this->stdad->dt26_ministry_name = (strval($val->dt26_ministry_name)=='NULL') ? '' : strval($val->dt26_ministry_name);
$this->stdad->dt26_year_end = intval($val->dt26_year_end);
$this->stdad->dt26_gpax = floatval($val->dt26_gpax);
$this->stdad->itv_prv_id = intval($val->itv_prv_id);
$this->stdad->itv_prv_name = (strval($val->itv_prv_name)=='NULL') ? '' : strval($val->itv_prv_name);
$this->stdad->itv_ap_id = intval($val->itv_ap_id);
$this->stdad->itv_ap_name = (strval($val->itv_ap_name)=='NULL') ? '' : strval($val->itv_ap_name);
$this->stdad->itv_crs_id = intval($val->itv_crs_id);
$this->stdad->crs_name = strval($val->crs_name);
$this->stdad->itv_qt_id = intval($val->itv_qt_id);
$this->stdad->qt_name = strval($val->qt_name);
$this->stdad->itv_clg_id = intval($val->itv_clg_id);
$this->stdad->itv_clg_name = strval($val->itv_clg_name);
$this->stdad->app_result_status = strval($val->app_result_status);
$this->stdad->createUsLogin = $this->session->userdata('UsLogin');
$this->stdad->updateDateTime = date('Y-m-d H:i:s');
$this->stdad->curId = $qu_stdAd->row()->curId;
$this->stdad->update();
}
$i++;
}
}
if($this->db->trans_status() === false) {
$this->db->trans_rollback();
} else {
$this->db->trans_commit();
}
/*----[]----- end add rg_RealStudenAd */
redirect($this->config->item("rg_folder")."import/showAfterAddRealStdAd");
} else {
$this->output($this->config->item("rg_folder")."v_errImportStdNoEqual");
}
}
function showAfterAddRealStdAd() {
$this->output($this->config->item("rg_folder")."v_showMatchCur");
}
function processMatchingCur() {
$this->load->model($this->config->item("rg_folder").'mo_rg_realstudentad','stdad');
$this->load->model($this->config->item("rg_folder").'mo_rg_curriculum','cur');
$acY_R = $this->session->userdata('acY_R');
$this->contents['acY_R'] = $acY_R;
$this->contents['crsAd'] = $this->stdad->qryStdAdByAppYearGrpItvCrsId($acY_R);
$con_curRg = array('curStatus' => 'Y');
$ord_curRg = array('curName' => '');
$this->contents['curRg'] = $this->cur->get_options($con_curRg,$ord_curRg,'','---เลือกหลักสูตรของวิทยาลัย---');
/*---- หลักสูตรที่ไม่ได้กำหนดรุ่น -------*/
$this->contents['noGs'] = $this->stdad->qryBySyNameAndNoGs($acY_R);
//Debug($this->contents);
//die();
/*---- จับคู่หลักสูตรให้ นักศึกษาครบแล้ว -------*/
$con_noMatch = array('app_year' => $acY_R,
'curId' => '0',
'app_result_status' => 'Y');
//Debug($con_noMatch);
//$noMatch = $this->stdad->qryBySyNameAndNoGs($acY_R);
$noMatch = $this->stdad->qryRealStdAd($con_noMatch);
//Debug($noMatch);
$this->contents['noMatch'] = $noMatch->num_rows();
//Debug($this->db->queries);
//echo "<hr>".$this->config->item("rg_folder")."v_showMatchingCur";
//die();
$this->output($this->config->item("rg_folder")."v_showMatchingCur");
}
function showListStdAdMatching($crsAd) {
header("Content-type: charset=utf-8");
$this->load->model($this->config->item("rg_folder").'mo_rg_realstudentad','stdad');
$this->load->model($this->config->item("rg_folder").'mo_rg_config','cfg');
$acY_R = $this->session->userdata('acY_R');
$con_rs_stdAd = array('app_year' => $acY_R,
'itv_crs_id' => $crsAd
);
$ord_rs_stdAd = array('app_name' => '',
'app_lname' => '');
$data['rs_stdAd'] = $this->stdad->qryRealStdAdJoinCur($con_rs_stdAd, $ord_rs_stdAd);
$data['qu_cfg'] = $this->cfg->qryCfg();
$data['acY_R'] = $acY_R;
//Debug($this->db->queries);
//die();
echo $this->load->view($this->config->item("rg_folder")."v_showListStdAdMatching", $data, TRUE);
}
function processSaveMatchingCur() {
$crsAd = $this->input->post('crsAd');
$curRg = $this->input->post('curRg');
$cnt = $this->input->post('cnt');
$acY_R = $this->input->post('acY_R');
$add = $this->input->post('add');
$this->load->model($this->config->item("rg_folder").'mo_rg_realstudentad','stdad');
if($add) {
$this->load->library('form_validation');
$this->form_validation->set_error_delimiters('<div class="error">','</div>');
$this->form_validation->set_rules('crsAd',' ','trim|required|xss_clean');
$this->form_validation->set_rules('curRg',' ','trim|required|xss_clean');
$this->form_validation->set_rules('cnt',' ','trim|xss_clean');
$this->form_validation->set_rules('acY_R',' ','trim|xss_clean');
// for($i=0; $i<$cnt; $i++) {
// $this->form_validation->set_rules('chk'.$i,' ','trim|xss_clean');
// }
if($this->form_validation->run() == true) {
$this->db->trans_begin();
for($i=0; $i<$cnt; $i++) {
$chk = $this->input->post('chk'.$i);
$citizen = $this->input->post('citizenId'.$i);
if($chk=='Y') {
$this->stdad->app_year = $acY_R;
$this->stdad->app_idcard = $citizen;
$this->stdad->get_by_key(TRUE);
$this->stdad->curId = $curRg;
$this->stdad->createUsLogin = $this->session->userdata('UsLogin');
$this->stdad->updateDateTime = date('Y-m-d H:i:s');
$this->stdad->update();
}
}
if($this->db->trans_status() === false) {
$this->db->trans_rollback();
} else {
$this->db->trans_commit();
}
//$this->processMatchingCur();
redirect($this->config->item("rg_folder")."import/processMatchingCur");
} else {
$this->processMatchingCur();
}
} else {
$this->stdad->setStdAdByCurIdIs0($acY_R, $crsAd);
redirect($this->config->item("rg_folder")."import/processMatchingCur");
}
}
function processConfirmMatchCur() {
$this->load->model($this->config->item("rg_folder").'mo_rg_realstudentad','stdad');
$acY_R = ($this->input->post('acY_')) ? $this->input->post('acY_') : $this->session->userdata('acY_R');
$this->contents['acY_R'] = $acY_R;
/*---[]--- return array 3d
std[i][j][crsAd]
std[i][j][curRg]
std[i][j][std]
*/
$this->contents['show_std'] = $this->stdad->qryStdAdForConfirmImpToRg($acY_R);
//Debug($this->db->queries);
$this->output($this->config->item("rg_folder")."v_showConfirmMatchCur");
}
function processAddStdAndSdt() {
$this->load->model($this->config->item("rg_folder").'mo_rg_realstudentad','stdad');
$this->load->model($this->config->item("rg_folder").'mo_rg_student','std');
$this->load->model($this->config->item("rg_folder").'mo_rg_studentdetails','sdt');
$this->load->model($this->config->item("rg_folder").'mo_rg_generation','gen');
$this->load->model($this->config->item("rg_folder").'mo_rg_termconfig','tmc');
$this->load->model($this->config->item("ppc_folder").'mo_prefix','pf');
$acY_R = $this->input->post('acY_R');
//---[]--- find admitdate of acY_R
$qu_tmc = $this->tmc->getMinToDateByAcY($acY_R);
//---[]--- find curriculum will add
$con_curId = array('app_year' => $acY_R);
$curId = $this->stdad->qryStdDistinctGsByCurId($con_curId);
//$this->db->trans_begin();
if($curId->num_rows()) {
foreach($curId->result() as $row_curId) {
//----[o]---- find gen studentcode yet?
$con_gs = array('stdCurId' => $row_curId->curId,
'stdAdY' => $acY_R);
$gs = $this->std->qryStdGroupGS($con_gs);
//----[x]---- find generation number
//----[o]---- find generation number
$con_qu_gen = array('genCurId' => $row_curId->curId,
'genTmId' => 1,
'genAcY' => $acY_R);
$qu_gen = $this->gen->qryGen($con_qu_gen);
//----[x]---- find generation number
$con_rs_stdad = array('curId' => $row_curId->curId,
'app_year' => $acY_R,
'app_result_status' => 'Y');
$ord_rs_stdad = array('app_name' => '',
'app_lname' => '');
$rs_stdad = $this->stdad->qryRealStdAd($con_rs_stdad, $ord_rs_stdad);
if($rs_stdad->num_rows()) {
foreach($rs_stdad->result() as $row_std) {
//----[o]---- duplicate student
$con_dupStd = array('sdtCitizenId' => $row_std->app_idcard,
'stdAdY' => $acY_R);
$dupStd = $this->std->qryStdJoinSdt($con_dupStd);
if($dupStd->num_rows()==0) {
//----[o]---- find stdCode
if($gs=='Y') {
$stdCode = $this->std->GetNextStdCode($con_gs);
} else {
$stdCode = NULL;
}
//----[x]---- find stdCode
//----[o]---- find prefix
$con_qu_pf = array('prefixName' => $row_std->pf_name);
$qu_pf = $this->pf->qryPf($con_qu_pf);
//----[x]---- find prefix
$this->std->stdId = '';
$this->std->stdCode = $stdCode;
$this->std->stdName = $row_std->app_name;
$this->std->stdNameE = '';
$this->std->stdSurname = $row_std->app_lname;
$this->std->stdSurnameE = '';
$this->std->stdCreditAttempt = 0;
$this->std->stdCreditSatisfy = 0;
$this->std->stdGPA = 0;
$this->std->stdAdY = $acY_R;
$this->std->stdAdmitDate = $qu_tmc;
$this->std->stdGraduateY = 0;
$this->std->stdGraduateDate = '0000-00-00';
$this->std->stdTotalPoint = 100;
$this->std->stdExitExam = 'N';
$this->std->stdHonor = '';
$this->std->stdMedal = '';
$this->std->stdGenStatus = $gs;
$this->std->stdPfId = $qu_pf->row()->prefixId;
$this->std->stdCurId = $row_std->curId;
$this->std->stdTmIdAdmit = 1;
$this->std->stdSyId = 1;
$this->std->stdSstId = 1;
$this->std->stdGenId = $qu_gen->row()->genId;
$this->std->stdEtId = 1;
$this->std->stdEt2Id = 1;
$this->std->stdPaId = NULL;
$this->std->stdSoId = 1;
$this->std->stdFsId = 1;
$this->std->stdSstIdTmp = 1;
$this->std->stdUpdateDate = date('Y-m-d H:i:s');
$this->std->stdUpdateUsLogin = $this->session->userdata('UsLogin');
$this->std->insert();
$this->sdt->sdtStdId = $this->std->last_insert_id();
$this->sdt->sdtOldName = $row_std->app_old_name.' '.$row_std->app_old_lname;
$this->sdt->sdtSex = $qu_pf->row()->defaultSex;
$this->sdt->sdtCitizenId = $row_std->app_idcard;
$this->sdt->sdtBirthDate = $row_std->app_birthday;
$this->sdt->sdtBloodGroup = '';
$this->sdt->sdtCardExpireDate = '0000-00-00';
$this->sdt->sdtEmail = $row_std->ul_email;
$this->sdt->sdtWeight = 0;
$this->sdt->sdtHeight = 0;
$this->sdt->sdtPicturePath = 'photo.jpg';
$this->sdt->sdtCanRefund = 'N';
$this->sdt->sdtOccExamResult = '';
// ภูมิลำเนาที่ใช้สมัคร 1:ที่อยู่ตามภูมิลำเนาตนเอง
if($row_std->dt1_ht_id==1) {
$this->sdt->sdtHomeAddr = $row_std->dt1_ht_housenum.' ม.'.$row_std->dt1_ht_housegrp.' ถ.'.$row_std->dt1_ht_road.' ซ.'.$row_std->dt1_ht_soi;
$this->sdt->sdtHomePostCode = $row_std->dt1_ht_postcode;
$this->sdt->sdtHomePhoneNo = $row_std->dt1_ht_phone;
$this->sdt->sdtDtIdHome = $row_std->dt1_ht_dt_id;
$this->sdt->sdtApIdHome = $row_std->dt1_ht_ap_id;
$this->sdt->sdtPrvIdHome = $row_std->dt1_ht_prv_id;
} else {
$this->sdt->sdtHomeAddr = '';
$this->sdt->sdtHomePostCode = '';
$this->sdt->sdtHomePhoneNo = '';
$this->sdt->sdtDtIdHome = NULL;
$this->sdt->sdtApIdHome = NULL;
$this->sdt->sdtPrvIdHome = NULL;
}
// ที่อยู่ปัจจุบัน: Current address
$this->sdt->sdtCurrentAddr = $row_std->app_cont_housenum.' ม.'.$row_std->app_cont_housegrp.' ซ.'.$row_std->app_cont_soi.' ถ.'.$row_std->app_cont_road;
$this->sdt->sdtCurrentPostCode = $row_std->app_cont_postcode;
$this->sdt->sdtCurrentPhoneNo = $row_std->app_cont_phone;
$this->sdt->sdtDtIdCurrent = $row_std->app_cont_dt_id;
$this->sdt->sdtApIdCurrent = $row_std->app_cont_ap_id;
$this->sdt->sdtPrvIdCurrent = $row_std->app_cont_prv_id;
// ที่อยู่ที่ทำงาน
$this->sdt->sdtWorkName = '';
$this->sdt->sdtWorkAddr = '';
$this->sdt->sdtWorkPostCode = '';
$this->sdt->sdtWorkPhoneNo = '';
$this->sdt->sdtWorkPosition = '';
$this->sdt->sdtWorkSalary = 0;
$this->sdt->sdtWorkStatus = '';
$this->sdt->sdtDtIdWork = NULL;
$this->sdt->sdtApIdWork = NULL;
$this->sdt->sdtPrvIdWork = NULL;
// ภูมิลำเนาที่ใช้สมัคร 2:ที่อยู่ของบิดา
if($row_std->dt1_ht_id==2) {
$this->sdt->sdtFatherName = $row_std->dt1_ht_name;
$this->sdt->sdtFatherSurname = $row_std->dt1_ht_lname;
$this->sdt->sdtFatherAddr = $row_std->dt1_ht_housenum.' ม.'.$row_std->dt1_ht_housegrp.' ถ.'.$row_std->dt1_ht_road.' ซ.'.$row_std->dt1_ht_soi;
$this->sdt->sdtFatherPostCode = $row_std->dt1_ht_postcode;
$this->sdt->sdtFatherPhoneNo = $row_std->dt1_ht_phone;
$this->sdt->sdtDtIdFather = $row_std->dt1_ht_dt_id;
$this->sdt->sdtApIdFather = $row_std->dt1_ht_ap_id;
$this->sdt->sdtPrvIdFather = $row_std->dt1_ht_prv_id;
} else {
$this->sdt->sdtFatherName = '';
$this->sdt->sdtFatherSurname = '';
$this->sdt->sdtFatherAddr = '';
$this->sdt->sdtFatherPostCode = '';
$this->sdt->sdtFatherPhoneNo = '';
$this->sdt->sdtDtIdFather = NULL;
$this->sdt->sdtApIdFather = NULL;
$this->sdt->sdtPrvIdFather = NULL;
}
$this->sdt->sdtFatherOccupation = '';
$this->sdt->sdtFatherStatus = 0;
// ภูมิลำเนาที่ใช้สมัคร 3:ที่อยู่ของมารดา
if($row_std->dt1_ht_id==3) {
$this->sdt->sdtMotherName = $row_std->dt1_ht_name;
$this->sdt->sdtMotherSurname = $row_std->dt1_ht_lname;
$this->sdt->sdtMotherAddr = $row_std->dt1_ht_housenum.' ม.'.$row_std->dt1_ht_housegrp.' ถ.'.$row_std->dt1_ht_road.' ซ.'.$row_std->dt1_ht_soi;
$this->sdt->sdtMotherPostCode = $row_std->dt1_ht_postcode;
$this->sdt->sdtMotherPhoneNo = $row_std->dt1_ht_phone;
$this->sdt->sdtDtIdMother = $row_std->dt1_ht_dt_id;
$this->sdt->sdtApIdMother = $row_std->dt1_ht_ap_id;
$this->sdt->sdtPrvIdMother = $row_std->dt1_ht_prv_id;
} else {
$this->sdt->sdtMotherName = '';
$this->sdt->sdtMotherSurname = '';
$this->sdt->sdtMotherAddr = '';
$this->sdt->sdtMotherPostCode = '';
$this->sdt->sdtMotherPhoneNo = '';
$this->sdt->sdtDtIdMother = NULL;
$this->sdt->sdtApIdMother = NULL;
$this->sdt->sdtPrvIdMother = NULL;
}
$this->sdt->sdtMotherOccupation = '';
$this->sdt->sdtMotherStatus = 0;
// ภูมิลำเนาที่ใช้สมัคร 4:ผู้ปกครอง
$this->sdt->sdtPfIdParent = NULL;
if($row_std->dt1_ht_id==4) {
$this->sdt->sdtParentName = $row_std->dt1_ht_name;
$this->sdt->sdtParentSurname = $row_std->dt1_ht_lname;
$this->sdt->sdtParentAddr = $row_std->dt1_ht_housenum.' ม.'.$row_std->dt1_ht_housegrp.' ถ.'.$row_std->dt1_ht_road.' ซ.'.$row_std->dt1_ht_soi;
$this->sdt->sdtParentPostCode = $row_std->dt1_ht_postcode;
$this->sdt->sdtParentPhoneNo = $row_std->dt1_ht_phone;
$this->sdt->sdtParentMobileNo = $row_std->dt1_ht_phone;
$this->sdt->sdtDtIdParent = $row_std->dt1_ht_dt_id;
$this->sdt->sdtApIdParent = $row_std->dt1_ht_ap_id;
$this->sdt->sdtPrvIdParent = $row_std->dt1_ht_prv_id;
} else {
$this->sdt->sdtParentName = '';
$this->sdt->sdtParentSurname = '';
$this->sdt->sdtParentAddr = '';
$this->sdt->sdtParentPostCode = '';
$this->sdt->sdtParentPhoneNo = '';
$this->sdt->sdtParentMobileNo = '';
$this->sdt->sdtDtIdParent = NULL;
$this->sdt->sdtApIdParent = NULL;
$this->sdt->sdtPrvIdParent = NULL;
}
$this->sdt->sdtParentRelationship = '';
$this->sdt->sdtParentEmail = '';
$this->sdt->sdtParentOccupation = '';
$this->sdt->sdtParentIncome = 0;
// ที่อยู่ที่ติดต่อได้: Contact address นำเข้าเด็กทุกคน
$this->sdt->sdtContactName = $row_std->app_cont_name1.' '.$row_std->app_cont_lname1;
$this->sdt->sdtContactAddr = $row_std->app_cont_housenum.' ม.'.$row_std->app_cont_housegrp.' ซ.'.$row_std->app_cont_soi.' ถ.'.$row_std->app_cont_road;
$this->sdt->sdtContactPostCode = $row_std->app_cont_postcode;
$this->sdt->sdtContactPhoneNo = $row_std->app_cont_phone;
$this->sdt->sdtDtIdContact = $row_std->app_cont_dt_id;
$this->sdt->sdtApIdContact = $row_std->app_cont_ap_id;
$this->sdt->sdtPrvIdContact = $row_std->app_cont_prv_id;
$this->sdt->sdtGraduateAddr = '';
$this->sdt->sdtGraduatePostCode = '';
$this->sdt->sdtGraduatePhoneNo = '';
$this->sdt->sdtDtIdGraduate = NULL;
$this->sdt->sdtApIdGraduate = NULL;
$this->sdt->sdtPrvIdGraduate = NULL;
$this->sdt->sdtPrvIdBirth = NULL;
$this->sdt->sdtCntId = NULL;
$this->sdt->sdtNtId = NULL;
$this->sdt->sdtRlgId = NULL;
$this->sdt->sdtMsId = NULL;
$this->sdt->sdtRtId = NULL;
$this->sdt->sdtHpId = NULL;
$this->sdt->sdtEdgIdPre = NULL;
$this->sdt->insert();
} else {
// update เลขบัตรประชาชน
$StudentDetail = $dupStd->result();
$this->sdt->UpdateSdtCitizen($StudentDetail[0]->stdId,$row_std->app_idcard);
}
}
}
}
}
//---[]--- ลบข้อมูลเด็กที่สละสิทธิ์ออก
$con_rs_stdad = array('app_result_status' => 'N',
'app_year' => $acY_R);
$rs_stdad = $this->stdad->qryStdAdJoinStdSdt($con_rs_stdad);
if($rs_stdad->num_rows()) {
foreach($rs_stdad->result() as $row_stdad) {
$this->sdt->sdtStdId = $row_stdad->stdId;
$this->std->stdId = $row_stdad->stdId;
$this->sdt->delete();
$this->std->delete();
}
}
/*Debug($this->db->queries);
echo "<hr>next<hr>";
Debug($this->config->item("rg_folder")."import/processConfirmMatchCur");
die();*/
/*
if($this->db->trans_status() === false) {
$this->db->trans_rollback();
} else {
$this->db->trans_commit();
}
*/
redirect($this->config->item("rg_folder")."import/processConfirmMatchCur");
}
}
?>
|