Viewing file: 2552-12-09-1.0.04-clsDefineAssessment.php (17.25 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
//--Class DefineAssessment--------------------------
//--PK of DefineAssessment ::
// 1. defineid
// 2. acadYear
// 3. semester
// 4. noAss
class DefineAssessment extends clsDB{
var $result;
var $defineid;
var $assid;
var $startDate;
var $endDate;
var $acadYear;
var $semester;
var $noAss;
var $flag;
var $closeDate;
var $isPreAssess;
function DefineAssessment(&$c){
$this->c=$c->c;
$this->DB=$c->db;
}
function Save(){
//--ข้อมูลในอ๊อบเจ๊กเป็นข้อมูลใหม่หรือข้อมูลเดิม --1:ข้อมูลใหม่ 2:ข้อมูลเดิม
if ($this->status==1){
//uncomment a line below if your table use ID as running number
$this->defineid=$this->GetNextCode();
$sql = "insert into DefineAssessment values(
'$this->defineid',
'$this->assid',
'$this->startDate',
'$this->endDate',
'$this->acadYear',
'$this->semester',
'$this->noAss',
'$this->flag',
'$this->closeDate',
'$this->isPreAssess'
)";
}else {
$sql = "update DefineAssessment set
assid='$this->assid',
startDate='$this->startDate',
endDate='$this->endDate',
flag='$this->flag',
closeDate='$this->closeDate',
isPreAssess='$this->isPreAssess'
where defineid='$this->defineid' and acadYear='$this->acadYear' and semester='$this->semester' and noAss='$this->noAss'";
}
return $this->Dml($sql);
}
function Delete(){
//--ลบข้อมูลเดิมในอ๊อบเจ๊ก, เป็นการลบข้อมูลทีละ 1 เรคอร์ด
//--ต้องเรียกเมธอดตามลำดับดังนี้ SearchByKey()-->GetRecord()-->Delete()
return $this->Dml("delete from DefineAssessment where defineid='$this->defineid' and acadYear='$this->acadYear' and semester='$this->semester' and noAss='$this->noAss'");
}
function GetNextCode(){
//--หาค่าสูงสุดของฟิลด์ที่ใช้เป็นคีย์ของตาราง ในลักษณะ auto increment
//--ต้องเป็นฟิลด์ชนิดตัวเลขจำนวนเต็มเท่านั้น และไม่ได้กำหนดรหัสเองทางจอภาพ
$this->SetQuery("select max(defineid) as num from DefineAssessment");
if ($result=$this->GetResult()) {
return $result['num']+1;
}
}
function RSDefineAssessment(){
//--เมธอดที่ขึ้นต้นด้วย RS (ResultSet) มีความหมายว่าจะได้รับข้อมูลกลับมาจากการ select มากกว่า 1 เรคอร์ด
//--จะต้องเรียกเมธอด GetRecord() ด้วยเสมอ นำข้อมูลจาก ResultSet เข้าอ๊อบเจ๊ก
//--โดยสามารถเพิ่มเมธอดได้ตามต้องการ แต่ต้องขึ้นต้นด้วย RS
$this->SetQuery("select * from DefineAssessment order by acadYear DESC, semester, noAss ");
}
function GetRecord(){
//--นำข้อมูลจาก ResultSet มากำหนดให้กับแอตทริบิวต์ของอ๊อบเจ็ก
//--เรียก GetRecord() หนึ่งครั้ง จะเลื่อนตัวชี้เรคอร์ดไปอีกหนึ่งเรคอร์ด
if ($this->result = $this->GetResult()) {
$this->defineid = $this->result['defineid'];
$this->assid = $this->result['assid'];
$this->startDate = $this->result['startDate'];
$this->endDate = $this->result['endDate'];
$this->acadYear = $this->result['acadYear'];
$this->semester = $this->result['semester'];
$this->noAss = $this->result['noAss'];
$this->flag = $this->result['flag'];
$this->closeDate = $this->result['closeDate'];
$this->isPreAssess = $this->result['isPreAssess'];
return 1;
}else {
return 0;
}
}
function SearchByKey($xKey1, $xKey2, $xKey3, $xKey4){
//--ค้นหาข้อมูลตาม PK ต้องระบุพารามิเตอร์ด้วย และต้องตามด้วยเมธอด GetRecord() เสมอ
if ($this->SetQuery("select * from DefineAssessment where defineid='$xKey1' and acadYear='$xKey2' and semester='$xKey3' and noAss='$xKey4'")){
return 1;
}else {
return 0;
}
}
//****************** You can add new functions below **********************//
function NumRow(){
return $this->GetRowSelected();
}
function SearchByFlag($xKey1){
if ($this->SetQuery("select * from DefineAssessment where flag='$xKey1' order by acadYear , semester, noAss ")){
return 1;
}else {
return 0;
}
}
function getMaxNoAss($xKey1,$xKey2){
$this->SetQuery("select max(noAss) as num from DefineAssessment where acadYear = '$xKey1' and flag = '$xKey2'");
if ($result=$this->GetResult()) {
return $result['num'];
}
}
function getMaxNoAssByAcadSemFlag($xacadYear,$xsemester,$xflag){
$this->SetQuery("select max(noAss) as num from DefineAssessment where acadYear = '$xacadYear' and semester = '$xsemester' and flag = '$xflag'");
if ($result=$this->GetResult()) {
return $result['num'];
}
}
function SearchByAcadSemNo($xacadYear,$xsemester,$xnoAss){
if ($this->SetQuery("select * from DefineAssessment where acadYear = '$xacadYear' and semester = '$xsemester' and noAss = '$xnoAss'")){
return 1;
}else {
return 0;
}
}
function SearchByDefineid($xdefineid){
if ($this->SetQuery("select * from DefineAssessment where defineid = '$xdefineid'")){
return 1;
}else {
return 0;
}
}
function SearchByAcadSemFlag($xacadYear,$xsemester,$xflag){
if ($this->SetQuery("select * from DefineAssessment where acadYear = '$xacadYear' and semester = '$xsemester' and flag = '$xflag' order by defineid")){
return 1;
}else {
return 0;
}
}
function SearchAssidByShow($xnowDate,$xflag,$xacadYear,$xsemester){
if ($this->SetQuery("select * from DefineAssessment where startDate <= '$xnowDate' and closeDate >= '$xnowDate' and flag = '$xflag' and acadYear = '$xacadYear' and semester = '$xsemester' order by defineid")){
return 1;
}else {
return 0;
}
}
//16/11/2006
function SearchByFlagAcadSem($xflag,$xacadYear,$xsemester){
if ($this->SetQuery("select * from DefineAssessment where flag = '$xflag' and acadYear = '$xacadYear' and semester = '$xsemester' order by defineid")){
return 1;
}else {
return 0;
}
}
function SearchAssidByShowFlag2($xnowDate,$xflag1,$xflag2,$xacadYear,$xsemester){
if ($this->SetQuery("select * from DefineAssessment where startDate <= '$xnowDate' and closeDate >= '$xnowDate' and (flag = '$xflag1' or flag = '$xflag2') and acadYear = '$xacadYear' and semester = '$xsemester' order by assid,flag")){
return 1;
}else {
return 0;
}
}
//16/11/2006
function SearchByFlag2FlagAcadSem($xflag1,$xflag2,$xacadYear,$xsemester){
if ($this->SetQuery("select * from DefineAssessment where (flag = '$xflag1' or flag = '$xflag2') and acadYear = '$xacadYear' and semester = '$xsemester' order by assid,flag")){
return 1;
}else {
return 0;
}
}
function SearchDefineidByAcadSemAssid($xacadYear,$xsemester,$xassid){
$this->SetQuery("select * from DefineAssessment where acadYear = '$xacadYear' and semester = '$xsemester' and assid = '$xassid'");
}
function RSAssessLimitByFlag($xflag,$xstart, $xpageSize){
$this->SetQuery("select * from DefineAssessment where flag = '$xflag' order by acadYear , semester, noAss limit $xstart, $xpageSize");
}
function RSAssessLimitByAcadSemFlag($xacadYear,$xsemester,$xflag,$xstart, $xpageSize){
$this->SetQuery("select * from DefineAssessment where acadYear = '$xacadYear' and semester = '$xsemester' and flag = '$xflag' order by acadYear , semester, noAss limit $xstart, $xpageSize");
}
function RSAssessLimitByAcadSemFlag2($xacadYear,$xsemester,$xflag1,$xflag2,$xstart, $xpageSize){
$this->SetQuery("select * from DefineAssessment where acadYear = '$xacadYear' and semester = '$xsemester' and (flag = '$xflag1' or flag = '$xflag2') order by acadYear , semester, noAss limit $xstart, $xpageSize");
}
function RSAssessLimitByAcadSem5Flag($xacadYear,$xsemester,$xflag1,$xflag2,$xflag3,$xflag4,$xflag5,$xstart, $xpageSize){
$this->SetQuery("select * from DefineAssessment where acadYear = '$xacadYear' and semester = '$xsemester' and (flag = '$xflag1' or flag = '$xflag2' or flag = '$xflag3' or flag = '$xflag4' or flag = '$xflag5') order by noAss limit $xstart, $xpageSize");
}
function CountDefineidByAssid($xassid){
$this->SetQuery("select count(defineid) as num from DefineAssessment where assid = '$xassid'");
$result = $this->GetResult();
return $result['num'];
}
function CountDefineidByNowDateFlagAcadSem($xnowDate,$xflag,$xacadYear,$xsemester){
$this->SetQuery("select count(assid) as num from DefineAssessment where startDate <= '$xnowDate' and endDate >= '$xnowDate' and flag = '$xflag' and acadYear = '$xacadYear' and semester = '$xsemester'");
$result = $this->GetResult();
return $result['num'];
}
//16/11/2006
function CountDefineidByFlagAcadSem($xflag,$xacadYear,$xsemester){
$this->SetQuery("select count(assid) as num from DefineAssessment where flag = '$xflag' and acadYear = '$xacadYear' and semester = '$xsemester'");
$result = $this->GetResult();
return $result['num'];
}
function CountDefineidByFlag2AcadSem($xacadYear,$xsemester,$xflag1,$xflag2){
$this->SetQuery("select count(assid) as num from DefineAssessment where acadYear = '$xacadYear' and semester = '$xsemester' and (flag = '$xflag1' or flag = '$xflag2')");
$result = $this->GetResult();
return $result['num'];
}
// fine 4 Flag
function CountDefineidByAcadSem4Flag($xacadYear,$xsemester,$xflag1,$xflag2,$xflag3,$xflag4){
$this->SetQuery("select count(assid) as num from DefineAssessment where acadYear = '$xacadYear' and semester = '$xsemester' and (flag = '$xflag1' or flag = '$xflag2' or flag = '$xflag3' or flag = '$xflag4')");
$result = $this->GetResult();
return $result['num'];
}
// closeDate
function RSDefineAssessmentByAcYAndSeAndFlagAndBetweenSCDate($acY, $se, $flg, $scDate){
$this->SetQuery("select * from DefineAssessment where acadYear='$acY' and semester='$se' and flag='$flg' and '$scDate' between startDate and closeDate order by defineid");
}
function RSDefineAssessmentByAcYAndSeAndFlagAndECDate($acY, $se, $flg, $ecDate){
$this->SetQuery("select * from DefineAssessment where acadYear='$acY' and semester='$se' and flag='$flg' and endDate<'$ecDate' and closeDate>='$ecDate' order by defineid");
}
function RSDefineAssessmentByAcYAndSeAndFlagAndCoId($acY, $se, $flg, $coId){
$this->SetQuery("select distinct(d.defineid), assid from DefineAssessment d, HoldCourse h, ClassAssess cl
where d.acadYear='$acY' and d.semester='$se' and d.flag='$flg'
and d.defineid=h.defineid and h.classId=cl.classId and cl.courseId='$coId'
order by d.defineid");
}
function RSDefineAssessmentByAcYAndSeAndFlagAndCoIdAndOfId($acY, $se, $flg, $coId, $ofId){
$this->SetQuery("select distinct(d.defineid), assid from DefineAssessment d, HoldCourse h, ClassAssess cl, ClassInStructorAssess ci
where d.acadYear='$acY' and d.semester='$se' and d.flag='$flg'
and d.defineid=h.defineid and h.classId=cl.classId and cl.courseId='$coId'
and cl.classId=ci.classId and ci.officerId='$ofId'
order by d.defineid");
}
function SearchDefineAssessmentByAcYSeFlagAssid($acY, $se, $flg, $assid){
$this->SetQuery("select * from DefineAssessment
where acadYear='$acY'
and semester='$se'
and flag='$flg'
and assid='$assid'");
}
function SearchAssidDistinctByShow($xnowDate,$xflag,$xacadYear,$xsemester){
$this->SetQuery("select distinct Assid from DefineAssessment where startDate <= '$xnowDate' and closeDate >= '$xnowDate' and flag = '$xflag' and acadYear = '$xacadYear' and semester = '$xsemester' order by defineid") ;
}
function RSByAcadSemFlag2BetweenSCDateClId($xacadYear,$xsemester,$xflag1,$xflag2,$xnowDate,$ClId){
$this->SetQuery("select distinct df.defineid from DefineAssessment df
join HoldCourse hc
on df.defineid = hc.defineid
where classId='$ClId' and acadYear = '$xacadYear' and semester = '$xsemester' and (flag = '$xflag1' or flag = '$xflag2') and startDate <= '$xnowDate' and closeDate >= '$xnowDate' order by Assid ,noAss ");
}
function CountDefineidByFlag2AcadSmClId($xacadYear,$xsemester,$xflag1,$xflag2,$ClId){
$this->SetQuery("select count(assid) as num from DefineAssessment df
join HoldCourse hc
on df.defineid = hc.defineid
where classId='$ClId' and acadYear = '$xacadYear' and semester = '$xsemester' and (flag = '$xflag1' or flag = '$xflag2')");
$result = $this->GetResult();
return $result['num'];
}
function RSAssidByFlagBetweenSCDateClId($xflag,$xnowDate,$ClId){
$this->SetQuery("select distinct df.assid from DefineAssessment df
join HoldCourse hc
on df.defineid = hc.defineid
where classId='$ClId'
and flag = '$xflag'
and startDate <= '$xnowDate'
and closeDate >= '$xnowDate'
order by Assid ,noAss ");
}
function RSDefineByAcadSemFlag2BetweenSCDateClId($xacadYear,$xsemester,$xflag1,$xflag2,$xnowDate,$ClId,$assid){
$this->SetQuery("select distinct df.defineid from DefineAssessment df
join HoldCourse hc
on df.defineid = hc.defineid
where classId='$ClId' and acadYear = '$xacadYear' and semester = '$xsemester' and (flag = '$xflag1' or flag = '$xflag2') and startDate <= '$xnowDate' and closeDate >= '$xnowDate' and Assid='$assid' order by df.defineid ,noAss ");
}
function CountDefineByFlag2BetweenSCDateClId($xflag1,$xflag2,$xnowDate,$ClId){
$this->SetQuery("select count(df.defineid) as num from DefineAssessment df
join HoldCourse hc
on df.defineid = hc.defineid
where classId='$ClId' and (flag = '$xflag1' or flag = '$xflag2') and startDate <= '$xnowDate' and closeDate >= '$xnowDate' order by Assid ,noAss ");
$result = $this->GetResult();
return $result['num'];
}
function RSDefineidByFlagBetweenSCDateClId($xflag,$xnowDate,$ClId){
$this->SetQuery("select distinct df.defineid from DefineAssessment df
join HoldCourse hc
on df.defineid = hc.defineid
where classId='$ClId'
and flag = '$xflag'
and startDate <= '$xnowDate'
and closeDate >= '$xnowDate'
order by Assid ,noAss ");
}
function RSByFlagAndBetweenSCDate($flg, $scDate){
$this->SetQuery("select * from DefineAssessment where flag='$flg' and '$scDate' between startDate and closeDate order by defineid");
}
function RSDefineidByFlag2BetweenSCDateClId($xflag1,$xflag2,$xnowDate,$ClId){
$this->SetQuery("select distinct df.defineid from DefineAssessment df
join HoldCourse hc
on df.defineid = hc.defineid
where classId='$ClId'
and (flag = '$xflag1' or flag = '$xflag2')
and startDate <= '$xnowDate'
and closeDate >= '$xnowDate'
order by Assid ,noAss ");
}
function RSDefineAssessmentByFlagAndECDate($flg, $ecDate){
$this->SetQuery("select * from DefineAssessment where flag='$flg' and endDate<'$ecDate' and closeDate>='$ecDate' order by defineid");
}
function RSDefineTeacherByAcYSeClassIdOfficerId($xacadYear,$xsemester,$xclassId,$xofficerId){
if ($this->SetQuery("
select da.* from DefineAssessment da,(
select distinct da.defineid as defineid from
DefineAssessment da
where da.acadYear = '$xacadYear'
and da.semester = '$xsemester'
and da.flag = '0'
union
select distinct da.defineid as defineid from DefineAssessment da
join HoldCourse hc on da.defineid = hc.defineid
where da.flag = '1' and hc.classId = '$xclassId'
union
select distinct defineid as defineid from DoAssessment
where classId = '$xclassId' and officerId = '$xofficerId'
union
select distinct hc.defineid as defineid from HoldCourse hc
where hc.classId = '$xclassId' and hc.officerId = '$xofficerId'
union
select distinct hc.defineid as defineid from HoldCourse hc
join TimeTableAssess tt on hc.ttId = tt.ttId
where hc.classId = '$xclassId' and tt.ttOfId = '$xofficerId'
)A
where da.defineid = A.defineid
and da.acadYear = '$xacadYear'
and da.semester = '$xsemester'
order by da.noAss
")){
return 1;
}else {
return 0;
}
}
function RSFlag5And6ByAcYSeClassId($xacadYear,$xsemester,$xclassId){
if ($this->SetQuery("
select da.* from DefineAssessment da,(
select distinct da.defineid as defineid from
DefineAssessment da
where da.acadYear = '$xacadYear'
and da.semester = '$xsemester'
and da.flag = '5'
union
select distinct da.defineid as defineid from DefineAssessment da
join HoldCourse hc on da.defineid = hc.defineid
where da.acadYear = '$xacadYear'
and da.semester = '$xsemester'
and da.flag = '6' and hc.classId = '$xclassId'
)A
where da.defineid = A.defineid
order by da.noAss
")){
return 1;
}else {
return 0;
}
}
function RSByAcYSe($acY, $se ,$xflag1,$xflag2,$xflag3,$xflag4){
$this->SetQuery("select distinct(assid) from DefineAssessment
where acadYear LIKE '$acY'
and semester LIKE '$se'
and (flag = '$xflag1' or flag = '$xflag2' or flag = '$xflag3' or flag = '$xflag4')
order by assid");
return 1;
}
function RSByAcYSePgCoClOfFlag($acy, $se, $pg, $co, $cl, $of, $flag){
if($this->SetQuery("SELECT DISTINCT df.* FROM DefineAssessment df
JOIN HoldCourse hc ON hc.defineid = df.defineid
JOIN ClassAssess ca ON hc.classId = ca.classId
WHERE df.acadYear = '$acy' AND df.semester = '$se'
AND df.flag = '$flag' AND hc.classId LIKE '$cl'
AND hc.officerId LIKE '$of' AND ca.acadYear = '$acy'
AND ca.semester = '$se' AND ca.programId = '$pg'
AND ca.courseId = '$co'")){
return 1;
}else{
return 0;
}
}
function RSDefineidHPByFlagBetweenSCDateClId($xflag,$xnowDate,$ClId){
$this->SetQuery("select distinct df.defineid from DefineAssessment df
join HoldPlace hp
on df.defineid = hp.defineid
where classId='$ClId'
and flag = '$xflag'
and startDate <= '$xnowDate'
and closeDate >= '$xnowDate'
order by Assid ,noAss ");
}
} //--End class DefineAssessment--
?>
|