<?php
include("include/config.inc.php");
if(!isset($_SESSION['s_activId']))
{
  $_SESSION['s_urlRedirectDir'] = $_SERVER['REQUEST_URI'];
  header("Location:checkLogin.php");
}
else
{
	$partyId   = $_REQUEST['partyId'] ?  $_REQUEST['partyId'] : 0;
	$to        = $_REQUEST['toDtYear']."-".$_REQUEST['toDtMonth']."-".$_REQUEST['toDtDay'];  
	$from      = $_REQUEST['fromDtYear']."-".$_REQUEST['fromDtMonth']."-".$_REQUEST['fromDtDay'];  

    if(isset($_POST['btn']))
	{
	  $deleteEntry = "UPDATE client
                         SET cstatus = 'D'
                        	 WHERE cDate BETWEEN   
						  '".$to."' AND '".$from."'
						  AND partyId = ".$partyId;
						   
	  $insertClientRes = mysql_query($deleteEntry);
	  if(!$insertClientRes)
	  {
	  	echo "Update Fail";
	  }
	  else
	  {
	    header("Location:cstanding.php");
	  }
	  
	}
	
	$z = 0;
	$clientArray = array();
	$selectClient = "SELECT * FROM party
	                  WHERE partyType = 'C'";
	$res = mysql_query($selectClient);
	while($row = mysql_fetch_array($res))
	{
	  $clientArray['partyId'][$z] = $row['partyId'];
	  $clientArray['partyName'][$z] = $row['partyName'];
	  $z++;
	}
	
	include("./bottom.php");
	$smarty->assign('clientArray',$clientArray);
	$smarty->display("cstanding.tpl");
}
?>