<?php    
    
	session_start();
	$id_usuario = $_SESSION['idusuario'];
	$chasis = $_GET['itemdai'];
	$color = $_GET['d'];
	$iddai = $_GET['id'];
	$marca = $_GET['m'];
	$id_ubicacion =3;	
	$condicion = 1;
	$temp = 1;
	$actividad = "REGISTRO DE UNIDADES";
		
	$my_ip = $_SERVER["REMOTE_ADDR"]; 
	date_default_timezone_set('America/Guayaquil');
	$fecha_actual = date('Y/m/d');
	$time_actual =date("H:m:s");
	//echo $time_actual;
	include ("../conex.php");
	$sql = "UPDATE tb_datadai SET id_estado = 2 WHERE iddatadai = '$iddai'";
	$regis = mysqli_query($conn, $sql); 
	
	$sql = "UPDATE tb_datadai SET id_ubicacion = '$id_ubicacion' WHERE iddatadai = '$iddai'";
	$regis = mysqli_query($conn, $sql); 
	
	$sqlau = "INSERT INTO tb_auditoria(fecha, hora, ip, detalle, id_datadai, id_usuario)
	VALUES ('$fecha_actual','$time_actual','$my_ip','$actividad','$iddai','$id_usuario')";
	$inser = mysqli_query($conn, $sqlau);
      
    //echo "<h3> LATKIC S.A.</h3>";
    
    //set it to writable location, a place for temp generated PNG files
    $PNG_TEMP_DIR = dirname(__FILE__).DIRECTORY_SEPARATOR.'temp'.DIRECTORY_SEPARATOR;
    
    //html PNG location prefix
    $PNG_WEB_DIR = 'temp/';

    include "qrlib.php";    
    
    //ofcourse we need rights to create temp dir
    if (!file_exists($PNG_TEMP_DIR))
        mkdir($PNG_TEMP_DIR);
    
    
    $filename = $PNG_TEMP_DIR.'test.png';
    
    //processing form input
    //remember to sanitize user input in real-life solution !!!
    $errorCorrectionLevel = 'L';
    if (isset($_REQUEST['level']) && in_array($_REQUEST['level'], array('L','M','Q','H')))
        $errorCorrectionLevel = $_REQUEST['level'];    

    $matrixPointSize = 6;
    if (isset($_REQUEST['size']))
        $matrixPointSize = min(max((int)$_REQUEST['size'], 1), 10);


    if (isset($_REQUEST['data'])) { 
    
        //it's very important!
        if (trim($_REQUEST['data']) == '')
            die('data cannot be empty! <a href="?">back</a>');
            
        // user data
        $filename = $PNG_TEMP_DIR.'test'.md5($_REQUEST['data'].'|'.$errorCorrectionLevel.'|'.$matrixPointSize).'.png';
        QRcode::png($_REQUEST['data'], $filename, $errorCorrectionLevel, $matrixPointSize, 2);    
        
    } else {    
    
        //default data
        //echo 'You can provide data in GET parameter: <a href="?data=like_that">like that</a><hr/>';    
        QRcode::png($chasis, $filename, $errorCorrectionLevel, $matrixPointSize, 2);    
        
    }  

		
?>         
      
 

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta name="description" content="">
		<meta name="author" content="">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
		<!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>-->
		<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
		<title>SGO</title>
		<link rel="shortcut icon" href="../../resources/img/icon.ico">
		<link href="../../vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
		<link href="../../vendor/metisMenu/metisMenu.min.css" rel="stylesheet">
		<link href="../../dist/css/sb-admin-2.css" rel="stylesheet">
		<link href="../../vendor/morrisjs/morris.css" rel="stylesheet">
		<link href="../../vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
		<link rel="stylesheet" type="text/css" href="../../resources/media/css/datatables.bootstrap.min.css"/>
	</head>
		<div class="col-lg-12 col-md-12">
			
			<?php 
				//display generated file
				//echo '<img src="'.$PNG_WEB_DIR.basename($filename).'">'; 
				echo "<center><h3> LATKIC S.A.</h3></center>";
				
			?> 
			
		</div>
		<div class="col-lg-12 col-md-12">
			
			<?php 
				//display generated file
				echo '<center><img src="'.$PNG_WEB_DIR.basename($filename).'"></center>'; 
				//echo "<h3>".$chasis."</h3>";
			?> 
			
		</div>
		<div class="col-lg-12 col-md-12">
			
			<?php 				
				echo "<center><h4>".$chasis."</h4></center>";
				//echo "<center><h5>".$fecha_actual." ".$time_actual."</h5></center>";
				echo "<center><h4>".$marca." ".$color."</h4></center>";
			?> 
		</div>
	<script>	
		window.print();
	</script>
	
</html>	
