<?php
	include_once('config.php');   
    if(!isset($_SESSION['custId'])) 
    {
         header("Location: ".ROOTPATH."/");
         die;
    }  

         if(isset($_POST['submitComp']))
         {       
                $stmt=$conn->prepare("insert into   pw__comp (commodity,grade,qtyperunit1,qtyperunit2,qtyamt,Tdate,custId,randNo,agency,RaBillNO1) values(:commodity,:grade,:qtyperunit1,:qtyperunit2,:qtyamt,:Tdate,:custId,:randNo,:agency,:RaBillNO1) "); 
                $stmt->bindValue(':commodity', $_POST['commodity'] , PDO::PARAM_STR);  
				$stmt->bindValue(':grade', $_POST['grade'] , PDO::PARAM_STR); 
				$stmt->bindValue(':qtyperunit1', $_POST['qtyperunit1'] , PDO::PARAM_STR); 
				$stmt->bindValue(':qtyperunit2', $_POST['qtyperunit2'] , PDO::PARAM_STR); 
				$stmt->bindValue(':qtyamt', ($_POST['qtyperunit1']*$_POST['qtyperunit2']) , PDO::PARAM_STR);  
				$stmt->bindValue(':Tdate', date("d-M-Y") , PDO::PARAM_STR);  
				$stmt->bindValue(':custId', $_SESSION['custId'] , PDO::PARAM_STR);  
				$stmt->bindValue(':randNo', $_REQUEST['randNo'] , PDO::PARAM_STR);  
				$stmt->bindValue(':agency', $_REQUEST['agency'] , PDO::PARAM_STR);  
				$stmt->bindValue(':RaBillNO1', $_POST['RaBillNO1'] , PDO::PARAM_STR);  
                $stmt->execute();     
				$_SESSION['comdTY'] = 1;
                header("Location: addRabill.php?randNo=".$_REQUEST['randNo']."&agency=".$_REQUEST['agency']);
                die;
         }
		 
		 if(isset($_POST['submitLogin']))
         {      
                $stmt=$conn->prepare("insert into   pw__rabills (recordingD,RaBillNO,vourchar,dpayment,amtwork,costofBit,royalty,clause38,netpayment,eightPer,Tdate,custId,randNo,agency) values(:recordingD,:RaBillNO,:vourchar,:dpayment,:amtwork,:costofBit,:royalty,:clause38,:netpayment,:eightPer,:Tdate,:custId,:randNo,:agency) ");   
                $stmt->bindValue(':recordingD', $_POST['recordingD'] , PDO::PARAM_STR); 
                $stmt->bindValue(':RaBillNO', $_POST['RaBillNO'] , PDO::PARAM_STR); 
                $stmt->bindValue(':vourchar', $_POST['vourchar'] , PDO::PARAM_STR);  
                $stmt->bindValue(':dpayment', $_POST['dpayment'] , PDO::PARAM_STR);  
                $stmt->bindValue(':amtwork', $_POST['amtwork'] , PDO::PARAM_STR);  
                $stmt->bindValue(':costofBit', $_POST['costofBit']  , PDO::PARAM_STR);  
                $stmt->bindValue(':royalty', $_POST['royalty'] , PDO::PARAM_STR);  
                $stmt->bindValue(':clause38', $_POST['clause38'] , PDO::PARAM_STR);  
                $stmt->bindValue(':netpayment',$_POST['netpayment']   , PDO::PARAM_STR);  
                $stmt->bindValue(':eightPer', $_POST['eightPer'] , PDO::PARAM_STR);   
				 
				$stmt->bindValue(':Tdate', date("d-M-Y") , PDO::PARAM_STR);  
				$stmt->bindValue(':custId', $_SESSION['custId'] , PDO::PARAM_STR);  
				$stmt->bindValue(':randNo', $_REQUEST['randNo'] , PDO::PARAM_STR);  
				$stmt->bindValue(':agency', $_REQUEST['agency'] , PDO::PARAM_STR);  
                $stmt->execute();    
				$_SESSION['Radded'] = 1;
                header("Location: addRabill.php?randNo=".$_REQUEST['randNo']."&agency=".$_REQUEST['agency']);
                die;
         }
         
        
		
		
				
		if(isset($_POST['RaBillNo']))
		{
			
			
				 
				$stmt=$conn->prepare("select  *  from    pw__comp where  custId=:custId  and randNo=:randNo and RaBillNO1=:RaBillNO1 ");   
				$stmt->bindValue(':custId', $_SESSION['custId'] , PDO::PARAM_STR); 
				$stmt->bindValue(':randNo', $_POST['randNo'] , PDO::PARAM_STR); 
				$stmt->bindValue(':RaBillNO1', $_POST['ra'] , PDO::PARAM_STR); 
				 
				$stmt->execute();   
				$FinalResult = $stmt->fetchAll(PDO::FETCH_OBJ); 
				
				 
				
				$calCadta = 0;
					foreach($FinalResult as $mpp)
						$calCadta += $mpp->qtyamt; 
						
				echo $calCadta;
				die;    
		}		
		 
		 
		$stmt=$conn->prepare("select  *  from    pw__newage where  id=:id ");   
		$stmt->bindValue(':id', $_REQUEST['agency'], PDO::PARAM_STR); 
		$stmt->execute();   
		$pw__newage = $stmt->fetch(PDO::FETCH_OBJ); 
		
		
		$stmt=$conn->prepare("select  *  from    MyWorks where  randNo=:randNo");   
		$stmt->bindValue(':randNo', $_REQUEST['randNo'], PDO::PARAM_STR); 
		$stmt->execute();   
		$randNoDetails = $stmt->fetch(PDO::FETCH_OBJ); 
		 

include_once("view/addRabill.php");
?>