Viewing file: mo_rg_realstudentad.php (7 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
include_once("da_rg_RealStudentAd.php");
class Mo_rg_realstudentad extends Da_rg_RealStudentAd {
/**
* หน้าที่ของฟังก์ชั่น คือ หาข้อมูลนักศึกษาจากระบบ admission
*
* @access public
* @param array condition โดยรูปแบบของ array จะอยู่ในรูป condition('key' => value) ไว้สำหรับระบุเงื่อนไขของคำสั่ง SELECT
* @param array order โดยรูปแบบของ array จะอยู่ในรูป condition('key' => value) ไว้สำหรับระบุเงื่อนไขการเรียงลำดับ ORDER BY
* @param array group โดยรูปแบบของ array จะอยู่ในรูป condition('key' => value) ไว้สำหรับระบุเงื่อนไขการจัดกลุ่ม GROUP BY
* @return query >= 1 rows : rg_RealStudentAd.*
*/
public function qryRealStdAd($condition="",$order="",$group="") {
$where = $this->checkCondition($condition);
$order = $this->checkOrderBy($order);
$group = $this->checkGroupBy($group);
$c1 = substr($where, 0, -3);
$c2 = substr($order, 0, -1);
$c3 = substr($group, 0, -1);
$sql = "SELECT *
FROM $this->rg_dbname.rg_RealStudentAd
$c1
$c2
$c3";
$query = $this->db->query($sql);
return $query;
}
/**
* หน้าที่ของฟังก์ชั่น คือ ลบข้อมูลนักศึกษาจากระบบ admission
*
* @access public
* @param array condition โดยรูปแบบของ array จะอยู่ในรูป condition('key' => value) ไว้สำหรับระบุเงื่อนไขของคำสั่ง SELECT
* @return query >= 1 rows : rg_RealStudentAd.*
*/
public function delStdAd($condition="") {
$where = $this->checkCondition($condition);
$c1 = substr($where, 0, -3);
$sql = "DELETE
FROM $this->rg_dbname.rg_RealStudentAd
$c1";
$query = $this->db->query($sql);
return $query;
}
function qryStdAdByCurIdIsNotZeroAndGsIsNOrNullJoinStdSdt() {
$sql = "SELECT *
FROM $this->rg_dbname.rg_RealStudentAd
LEFT JOIN $this->rg_dbname.rg_Student ON app_year=stdAdY AND app_name=stdName AND app_lname=stdSurname
LEFT JOIN $this->rg_dbname.rg_StudentDetails ON app_idcard=sdtCitizenId AND stdId=sdtStdId
WHERE curId!=0
AND stdGenStatus='N'
OR stdGenStatus IS NULL";
$query = $this->db->query($sql);
return $query;
}
function qryStdAdByAppYearGrpItvCrsId($app_year) {
$sql = "SELECT itv_crs_id, crs_name
FROM $this->rg_dbname.rg_RealStudentAd
WHERE app_year=?
GROUP BY itv_crs_id";
$query = $this->db->query($sql, array($app_year));
$opt[''] = '---เลือกหลักสูตรจากระบบ Admission----';
foreach($query->result() as $row) {
$opt[$row->itv_crs_id] = $row->crs_name;
}
return $opt;
}
public function qryRealStdAdJoinCur($condition="",$order="",$group="") {
$where = $this->checkCondition($condition);
$order = $this->checkOrderBy($order);
$group = $this->checkGroupBy($group);
$c1 = substr($where, 0, -3);
$c2 = substr($order, 0, -1);
$c3 = substr($group, 0, -1);
$sql = "SELECT *
FROM $this->rg_dbname.rg_RealStudentAd ad
LEFT JOIN $this->rg_dbname.rg_Curriculum cur ON ad.curId=cur.curId
$c1
$c2
$c3";
$query = $this->db->query($sql);
return $query;
}
public function qryBySyNameAndNoGs($app_year) {
$sql = "SELECT * FROM
(SELECT curId
FROM $this->rg_dbname.rg_RealStudentAd
WHERE app_year=?
AND curId!=0
GROUP BY curId) AS T1
LEFT JOIN $this->rg_dbname.rg_Curriculum cur ON T1.curId=cur.curId
LEFT JOIN $this->rg_dbname.rg_Generation gen ON gen.genCurId=T1.curId AND genAcY=? AND genTmId=1
WHERE gen.genId IS NULL";
$query = $this->db->query($sql, array($app_year, $app_year));
return $query;
}
public function qryStdAdForConfirmImpToRg($app_year) {
$arr = array();
$sql_grp_crsAd = "SELECT itv_crs_id, crs_name
FROM $this->rg_dbname.rg_RealStudentAd
WHERE app_year=?
GROUP BY itv_crs_id";
$crsAd = $this->db->query($sql_grp_crsAd, array($app_year));
if($crsAd->num_rows()) {
$i = 0;
foreach($crsAd->result() as $row_crsAd) {
$sql_grp_curId = "SELECT *
FROM $this->rg_dbname.rg_RealStudentAd ad
LEFT JOIN $this->rg_dbname.rg_Curriculum cur ON ad.curId=cur.curId
WHERE app_year=?
AND itv_crs_id=?
GROUP BY ad.curId";
$curRg = $this->db->query($sql_grp_curId, array($app_year, $row_crsAd->itv_crs_id));
if($curRg->num_rows()) {
$j = 0;
foreach($curRg->result() as $row_curRg) {
$sql_std = "SELECT *
FROM $this->rg_dbname.rg_RealStudentAd ad
LEFT JOIN $this->rg_dbname.rg_Curriculum cur ON ad.curId=cur.curId
WHERE app_year=?
AND itv_crs_id=?
AND app_result_status='Y'
ORDER BY CONVERT(app_name USING TIS620),
CONVERT(app_lname USING TIS620)";
$std = $this->db->query($sql_std, array($app_year, $row_crsAd->itv_crs_id));
$arr[$i][$j]['crsAd'] = $row_crsAd;
$arr[$i][$j]['curRg'] = $row_curRg;
$arr[$i][$j]['std'] = $std;
$j++;
}
}
$i++;
}
}
return $arr;
}
function qryStdAdNotInStdAndSdt($app_year) {
$sql = "SELECT *
FROM $this->rg_dbname.rg_RealStudentAd
LEFT JOIN rg_StudentDetails ON app_idcard=sdtCitizenId
LEFT JOIN rg_Student ON sdtStdId=stdId
WHERE stdId IS NULL
AND app_year=?";
$query = $this->db->query($sql, array($app_year));
return $query;
}
function setStdAdByCurIdIs0($app_year, $itv_crs_id) {
$sql = "UPDATE
$this->rg_dbname.rg_RealStudentAd
SET curId=0
WHERE app_year=?
AND itv_crs_id=?";
$query = $this->db->query($sql, array($app_year, $itv_crs_id));
return $query;
}
function qryStdDistinctGsByCurId($condition="") {
$where = $this->checkCondition($condition);
$c1 = substr($where, 0, -3);
$sql = "SELECT DISTINCT(curId)
FROM $this->rg_dbname.rg_RealStudentAd
WHERE curId";
$query = $this->db->query($sql, array($sql));
return $query;
}
function qryStdAdJoinStdSdt($condition="",$order="",$group="") {
$where = $this->checkCondition($condition);
$order = $this->checkOrderBy($order);
$group = $this->checkGroupBy($group);
$c1 = substr($where, 0, -3);
$c2 = substr($order, 0, -1);
$c3 = substr($group, 0, -1);
$sql = "SELECT *
FROM $this->rg_dbname.rg_RealStudentAd
INNER JOIN $this->rg_dbname.rg_StudentDetails ON app_idcard=sdtCitizenId
INNER JOIN $this->rg_dbname.rg_Student ON sdtStdId=stdId
$c1
$c3
$c2";
$query = $this->db->query($sql, array($sql));
return $query;
}
}
?>
|