<?php
 ini_set('display_errors', 1);
 ini_set('display_startup_errors', 1);
 error_reporting(E_ALL);
if($_POST["submit"])

{

	$tname= $_POST['tname'];
	 $tPrice=$_POST['tPrice'];   
    $exDate=$_POST['sdate']; 
    $sdate=$_POST['sdate'];
    $user=$_POST['user'];                                                       //CHECKING ENDS HERE

  require_once"labClass.php";

  $con=new labClass();

  if(!$con->vtPrice($tPrice))
          
          {
            
          ?>
            <h6 class="text-danger">Error occured!..</h6>
          <?php
            require_once "expensesRegForm.php";

 
        }
 
   else {
               $rQ= $con->registerEx($tname, $tPrice,$exDate);
               if($rQ->rowCount()>0)
                {    
                 
              //////////////////////////////
                $pOpt="CASH";
                $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)
                       { 
                          ?>
                           <h6 class="text-success">Save!..</h6>
                          <?php
                       }
                       else{
                          ?>
                          <h6 class="text-danger">Transaction update failed!..</h6>
                         <?php
                           }
                      }
                       else{
                         
                            ?>
                            <h6 class="text-danger">Transaction not found!..</h6>
                           <?php
                            
                       }
               //////////////  
                
              
                require_once "expensesRegForm.php";

               }
   
 
         }
}


?>