<?php

    session_start();

    include "../db.php";

    date_default_timezone_set('Asia/Kolkata');

    $currentTime = date('M j, Y g:i a');



    if ( !isset($_SESSION['uid']) && !isset($_SESSION['uref']) && !isset($_SESSION['utype']) && !isset($_SESSION['uname']) )

        header("Location: logout.php");

    if (!isset($_GET['h_ref']) && empty($_GET['h_ref'])) {

        header("Location: view-homework.php");

    }



    $h_sql = "SELECT * FROM homework WHERE h_ref = '$_GET[h_ref]'";

    $h_res = mysqli_query($con,$h_sql);

    $h_row= mysqli_fetch_assoc($h_res);



?>

<!DOCTYPE html>

<html lang="en">

<head>

 <?php include "includes/meta.php"; ?>        

    <?php include "includes/css.php"; ?>  

        <link hr ef="css/all.min.css" rel="stylesheet" type="text/css">  

           <!-------Including Image Upload CSS File------>

        <link rel="stylesheet" type="text/css" href="multiPhotoUploadApp/style.css">

</head>

<body id="page-top" class="mt-55">

            <div style="margin-top: 130px;"></div>

                <?php include "includes/header2.php"; ?>



<?php 

$ck_sql = "SELECT * FROM homework_img  WHERE hi_ref = '$_GET[h_ref]' AND sh_id = '$_SESSION[uid]' LIMIT 1";

$ck_res = mysqli_query($con,$ck_sql);

if ($ck_total_rows=mysqli_num_rows($ck_res)>0) {

    ?>

            <script>

                alert('Already Submited Your Homework, Goto Edit to Change...');

                window.location = "edit-homework.php?edit_ref=<?php echo $_GET['h_ref']; ?>";

            </script>

    <?php

}

?>

            <div class="container">

                    <div class="row justify-content-center">

                    <div class="col-md-8">

                        <div class="card shadow mt-3">

                        <h5 class="card-header text-dark  text-center font-weight-bold"> Submit Homework</h5>

                            <div class="card-body">

                                <form method="POST" enctype="multipart/form-data">

                                    <div class="row mt-4">

                                        <div class="col-md-12">

                                            <label class="badge badge-warning">Homework Title</label>

                                            <div class="form-control"><?php echo $h_row['h_title']; ?></div>

                                        </div>

                                    </div>

                                    <div class="row mt-4">

                                        <div class="col-md-12">

                                            <label class="badge badge-warning">Homework  Answer Script</label>

                                            <textarea name="content" id="content" class="form-control ckeditor" required></textarea>

                                        </div>

                                    </div>

                                    <div class="row mt-4">

                                        <div class="col-md-12">

                                            <label class="badge badge-warning">Image Upload</label>

                                            <div id="filediv"><input name="file[]" type="file" id="file"/></div><br/>

           

                                            <input type="button" id="add_more" class="upload" value="Add More Files"/>



                                            <input type="hidden" name="teacher_id" value="<?php echo $h_row['uploadedby']; ?>">

                                        </div>

                                    </div>



                                    <div class=" row justify-content-center text-center">

                                         <input type="submit" value="Upload Homework" name="img_submit" id="upload" 

                                         class="btn btn-success text-sm-center mt-4"/>



                                         &nbsp;&nbsp;&nbsp; 

                                         <a href="view-homework.php" class="btn btn-warning text-sm-center mt-4"> Cancel</a>



                                    </div>



                                </form>

                            </div>

                        </div>

                    </div>

                </div>

            </div>



     <div style="margin-top: 170px;"></div>

            <?php include "includes/ft.php"; ?>

            <?php include "includes/js.php"; ?>

            <!-------Including ckeditor Js File------>

            <script src="vendor/ckeditor.js"></script>

            <!-------Including Image Upload Js File------>

            <script src="multiPhotoUploadApp/multiPhotoScript.js"></script>







</body>

</html>



<?php include "multiPhotoUploadApp/uploadHomework.php"; ?>



