
<!--/span-->				<div class="span9">
<script type="text/javascript">
	function newLocation(){
    	d = document.Location;
    	d.lid.value = "";
    	d.cname.value = "";
    	d.cparent.value = "";
    	d.action.value ="new";
    	d.submitLocation.value ="New Location";
    	document.getElementById("form-tab").innerHTML ="New Location";
    	show("formLocation");
    	location.href = "#formLocation";
    }	
    function editLocation(lid,cparent){
    	d = document.Location;
    	d.lid.value = lid;
    	d.cname.value = document.getElementById('name-'+lid).innerHTML;
    	d.cparent.value = cparent;
    	d.action.value ="edit";
    	d.submitLocation.value ="Edit Location";
    	document.getElementById("form-tab").innerHTML ="Edit Location";
    	show("formLocation");
    	location.href = "#formLocation";
    }	
    function deleteLocation(Location){
    	if (confirm('Delete Location "' + document.getElementById('name-'+Location).innerHTML + '"?'))
    	window.location = "locations.php?action=delete&lid=" + Location;
    }
</script>

<div class="page-header">

	<h1>Locations</h1>
	Locations are disabled, please go to the settings to enable this feature.<br />	
	<button class="btn btn-primary pull-right" onclick="newLocation();return false;">
		<i class="icon-pencil icon-white"></i>
		New Location	</button>		
</div>


Manage your website locations<form class="well form-inline" action="locations.php" method="get" ><select name="lid" id="lid">
	  <option>None</option><option  value='1'>Indore</option></select><input type="hidden" name="action" value="filter" />
			<input type="submit" class="btn" value="Filter" /></form>	
<div id='formLocation' style="display:none;">
	<div id="form-tab" class="form-tab"></div>
    <form class="well" name="Location" action="locations/add" method="post" onsubmit="return checkForm(this);">
		<fieldset>
			<p>
				<label>Name</label>
				<input name="cname" type="text" class="text-long" lang="false" onblur="validateText(this);" />
			</p>                          
			<p>
				<label>Parent</label>
        <select name="cparent" id="cparent" onChange="validateNumber(this);" lang="false">
    <option>None</option> <?php foreach($locations as $location){?>
<option  value='<?php echo $location->id;?>'><?php echo $location->name;?></option>
<?php } ?></select>			</p>
			<input id="submitLocation" type="submit" value="" class="btn btn-primary" />
			<input type="submit" value="Cancel" class="btn" onclick="hide('formLocation');return false;" />
			<input type="hidden" name="lid" value="" />
			<input type="hidden" name="action" value="" />
		</fieldset>
    </form>            
</div>

<table class="table table-bordered">
	<thead>
	<tr>
		<th>Name</th>
		<th>Parent</th>
		<th>&nbsp;</th>
	</tr>
	</thead>
	<tbody>
	<?php foreach($locations as $location){?>
		<tr>      
		<td><?php echo $location->name;?></td>
		<td><?php echo $location->parent_id;?></td>
		<td class="action">
        	<button  class="btn btn-primary" onclick="editLocation('<?php echo $location->id;?>','0');return false;">
				<i class="icon-edit icon-white"></i>
			</button>
        	<button class="btn btn-danger" onclick="deleteLocation('<?php echo $location->id;?>');return false;" >
				<i class="icon-trash icon-white"></i>
			</button>
        </td>
	</tr>

	<div style="display:none;" id="name-<?php echo $location->id;?>"><?php echo $location->name;?></div>
	<?php } ?>
		</tbody>
</table>
</div><!--/span--> 
