<?php
 
 ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
//require_once("header.php");
 
if( isset($_POST["recID"]) && isset($_POST["cname"])  && isset($_POST["depo"]) && isset($_POST["depon"])  && isset($_POST["sdate"])  &&   isset($_POST["user"]))

{  
	 $cname= $_POST['cname']."(Returned-deposit)";
	 $depo=$_POST['depo'];  
	 $depon=$_POST['depon'];
	 $bal=$depo-$depon;
     $user=$_POST['user'];
     $sdate=$_POST['sdate'];    
     $recID=$_POST['recID'];
     ///$rg=Date("Ymdhis").substr(10,2);
   ///$reg=md5(substr($rg,1,11));
     $regdate=Date("Y-m-d");
  //CHECKING ENDS HERE
     require_once "labClass.php";
     $con = new labClass();
     $pOpt="CASH";
     if($depon<=$depo){
     $con->updateAddDp($bal,$recID);
    // $con->addDepo($recID,$cname,$depon,$sdate,$user);
              
           //require_once "empRegForm.php";
               ///////////////////////////////////////
          $tPrice=$_POST['depon'];
          $e= $con->getMuamalaCash($pOpt,$sdate);
          if($e->rowCount()>0)
           {
          $nn=$e->fetch();
          $tPrice= $nn['amount']-$tPrice;
          $r= $con->updateToDayCash($tPrice,$pOpt,$sdate);
              if($r->rowCount()>0)
               {
                   $tname=$cname;
                   $exDate=$sdate;
                   $tPrice=$depon;
                   $rQ= $con->registerEx($tname, $tPrice,$exDate);
                ///$rQc= $con->miamala($pOpt,$user,$tPrice,$sdate);
              ?>
                <h6 class="text-success">Save!..</h6>
              <?php
               }
               else{
                  ?>
                  <h6 class="text-danger">Transaction update failed!..</h6>
                 <?php
                   }
               
               ////////////////////////////////////////
          }
          else{
            echo "Transaction not found!..";
          }
     }   else{
            echo "Return amount is greater than balance!..";
          }
 


}

?>