<html>
<head>
<link rel="stylesheet" href="../../css/jquery-ui.css" />
<link rel="stylesheet" href="../../css/jquery.autocomplete.css" type="text/css" />
<link href="../../css/pop_up style.css" rel="stylesheet" type="text/css">
<script src="../../js/party_creation_ajax.js"         type="text/javascript"></script>
<script src="../../js/jquery/jquery.js" type="text/javascript"></script>
<script src="../../js/jquery/jquery-1.8.2.js"></script>
<script src="../../js/jquery/jquery-ui.js"></script>
<script type="text/javascript" src="../../js/jquery/autocomplete_jquery_plugin.js"></script>
<script src="../../js/shortcut.js"  type="text/javascript"></script>
<script src="../../js/enter_event_ajax.js"       type="text/javascript"></script>

<script>
shortcut.add("Alt+i",function() 
{
	document.getElementById("item_name").focus();
});
</script>
<script>
var va= jQuery.noConflict();
va().ready(function() 
{ 
	va("#item_name").autocomplete("../../include/autocomplete/item_creation_name_auto.php", {
	width: 240,
	matchContains: true,
		selectFirst: true
	});
});
var it= jQuery.noConflict();
it().ready(function() 
{ 
	it("#item_name2").autocomplete("../../include/autocomplete/item_creation_name_auto.php", {
	width: 220,
	matchContains: true,
		selectFirst: true
	});
});

</script>

<style>
.style9 {border-top: solid 1px;border-top-color: #CCCCCC;border-bottom: solid 1px;border-bottom-color: #CCCCCC;}
.style5 {border-left: solid 1px;border-left-color: #CCCCCC;}
.style3{ border-right: solid 1px;border-right-color: #CCCCCC; }
.style4 {border-bottom: solid 1px;border-bottom-color: #CCCCCC;}
.text{ font-family: Verdana; font-size:13px;}
</style>
</head>
<?php
$party_no=$_GET['party_no'];
 $party_type=$_GET['party_type'];
error_reporting(0);
//$edit_id=$_GET['edit_id'];
include("../../include/db.php");
 $id=$_POST['id']; 
 $party_type=$_POST['party_type'];
?>
<style type="text/css">
.txt{ font-family: Verdana, Arial, Helvetica, sans-serif; font-size:13px;}
</style>
<style type="text/css">

.style2 {color: #FF0000}
.style7{font-family: Tahoma, Arial, Helvetica, sans-serif;font-size: 13px;}
.headings{ font-family:verdana; font-size:10px;}
</style>
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
<body bgcolor="#F2F2F2">
<?php if($_GET['party_type']=='Supplier' or $_POST['party_type']=='Supplier'){ ?>
<div id="supplier_list_div">
<?php
function get_sup_par_name($party_name,$sup_mob_no)
{
	$sql_user="select * from party_creation where party_id='$party_name' and mobile_no='$sup_mob_no' and delete_status!='1'  and `party_type`='Customer'  order by party_name ASC ";
	$rs_user=mysql_query($sql_user);
	while($rsdata_user=mysql_fetch_object($rs_user))
	{ 
	$party_name=$rsdata_user->party_name;
	}
	return $party_name;
} 

/****************edit id ************************/	
 $supp_rat_id=$_POST['id'];
 $party_no=$_POST['party_no'];
$party_name=$_GET['party_name'];
$mob_no=$_GET['mobile_no'];
$addresss=$_GET['address'];

 $sql="select * from  customer_rate_fix where id='$supp_rat_id'";
 $rs=mysql_query($sql);
 $sno=0;
   while($rsdata=mysql_fetch_array($rs))
  {
    $sno=$sno+1;
    $id=$rsdata['id'];
    $party_no=$rsdata['party_no'];
    $party_name=$rsdata['party_id'];
	$sup_mob_no=$rsdata['mob_no'];
	$sup_par_nam=get_sup_par_name($party_name,$sup_mob_no);
	$item_name=$rsdata['item_name'];
	$rate_type1=$rsdata['rate_type'];
	$rate=$rsdata['rate'];
	   
	   $create_date=date("d-m-Y",strtotime($create_date));
	   }
 ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="31" colspan="9" class="txt"><strong>Supplier Rate Fix</strong></td>
  </tr>
  <tr>
    <td colspan="9"></td></tr>
      <tr>
        <td width="7%">&nbsp;</td>
        <td width="22%" class="txt">Party Name </td>
        <td width="2%" class="txt">:</td>
        <td width="26%" class="txt"><input type="text"  name="sup_par_name" id="sup_par_name" readonly style="width:250px; height:25px; border:0px;background-color:#F2F2F2;" value="<?php if($_POST['id']!='') {  echo $sup_par_nam; } else  {  echo $party_name; } ?>"/></td>
        <td width="22%" class="txt">Mob No :</td>
        <td width="21%" class="txt">
          <input type="text"  name="sup_mob_no" id="sup_mob_no" readonly style="width:250px; height:25px; border:0px;background-color:#F2F2F2;" value="<?php if($_POST['id']!='') {  echo $sup_mob_no; } else  {   echo $mob_no; }?>"/>        </td>
      </tr>
      <tr>
        <td height="34">&nbsp;</td>
        <td class="txt">Address </td>
        <td class="txt">:</td>
        <td colspan="2" class="txt">
          <input type="text"  name="sup_par_addr" id="sup_par_addr" readonly style="width:250px; height:25px; border:0px;background-color:#F2F2F2;" value="<?php if($_POST['id']!='') {  echo $addresss; } else  {  echo $addresss; } ?>" />        </td>
        <td>&nbsp;</td>
      </tr>
    </table>
     <div style="height:200px; width:98%;padding-left:0px;  overflow-x:hidden;overflow-y:scroll;white-space:nowrap;" class="style3">

    <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="4%" height="34">&nbsp;</td>
    <td width="3%" class="text style5 style9" align="center"><strong>S.No</strong></td>
    <td colspan="2" class="style9 style5 text"><strong><span class="style8">&nbsp;I</span>tem Name <span class="style2 style1">*</span></strong></td>
    <td width="24%" class="style9 style5 text"><strong>Type</strong></td>
    <td width="14%" class="style9 style5 text" align="right"><strong>Rate</strong></td>
    <td width="14%" class="style9 style5 text style3"><strong>Action</strong></td>
    </tr>
  <tr>
    <td>&nbsp;</td>
    <td class="style9 style5 text">&nbsp;</td>
    <td colspan="2" class="style9 style5 text"><span class="style7">
      <input type="text" name="item_name" id="item_name" autofocus class="text_box" tabindex="1" onKeyUp="supplier_clear_validation(this.value)" style="width:100%; height:26px;" value="<?php if($_POST['id']!='') { echo $item_name; } ?>">
    </span></td>
    <td ><span class="style5 style4">
      <select name="rate_type" id="rate_type" tabindex="2" style="width:100%; height:26px;" onChange="">
          
        <option value="Ts" <?php if($rate_type1=='Ts') { ?> selected="selected" <?php } ?>>Ts</option>
        <option value="Fixed" <?php if($rate_type1=='Fixed') { ?> selected="selected" <?php } ?>>Fixed</option>
      </select>
    </span></td>
    <td><span class="style5 style4">
      <input type="text" name="rate" id="rate"  class="text_box" style="width:100%; height:26px;" tabindex="3" onKeyPress="if ((event.keyCode &lt; 46) || (event.keyCode &gt; 57)) event.returnValue = false"  value="<?php if($_POST['id']!='') { echo $rate; } ?>" onKeyUp="">
    </span></td>
    <td class="style3"><input type="button" name="action"  id="action" tabindex="4" value="<?php if($_POST['id']!='') { echo "EDIT";  } else { echo "ADD"; } ?>" class="add_button" onClick="supplier_rate_fix_add('<?php if($id!='') { echo $_POST['party_no']; } else { echo $_GET['party_no']; }?>','<?php if($id!='') { echo $_POST['party_type']; } else { echo $_GET['party_type']; } ?>',sup_par_name.value,sup_mob_no.value,item_name.value,rate_type.value,rate.value,'<?php echo $_POST['id'];?>','<?php if($_POST['id']!='') { echo "SUPP_EDIT";  } else { echo "SUPP_ADD"; } ?>')" style="width:100px; height:26px;"/></td>
    </tr>
   <?php

 $party_no1=$_GET['party_no'];
  $party_no2=$_POST['party_no'];
    $sql="select * from  customer_rate_fix where party_no='$party_no1' or party_no='$party_no2' ";
    $rs=mysql_query($sql);
	$sno=0;

   while($rsdata=mysql_fetch_array($rs))
  {
   $sno=$sno+1;
   $from=$from+1;
   $sup_id=$rsdata['id'];
   $party_no=$rsdata['party_no'];
   $party_type=$rsdata['party_type'];
    $item_name=$rsdata['item_name'];
	$rate_type=$rsdata['rate_type'];
	$rate=$rsdata['rate'];
	     
 ?>
  <tr>
    <td>&nbsp;</td>
    <td class="style9 style5 text" align="center"><?php echo $sno;?></td>
    <td colspan="2" class="style9 style5 text"><?php echo $item_name;?></td>
    <td class="style9 style5 text"><?php echo $rate_type;?></td>
    <td class="style9 style5 text" align="right"><?php echo number_format($rate,2);?></td>
    <td class="style9 style5 text style3" align="center"><img src="../../img/edit.png" 
      onClick="supplier_rate_edit('<?php echo $sup_id;?>','<?php echo $party_type;?>','<?php echo $party_no;?>')" width="18px" height="18px"> <img src="../../img/cross-small.png" onClick="supplier_rate_delete('<?php echo $sup_id;?>','<?php  echo $_GET['party_no']; ?>')" width="20px" height="20px"></td>
    </tr>

<?php } ?>
  
    <tr height="148px">
    <td></td>
   <td colspan="6"  align="center" class="style4  style5 style3" ></td>
    </tr>
    </table>
     </div>
   <table width="100%" border="0" cellspacing="0" cellpadding="0">
   <tr>&nbsp;<td colspan="3"></td></tr>
  <tr><td></td><td align="center"><input type="button" name="action"  id="action" tabindex="9" value="<?php  echo "CLOSE";  ?>" class="add_button" onClick="supplier_rate_fix_clos(this.value)" style="width:70px; height:26px;"/></td>&nbsp;<td></td></tr></table>
 </table>
<?php } ?>
</div>

  
  <?php
if($_GET['party_type']=='Customer' or $_POST['party_type']=='Customer')
{ 
?>
<div id="customer_list_div">
<?php
function get_cus_par_name($party_name,$cus_mob_no)
{
	$sql_user="select * from party_creation where party_id='$party_name' and mobile_no='$cus_mob_no' and delete_status!='1' and `party_type`='Customer'   order by party_name ASC ";
	$rs_user=mysql_query($sql_user);
	while($rsdata_user=mysql_fetch_object($rs_user))
	{ 
	$party_name=$rsdata_user->party_name;
	}
	return $party_name;
} 
$cust_id=$_POST['id']; 
$party_type=$_POST['party_type'];
$party_name=$_GET['party_name'];
$party_no=$_GET['party_no'];
$mob_no=$_GET['mobile_no'];
$address2=$_GET['address'];


     $sql="select * from  customer_rate_fix where id='$cust_id'  ";
    $rs=mysql_query($sql);
	$sno=0;

   while($rsdata=mysql_fetch_array($rs))
  {
   $sno=$sno+1;
   $from=$from+1;
   $id=$rsdata['id'];
   $party_no=$rsdata['party_no'];
   $party_name=$rsdata['party_id'];
	$cus_mob_no=$rsdata['mob_no'];
	$cus_par_nam=get_cus_par_name($party_name,$cus_mob_no);

    $item_name=$rsdata['item_name'];
		$rate_type=$rsdata['rate_type'];
	   $rate=$rsdata['rate'];
	}
?>
  <table width="100%" cellpadding="0" cellspacing="0">
    <tr>
      <td height="24" colspan="4" valign="top" class="style7"><strong>Customer Rate Fix</strong></td>
      <td valign="top"  >&nbsp;</td>
      <td valign="top"  >&nbsp;</td>
      <td  >&nbsp;</td>
      <td width="0%"  >&nbsp;</td>
    </tr>
    <tr>
      <td width="7%">&nbsp;</td>
      <td width="23%"><span class="txt">Party Name</span></td>
      <td width="2%"><span class="txt"> :</span></td>
      <td width="26%"><span class="txt">
          <input type="text"  name="sup_par_name2" id="sup_par_name2" readonly style="width:250px; height:25px; border:0px;background-color:#F2F2F2;" value="<?php if($_POST['id']!='') {  echo $cus_par_nam; } else  {   echo $party_name; }?>"/>
      </span></td>
      <td width="21%"><span class="txt">Mob No :</span></td>
      <td colspan="2"><span class="txt">
          <input type="text"  name="sup_mob_no2" id="sup_mob_no2" readonly style="width:250px; height:25px; border:0px;background-color:#F2F2F2;" value="<?php if($_POST['id']!='') {  echo $cus_mob_no; } else  {    echo $mob_no; }?>"/>
      </span></td>
          </tr>
        <tr>
          <td height="31">&nbsp;</td>
          <td><span class="txt">Address</span></td>
          <td><span class="txt"> :</span></td>
          <td><span class="txt">
            <input type="text"  name="sup_par_addr2" id="sup_par_addr2" readonly style="width:250px; height:25px; border:0px;background-color:#F2F2F2;" value="<?php if($_POST['id']!='') {  echo $address2; } else  {    echo $address2; }?>" />
          </span></td>
          <td>&nbsp;</td>
          <td width="2%">&nbsp;</td>
          <td width="19%">&nbsp;</td>
        </tr>
      </table>
  <div style="height:200px; width:98%;padding-left:0px;  overflow-x:hidden;overflow-y:scroll;white-space:nowrap;" class="style3">

    <table width="100%" cellpadding="0" cellspacing="0">
    <tr>
      <td width="61" valign="top" >&nbsp;</td>
    <td width="57" height="24" align="center"  class="text style5 style9"><strong>S.No</strong></td>
    <td width="462" class="text style5 style9"><strong>Item Name</strong><span style="color:#FF0000" >*</span> </td>
    <td width="273" align="left" class="text style5 style9" ><strong>Type</strong></td>
    <td width="233" align="right" class="text style5 style9" ><strong>Rate</strong></td>
    <td align="center" class="text style5 style9 style3"  ><strong>Action</strong></td>
    </tr>
  <tr>
    <td valign="top" >&nbsp;</td>

  <td height="24" align="center" class="style5 style4">&nbsp;</td>
  <td class="style5 style4"><input type="text" name="item_name2" id="item_name2" autofocus class="text_box" tabindex="1" onKeyUp="supplier_clear_validation(this.value)" style="width:100%; height:26px;" value="<?php if($_POST['id']!='') { echo $item_name; } ?>"></td>
  <td class="style5 style4"  ><select name="rate_type2" id="rate_type2" tabindex="2" style="width:100%; height:26px;"  >
    <option value="Fixed"  <?php if($rate_type1=='Fixed') { ?> selected="selected" <?php } ?>>Fixed</option>
    <option value="Ts"  <?php if($rate_type1=='Ts') { ?> selected="selected" <?php } ?>>Ts</option>
  </select></td>
  <td class="style5 style4"  ><span style="color:#F00">
    <input type="text" name="rate2" id="rate2"  class="text_box" style="width:100%; height:26px;" tabindex="3" onKeyPress="if ((event.keyCode &lt; 46) || (event.keyCode &gt; 57)) event.returnValue = false"  value="<?php if($_POST['id']!='') { echo $rate; } ?>">
  </span></td>
  <td align="center"  class="style5 style4 style3">
    <input type="button" name="action2"  id="action2" tabindex="9" value="<?php if($_POST['id']!='') { echo "EDIT";  } else { echo "ADD"; } ?>" class="add_button" onClick="customer_rate_fix_add('<?php if($id!='') { echo $_POST['party_no']; } else { echo $_GET['party_no']; }?>','<?php if($id!='') { echo $_POST['party_type']; } else { echo $_GET['party_type']; }?>',sup_par_name2.value,sup_mob_no2.value,item_name2.value,rate_type2.value,rate2.value,'<?php echo $_POST['id'];?>','<?php if($_POST['id']!='') { echo "CUS_EDIT";  } else { echo "CUS_ADD"; } ?>')" style="width:100px; height:26px;"/>  </td>
  </tr>
 <?php
include("../../include/db.php");
 
	$sql="select * from  customer_rate_fix where party_no='$_GET[party_no]' or party_no='$_POST[party_no]'  order by id DESC ";
    $rs=mysql_query($sql);
	$sno=0;

   while($rsdata=mysql_fetch_array($rs))
  {
   $sno=$sno+1;
   $from=$from+1;
   $cus_id=$rsdata['id'];
   $party_no=$rsdata['party_no'];
   $party_type=$rsdata['party_type'];
    $item_name=$rsdata['item_name'];
		$rate_type=$rsdata['rate_type'];
	   $rate=$rsdata['rate'];
	     
 ?>
  <tr style="border:1px solid #ddd">
    <td width="61"  align="center" >&nbsp;</td>
    <td width="57"  align="center" style="border:1px solid #ddd" class="txt"><?php echo $from; ?></td>
    <td width="462" align="left" style="border:1px solid #ddd" class="txt">&nbsp;&nbsp;<?php echo $item_name;?></td>
    <td width="273" align="left" style="border:1px solid #ddd" class="txt"><?php echo $rate_type;?></td>
    <td width="233" align="right" style="border:1px solid #ddd" class="txt"><?php echo number_format($rate,2);?></td>
    <td width="102" align="center" style="border:1px solid #ddd" ><img src="../../img/edit.png" 
      onClick="customer_rate_edit('<?php echo $cus_id;?>','<?php echo $party_type;  ?>','<?php echo $party_no;?>')" width="18px" height="18px"> <img src="../../img/cross-small.png" onClick="customer_rate_delete('<?php echo $cus_id;?>','<?php  echo $party_no;?>')" width="20px" height="20px"> </td>
      </tr>
  <?php } ?>
    <tr height="148px">
    <td></td>
   <td colspan="5"  align="center" class="style4  style5 style3" ></td>
   </tr>
 </table>
 </div>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr>&nbsp;<td colspan="3"></td></tr>
  <tr><td> </td><td align="center"><input type="button" name="action"  id="action" tabindex="9" value="<?php  echo "CLOSE";  ?>" class="add_button" onClick="supplier_rate_fix_clos(this.value)" style="width:70px; height:26px;"/></td><td>&nbsp;</td></tr></table>
<?php } ?>
</div>
 
</body>
</html>