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

    if($vepariId > 0)
	{
		
	  $select = "SELECT rojmelId 
	                FROM vepari
				 WHERE vepariId = ".$vepariId;
	  $res = mysql_query($select);
	  if($row = mysql_fetch_array($res))
	  {
	    $rojmelId = $row['rojmelId'];
	  }
	  
	  if($rojmelId > 0)
	  {
	    $deleteVepari = "DELETE FROM rojmel
	                    WHERE rojmelId = ".$rojmelId;
	    $deleteVepariRes = mysql_query($deleteVepari);
	    if($deleteVepariRes)
	    {
	      $deleteEntry = "DELETE FROM vepari
							WHERE  
						 vepariId = ".$vepariId; 
		  $insertClientRes = mysql_query($deleteEntry);
		  if(!$insertClientRes)
		  {
		    echo "Delete Fail";
		  }
		}
	  }
	  else
	  {
	    $deleteEntry = "DELETE FROM vepari
							WHERE  
						 vepariId = ".$vepariId; 
		$insertClientRes = mysql_query($deleteEntry);
		if(!$insertClientRes)
		{
		  echo "Delete Fail";
		}
		else
		{
	      header("Location:vepariList.php");
		}
	  }
	}
	
	include("./bottom.php");
	$smarty->display("vepariList.tpl");
}
?>