<?php session_start();
require_once 'config.php';
require_once 'auth.php';
$PageName = "Material Details";
$UserId = $_SESSION['User']['id'];
 ?>
<!doctype html>
<html lang="en" class="h-100">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <meta name="generator" content="">
    <title><?php echo $Proj_Title; ?></title>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <link rel="apple-touch-icon" href="img/favicon180.png" sizes="180x180">
    <link rel="icon" href="img/favicon32.png" sizes="32x32" type="image/png">
    <link rel="icon" href="img/favicon16.png" sizes="16x16" type="image/png">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&amp;display=swap" rel="stylesheet">
    <link href="vendor/swiper/css/swiper.min.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet" id="style">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>

<body class="body-scroll d-flex flex-column h-100 menu-overlay">
    <main class="flex-shrink-0 main">
        <?php include_once 'back-header.php'; ?> 


        <?php 
        $sql2 = "SELECT ts.*,td.Name As Department,tc.Name As Course FROM tbl_upload_materials ts
                 LEFT JOIN tbl_departments td ON ts.DeptId = td.id 
                 LEFT JOIN tbl_courses tc ON ts.CourseId = tc.id 
                 WHERE ts.id='".$_GET['id']."'"; 
        $row = getRecord($sql2);
        ?>
        <div class="main-container">
             <?php 
                if($row["Photo2"] == ''){} 
                else {?>  
                <div class="container mb-4">
                <div class="card">
                <div class="card-body">
                    <!-- Swiper -->
                    <div class="swiper-container gallery-top">
                        <div class="swiper-wrapper">
                            <div class="swiper-slide has-background">
                                <div class="background">
                                    <img src="<?php echo $UploadUrl;?>/uploads/<?php echo $row['Photo2']; ?>" alt="" style="width: 280px;height: 250px;">
                                </div>
                            </div>
                            
                        </div>
                        <!-- Add Arrows -->
                       
                    </div>
                    

                </div>
            </div>
            </div>
                
                <?php } ?>
            
            <div class="container">
                <p class="text-mute mb-1"><?php echo $row['Department']; ?> / <?php echo $row['Course']; ?></p>
                <h5><?php echo $row['Name']; ?></h5>
               
                <hr>
                <?php 
                $url =  $SiteUrl.'uploads/'.$row["Photo"];
                if($row["Photo"] == ''){} 
                else {?>
                <div class="row">
                    <div class="col">
                         <a href="JavaScript:Void(0);" 
onclick="onDownloadFileFromUrl('<?php echo $url;?>','<?php echo $row["Photo"];?>')"><button class="btn btn-default rounded"><i class="fa fa-download"></i> Download</button></a>
                    </div>
                    <div class="col-auto">
                       
                    </div>
                </div>
                <hr>
                <?php } ?>
                <p class="text-mute"><?php echo $row['Details']; ?></p>
                <br><br><br><br>


            </div>

            <!-- page content ends -->
        </div>
    </main>
    <?php include_once 'footer.php'; ?>

<script src="js/jquery-3.3.1.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="js/jquery.cookie.js"></script>
<script src="vendor/swiper/js/swiper.min.js"></script>
<script src="js/main.js"></script>
<script src="js/color-scheme-demo.js"></script>
<script src="js/app.js"></script>
<script>
    function onDownloadFileFromUrl(url,filename){
         Android.onDownloadFileFromUrl(''+url+'',''+filename+'');
    }
</script>
</body>
</html>
