<?php
    require_once("db.php");

    class recharge extends db {

        public function checkreferencenumber($paymentmode,$referenceno){
            $sql="CALL `sp_checkpaymentreference`('{$paymentmode}','{$referenceno}')";
            return $this->getData($sql)->rowCount()?true:false;
        }

        public function saverecharge($paymentmode,$referenceno,$paymentdate,$amount){
            if(!$this->checkreferencenumber($paymentmode,$referenceno)){
                $paymentdate=$this->mySQLDate($paymentdate);
                $sql="CALL `sp_saveaccountrecharge`('{$paymentmode}','{$referenceno}',{$amount},'{$paymentdate}')";
                $this->getData($sql);
                return "success";
            }else{
                return "exists";
            }
        }

        public function filterrecharge($startdate,$enddate){
            $startdate=$this->mySQLDate($startdate);
            $enddate=$this->mySQLDate($enddate);
            $sql="CALL `sp_filterrecharge`('{$startdate}','{$enddate}')";
            return $this->getJSON($sql);
        }
    }

?>