<?php
$modid=$_REQUEST['modid'];
$frmid=$_REQUEST['frmid'];
$url="&modid=".$modid."&frmid=".$frmid;
$targetpagedata="index.php?route=DealerDistrbutions/Transaction/enquiry_index".$url;

?>
<script language="javascript" >
function checkenqueryno()
{	
	var chk = document.getElementsByName('enquiry_id[]');
	var len = chk.length;
	//alert(len)
	var cout=0;
	var arr1=new Array();
	var arr2;
	for(var i=0;i<=len;i++)
	{
		if(chk[i].checked==true)
		{
			var n=chk[i].id;
			var t1=n.split("_");
			k=t1[2];
			var s=document.getElementById("cust_type_"+k).value;
			//alert(s);
			arr2=arr1.push(s);
			//alert(arr1);
			var arr3=arr1.length;
			for(var z=0;z<arr3;z++)
			{
				if(s!=arr1[z])
				{
					alert("Please Check Same Type Of Customer At a Time");
					document.getElementById("enquiry_id_"+k).checked=false;
				}
			}
		}
	
	}
}





</script>


<table width="100%" border="1" cellspacing="0" cellpadding="0">
   <tr class="row1">
   <td class="tabledata">Select</td>
   <td class="tabledata" >Date
   <div style="width:17px; float:right;"><a href="#"><img src="images/topdaddy1.png"  id="show" style="display:none;" onclick="showicon1(this.id)"  /></a>
   <a href="#"><img src="images/topdaddy.png"  onclick="showicon(this.id)" id="hideicon" /></a></div></td>
   <td class="tabledata" >Enquiry No</td>
   <td class="tabledata" >Customer</td>
   <td class="tabledata">Exp.Delivery Date</td> 
   <td class="tabledata">Send Quote</td> 
   <td class="tabledata">Convert To SOI</td> 
   <td class="tabledata">Close</td> 
   <td class="tabledata">Created By</td> 
   <td class="tabledata">Actions</td> 
   <td class="tabledata">Status</td>
   </tr>
   <?php 
    // LIMIT $startpoint,$perpage
	$arr=array();
	if(isset($_SESSION['dealerid']))
    {
    $GetRecord = "Select * from dbl_enquiry_form where dealer='".$_SESSION['dealerid']."' order by id  DESC";
    }
   else
   {
   $GetRecord = "Select * from dbl_enquiry_form where company='".$_SESSION['ACGCompanyId']."' order by id DESC";
   }
   $ResultData = DB_query($GetRecord,$db);
   $i=1;
   if(DB_num_rows($ResultData)==0)
   echo "<td colspan='11'>--No Record--</td>";   
   while($RowData = DB_fetch_array($ResultData))
   {
    $enq=$s->getField('dbl_process_sale_order','enquiry_no',$RowData['id'],'enquiry_no');
	$close_status=$RowData['close_status'];
	if($close_status==1)
	{
	$status="Closed";
	}
	else if($RowData['conv_status_soi']==1)
	{
	$status="Converted";
	}
	else
	{
	$status='';
	}	
	if($status=='')
	{
	$disable='';
	}
	else
	{
	$disable='disabled';
	}
	if($RowData['enquiry_status']=='Partial Converted')
	{
	$status1="Partial Converted";
	}
	else
	{
	$status1='';
	}
?>
 <tr class="row1"> <td ><div align="center"><input type="checkbox" <?php echo $disable; ?> onclick="return checkenqueryno();"  name="enquiry_id[]"  id="enquiry_id_<?php echo $i; ?>" value="<?php echo $RowData['id'];?>" />
 <input type="hidden" name="cust_type[]" id="cust_type_<?php echo $i; ?>" value="<?php echo $RowData['customer']; ?>" />
 </div></td>
 <td><?php echo ConvertSQLDate($RowData['date']);  ?></td>
 <td><?php echo $RowData['form_no']; ?> </td>
<td><?php echo $Companyname= $s->getField('clientmaster','id',$RowData['customer'],'c_name'); ?></td>
<td><?php echo ConvertSQLDate($RowData['date']);  ?></td>
<td><?php if($status!='Closed'   ) {?><a href="Quotation_print.php?id=<?php echo $RowData['id'];?>" target="_blank"><input type="button" name="Quote" value="Send Quote" class="search" /></a>
<?php } else  { echo "<center><b>".$status."</b></center>"; }?>
</td>
<td><?php if($status=='' && $RowData['entry_type']=='Auto' ) {?><a href="index.php?route=DealerDistrbutions/Transaction/sale_order_creations&modid=<?php echo $_REQUEST['modid']; ?>&frmid=<?php echo $_REQUEST['frmid']; ?>&id=<?php echo $RowData['id'];?>&action=Add"><input type="button" name="Conver" value="Convert into SOI" class="search"  />
</a><?php } else  if($RowData['entry_type']=='Manual') { echo "<center><b>"."Items With No Price"."</b></center>"; } else { echo "<center><b>".$status."</b></center>"; }?>
</td>
<td><?php if($status=='') { ?> <a href="index.php?route=DealerDistrbutions/Transaction/short_close_enquiry&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&mrnid=<?php echo $RowData['id'];?>&action=Cancel" onclick="return confirm('Are You Sure You Want To Close This Enquiry ?')"><input type="button" name="" value="Close" class="search" /></a>
<?php } else { echo "<center><b>".$status."</b></center>"; } ?>
</td>
<td><?php echo  $s->getField('www_users','id',$RowData['created_by'],'realname'); ?></td>
<td>
<?php
if($RowData['entry_type']=='Manual') { ?> 
<a href="index.php?route=DealerDistrbutions/Transaction/enquiry_form_Edit_manual&amp;action=Edit&amp;id=<?php echo $RowData['id']; ?>&frmid=<?php echo $_REQUEST['frmid']; ?>&modid=<?php echo $_REQUEST['modid']; ?>"><img src="images/icon-edit.png"  width="10" height="10"/></a>
<a href="<?php echo $targetpage1?>&amp;action=Delete&amp;id=<?php echo $RowData['id']; ?>"><img src="images/delete1.gif"  width="10" height="10"/></a>
<?php  } else if($enq=='' && $status=='' && $status1=='' ) { ?>
<a href="index.php?route=DealerDistrbutions/Transaction/enquiry_form_Edit&amp;action=Edit&amp;id=<?php echo $RowData['id']; ?>&frmid=<?php echo $_REQUEST['frmid']; ?>&modid=<?php echo $_REQUEST['modid']; ?>"><img src="images/icon-edit.png"  width="10" height="10"/></a>
<a href="<?php echo $targetpage1?>&amp;action=Delete&amp;id=<?php echo $RowData['id']; ?>"><img src="images/delete1.gif"  width="10" height="10"/></a>
<?php } else if($status=='Closed') { echo $status; } else   { echo "No Permission"; } ?></td>
<td><?php echo $RowData['enquiry_status']; ?></td>

</tr>
<?php $i++;} ?> 
<input type="hidden" name="count" id="count" value="<?php echo $i; ?>" />
</table>


  