<?php
  session_start();
  require_once '../system/conn.php';
  $date=explode('-',date("Y-m-d", strtotime("last day of previous month")));
  $month=$date[1];
  $year=$date[0];
  $delete=$conn->query("DELETE FROM `admin_salary_attendance` WHERE `month`='$month' AND `year`='$year' ");
  if($delete){
    //$delete_ad=$conn->query("DELETE FROM `advance_cal` WHERE `month`='$month' AND `year`='$year' ");
    //if($delete_ad){
      $delete_sa=$conn->query("DELETE FROM `admin_emp_salary` WHERE `month`='$month' AND `year`='$year' ");

      if($delete_sa){
        $delete_sas=$conn->query("DELETE FROM `admin_ot_details` WHERE `month`='$month' AND `year`='$year' ");
        if($delete_sas){
            $_SESSION['delete']="Data deleted successfully . Click generate for re-regenerate";
            echo "<script>window.location.assign('gross-sheet.php')</script>";
        }
      }
    //}
  }
?>