<?php
if($_POST["exD"])
{
$exD= $_POST['exD'];
require_once"labClass.php";
$con=new labClass();
$pOpt="CASH";
 
       
 $rr= $con-> getThisexD($exD);
//print_r($rr->ErrorInfo());
 if($rr->rowCount()>0)
      {
    $ex=$rr->fetch();
    $sdate=$ex['exDate'];
    $tPrice=$ex['exAmount'];
    $k= $con->getMuamalaCash($pOpt,$sdate);
 if($k->rowCount()>0)
      {
   $cs=$k->fetch() ;
   if($cs['statusB']=="Saved"){
    $Qr= $con->delexD($exD);
   if($Qr->rowCount()>0)
      {
          //////////////////////////////
              
                $e= $con->getMuamalaCash($pOpt,$sdate);
                  if($e->rowCount()>0)
                   {
                  $nn=$e->fetch();
                  $tPrice= $nn['amount']+$tPrice;
                  $r= $con->updateToDayCash($tPrice,$pOpt,$sdate);
                      if($Qr->rowCount()>0)
                       {
                        ///$rQc= $con->miamala($pOpt,$user,$tPrice,$sdate);
                          ?>
                           <h6 class="text-success">Deleted!..</h6>
                          <?php
                       }
                       else{
                          ?>
                          <h6 class="text-danger">Transaction update failed!..</h6>
                         <?php
                           }
                      }
                       else{
                          
                            ?>
                            <h6 class="text-danger">Transaction not found!..</h6>
                           <?php
                           
                       }
               //////////////
      }
else{
    echo "Expenses id required!";
}

}
else{
   echo "Transaction closed up can't delete!";

}
      }
  else{
       ?>
        <h6 class="text-danger">Item occurred!..</h6>
       <?php
       } 
          
     
        }
  else{
       ?>
        <h6 class="text-danger">No matching records!..</h6>
       <?php
       }
       
       
       





}
else{
    echo "Transaction not found!";
}

?>