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

         if(isset($_POST['submitComp']))
         {        
			 
				
				if($_POST['grade']=='')
						$_POST['grade'] = 0;
					
                $stmt=$conn->prepare("update pw__comp set commodity=:commodity, grade=:grade,qtyperunit1=:qtyperunit1,qtyperunit2=:qtyperunit2,qtyamt=:qtyamt  where id=:id"); 
                $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(':id', $_REQUEST['id'] , PDO::PARAM_STR);  
                $stmt->execute();      
				$_SESSION['comdTY'] = 1;
                header("Location: editComsuption.php?id=".$_REQUEST['id']);
                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); 
		
		
		
		$stmt=$conn->prepare("select  *  from    pw__comp  where  id=:id");   
		$stmt->bindValue(':id', $_REQUEST['id'], PDO::PARAM_STR); 
		$stmt->execute();   
		$editComp = $stmt->fetch(PDO::FETCH_OBJ); 
		 
		  
		  
		
		 

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