<?php require_once('../Connections/oprmConn.php');  
include('check-admin-session.php'); 

if(!isset($_REQUEST['payslip_id'])){
	header("Location: payslips-list");
}
if(isset($_REQUEST['payslip_id'])){
	//check task id
mysql_select_db($database_oprmConn, $oprmConn);
// $query_checktaskid = "SELECT * FROM weby_tasks WHERE status IN ('A','C') AND task_id = '$_REQUEST[payslip_id]'";
$query_checktaskid = "SELECT * FROM weby_payslips WHERE status IN ('A','C','CO') AND payslip_id = '$_REQUEST[payslip_id]'";
$checktaskid = mysql_query($query_checktaskid, $oprmConn) or die(mysql_error());
$row_checktaskid = mysql_fetch_assoc($checktaskid);
$totalRows_checktaskid = mysql_num_rows($checktaskid);
if($totalRows_checktaskid==0){
	header("Location: payslips-list");
}
	
	//for delete task
mysql_select_db($database_oprmConn, $oprmConn);
$query_deletetask = "UPDATE weby_payslips set status = 'D', updated_by = '$_SESSION[user_id]' WHERE status IN ('A','C','CO') AND payslip_id = '$_REQUEST[payslip_id]'";
$deletetask = mysql_query($query_deletetask, $oprmConn) or die(mysql_error());
	header("Location: payslips-list?msgdelpayslip");
}
?>