<?php  
	    if(isset($_POST['Submit']))
	    { 
	               
                $path = ABS_PATH.'/uploads/WorkPic/'.$_SESSION['custId']; 
                if (!file_exists($path))
                    mkdir($path, 0777, true);
 
	            $digits = 6; 
	            $ext = explode('.', basename($_FILES['pict']['name'])); 
                $file_extension = end($ext);
                $target_path = $path.'/temp.'.$file_extension;
                move_uploaded_file($_FILES['pict']['tmp_name'],$target_path);
                
                
                $cuurentId = rand(pow(10, $digits-1), pow(10, $digits)-1).'.'.$file_extension;  
                $target_pathX = $path.'/'.$cuurentId;
                
                $lv = "longitude :".$_POST['long']." "."latitude :".$_POST['lat']; 
                shell_exec("convert  $target_path   -gravity South  -pointsize 50 -annotate +0+5 ' $lv '  $target_pathX "); 
                 
                
                $stmt=$conn->prepare("insert into  UploadPics (nm,custId,UploadDate) values(:nm,:custId,:UploadDate) ");   
                $stmt->bindValue(':nm', $cuurentId , PDO::PARAM_STR); 
                $stmt->bindValue(':custId', $_SESSION['custId'] , PDO::PARAM_STR); 
                $stmt->bindValue(':UploadDate', date("d-M-y H:i:s") , PDO::PARAM_STR);   
                $stmt->execute();   
                unlink($target_path); 
                header("Location: uploadImage.php");
                die;
	    }
	    
            $stmt=$conn->prepare("select  *  from    MyWorks where  id=:custId    ");   
            $stmt->bindValue(':custId',$_REQUEST['id'] , PDO::PARAM_STR); 
            $stmt->execute();   
            $FinalResult = $stmt->fetch(PDO::FETCH_OBJ); 
            
            $originalDate = $FinalResult->workOrder;
            $workOrder = date("d-M-Y", strtotime($originalDate));

	        $originalDate = $FinalResult->workcomm;
            $workcomm = date("d-M-Y", strtotime($originalDate));

	
?>
<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"> 
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.min.js" integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
    <title>Upload Image</title>
 
    
 
<script src="<?php echo ROOTPATH;?>/view/js/jquery-1.11.1.min.js"></script> 
	<link href="<?php echo ROOTPATH;?>/view/css/screen-600.css" rel="stylesheet" type="text/css">
</head>
<body>

        
  <script type="text/javascript">
     function initGeolocation()
     {
        if( navigator.geolocation )
        {
           // Call getCurrentPosition with success and failure callbacks
           navigator.geolocation.getCurrentPosition( success, fail );
        }
        else
        {
           alert("Sorry, your browser does not support geolocation services.");
        }
     }

     function success(position)
     {

         document.getElementById('long').value = position.coords.longitude;
         document.getElementById('lat').value = position.coords.latitude
     }

     function fail()
     {
        // Could not obtain location
     }

   </script>    
	<?php 
	    include_once(ABS_PATH."/menu.php");
	?>
	<style>
	    h5{
	        font-size:11px;
	        font-weight:bold;
	    }
	    .card-titleInner{
	        text-align:center;
	    }
	    table{margin-bottom:0rem!important;}
	    table tr td{padding:0.2rem!important}
	</style>

    <div class="container mt-35">
                    <div class="row justify-content-center FormRegister">
                        <div class="card bgwhite pt-3 pb-2">
                            <div class="card-body p-0"><h3><?php  echo $FinalResult->title;?></h3>  
        </div>   
        
        <div class="pt-2 mb-2 col-12" style="width:97%;padding:0 0px;box-shadow:0px 0px 5px 5px #0ff;margin:10px 5px"> 
              
                <table class="table table-striped">

  <tbody>
    <tr>
      <td><b>Agrement No</b></td>
      <td>:</td>
      <td><?php echo $FinalResult->AggNo;?></td>
     
    </tr>
    <tr>
      <td><b>Devision</b></td>
      <td>:</td>
      <td>
        <?php 
            if($FinalResult->diVision==1)
            echo "PWD East Nashik";
            else if($FinalResult->diVision==2)
                echo "ZP";
         ?>
      </td>
     
    </tr>
    <tr>
      <td><b>Date of work order</b></td>
      <td>:</td>
      <td><?php echo $workOrder;?></td>
     
    </tr>
    <tr>
      <td><b>Date of commencement</b></td>
      <td>:</td>
      <td><?php echo $workcomm;?></td>
      
    </tr>
     <tr>
      <td><b>Project Cost</b></td>
      <td>:</td>
      <td>Rs <?php echo $FinalResult->cost;?></td>
      
    </tr>
  </tbody>
</table>
        </div>   
        <div style="clear:both">&nbsp;</div>
       
   <div class="flx">                          
  <div class="col-5 mb-2" style="float:left;margin: 0 4px 0 0;width: 48%;">
    <div class="card">
      <a href="<?php echo ROOTPATH;?>/uploadImage.php?type=1&Mid=<?php echo $_REQUEST['id'];?>">
      <img src="<?php echo ROOTPATH;?>/view/images/uploadDoc.jpg" class="card-img-top" alt="...">
      <div class="card-body">
        <h5 class="card-titleInner">Site photos</h5>
        
      </div>
      </a>
    </div>
  </div>
  <div class="col-5 mb-2" style="float:left;width: 48%;">
    <div class="card">
    <a href="<?php echo ROOTPATH;?>/uploadImage.php?type=2&Mid=<?php echo $_REQUEST['id'];?>">
      <img src="<?php echo ROOTPATH;?>/view/images/uploadDoc.jpg" class="card-img-top" alt="...">
      <div class="card-body">
        <h5 class="card-titleInner">Work Order</h5>
        
      </div>
      </a>
    </div>
  </div>
  <div class="col-5 mb-2" style="float:left;margin: 0 4px 0 0;width: 48%;">
    <div class="card">
        <a href="<?php echo ROOTPATH;?>/uploadImage.php?type=3&Mid=<?php echo $_REQUEST['id'];?>">
      <img src="<?php echo ROOTPATH;?>/view/images/uploadDoc.jpg" class="card-img-top" alt="...">
      <div class="card-body">
        <h5 class="card-titleInner">QC Report</h5>
        
      </div>
      </a>
    </div>
  </div>
  
   <div class="col-6 mb-2" style="float:left;width: 48%;">
    <div class="card">
      <a href="<?php echo ROOTPATH;?>/uploadImage.php?type=4&Mid=<?php echo $_REQUEST['id'];?>">
      <img src="<?php echo ROOTPATH;?>/view/images/uploadDoc.jpg" class="card-img-top" alt="...">
      <div class="card-body">
        <h5 class="card-titleInner">Insurance</h5>
        
      </div>
      </a>
    </div>
  </div>
  
   <div class="col-5 mb-2" style="float:left;margin: 0 4px 0 0;width: 48%;">
    <div class="card">
      <a href="<?php echo ROOTPATH;?>/uploadImage.php?type=5&Mid=<?php echo $_REQUEST['id'];?>">
      <img src="<?php echo ROOTPATH;?>/view/images/uploadDoc.jpg" class="card-img-top" alt="...">
      <div class="card-body">
        <h5 class="card-titleInner">Royalty</h5>
        
      </div>
      </a>
    </div>
  </div>
  
   <div class="col-5 mb-2" style="float:left;width: 48%;">
    <div class="card">
      <a href="<?php echo ROOTPATH;?>/uploadImage.php?type=6&Mid=<?php echo $_REQUEST['id'];?>">
      <img src="<?php echo ROOTPATH;?>/view/images/uploadDoc.jpg" class="card-img-top" alt="...">
      <div class="card-body">
        <h5 class="card-titleInner">Any other Documents</h5>
        
      </div>
      </a>
    </div>
  </div>
 </div>
</div>
</div>
 
 <script> 
 initGeolocation();
  $(document).ready(function()
  {   
      
 
    $(".menuIcon").click(function(){
      $('.menuBox').animate({left: '0'});
    });

    $(".closeMenu").click(function(){
      $('.menuBox').animate({left: '-280px'});
    });
  });
</script> 
 
</body>
</html>
