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

    if(isset($_POST['btn']))
	{
	  foreach($_REQUEST['partyId'] as $did)
	  {
		$partyId    = isset($_REQUEST['partyId'][$did]) && $_REQUEST['partyId'][$did] != '' ? $_REQUEST['partyId'][$did] : 0;
		
	    $deleteEntry = "UPDATE client
                         SET cstatus = 'D'
                        	 WHERE cDate BETWEEN   
						  '".$to."' AND '".$from."'
						  AND partyId = ".$did;
						   
	    $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'
					 ORDER BY partyName";
	$res = mysql_query($selectClient);
	while($row = mysql_fetch_array($res))
	{
	  $clientArray[$z]['partyId']   = $row['partyId'];
	  $clientArray[$z]['partyName'] = $row['partyName'];
	  $z++;
	}
	
	include("./bottom.php");
	$smarty->assign('clientArray',$clientArray);
	$smarty->display("cstanding.tpl");
}
?>