<?php 
set_time_limit(10000);
include('../dbconnect.php');
include('../phps.php');
ob_start();
session_start();
if( !isset($_SESSION['user']) ) {
header("Location: ../index.php");
exit;
}
/*
$date=date("W");
$day = date("l");
echo $date." Week Number" .$day;
$year = "2020";
$month = "01";
$day = "01";
$first_date = $year."-".$month."-".$day;
$last_date = date("Y-m-t",strtotime($first_date));
$first_week = date("W",strtotime($first_date));
$last_week = date("W",strtotime($last_date));
$yearw = idate('W', mktime(0, 0, 0, 12, 27, $year));
for($i=$first_week;$i<=$yearw;$i++)
{
echo "Week #".$i.", ";
}
$yearw = idate('W', mktime(0, 0, 0, 12, 27, $year));
echo $yearw
$month = 1;
$year = date("Y");
$timestamp = mktime(0, 0 , 0, $month, 1, $year); 
$timestamp += (60 * 60 * 24); 
$first_week_no = date('W', $timestamp); 
$range = range($first_week_no, $first_week_no + 51); 
foreach ($range as $week_no) {
$week_start = new DateTime();
$week_start->setISODate($year, $week_no);
$week_start->modify('-1 day');
$seven_day_week = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
$week = array();
for ($i = 0; $i < 7; $i++) {
$day = $seven_day_week[$i];
$week[$day] = $week_start->format('n-j-y');
$week_start->modify('+1 day');
}
echo '<pre>';
echo "Week {$week_no}";
var_dump($week);
echo '</pre>';
}
*/
$week = $_POST['week'];
$week2 = $_POST['week2'];
$team = $_POST['team'];
$getday = $_POST['day'];
$getdate = $_POST['date'];
$off = $_POST['off'];
$hol = $_POST['hol'];
$start = $_POST['start'];
$end = $_POST['end'];
$years = date('Y');
$weekno = $_POST['weekno'];
$hidden= "hidden";
$week = phps($_GET['week']);
$week2 = phps($_GET['week2']);
$show="style='display: none;'";
$first_week_no = $_GET['week'];
$numberofdays = (((int)$week2 - (int)$week) + 1) * 7;
$numberofweeks = ((int)$week2 - (int)$week) + 1;
if(isset($_POST['addsched'])){
$howManyTimes = $numberofweeks;
$starttime = array();
$endtime = array();
for ($c=0; $c < $howManyTimes; $c++) {
$starttime = array_merge($starttime, array($start[0],$start[1],$start[2],$start[3],$start[4],$start[5],$start[6]));
$endtime = array_merge($endtime, array($end[0],$end[1],$end[2],$end[3],$end[4],$end[5],$end[6]));
}
if($team == 'All'){
$empsql = "SELECT * FROM empdetails";
$originalteam = "SELECT * FROM empdetails GROUP BY team";
}else{
$empsql = "SELECT * FROM empdetails WHERE team='$team'";
$originalteam = "SELECT * FROM empdetails GROUP BY team";
}
$result = mysqli_query($conn, $empsql);
$rowcount = mysqli_num_rows($result);
$oriresult = mysqli_query($conn, $originalteam);
$orirowcount = mysqli_num_rows($oriresult);
$empid = array();
$empteam = array();
$originalteam = array();
  while($r = mysqli_fetch_assoc($result)) {
  $empid[] = $r['empid'];
  $empteam[] = $r['team'];
  }
  while($ori = mysqli_fetch_assoc($oriresult)){
  $originalteam[] = $ori['team'];
  }
  for($d=0; $d < $orirowcount; $d++){
      //echo '<b>Original Team no'.$d.'<br/> </b>';
      for($c=0; $c < $numberofdays; $c++){
      //echo 'Number of Days'.$c.'<br/>';
      $months[$c] =  (new DateTime())->setISODate($years, $weekno[$c])->format('F');
      if($weekno[$c] == 1 && $months[$c] == 'December'){
      $months[$c] = 'January';
      }
      $orisql = "INSERT INTO `schedule`(`schedcode`, `week`, `day`,`date`,`year`,`starttime`, `endtime`, `team`, `indi`, `month`) 
      VALUES 
      ('$originalteam[$d].$getdate[$c]','$weekno[$c]','$getday[$c]','$getdate[$c]','$years','$starttime[$c]','$endtime[$c]','$originalteam[$d]','Original', '$months[$c]')";
      if (mysqli_query($conn, $orisql)){
      }else{
      echo mysqli_error($conn);
      }
      }
  }
  for($b=0; $b < $rowcount; $b++){
    for($a=0; $a < $numberofdays; $a++){
          $months[$a] =  (new DateTime())->setISODate($years, $weekno[$a])->format('F');
          if($weekno[$a] == 1 && $months[$a] == 'December'){
          $months[$a] = 'January';
          }
          $empschedsql = "INSERT INTO `schedule`(`schedcode`, `week`, `day`,`date`,`year`,`starttime`, `endtime`, `team`, `indi`, `month`, `empid`) 
          VALUES 
          ('$empid[$b]$getdate[$a]','$weekno[$a]','$getday[$a]','$getdate[$a]','$years','$starttime[$a]','$endtime[$a]','$empteam[$b]','0', '$months[$a]','$empid[$b]')";
          if (mysqli_query($conn, $empschedsql))
          {
          $alert="<div class='alert alert-success'>
          <strong style='font-size:12pt;'>Schedule Successfully Added</strong> 
          </div>";
          //echo $a.'<br/>';
          //header('location: schedule.php');
          } 
          else 
          {
          $alert="<div class='alert alert-danger'>
          <strong style='font-size:12pt;'>Week # ".$week." schedule alreay exist</strong> 
          </div>";
          //echo mysqli_error($conn);
          } 
    }
  }
}
/* 
for($i=0;$i<$rowcount;$i++) //loop number of employee under specific team
{
$schedcode =  $empid[$i].''.$getday[$i].''.$week.''.$years;
if( $getday[$i]!="")
{
$comsql = "INSERT INTO `schedule`(`schedcode`, `week`, `day`,`date`,`year`,`starttime`, `endtime`, `team`, `empid`, `indi`, `month`) 
VALUES 
('$empid[$i]$getday[0]$week$years','$week','$getday[0]','$getdate[0]','$years','$start[0]','$end[0]','$team', '$empid[$i]', '0', '$getmonth'),
('$empid[$i]$getday[1]$week$years','$week','$getday[1]','$getdate[1]','$years','$start[1]','$end[1]','$team', '$empid[$i]', '0', '$getmonth'),
('$empid[$i]$getday[2]$week$years','$week','$getday[2]','$getdate[2]','$years','$start[2]','$end[2]','$team', '$empid[$i]', '0', '$getmonth'),
('$empid[$i]$getday[3]$week$years','$week','$getday[3]','$getdate[3]','$years','$start[3]','$end[3]','$team', '$empid[$i]', '0', '$getmonth'),
('$empid[$i]$getday[4]$week$years','$week','$getday[4]','$getdate[4]','$years','$start[4]','$end[4]','$team', '$empid[$i]', '0', '$getmonth'),
('$empid[$i]$getday[5]$week$years','$week','$getday[5]','$getdate[5]','$years','$start[5]','$end[5]','$team', '$empid[$i]', '0', '$getmonth'),
('$empid[$i]$getday[6]$week$years','$week','$getday[6]','$getdate[6]','$years','$start[6]','$end[6]','$team', '$empid[$i]', '0', '$getmonth')
";
}
} */
if(isset($_POST['set'])){
$dater = $_POST['date'];
$enddate = count($dater)-1;
$daterange = date('F j, Y', strtotime($dater[0])).' - '.date('F j, Y', strtotime($dater[$enddate]));
$show = "style='display: block'";
}
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>Super Admin | Dashboard
    </title>
    <!-- Bootstrap core CSS-->
    <link href="../vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <!-- Custom fonts for this template-->
    <link href="../vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
    <!-- Page level plugin CSS-->
    <link href="../vendor/datatables/dataTables.bootstrap4.css" rel="stylesheet">
    <!-- Custom styles for this template-->
    <link href="../css/sb-admin.css" rel="stylesheet">
    <link href="../css/style.css" rel="stylesheet">
    <link href="../css/style.css" rel="stylesheet">
    <link rel="icon" href="../images/logo.jpg" type="image/gif" sizes="16x16">
    <style>
      #pageloader
      {
        background-color: #fff;
        display: none;
        height: 100%;
        position: fixed;
        width: 100%;
        z-index: 9999;
      }
      #pageloader img
      {
        left: 50%;
        margin: 0;
        position: absolute;
        top: 50%;
        transform: translate(-50%, -50%);
      }
      #preloader
      {
        background-color: #fff;
        display: block;
        height: 100%;
        position: fixed;
        width: 100%;
        z-index: 9999;
      }
      #preloader img
      {
        left: 50%;
        margin: 0;
        position: absolute;
        top: 50%;
        transform: translate(-50%, -50%);
      }
    </style>
    <script>
      function display_c(){
        var refresh=1000;
        // Refresh rate in milli seconds
        mytime=setTimeout('display_ct()',refresh)
      }
      function display_ct() {
        var x = new Date();
        var hour = x.getHours();
        var minute = x.getMinutes();
        var second = x.getSeconds();
        if (hour > 12) {
          hour = hour - 12;
        }
        if(hour==0){
          hour=12;
        }
        if(hour <10 ){
          hour='0'+hour;
        }
        if(minute <10 ) {
          minute='0' + minute;
        }
        if(second<10){
          second='0' + second;
        }
        var months = ["January","February","March","April","May","June","July","August","September","October","November","December"];
        var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
        var hours = x.getHours();
        var ampm = hours >= 12 ? 'PM' : 'AM';
        document.getElementById('dmdy').innerHTML = days[x.getDay()] +", "+ months[x.getMonth()]+" "+x.getDate()+" "+x.getFullYear();
        document.getElementById('tt').innerHTML = hour + ":" + minute + ":" + second + " "+ampm;
        display_c();
      }
      function cb(){
        var off =  document.getElementsByName("off[]");
        var offlength = off.length;
        var hol =  document.getElementsByName("hol[]");
        var hollength = hol.length;
        var start =  document.getElementsByName("start[]");
        var end =  document.getElementsByName("end[]");
        for(k=0; k < offlength;k++)
        {
          //off[k].checked = false;
          start[k].readOnly = false;
          end[k].readOnly = false;
          start[k].type = "time";
          end[k].type = "time";
          end[k].hidden = false;
          if(off[k].checked == true){
            hol[k].disabled = true;
            start[k].readOnly = true;
            end[k].readOnly = true;
            start[k].type = 'text';
            start[k].value = 'OFF';
            end[k].type = 'text';
            end[k].value = 'OFF';
            end[k].hidden = true;;
          }
          else{
            hol[k].disabled = false;
          }
          if(hol[k].checked == true){
            start[k].readOnly = true;
            end[k].readOnly = true;
            off[k].disabled = true;
            start[k].type = 'text';
            start[k].value = 'HOLIDAY OFF';
            end[k].type = 'text';
            end[k].value = 'HOLIDAY OFF';
            end[k].hidden = true;
          }
          else{
            off[k].disabled = false;
          }
        }
        /*
    if (document.getElementById("off").checked == true) {
        document.getElementById("hol").disabled = true;
        } else {
            document.getElementById("hol").disabled = false;
    }
    if (document.getElementById("hol").checked == true) {
    document.getElementById("off").disabled = true;
    } else {
       document.getElementById("off").disabled = false;
    }
*/
      }
      function show(){
        document.getElementById('divsched').hidden= false;
        var weekno = document.getElementById('week').value;
        window.location.href = "addsched.php?week=" + week1 + "&week2=" + week2;
      }
      function validrange(){
        var week1 = parseInt(document.getElementById('week').value);
        var week2 = parseInt(document.getElementById('week2').value);
        var team = document.getElementById('team').value;
        var button = document.getElementById('set');
        var form = document.getElementById('theForm');
        if(week2 < week1){
          button.disabled = true;
          form.elements[0].reportValidity();
          document.getElementById('weekalert').hidden = false;
        }
        else{
          window.location.href = "addsched.php?week=" + week1 + "&week2=" + week2 +  "&team=" + team;
        }
      }
    </script>
  </head>
  <body id="page-top" onload=display_ct();>
    <div id="pageloader">
      <img src="../images/loaderS.gif" alt="processing..." height="150px" width="200px"/>
    </div>
    <div id="preloader">
      <img src="../images/loaderS.gif" alt="processing..." height="150px" width="200px"/>
    </div>
    <form method="POST" id="theForm">
      <?php include('uppernav.php')?>
      <!-- Sidebar -->
      <?php 
        $dashboard = "active";
        include('sidebar.php');
        ?>
      <div id="content-wrapper">
        <div class="container-fluid">
          <!-- Breadcrumbs-->
          <ol class="breadcrumb">
            <li class="breadcrumb-item">
              <a href="schedule.php">Employee Schedule
              </a>
            </li>
            <li class="breadcrumb-item active" >
              Add Schedule
            </li>
          </ol>
          
          <div class="row p-3" >
            <div class="col-sm-12 form-group">
              <div class="alert alert-danger alert-dismissible fade show" id="weekalert" role="alert" hidden>
                Week 2 must be greater than Week 1
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                  <span aria-hidden="true">&times;
                  </span>
                </button>
              </div>
              <?php echo $alert?>
            </div>
            <div class="col-sm-12 form-inline">
              <label>
                <b> Week : &nbsp &nbsp 
                </b>
              </label>
              <select name="week" id="week" class="form-control" onchange='validrange()' required>
                <option value='' disabled selected> Week  
                </option>;
                <?php 
                    $yearw = idate('W', mktime(0, 0, 0, 12, 28, $year));
                    $month = 1;
                    $year = date("Y");
                    $timestamp = mktime(0, 0 , 0, $month, 1, $year); 
                    $timestamp += (60 * 60 * 24); 
                    $a= 1;
                    $range = range(1, $yearw ); 
                    foreach ($range as $week_no) {
                    $week_start = new DateTime();
                    $week_start->setISODate($year, $week_no);
                    $week_start->modify('-1 day');
                    $seven_day_week = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
                    $week = array();
                    $day = $seven_day_week[$i];
                    $week[$day] = $week_start->format('n/j/Y');
                    if($_GET['week'] == $a ){
                    echo '
                    <option value='.$a.' selected>Week  '.$a.' - '.$week[$day] = $week_start -> format('F j,Y').'</option>
                    ';
                    }else{
                    echo '
                    <option value='.$a.'>Week  '.$a.' - '.$week[$day] = $week_start -> format('F j,Y').'</option>
                    ';
                    }
                    $week_start->modify('+1 day');
                    $a++;
                    }
                    ?>
              </select> &nbsp - &nbsp
              <select name="week2" id="week2" class="form-control" onchange='validrange()'required>
                <option value='' disabled selected> Week  
                </option>;
                <?php 
                    $month = 1;
                    $year = date("Y");
                    $timestamp = mktime(0, 0 , 0, $month, 1, $year); 
                    $timestamp += (60 * 60 * 24); 
                    $a= 1;
                    $range = range(1, $yearw ); 
                    foreach ($range as $week_no) {
                    $week_start = new DateTime();
                    $week_start->setISODate($year, $week_no);
                    $week_start->modify('+5 day');
                    $seven_day_week = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Hey');
                    $week = array();
                    $day = $seven_day_week[$i];
                    if($_GET['week2'] == $a ){
                    echo '
                    <option value='.$a.' selected>Week  '.$a.' - '.$week[$day] = $week_start -> format('F j,Y').'</option>
                    ';
                    }else{
                    echo '
                    <option value='.$a.' >Week  '.$a.' - '.$week[$day] = $week_start -> format('F j,Y').'</option>
                    ';
                    }
                    $week_start->modify('-2 day');
                    $a++;
                    }
                    ?>
              </select> &nbsp &nbsp
              <label>
                <b> Team : &nbsp &nbsp 
                </b>
              </label>
              <?php 
                switch ($team) {
                case 'All':
                $all =  'selected';
                break;
                default:
                # code...
                break;
                }
                $qt = "SELECT * FROM empdetails GROUP BY team";                                                
                $rt = mysqli_query ($conn,$qt); 
                echo "<select name='team' id='team' class='form-control' required>"; 
                echo "<option value='' disabled selected> Team </option>";
                echo "<option value='All' $all> All </option>";
                while($r = mysqli_fetch_array($rt)) {
                if($team==$r['team']){
                echo "<option value='".$r['team']."' selected='selected'>".$r['team']."</option>";
                }
                else{
                echo "<option value='".$r['team']."' >".$r['team']."</option>";
                }
                }
                echo "</select>"; ?>
              &nbsp &nbsp
              <button type="submit" name="set" class="btn btn-success form-control" id="set" >Set
              </button>
            </div>
            <div class="col-sm-12"  id="divsched" 
                 <?php echo $show?>>
            <hr>
            <div class="row">
              <div class="col-sm-2 form-group">
                <div class="tableFixHead">
                  <table class="table table-bordered table-sm table-fixed" id="emptable">
                    <thead class="thead-dark">
                      <tr>
                        <th>Employee
                        </th>
                      </tr>
                    </thead>
                    <tbody>
                      <?php 
                        if($team == 'All'){
                        $emplistsql = "SELECT * FROM empdetails JOIN empinfo ON empdetails.detailid= empinfo.empid";
                        }else{
                        $emplistsql = "SELECT * FROM empdetails JOIN empinfo ON empdetails.detailid= empinfo.empid WHERE team='$team'";
                        }
                        $empquery = mysqli_query($conn, $emplistsql);
                        while($emprow = mysqli_fetch_array($empquery)){
                        echo'<tr>
                        <td>'.$emprow['firstname'].' '.$emprow['surname'].'</td>
                        </tr>';
                        }
                        ?>
                    </tbody>
                  </table>
                </div>
              </div>
              <div class="col-sm-10 form-group" >
                <div class="row">
                  <?php 
                    $month = 1;
                    $year = date("Y");
                    $timestamp = mktime(0, 0 , 0, $month, 1, $year); 
                    $timestamp += (60 * 60 * 24); 
                    $range = range($_GET['week'], $_GET['week2'] ); 
                    foreach ($range as $week_no) {
                    $week_start = new DateTime();
                    $week_start->setISODate($year, $week_no);
                    $week_start->modify('-1 day');
                    $seven_day_week = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
                    $week = array();
                    for ($i = 0; $i < 7; $i++) {
                    $day = $seven_day_week[$i];
                    $week[$day] = $week_start->format('n/j/Y');
                    echo '
                    <div class="col-sm-3 form-group"  hidden>
                    <div class="col-sm-12">
                    <label> <b>'. $day = $seven_day_week[$i].'</b></label>
                    <input type="text" name="day[]" placeholder="Time" class="form-control" value="'.$day = $seven_day_week[$i].'" hidden> 
                    </div>
                    <div class="col-sm-12">
                    <p>'.$week[$day] = $week_start->format('F j, Y').'</p>
                    <input type="text" name="date[]"  placeholder="Time" class="form-control" value="'.$week[$day] = $week_start->format('Y-m-d').'" hidden> 
                    </div>
                    <div class="col-sm-12">
                    <input type="text" name="weekno[]" value="'.$week_no.'" >
                    <input type="text" name="months[]" placeholder="Time" class="form-control" value="'.$week[$day] = $week_start->format('F').'" > 
                    </div>
                    </div>
                    ';
                    $week_start->modify('+1 day');
                    }
                    }
                    ?>
                                        <?php 
                    for($a=0; $a < 7; $a++){
                    echo'
                    <div class="col-sm-4 form-group">
                    <div class="col-sm-12">
                    <label> <b>'. $seven_day_week[$a].'</b></label>
                    </div>
                    <div class="col-sm-12 form-inline">
                    <input type="checkbox" class="off" name="off[]" id ="off" onclick="cb()" value="OFF" style="height: 20px; width: 20px;">&nbsp<label>&nbsp<b> OFF</b> </label>
                    &nbsp&nbsp&nbsp&nbsp
                    <input type="checkbox"  class="hol" name="hol[]" id="hol" onclick="cb()" value="HOLIDAY OFF" style="height: 20px; width: 20px;">&nbsp<label>&nbsp<b> HOLIDAY OFF</b> </label>
                    </div>
                    <div class="col-sm-12 form-inline">
                    <input type="time" name="start[]" id="start" placeholder="Time" class="form-control"> &nbsp-&nbsp<input type="time" name="end[]" id="end" placeholder="Time" class="form-control" >
                    </div>
                    </div>';
                    }
                    ?>
                  <div class="col-sm-3 form-group">
                    <br>
                    <br>
                    <br>
                    <span class="pull-right">  
                      <button type="button" class="btn btn-success" data-toggle="modal" data-target="#addsched">
                        <i class="fa fa-check">
                        </i> Submit 
                      </button>
                      <button class="btn btn-danger">Cancel
                      </button>
                    </span>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- Icon Cards-->
        <!-- /.container-fluid -->
        <!-- Sticky Footer -->
      </div>
      <!-- /.content-wrapper -->
      </div>
    <!-- /#wrapper -->
    <!-- Scroll to Top Button-->
    <a class="scroll-to-top rounded" href="#page-top">
      <i class="fas fa-angle-up">
      </i>
    </a>
    <!-- Logout Modal-->
    <div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
         aria-hidden="true">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLabel">Ready to Leave?
            </h5>
            <button class="close" type="button" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">×
              </span>
            </button>
          </div>
          <div class="modal-body">Select "Logout" below if you are ready to end your current session.
          </div>
          <div class="modal-footer">
            <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel
            </button>
            <a class="btn btn-primary" href="login.html">Logout
            </a>
          </div>
        </div>
      </div>
    </div>
    <div class="modal fade" id="addsched" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
      <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">
          <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLabel">Confirm Schedule
            </h5>
            <button class="close" type="button" data-dismiss="modal" aria-label="Close">
              <span aria-hidden="true">×
              </span>
            </button>
          </div>
          <div class="modal-body">Are you sure you want to add schedule?
          </div>
          <div class="modal-footer">
            <input type="submit" class="btn btn-success" name="addsched" value=" ✓ Yes" style="margin-right: 5px;" > 
            <button class="btn btn-danger" type="button" data-dismiss="modal">
              <i class="fa fa-close">
              </i> No
            </button>
          </div>
        </div>
      </div>
    </div>
    <!-- Bootstrap core JavaScript-->
    <script src="../vendor/jquery/jquery.min.js">
    </script>
    <script src="../vendor/bootstrap/js/bootstrap.bundle.min.js">
    </script>
    <!-- Core plugin JavaScript-->
    <script src="../vendor/jquery-easing/jquery.easing.min.js">
    </script>
    <!-- Page level plugin JavaScript-->
    <script src="../vendor/chart.js/Chart.min.js">
    </script>
    <script src="../vendor/datatables/jquery.dataTables.js">
    </script>
    <script src="../vendor/datatables/dataTables.bootstrap4.js">
    </script>
    <!-- Custom scripts for all pages-->
    <script src="../js/sb-admin.min.js">
    </script>
    <!-- Demo scripts for this page-->
    <script src="../js/demo/datatables-demo.js">
    </script>
    <script src="../js/demo/chart-area-demo.js">
    </script>
    <script language="javascript" type="text/javascript">
      $(document).ready(function(){
        $("form").on("submit", function(){
          $("#pageloader").fadeIn();
        }
                    );
        //submit
        $('#preloader').fadeOut();
      }
                       );
      //document ready
    </script>
    </form>
  <script language="javascript" type="text/javascript">
    $(document).ready(function(){
      $("form").on("submit", function(){
        $("#pageloader").fadeIn();
      }
                  );
      //submit
      $('#preloader').fadeOut();
    }
                     );
    //document ready
  </script>
  </body>
</html>
