<?php
include_once("../include/main.inc.php");
include_once("../ajax_functions.php");
check_session('MyCpanel','index.php');

################ Paging Starts From Here ##################
@extract($_REQUEST);

$heading="Add new City";
//$record_type="member";
$script_name="add-new-city.php";
$table_name="city";

admin_header();
if($_REQUEST[action]=="add_record" && $cityName!="") {
	@extract($_REQUEST);
	$numCnt=getCount($table_name," where cityName='$cityName'");
	if($numCnt>0) {
		$_SESSION[session_message]=$record_type.' already exist';
	}
	else{
		$sql=db_query("insert into $table_name set  cityName='$cityName', cityURL='$cityURL'");
		$_SESSION[session_message]=$record_type.' has been added successfully';
		header('Location: http://www.naturaltherapypages.in/sitepanel/manage-city.php');
		exit;
	}
}

if($_REQUEST[action]=='update_record' && $cityID!="" ) {
	@extract($_REQUEST);
	$numCnt=getCount($table_name,"where cityName='$cityName'");
	if($numCnt>0) {
		$_SESSION[session_message]=$record_type.' already exist';
		
	}else {
	echo $cityID."fffffff";
	updateTable($table_name,"cityName='$cityName',cityURL='$cityURL' where cityID='$cityID'");
  $_SESSION[session_message]=$record_type.' has been updated successfully';
	header('Location: http://www.naturaltherapypages.in/sitepanel/manage-city.php');
	exit;
}
}

echo $cityID."id";
echo $id."record";
if($id=="delete_record" && $cityID!="" ) {
	@extract($_REQUEST);

		db_query("delete from city where cityID='$cityID'");
		echo "11111111111";
		$_SESSION[session_message]='City has been deleted successfully';
		header('Location: http://www.naturaltherapypages.in/sitepanel/manage-city.php');
			exit;
	}

?>
<div align="left" class="myTitle"><?=$heading;?></div>
<hr size="2" width="100%" color="#92B2D6">
<?php
print_message();
$res=getResult($table_name," where cityID='$cityID'");

if($res[cityID]!="") {
	$cityName=$res[cityName];
	$cityURL=$res[cityURL];
}
else{
	$cityName=$cityName;
	$cityURL=$cityURL;
}
?>

<table width="100%"  border="0" cellpadding="0" cellspacing="2">
 <tr>
  <td align="right"><input type="button" class="button" value="Go Back To Manage <?=$record_type;?>" onclick="window.location.href='http://www.naturaltherapypages.in/sitepanel/manage-city.php';"></td>
 </tr>
</table><br />

<form name="formn" method="post" action="" enctype="multipart/form-data" onsubmit="return validate(this);">
<?=$msg;?>
<table width="100%"  border="0" cellpadding="0" cellspacing="2" class="lightBorder">
 <tr>
  <td class="brdrbtm" width="125"><b>City Name</b>*</td>
  <td class="brdrbtm">
   <input name="cityName" class="txtfieldadmin" size="70" value="<?=$cityName;?>" id="NOBLANK~Please enter category name~DM~">
  </td>
 </tr>
 
 <tr>
  <td class="brdrbtm" width="125"><b>City Url</b>*</td>
  <td class="brdrbtm">
   <input name="cityURL" class="txtfieldadmin" size="70" value="<?=$cityURL;?>" id="NOBLANK~Please enter category name~DM~">
  </td>
 </tr>
 
 
 <tr>
  <td></td>
  <td class="brdrbtm">
   <?php
   if($res[cityID]=="") {
	   ?>
	   <input type="submit" name="add_record" class="button" value="Add <?=$record_type;?>"><input type="hidden" name="action" value="add_record">
	   <?php	   
   }
   else{
	   ?>
	   <input type="submit" name="update_record" class="button" value="Update"><input type="hidden" name="action" value="update_record">
	   <input type="hidden" name="cityID" value="<?=$res[cityID];?>">
	   <?php	   
   }
   ?>
   &nbsp;&nbsp;<input type="button" name="cancel" class="button" value="Cancel" onclick="javascript: window.location.href='<?=SITE_ADMIN_URL;?>/<?=$redirect_script_name;?>?parentID=<?=$parentID;?>&cityID=<?=$cityID;?>&start=<?=$start;?>&pagesize=<?=$pagesize;?>'">   
  </td>
 </tr>
</table>
</form>




<?php
admin_footer();	
exit;
?>