<?php 
include("include/config.inc.php");
if(!isset($_SESSION['s_activId']))
{
  $_SESSION['s_urlRedirectDir'] = $_SERVER['REQUEST_URI'];
  header("Location:checkLogin.php");
}
else
{
	$clientId   = isset($_REQUEST['clientId']) && $_REQUEST['clientId'] != '' ? $_REQUEST['clientId'] : 0;	 

    if($clientId > 0)
	{
	  $selectRojmelId = "SELECT rojmelId 
	                           FROM client
	                     WHERE clientId = ".$clientId; 
	  $selectRojmelIdRes = mysql_query($selectRojmelId);
	  if($id = mysql_fetch_array($selectRojmelIdRes))
	  {
	    $rojmelId = $id['rojmelId'];
	  }
	  
	  if($rojmelId > 0)
	  {
		  $deleteRoj = "DELETE FROM rojmel 
						  WHERE rojmelId = ".$rojmelId;
		  $res = mysql_query($deleteRoj);
		  if($res)
		  {
		   $deleteEntry = "DELETE FROM client
                         WHERE  
					  clientId = ".$clientId; 
			$insertClientRes = mysql_query($deleteEntry);
			if(!$insertClientRes)
			{
			  echo "Delete Fail";
			}
		  }
		  
	  }
	  else
	  {
	   $deleteEntry = "DELETE FROM client
                         WHERE  
					  clientId = ".$clientId; 
	    $insertClientRes = mysql_query($deleteEntry);
	    if(!$insertClientRes)
	    {
	  	  echo "Delete Fail";
	    }
	    else
	    {
	      header("Location:clientList.php");
	    }
	  }
	}
	include("./bottom.php");
	$smarty->display("clientList.tpl");
}
?>