<?php
include("dashboard/config.inc.php");
if(isset($_GET['bid']) && $_GET['bid'] != "") {
    $book_id = $_GET['bid'];
}
else {
    exit;
}

$sql = "SELECT * FROM epapers WHERE p_id = '$book_id' ";
	$result = $conn->query($sql);
	
	if (isset($result->num_rows) && $result->num_rows > 0) {
    	$row = $result->fetch_assoc();
		$ebook_url = "dashboard/uploads/" .$row['p_path'];
		 
	} else {
   		$ebook_url = "test.pdf";
	}
	
?>
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="css/flipbook.min.css">
  <link rel="stylesheet" type="text/css" href="css/flipbook.style.css">
  <script src="js/flipbook.min.js"></script>

  <script type="text/javascript">
    document.addEventListener("DOMContentLoaded", function () {
      const options = {
        pdfUrl: '<?php echo $ebook_url; ?>',
        loadAllPages: false,
                        loadPagesF: 4,
                        loadPagesB: 1,
                        pageTextureSize: 3072,
                        minPixelRatio: 1.5,
                        singlePageMode: false,
                        icons: 'material',
                        backgroundColor: "#cacaca",
                        backgroundImage: "images/background.jpg",
                        skin: "dark",
                        layout: "1",
                        pageMiddleShadowSize: 3,
                        pageSegmentsW: 10,
                        coverHardness: '4.0',
                        pageHardness: '3.0',
                        zoomSize: 3000,
                        zoomStep: 1.1,
                        zoomMax2: 3,
                        shadowMapSize: 1024,
                        shadowOpacity: .1,
                        responsiveView: true,
                        responsiveViewTreshold: 9999,
                        responsiveViewRatio: 1.2,
                        rightToLeft: false,
                        sound: true,
                        thickness: 8.1,
                        btnSingle: true,
                        btnZoomIn: {
                            hideOnMobile: true
                        },
                        btnZoomOut: {
                            hideOnMobile: true
                        },
                        btnShare: {
                            enabled: true
                        },
                        btnDownloadPages: {
                            enabled: true
                        },
                        btnPrint: {
                            enabled: true
                        },
                        btnToc: {
                            enabled: true
                        },
                        btnSearch: {
                            enabled: false
                        },
                        btnSelect: {
                            enabled: true
                        },
                        btnSize: 10,
                        floatingBtnColorHover: "#8834fd",
                        sideBtnColorHover: "#8834fd",
                        btnColorHover: "#8834fd",
                        sideBtnSize: 40,
                        menuFloating: {
                            enabled: true
                        },
                        btnDownloadPdf: {
                            forceDownload: true,
                            enabled: true,
                            title: "Download PDF",
                            icon: "fa-file",
                            icon2: "picture_as_pdf",
                            url: null,
                            openInNewWindow: true,
                            name: "allPages.pdf"
                        },
                        btnSearch: {
                            enabled: true,
                            title: "Search"
                        },
                        deeplinkingEnabled: true,
                        deeplinkingPrefix: 'page',
                        doubleClickZoomDisabled: false,
                        currentPage: {
                            enabled: true,
                            title: "Current page",
                            vAlign: 'bottom',
                            hAlign: 'center',
                            marginH: 0,
                            marginV: 0
                        },
                        mobile: {
                            zoomSize: 1000,
                            btnSize: 6,
                            sidebtnSize: 26
                        },
                        strings: {
                            bookmarks: "Bookmarks",
                            bookmarkLeftPage: "Bookmark left page",
                            bookmarkRightPage: "Bookmark right page",
                            bookmarkCurrentPage: "Bookmark current page",
                            search: "Search",
                            findInDocument: "Find in document",
                            pagesFoundContaining: "pages found containing",
                            thumbnails: "Page List",
                            pressEscToClose: "Press ESC to close"
                        }

      };
      const container = document.getElementById('container');
      new FlipBook(container, options);
    });
  </script>

</head>

<body>
    <div style="width: 100%; height: auto; position: absolute; top: 0px; bottom: 0px; left: 0px; right: 0px; overflow: hidden;">
  <div id="container"></div>
</div>
</body>

</html>

