<?php
/*=======================================================\
|                 Point of Sales Module                  |
|--------------------------------------------------------|
|   Creator: Phương                                      |
|   Date :   18-Dec-2017                                 |
|   Description: ERP Point of Sales Extension            |
|   Website: https://reccle.net                          |
|                                                        |
\=======================================================*/

$path_to_root = '../../..';

include_once($path_to_root . '/includes/session.inc');

if(!empty($_GET['file']))
	$_SESSION['temp_name'] = $_GET['file'];

$temp_name = empty($_SESSION['temp_name']) ? '' : $_SESSION['temp_name'];

$file = root_folder_name().'/company/0/pdf_files/'.$temp_name;

function root_folder_name() {
	$this_dir = explode('/modules', dirname($_SERVER['PHP_SELF']));
	return $this_dir[0];
}

echo '<HTML>';
echo '<head>';
echo "<script src='".$path_to_root."/modules/pos/js/jquery-1.10.2.min.js'></script>";
echo "<script src='".$path_to_root."/modules/pos/js/print.min.js'></script>";
echo '</head>';

echo '<body>';
echo "<object data='".$file."' type='application/pdf' title='".$file."' width='100%' height='100%'>";
echo "<p><b>"._('Fallback content')."</b>"._(': This browser does not support PDFs. Please download the PDF to view it: ')."<a href='".$file."'>"._('Download PDF').'</a></p>';
echo '</object>';
echo '</body>';

echo '</HTML>';

echo '<script>';
echo "$(document).ready(function() {
	printJS({printable:'$file', type:'pdf', showModal:false})
})";
echo '</script>';

unset($_SESSION['temp_name']);