<!--
Author: W3layouts
Author URL: http://w3layouts.com
License: Creative Commons Attribution 3.0 Unported
License URL: http://creativecommons.org/licenses/by/3.0/
-->
<!DOCTYPE HTML>
<html>
<head>
<title>nehrdelivery.com</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
 <!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel='stylesheet' type='text/css' />
<!-- Custom CSS -->
<link href="css/style.css" rel='stylesheet' type='text/css' />
<link href="css/font-awesome.css" rel="stylesheet"> 
<!-- jQuery -->
<script src="js/jquery.min.js"></script>
<!----webfonts--->
<link href='http://fonts.googleapis.com/css?family=Roboto:400,100,300,500,700,900' rel='stylesheet' type='text/css'>
<!---//webfonts--->  
<script>
    $(document).ready(function(){
      
    });
</script>
<style>
.view {
  background: #bbf0bbab; 
  border: none;
  color: #00000;
  padding: 5px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 10px;
  margin: 4px 2px;
  cursor: pointer;
  border-radius: 5px;
}
</style>
</head>
<body>
    <div id="wrapper">
     <!-- Navigation -->
        <?php include 'common/nav.php';?>
        <?php include 'common/connection.php';?>
        <div id="page-wrapper">
        <div class="graphs">
	   <div class="md">
		 <h3>Document View</h3>
			
			<div class="clearfix"> </div>
			<div class="row">
			<div class="col-md-12">
				<div class="panel " data-widget="{&quot;draggable&quot;: &quot;false&quot;}" data-widget-static="">
					<div class="panel-heading">
						<h2></h2>
						<div class="panel-ctrls" data-actions-container="" data-action-collapse="{&quot;target&quot;: &quot;.panel-body&quot;}"><span class="button-icon has-bg"><i class="ti ti-angle-down"></i></span></div>
					</div>
					<?php
					    $doc_id = $_POST["doc_id"];
					    $doc_type = $_POST["doc_type"];
					    $servername = "localhost";
                        $username = "finstech_sales";
                        $password = "SalesApp@123";
                        $dbname = "finstech_salesapp";
                        
                        try {
                            $pdo = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
                            $stmt = $pdo->prepare("select master_documents.data_b64 from master_documents where master_documents.doc_id = ?");
                            $stmt->execute([$doc_id]); 
                            $user = $stmt->fetch();
                        }catch(PDOException $e) {
                            echo $sql . "<br>" . $e->getMessage();
                        }
                        $pdo = null;
                    if($doc_type == "image"){    
					?>
					<img src="data:image/png;base64,<?php echo $user['data_b64']; ?>"/>
					<?php } if($doc_type == "text"){ 
					    ?><div style="padding: 50px;"> <?php echo  base64_decode($user['data_b64']); ?></div><?php
					 } if($doc_type == "doc"){
                        $pdf_decoded = base64_decode ($user['data_b64']);
                        $pdf = fopen ('downloads/download.pdf','w');
                        fwrite ($pdf,$pdf_decoded);
                        fclose ($pdf);
                        ?><div style="padding: 50px;"><a id="download" href="downloads/download.pdf">Click here to view pdf</a></div><?php
					 } ?>
					<div class="panel-body no-padding" style="display: block;">
						
					</div>
				</div>
			</div>
			
			<div class="clearfix"> </div>
		   </div>
		</div>					
       </div>
      </div>
      <!-- /#page-wrapper -->
   </div>
    <!-- /#wrapper -->
    <!-- Nav CSS -->
<link href="css/custom.css" rel="stylesheet">
<!-- Metis Menu Plugin JavaScript -->
<script src="js/metisMenu.min.js"></script>
<script src="js/custom.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>

</body>
</html>
