<?php
//--Class Debt--------------------------

include_once "clsbase_Debt.php";

class 
Debt extends base_Debt{

function 
GetNextSeqByStIdAndAcYAndSe($stId$acY$se){
    
$this->SetQuery("select max(sequence) as num from Debt 
                        where studentId='$stId' and acadYear='$acY' and semester='$se'"
);
    if (
$result=$this->GetResult()) {
        return 
$result['num']+1;
    }
}

function 
RSDebtByStIdAndAcYAndSeAndOgIdAndNoPay($stId$acY$se$ogId){
    
$this->SetQuery("select * from Debt 
                        where studentId='$stId' and acadYear='$acY' and semester='$se' 
                        and organId='$ogId' and refNo='' order by sequence"
);
}

function 
GetSumAmountByStIdAndAcYAndSeAndOgIdAndNoPay($stId$acY$se$ogId){
    
$this->SetQuery("select sum(amount) as num from Debt 
                        where studentId='$stId' and acadYear='$acY' and semester='$se' 
                        and organId='$ogId' and refNo=''"
);
    if (
$result=$this->GetResult()) {
        return 
$result['num'];
    }
}

function 
GetSumAmountByStIdAndAcYAndSeAndNoPay($stId$acY$se){
    
$this->SetQuery("select sum(amount) as num from Debt 
                        where studentId='$stId' and acadYear='$acY' and semester='$se' 
                        and refNo=''"
);
    if (
$result=$this->GetResult()) {
        return 
$result['num'];
    }
}

function 
RSDebtByStIdAndOgIdAndNoPayOrderAcYSeSeq($stId$ogId){
    
$this->SetQuery("select * from Debt 
                        where studentId='$stId' and organId='$ogId' and refNo='' 
                        order by acadYear, semester, sequence"
);
}

function 
GetSumAmtByStId($xKey){
    
$this->SetQuery("select sum(amount) as num from Debt where studentId='$xKey' and refNo=''");
    if (
$result=$this->GetResult()) {
        return 
$result['num'];
    }
}

//--End class Debt--
?>