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

         if(isset($_POST['submitLogin']))
         {
               
			    if($_REQUEST['AgId']!='')
				{
					$workOrderdate = date("d-M-Y", strtotime($_POST['workOrderdate']));
					$timeLimit = date("d-M-Y", strtotime($_POST['timeLimit']));
					$extention = date("d-M-Y", strtotime($_POST['extention']));
					$recDate = date("d-M-Y", strtotime($_POST['recDate']));  
					
					if($_POST['dateOFcompetition']=='')
							$_POST['dateOFcompetition'] = "NA";
					
					if($_POST['workorderNo']=='')
						$_POST['workorderNo']  = "NA";
						
					//number_format((float)(GetBalance()), 2, '.', '');  	

						 
					$stmt=$conn->prepare("insert into  MyWorks(agency,custId,workN,AggNo,workorderNo,workOrderdate,timeLimit,extention,recDate,basicIndices,recPientOftender,dateOFcompetition,TenderAccAt,TenderAccAtStats,shortName,randNo,is_active) values(:agency,:custId,:workN,:AggNo,:workorderNo,:workOrderdate,:timeLimit,:extention,:recDate,:basicIndices,:recPientOftender,:dateOFcompetition,:TenderAccAt,:TenderAccAtStats,:shortName,:randNo,1) ");   
					$stmt->bindValue(':agency', $_REQUEST['AgId'] , PDO::PARAM_STR); 
					$stmt->bindValue(':custId',$_SESSION['custId'] , PDO::PARAM_STR); 
					$stmt->bindValue(':workN', $_POST['workN'], PDO::PARAM_STR);   
					$stmt->bindValue(':AggNo', $_POST['AggNo'], PDO::PARAM_STR);   
					$stmt->bindValue(':workorderNo',$_POST['workorderNo'] , PDO::PARAM_STR);   
					$stmt->bindValue(':workOrderdate', $workOrderdate , PDO::PARAM_STR);   
					$stmt->bindValue(':timeLimit',$timeLimit , PDO::PARAM_STR);   
					$stmt->bindValue(':extention', $_POST['extention'], PDO::PARAM_STR);    
					$stmt->bindValue(':recDate', $recDate, PDO::PARAM_STR);      
					$stmt->bindValue(':basicIndices', $recDate  , PDO::PARAM_STR);      
					$stmt->bindValue(':recPientOftender', "NA" , PDO::PARAM_STR);      
					$stmt->bindValue(':dateOFcompetition', $_POST['dateOFcompetition'], PDO::PARAM_STR);      
					$stmt->bindValue(':TenderAccAt', $_POST['TenderAccAt'], PDO::PARAM_STR);      
					$stmt->bindValue(':TenderAccAtStats', $_POST['TenderAccAtStats'], PDO::PARAM_STR);      
					$stmt->bindValue(':shortName', $_POST['shortName'], PDO::PARAM_STR);      
					$stmt->bindValue(':randNo', $_POST['randNo'], PDO::PARAM_STR);      
					$stmt->execute();    
					$_SESSION['tenderSdd'] = "Tender Profile Added";					
					header("Location: Mywokexp.php");
					die;
				}else
				{
					$_SESSION['tenderSdd'] = "Please select agency and try again";		
					header("Location: Mywokexp.php");
					die;					
				}
         }
         
        $stmt=$conn->prepare("select  *  from    MyWorks where  custId=:custId    order by id desc");   
        $stmt->bindValue(':custId', $_SESSION['custId'] , PDO::PARAM_STR); 
        $stmt->execute();   
        $FinalResult = $stmt->fetchAll(PDO::FETCH_OBJ); 

		if($_REQUEST['AgId']!='')
		{
			$stmt=$conn->prepare("select  *  from    pw__newage where  id=:id ");   
			$stmt->bindValue(':id', $_REQUEST['AgId'], PDO::PARAM_STR); 
			$stmt->execute();   
			$pw__newage = $stmt->fetch(PDO::FETCH_OBJ); 
		}

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