<?php
    ini_set('display_errors', 1);
     ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);
if( isset($_POST["descrip"]) && isset($_POST["user"])  && isset($_POST["tprice"])  && isset($_POST["sdate"]))
{ 
    
    $descrip= $_POST['descrip'];
    $tPrice= $_POST['tprice']; 
    $user= $_POST['user'];    
    $sdate= $_POST['sdate']; 
    require_once"labClass.php";
    $con=new labClass(); 
    $rQc= $con->excessmoneyrec($descrip,$user,$tPrice,$sdate);
    if($rQc->rowCount()>0)
    {
        $recID=1;
        $r= $con->getExcBalance($recID)->fetch();
        $bal=$r['cbalance']+$tPrice;
        $u= $con->updateExcBalance($recID,$bal);
    }
    
               /* $recID=1;
                $r= $con->getBalance($recID)->fetch();
                $bal=$r['cbalance']+$tPrice;
                $u= $con->updateBalance($recID,$bal);
                if($u->rowCount()>0)
                 {*/
                     ///////////////////////
        $pOpt="CASH";
           $e= $con->getMuamalaCash($pOpt,$sdate);
          if($e->rowCount()>0)
           {
          $nn=$e->fetch();
          $pOpt="CASH";
          $tPrice= $tPrice+$nn['amount'];
          $r= $con->updateToDayCash($tPrice,$pOpt,$sdate);
              if($r->rowCount()>0)
               {
                ///$rQc= $con->miamala($pOpt,$user,$tPrice,$sdate);
              ?>
                <h6 class="text-success">Save!..</h6>
              <?php
               }
               else{
                  ?>
                  <h6 class="text-danger">Transaction update failed!..</h6>
                 <?php
                   }
              }
                     
                     
                     ///////////////////////
                      ?>
                      <!--<h6 class="text-success">Save!..</h6>-->
                      <?php
                /* }
                 else{
                      ?>
                       <h6 class="text-success">Excess update failed!..</h6>
                      <?php
                     }*/
        
   }
   else{
       echo "All field required!.";
   }
   //echo "2.finish";
?>