<?php

$PageSecurity = 15;

$title = _('Dealer Store Types');

 $modid=$_REQUEST['modid'];

$frmid=$_REQUEST['frmid'];

$table='dealer_store';

$url="&modid=".$modid."&frmid=".$frmid;

$targetpage="index.php?route=".$_REQUEST['route'].$url;

$targetpage1="index.php?route=DealerDistrbutions/Setup/dealer_storetype_add".$url;

if($_REQUEST['action']=='delete')

{

//echo "delete from dbl_dealer_store_type where id='".$_REQUEST['id']."'";

$del=DB_query("delete from dbl_dealer_store_type where id='".$_REQUEST['id']."'",$db);

//$s->pageLocation($targetpage.'&action=Addnew&daction=Deleted');



}	



	

?><link rel="stylesheet" href="css/new_mxerp.css">

<div class="body_contain">

<div class="tab_div">



 <div align="left"> <a href="index.php?route=DealerDistrbutions/Setup/dealer_storetype_add<?php echo $rurl; ?>&action=Addnew">

   <input type="button" name="Add New" value="Add New" class="search" /></a></div>

<h1>Associate Store Master</h1>

	

<?php

if (!isset($SelectedType))

{

   	$sql = "SELECT * FROM dbl_dealer_store_type ";

	$result = DB_query($sql,$db);

?>

	<table border="1" cellpadding="2" cellspacing="2"  width="100%;">

	<tr class="row1">

		<td width="23%" class="tabledata"><strong>Company</strong></td>

		<td width="34%" class="tabledata"><strong>Associate Store Type Name </strong></td>

		<td width="38%" class="tabledata"><strong>Associate Store Type Code</strong></td>

		<td width="5%" colspan="2" class="tabledata"><strong>Action</strong></td>

		

	</tr><?php

	$k=0; //row colour counter

while ($myrow = DB_fetch_array($result))

 {

 	    $associate=$s->GetTotalRecordsTalbes('dbl_dealer_store',"dealer_store_type='".$myrow['id']."'");

		

		if($associate<=0)

		{

		$status=0;

		}

		else

		{

		$status=1;

		}

 

 

 

 

 

 

 

 

 ?>

	<tr class="row1">

	<td><?php echo $s->getField('companies','CompanyId',$myrow['company'],'CompanyName'); ?></td>

		<td><?php echo $myrow['store_type_name'];?></td>

		<td><?php echo $myrow['store_type_code'];?></td>

		<td colspan="2"><a href="index.php?route=DealerDistrbutions/Setup/dealer_storetype_add&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&id=<?php echo $myrow['id'];?>&action=Edit"><img src="images/icon-edit.png"  width="10" height="10"/></a>

		

<?php if($status==0) { ?>				

		<a href='index.php?route=DealerDistrbutions/Setup/dealer_store_type_index&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&id=<?php echo $myrow['id'];?>&action=delete' onclick="return confirm('This Associate Store Type will be deleted. Are you sure?')"><img src="images/delete.Gif"  width="10" height="10"/></a>

<?php } else { ?>

<img src="images/delete.Gif"  width="10" height="10" onclick="abc()"/>

<?php } ?>		

		

		

		</tr>

	  </tr><?php

	}?>

</table>

</div></div>

	<?php }

include('includes/footer.inc');

?>



<script language="javascript">



function showdealer(str)

{

if (window.XMLHttpRequest)

  {// code for IE7+, Firefox, Chrome, Opera, Safari

  xmlhttp=new XMLHttpRequest();

  }

else

  {// code for IE6, IE5

  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");

  }

xmlhttp.onreadystatechange=function()

  {

  if (xmlhttp.readyState==4 && xmlhttp.status==200)

    {

    document.getElementById("dealercode").innerHTML=xmlhttp.responseText;

    }

  }

 

xmlhttp.open("GET","getdealerdata.php?country="+str,true);

xmlhttp.send();





}









function validate()

{



	if(document.getElementById("company").value=='0')

	{

		alert("Please Select The Company First");

		document.getElementById("company").focus();

		return false;

	}

	if(document.getElementById("dealer").value=='0')

	{

		alert("Please Select The Dealer First");

		document.getElementById("dealer").focus();

		return false;

	}

	if(document.getElementById("dealer_store_code").value=='')

	{

		alert("Please Fill The Dealer Store code First");

		document.getElementById("dealer_store_code").focus();

		return false;

	}

	if(document.getElementById("dealer_store_name").value=='')

	{

		alert("Please Fill The Dealer Store Name  First");

		document.getElementById("dealer_store_name").focus();

		return false;

	}

}



function abc()

{

window.alert("Associate Store Type Used You Can Not Delete");

}



</script>