<html>
<head>
<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/enter_event_ajax.js"   type="text/javascript"></script>
<link rel="stylesheet" href="../../css/jquery-ui.css" />
<link rel="stylesheet" href="../../css/jquery.autocomplete.css" type="text/css" />
<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/enter_event_ajax.js"       type="text/javascript"></script>
<script src="../../js/shortcut.js"  type="text/javascript"></script>
<script>
/***************************** Party Name Immeadiate Validation*********************************************************/
jQuery(document).ready(function(){
jQuery('#party_name').keyup(partynames_checkitem);
}); 
function partynames_checkitem(){ 
var party_names = jQuery('#party_name').val();
if(party_names == "" || party_names.length < 0){
jQuery('#party_name');
}else{
jQuery.ajax({
   type: "POST",
   url: "chk_party_name_db.php",
   data: 'party_names='+ party_names,
   cache: false,
   success: function(response){
if(response != 0){
//	$('#party_name').css('border', '3px #C33 solid'); 
 //$('#tick').hide();
 //$('#cross').fadeIn();
document.getElementById("party_name_validation_div").innerHTML="Party Name Already Exists.";
 }else{
	// $('#cross').hide();
    //$('#tick').fadeIn();
	 document.getElementById("party_name_validation_div").innerHTML="";
      }
}
});
}
}
</script>
<script>
shortcut.add("Alt+p",function() 
{
	document.getElementById("party_name").focus();
});
shortcut.add("Alt+e",function() 
{
	document.getElementById("email").focus();
});

shortcut.add("Alt+m",function() 
{
	document.getElementById("mob_no").focus();
});


shortcut.add("Alt+n",function() 
{
	document.getElementById("pho_no").focus();
});

shortcut.add("Alt+c",function() 
{
	document.getElementById("city").focus();
});



shortcut.add("Alt+a",function() 
{
	document.getElementById("address").focus();
});


</script>

</head>
<?php
include("../../include/db.php");
error_reporting(0);
session_start();
$user_id = $_SESSION['login_user_id'];
$date=date("Y");
$st_date=substr($date,2);
$month=date("m");	   
$datee=$st_date.$month;

if(!isset($_GET['party_no']))
{
	$rs5=mysql_query("select party_no from  party_creation order by party_id desc");
	if($res5=mysql_fetch_assoc($rs5))
	{
		$pur_array=explode('-',$res5['party_no']);
	    $year1=$pur_array[1];
        $year2=substr($year1, 0, 2);
	    $year='20'.$year2;
		$purchase_no=$pur_array[2];
	}
	if($purchase_no=='')
		$party_number='PC-'.$datee.'-0001';
	else
	{
		$purchase_no+=1;
		$party_number='PC-'.$datee.'-'.str_pad($purchase_no, 4, '0', STR_PAD_LEFT);
	}
}
  
  if($edit_id1!='')
  {
	  $purchase_num= $purchase_order_no;
  }
?>
<?php
error_reporting(0);
$edit_id=$_GET['edit_id'];
include("../../include/db.php");
$id=$_GET[edit_id];
  $sql="select * from party_creation where party_id='$_GET[edit_id]'";
  $rs=mysql_query($sql);
  $rscount=mysql_num_rows($rs);
 
  while($rsdata=mysql_fetch_array($rs))
  {
	  $party_name=$rsdata['party_name'];
	  $party_no=$rsdata['party_no'];
	  $mobile_no=$rsdata['mobile_no'];
	  $phone_no=$rsdata['phone_no'];
	  $email_id=$rsdata['email_id'];
	  $address=$rsdata['address'];
	  $city=$rsdata['city'];
	  $description=$rsdata['description'];
	  $tin_no=$rsdata['tin_no'];
	  $cst_no=$rsdata['cst_no'];
	  $party_type=$rsdata['party_type'];

    $status_type=$rsdata['status_type'];

	  $gst_no=$rsdata['gst_no'];
  }
?>
<style type="text/css">
.txt{ font-family: Verdana, Arial, Helvetica, sans-serif; font-size:13px;}
 .types_class { 
    height: 25px; 
    width: 200px; 
    background-color: transparent;  
    border-style: solid;  	
    border-width: 0px 0px 1px 0px;  
    border-color:#CCC; 
    outline:0;
	font-size:14px;
  } 
  input:focus {  border-color:#87BB07; }
select:focus {  border-color:#87BB07; } 
textarea:focus {  border-color:#87BB07; } 
</style>
<table width="100%"  cellpadding="2" cellspacing="0" border="0">
  <tr>
    <td height="30" colspan="2" class="txt"><strong>&nbsp;&nbsp;</strong><strong>&nbsp;&nbsp;Party Creation</strong></td>
    <td width="43%">&nbsp;</td>
    <td width="30%" class="txt"><span class="style2"><strong>
      <input type="hidden" readonly name="party_no" id="party_no" class="types_class" style="font-size:12px" value="<?php if($_GET['edit_id']!='') { echo $party_no; } else{ echo $party_number;  } ?>" />
      <?php if($_GET['edit_id']!='') { echo $party_no; } else{ echo $party_number; } ?>
      &nbsp;</strong></span></td>
  </tr>
  <tr>
    <td height="36">&nbsp;</td>
    <td><span class="txt"><span class="style2"><strong>P</strong></span>arty Type <span class="style2 style1">*</span></span></td>
    <td>
    <select id="party_type" name="party_type" tabindex="2"  autofocus class="types_class" > 
    <option value="">select</option>
    <option value="Customer"<?php if($party_type=='Customer'){echo "Selected";}?>>Customer</option>
    <option value="Supplier"<?php if($party_type=='Supplier'){echo "Selected";}?>>Supplier</option>
    </select>
    </td>
  </tr>

  <tr>
<?php if($user_id==1){ ?>

    <td height="36">&nbsp;</td>
    <td><span class="txt"><span class="style2"><strong>S</strong></span>tatus Type</span></td>
    <td>
    <select id="status_type" name="status_type" tabindex="2"  autofocus class="types_class" > 
    <option value="">select</option>
    <option value="Active"<?php if($status_type=='Active'){echo "Selected";}?>>Active</option>
    <option value="In-active"<?php if($status_type=='In-active'){echo "Selected";}?>>In-active</option>
    </select>

    </td>
  
<?php }else{ ?>

<td height="36">&nbsp;</td>
    <td><span class="txt"><span class="style2"><strong>S</strong></span>tatus Type</span></td>
    <td>
    <select id="status_type" name="status_type" tabindex="2"  autofocus class="types_class" > 
    <option value="">select</option>
</select>
</td>
<?php } ?>
</tr>
  <tr>
    <td width="8%" height="36">&nbsp;</td>
    <td width="19%"><span class="txt"><span class="style2"><strong>P</strong></span>arty Name<span class="style2 style1"> *</span></span></td>
    <td><input type="text" name="party_name" id="party_name" autofocus class="types_class" tabindex="1" style="width:200px; height:26px;" onKeypress="party_clear_validation(this.value),enterevent(event,'mob_no','party_name')" value="<?php if($_GET['edit_id']!='') { echo $party_name; } ?>" <?php if($_GET['edit_id']!='') {?><?php  } ?> />
   <div id="party_name_validation_div" style="color:#FF0000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px"></div></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="30">&nbsp;</td>
    <td><span class="txt"><span class="style2"><strong>M</strong></span>obile No</span></td>
    <td><span class="style7">
      <input type="text" name="mob_no" id="mob_no" class="types_class" onKeyPress="if ((event.keyCode &lt; 46) || (event.keyCode &gt; 57)) event.returnValue = false,enterevent(event,'pho_no','mob_no')" tabindex="2" maxlength="10" style="width:200px; height:26px;" value="<?php if($_GET['edit_id']!='') { echo $mobile_no; } ?>"  />
    </span>
    <div id="mobile_no_validation_div" style="color:#FF0000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px"></div></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="34">&nbsp;</td>
    <td><span class="txt">Phone <span class="style2"><strong>N</strong></span>o</span></td>
    <td><span class="style7">
      <input type="text" name="pho_no" id="pho_no" class="types_class" onKeyPress="if ((event.keyCode &lt; 46) || (event.keyCode &gt; 57)) event.returnValue = false,enterevent(event,'email','pho_no')" tabindex="3" maxlength="11" style="width:200px; height:26px;" value="<?php if($_GET['edit_id']!='') { echo $phone_no; } ?>" />
    </span>
    <div id="phone_validation_div" style="color:#FF0000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px"></div></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="30">&nbsp;</td>
    <td><span class="txt"><span class="style2"><strong>E</strong></span>-Mail ID</span></td>
    <td><span class="style7">
      <input type="text" name="email" id="email" class="types_class" tabindex="4" style="width:200px; height:26px;" value="<?php if($_GET['edit_id']!='') { echo $email_id; } ?>" onKeypress="enterevent(event,'address','email')" />
    </span></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="62">&nbsp;</td>
    <td><span class="txt"><span class="style2"><strong>A</strong></span>ddress <span class="style2 style1">*</span></span></td>
    <td><textarea name="address" id="address" cols="45" rows="5" class="types_class" tabindex="5"  style="width:200px; height:50px;" onKeypress="party_clear_validation(this.value),enterevent(event,'city','address')"><?php if($_GET['edit_id']!='') { echo $address; } ?></textarea>
    </span>
    <div id="address_validation_div" style="color:#FF0000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px"></div></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><span class="txt"><span class="style2"><strong>C</strong></span>ity<span class="style2 style1"> *</span></span></td>
    <td><span class="style7">
      <input type="text" name="city" id="city" class="types_class" tabindex="6" style="width:200px; height:26px;" value="<?php if($_GET['edit_id']!='') { echo $city; } ?>" onKeypress="party_clear_validation(this.value),enterevent(event,'tin_no','city')" />
    </span>
    <div id="city_validation_div" style="color:#FF0000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px"></div></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="29">&nbsp;</td>
    <td><span class="txt"><span class="style2"><strong>T</strong></span>in No<span class="style2 style1"> *</span></span></td>
    <td  align="left"><input type="text" name="tin_no" id="tin_no" class="types_class" onKeyPress="party_clear_validation(this.value),enterevent(event,'cst_no','city')" tabindex="2" style="width:200px; height:26px;" value="<?php if($_GET['edit_id']!='') { echo $tin_no; } ?>"  /><div id="tin_no_validation_div" style="color:#FF0000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px"></div></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="30">&nbsp;</td>
    <td><span class="txt"><span class="style2"><strong>C</strong></span>st No<span class="style2 style1"> *</span></span></td>
    <td  align="left"><input type="text" name="cst_no" id="cst_no" class="types_class" onKeyPress="party_clear_validation(this.value),enterevent(event,'action','tin_no')" tabindex="2" style="width:200px; height:26px;" value="<?php if($_GET['edit_id']!='') { echo $cst_no; } ?>"  /><div id="cst_no_validation_div" style="color:#FF0000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px"></div></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="30">&nbsp;</td>
    <td><span class="txt"><span class="style2"><strong>G</strong></span>st No<span class="style2 style1"> *</span></span></td>
    <td  align="left"><input type="text" name="gst_no" id="gst_no" class="types_class" onKeyPress="party_clear_validation(this.value),enterevent(event,'action','gst_no')" tabindex="2" style="width:200px; height:26px;" value="<?php if($_GET['edit_id']!='') { echo $gst_no; } ?>"  /><div id="gst_no_validation_div" style="color:#FF0000; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px"></div></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="37">&nbsp;</td>
    <td>&nbsp;</td>
    <td  align="center">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td  align="center">
      <input type="button" name="action"  id="action" tabindex="7" value="<?php if($_GET['edit_id']!='') { echo "EDIT";  } else { echo "ADD"; } ?>" class="add_button" style="height:30px; width:60px; background-color: #87BB07;color: #fff;border: 0px;" onClick="party_validation(),party_creation_add(party_type.value,status_type.value,party_no.value,party_name.value,mob_no.value,pho_no.value,email.value,address.value,city.value,cst_no.value,tin_no.value,'<?php if($_GET['source']!='') { echo $_GET['source'];} else { echo "Main"; } ?>','<?php echo $id;?>',this.value,gst_no.value)"/>
    </td>
    <td>&nbsp;</td>
  </tr>
</table>
</html>
