<?php
//--Class StudentActivity--------------------------

include_once "clsbase_StudentActivity.php";

class 
StudentActivity extends base_StudentActivity {

function 
RSStudentActivityByStIdAndActNameAndAcYAndStYAndSeAndDate($stId$actName$acY$stY$se$dateFrom$dateTo){
    
$this->SetQuery("select * from StudentActivity where studentId='$stId' and activityName='$actName' and acadYear='$acY' 
                        and classYear='$stY' and semester='$se' and dateFrom='$dateFrom' and dateTo='$dateTo'"
);
}

function 
GetNextSeqByStId($xKey){
    
$this->SetQuery("select max(sequenceId) as num from StudentActivity where studentId='$xKey'");
    if (
$result=$this->GetResult()) {
        return 
$result['num']+1;
    }
}

function 
RSStudentActivityByStId($stId){
    
$this->SetQuery("select * from StudentActivity where studentId='$stId' order by acadYear, semester, dateFrom");
}

function 
RSStudentActivityByStIdAndGEAdY($stId$adY){
    
$this->SetQuery("select * from StudentActivity 
                        where studentId='$stId' and acadYear>='$adY' 
                        order by acadYear, semester, dateFrom"
);
}

function 
RSStudentActivityByStIdAndLTAdY($stId$adY){
    
$this->SetQuery("select * from StudentActivity 
                        where studentId='$stId' and acadYear<'$adY' 
                        order by acadYear, semester, dateFrom"
);
}

function 
RSStudentActivityByAcYAndDateGroupActNameAndDate($acY$dateFrom$dateTo){
    
$this->SetQuery("select activityName, dateFrom, dateTo from StudentActivity 
                        where acadYear='$acY' and dateFrom>='$dateFrom' and dateTo<='$dateTo' 
                        group by activityName, dateFrom, dateTo 
                        order by dateFrom, dateTo"
);
}

function 
RSStudentActivityByStIdAndActNameAndAcYAndDate($stId$actName$acY$dateFrom$dateTo){
    
$this->SetQuery("select * from StudentActivity 
                        where studentId='$stId' and activityName='$actName' and acadYear='$acY' 
                        and dateFrom='$dateFrom' and dateTo='$dateTo'"
);
}

function 
GetCountStIdByAcYAndActNameAndDate($acY$actName$dateFrom$dateTo){
    
$this->SetQuery("select count(studentId) as num from StudentActivity 
                        where acadYear='$acY' and activityName='$actName' 
                        and dateFrom='$dateFrom' and dateTo='$dateTo'"
);
    if (
$result=$this->GetResult()) {
        return 
$result['num'];
    }
}

function 
GetCountStIdByAcYAndActNameAndStYAndDateAndPgId($acY$actName$stY$dateFrom$dateTo$pgId){
    
$this->SetQuery("select count(a.studentId) as num from StudentActivity a, StudentMaster m 
                        where a.acadYear='$acY' and a.activityName='$actName' and a.classYear='$stY' 
                        and a.dateFrom='$dateFrom' and a.dateTo='$dateTo' 
                        and a.studentId=m.studentId and m.programId='$pgId'"
);
    if (
$result=$this->GetResult()) {
        return 
$result['num'];
    }
}

//--End class StudentActivity--
?>