Skip to main content

LEV MD

LVLST.PHP
<?php
ob_start();
?>
<!DOCTYPE html>

<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <head>
  <title>Leave List</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
</head>
    </head>
    <body>
        <?php
        // put your code here
        session_start();
        include './Homemst.php';
        include './conn.php';
        $user_id=$_SESSION['user_id'];
        $sql="select * from tbl_leave where user_id='$user_id'";
        $result=mysqli_query($con,$sql);
        $usertype=$_SESSION['user_type'];
        if($usertype==1)
        {

        ?>
    <center>
        <br>
        <h3>STUDENT DETAILS</h3>
        <br>
        <table cellspacing="0" class="table table-bordered">
                            <tbody><tr>
                                <th>
                                    Start Date
                                </th>
                                <th>
                                    Start time
                                </th>
                                <th>
                                    End Date
                                </th>
                                <th>
                                    End time
                                </th>
                                <th>
                                    Leave Reason
                                </th>
                                <th>
                                    Leave Status
                                </th>
                               
                             
                            </tr>
                        <?php
                         
                            while($row=mysqli_fetch_assoc($result))
                            {
                                echo "<tr class=even>
                                    <td>$row[from_date]</td>
                                     <td>$row[from_time]</td>
                                    <td>$row[to_date]</td>
                                    <td>$row[to_time]</td>
                                    <td>$row[reason]</td>
                                    <td>$row[status]</td>
                                   
                                </tr>";

                            }
                        ?>   
                     
                       
                   
                        </tbody></table>
        <form action="lvapp.php" method="post">
        <input type="submit" value="Apply"  name="apply" class="btn btn-success">
        </form>
       
           
            <?php
                           
            }
                else if($usertype==2)
                {
               

            ?>
                      <table cellspacing="0" class="table table-bordered">
                            <tbody><tr>
                                <th>
                                    Student
                                </th>
                                <th>
                                    Start Date
                                </th>
                                <th>
                                    Start Time
                                </th>
                                <th>
                                    End Date
                                </th>
                                <th>
                                    End Time
                                </th>
                                <th>
                                    Leave Reason
                                </th>
                                <th>
                                    Leave Status
                                </th>
                                <th>
                                    Approve
                                </th>
                                <th>
                                    Reject
                                </th>
                               
                             
                            </tr>
                        <?php
                             $sql="select * from tbl_leave inner join tbl_user on tbl_user.user_id=tbl_leave.user_id";
                            $result=mysqli_query($con,$sql);
                           
                            while($row=mysqli_fetch_assoc($result))
                            {
                                echo "<form action=# method=get>";
                                echo "<tr class=even>
                                    <td>$row[name]</td>
                                    <td>$row[from_date]</td>
                                    <td>$row[from_time]</td>
                                   
                                    <td>$row[to_date]</td>
                                    <td>$row[to_time]</td>
                                    <td>$row[reason]</td>
                                    <td>$row[status]</td>
                                    <td><a href=lvlst.php?approve=$row[id]>Approve</a></td>
                                    <td><a href=lvlst.php?reject=$row[id]>Reject</a></td>
                                   
                                </tr>";

                                 echo "</form>";

                            }
                         
                           
                            if(isset($_GET['approve']))
                            {
                                 $id=$_GET['approve'];
                                $sql="update tbl_leave set status='Approve' where id='$id'";
                                $result=mysqli_query($con,$sql);
                                header('Location:lvlst.php');
                            }
                            if(isset($_GET['reject']))
                            {
                                 $id=$_GET['reject'];
                                $sql="update tbl_leave set status='reject' where id=$id";
                                $result=mysqli_query($con,$sql);
                                header('Location: lvlst.php');
                               
                            }
                        ?>   
                     
                       
                   
                        </tbody></table>
                    </div>
            <?php
                }
                ob_end_flush();
            ?>
    </center>
       
    </body>

</html>
========================================================================
LVAPP.php
<?php
include './Homemst.php';
ob_start();
session_start();
?>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
    <style>
      body{
          background-color: aliceblue;
      }
  </style>
    </head>
    <form action="#" method="post">
        <table>
<fieldset>
                    <center>
<legend align="center">
Apply For Leave
</legend>
                    
                    
                            <label style="width: 130px">From Date:</label>
                            <input name="fromdate" type="date" style="border-radius: 50px;height: 30px;width: 140px"><br>
                            
                            <br>
                            
                            <label style="width: 130px">From time:</label>
                            <input name="fromtime" type="time" style="border-radius: 50px;height: 30px;width: 140px"><br>
                        
                            <br> 
                            
                            <label style="width: 130px">To Date:</label>
                            <input name="todate" type="date" style="border-radius: 50px;height: 30px;width: 140px"><br>
                            <br>
                            
                            <label style="width: 130px">To time:</label>
                            <input name="totime" type="time" style="border-radius: 50px;height: 30px;width: 140px"><br>
                            <br>
                            
                          <label style="width: 130px;height: 50px">Reason:</label>
                    
                          <textarea name="txtreason" rows="2" cols="50"  class="txtbox" style="border-radius: 50px;"></textarea><br>
                    
                    
                            
                    
                    
                    
                            <input type="submit" name="btnSubmit" value="Submit"  class="btn btn-primary">&nbsp;
                            <input type="submit" name="btnCancel" value="Cancel"  class="btn btn-primary">
                    </center>
</fieldset>
        </table>
        

        
    </form>
        <?php
            if(isset($_POST['btnSubmit']))
            {
                include './conn.php';
                $fromdate=$_POST['fromdate'];
                $fromtime=$_POST['fromtime'];
                $todate=$_POST['todate'];
                $totime=$_POST['totime'];
                $reason=$_POST['txtreason'];
                $date=date('Y-m-d');
                $user_id=$_SESSION['user_id'];
                if(strtotime($fromdate)>strtotime($todate) || strtotime($fromtime)>strtotime($totime))
                {
                    echo "<script>alert('Invalid Date and Time')</script>";
                }
                else{
                $sql="insert into tbl_leave(user_id,apply_date,from_date,from_time,to_date,to_time,reason,status) values ('$user_id','$date','$fromdate','$fromtime','$todate','$totime','$reason','Pending')";
                $result=mysqli_query($con,$sql);
                //echo "<script>alert('Leave Apply Successfully')</script>";
                header('Location: lvlst.php');
                echo mysqli_error($con);
            }}
            ob_end_flush();
        ?>

Comments

Popular posts from this blog

DELL ES

<!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html>     <head>         <meta charset="UTF-8">         <title></title>     </head>     <body>         <?php                     include './Conn.php';                     $sv="select * from demo";                     $qsv= mysqli_query($conn, $sv);                                 ?>     <center>         <table border="1">           ...

SRCH OP

<!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <?php ob_start(); ?> <html>     <head>         <meta charset="UTF-8">         <title></title>         <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>     </head>     <style>       body{           background-color: aliceblue;       }   </style>     <body>     ...

IMAGE UP BACK

<!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html>     <head>         <meta charset="UTF-8">         <title></title>         <style>             h1{                 font-family: monospace;                 color: black;                 text-align: center;             }             h3{                 text-align: left;             }         </style>     </head>     <body> ...