<?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']))
	{
	  foreach($_REQUEST['partyId'] as $did)
	  {
		$partyId    = isset($_REQUEST['partyId'][$did]) && $_REQUEST['partyId'][$did] != '' ? $_REQUEST['partyId'][$did] : 0;
		
	    $deleteEntry = "UPDATE vepari
                         SET vstatus = 'D'
                        	 WHERE vDate BETWEEN   
						  '".$to."' AND '".$from."'
						  AND partyId = ".$did;
						   
	    $insertClientRes = mysql_query($deleteEntry);
	    if(!$insertClientRes)
	    {
	  	  echo "Update Fail";
	    }
	    else
	    {
	      header("Location:vstanding.php");
	    }
	  }
	}
	
	$z = 0;
	$clientArray = array();
	$selectClient = "SELECT * FROM party
	                  WHERE partyType = 'V'
					 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("vstanding.tpl");
}
?>