<?php 
session_start();
include_once('./sidemenu.php');
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <link type="text/css" href="css/dashboard.css" rel="stylesheet">
    <link href="css/styles.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="css/bootstrap.css">
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link
        href="https://fonts.googleapis.com/css2?family=Jacquard+12+Charted&family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap"
        rel="stylesheet">
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">

</head>
<style>
body {
    font-family: "Nunito", sans-serif;
}
</style>

<style>
hr.new3 {
    border-top: 1px dashed red;
}
</style>
<style>
span.good {
    font-family: "Nunito", sans-serif;
    font-weight: bold;
}
</style>
<style>
table,
th,
td {

    font-size: 15px;

}
</style>
<style>
h4 {
    font-family: "Nunito", sans-serif;
    font-weight: bold;
    text-align: center;
    font-size: 20px;
}
</style>

<style>
hr.new3 {
    border-top: 1px dashed red;
}
</style>

<style>
span.lon {
    color: black;
    font-family: "Nunito", sans-serif;
}

span.lon:hover {
    color: #669999;
}
</style>

<body>
                        <?php 

require_once('config.php');

    if(isset($_GET['page']))
    {
        $page = $_GET['page'];
    }
    else
    {
        $page = 1;
    }

    $num_per_page = 100;
    $start_from = ($page-1)*80;
    
    $query = "select * from dunees WHERE trash = 1 limit $start_from,$num_per_page";
    $result = mysqli_query($con,$query);

?>

    <section class="sticky-top" style="margin:0;box-shadow: 0 1px 2px rgb(0 0 0 / 15%);background:#00004d;">
        <div class="container-fluid">
            <div class="row">
                <div class="col-md-12" style="margin:0;">
                    <?=mynavbar()?>
                </div>
            </div>
        </div>
    </section>

    <section>
        <div class="container-fluid">
            <div class="row">
                <div class="col-md-1" style="padding:0;background:#EBEAEA;">
                    <?=sidemenu()?>
                </div>
                <div class="col-md-11">

                    <table style="width:104%; border: 2px solid #f0f5f5;padding-top:20px;">


                        <?php
 $conn=new mysqli("localhost","root","","threads");   
    if(isset($_GET['submit']))
    {   
    $Name=$_GET['Name'];
    $add_1=$_GET['Sender'];
    $add_2=$_GET['Sender_Address'];
    $add_3=$_GET['Sender_Email'];
    $add_4=$_GET['Sender_Number'];
    $add_5=$_GET['Receiver'];
    $add_6=$_GET['Receiver_Address'];
    $add_7=$_GET['Receiver_Email'];
    $add_8=$_GET['Receiver_Number'];
    $add_9=$_GET['Name_Item'];
    $add_10=$_GET['Number_Item'];
    $add_11=$_GET['Color_Item'];
    $add_12=$_GET['Weight'];
    $add_13=$_GET['Sent'];
    $add_14=$_GET['Delivery'];
    $add_15=$_GET['Amount'];
    $add_16=$_GET['Bill'];
    $add_17=$_GET['Type'];
    $add_18=$_GET['Status'];   
    $add_19=$_GET['Dip_Number'];     
    
    $rand='EC'.date('hs').'M';
    
    $sql="insert into dunees(COUR_NO,Name,Sender,Sender_Address,Sender_Email,Sender_Number,Receiver,Receiver_Address,Receiver_Email,Receiver_Number,Name_Item,Number_Item,Color_Item,Weight,Sent,Delivery,Amount,Bill,Type,Status,Dip_Number) values('$rand','$Name','$add_1','$add_2','$add_3','$add_4','$add_5','$add_6','$add_7','$add_8','$add_9','$add_10','$add_11','$add_12','$add_13','$add_14','$add_15','$add_16','$add_17','$add_18','$add_19')";
    
    if($conn->query($sql))
    {
        echo "<h4>Tracking Details Added Successfully</h4>";
        
        /*$sql="insert into deliver(COU_ID,DELIVERY_STATUS) values('$rand',0)";
    if($conn->query($sql))
    {
    }
        */
    }
    }    
    
    ?>
                        <?php
    
    if(isset($_GET['delete']))
    {
        $ID=$_GET['delete'];
        $sql="Update dunees SET trash = 0  where Cou_ID=$ID";
    if($conn->query($sql))
    {
        echo "<h4>Tracking Details Restored Successfully</h4>";
        
    }
    
    }
    
    ?>
                     <?php
    
    if(isset($_GET['delete1']))
    {
        $id=$_GET['delete1'];
        $sql="DELETE FROM dunees WHERE Cou_ID=$id";
    if($conn->query($sql))
    {
        echo "<h4>Tracking Details Permanently Deleted Successfully</h4>";
        
    }
    
    }
    
    ?>



                        <?php
$sql="select * from dunees";
$row=$conn->query($sql);
if($row->num_rows>0)
{
	                    while($data=$row=mysqli_fetch_assoc($result))
                    {
                ?>
                        <table style="border 1px solid #f0f5f5">
                            <tr>
                                <td style="background-color: #00e600"><span class="good">Tracking
                                        Number<br><?php echo $data['Cour_No'];?></span></td>
                                <td></td>
                                <td></td>
                                <td style="background-color: #669999"><span class="good">Way Bill Number<br>
                                        <?php echo $data['Bill'];?></td>
                                <td></td>
                                <td></td>
                                <td style="background-color: #e6e600"><span class="good">Sender
                                        Name<br><?php echo $data['Sender'];?></td>
                                <td></td>
                                <td></td>
                                <td style="background-color: #751aff"><span class="good" style="color:white">Sender
                                        Number<br><?php echo $data['Sender_Number'];?></td>
                                <td></td>
                                <td></td>
                                <td style="background-color: #ff0000"><span class="good" style="color:white">Receiver
                                        Name
                                        <br> <?php echo $data['Receiver'];?></td>
                                <td></td>
                                <td></td>
                                <td style="background-color: #a3a375"><span class="good" style="color:white">Receiver
                                        Number<br><?php echo $data['Receiver_Number'];?></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td><span style="color:white">fffffffb bbbbf</span></td>
                                <td><a
                                        href="trash.php?delete=<?php echo $data['Cou_ID'];?>"><button>Restore</button></a>
                                </td>
                                <td></td>
                                <td><a
                                        href="trash.php?delete1=<?php echo $data['Cou_ID'];?>"><button>Delete Permanently</button></a>
                                </td>
                                <td><span style="color:white">ffffff</span></td>
                               
                                <br>
                                <hr class="new3">
                                <?php
	
}

}

else{
    ?>
    <h1 style="text-align:center:margin-top:30px;text-indent:10em;">Oops!!Trash Is Empty </h1>
    <?php
}

?>

                            </tr>
                        </table>
                        <div style="height:40px"></div>
                        <div id="Sign-In" align="center">

                            <?php 

$pr_query = "select * from dunees ";
$pr_result = mysqli_query($con,$pr_query);
$total_record = mysqli_num_rows($pr_result );

$total_page = ceil($total_record/$num_per_page);

if($page>1)
{
echo "<a href='tracking-details.php?page=".($page-1)."' class='btn btn-danger'>Previous</a> ";
}


for($i=1;$i<$total_page;$i++)
{
echo " <a href='tracking-details.php?page=".$i."' class='btn btn-primary'>$i</a>";
}

if($i>$page)
{
echo "&nbsp &nbsp <a href='tracking-details.php?page=".($page+1)."' class='btn btn-danger'>Next</a> <br>";
}

?>
                        </div>
                </div>
            </div>
    </section>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>

    <script>
    document.getElementsByClassName('list-group-item')[4].style.backgroundColor = "#046469";
    document.getElementsByClassName('menu-list')[4].style.color = "#fff";
    </script>

</body>