<html>
<head>
<link rel="stylesheet" href="css/jquery-ui.css" />
<link rel="stylesheet" href="css/jquery.autocomplete.css" type="text/css" />
<link rel="stylesheet" href="css/font.css" type="text/css" />
<script type="text/javascript" src="js/sample_jobcard_creation_ajax.js"></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 type="text/javascript" src="js/enter_event_ajax.js"></script>

<script>
function add_new_party1(url)
{	
onmouseover10= window.open(url,'onmouseover10','height=400,width=650,scrollbars=no,resizable=no,left=50,top=50,toolbar=no,location=no,directories=no,status=no');	
}
function image_upload_jobcard2(url)
{	
onmouseover10= window.open(url,'onmouseover10','height=400,width=650,scrollbars=no,resizable=no,left=50,top=50,toolbar=no,location=no,directories=no,status=no');	
}

function samplejobcard_validation()
{
    var customer_name = document.getElementById("customer_name").value;
	if(customer_name=='')
	{
		document.getElementById("customer_name_validation_div").innerHTML="* This field is Required.";
		document.getElementById("customer_name").focus();
		return false;
	}
	
	var designer = document.getElementById("designer").value;
	if(designer=='')
	{
		document.getElementById("style_no_validation_div").innerHTML="* This field is Required.";
		document.getElementById("designer").focus();
		return false;
	}
	var created_by = document.getElementById("created_by").value;
	if(created_by=='')
	{
		document.getElementById("job_created_by_validation_div").innerHTML="* This field is Required.";
		document.getElementById("created_by").focus();
		return false;
	}
	var style_name = document.getElementById("style_name").value;
	if(style_name=='')
	{
		document.getElementById("style_name_validation_div").innerHTML="* This field is Required.";
		document.getElementById("style_name").focus();
		return false;
	}
	var cust_po_no = document.getElementById("cust_po_no").value;
	if(cust_po_no=='')
	{
		document.getElementById("cust_po_no_validation_div").innerHTML="* This field is Required.";
		document.getElementById("cust_po_no").focus();
		return false;
	}
	var combo = document.getElementById("combo").value;
	if(combo=='')
	{
		document.getElementById("combo_validation_div").innerHTML="* This field is Required.";
		document.getElementById("combo").focus();
		return false;
	}
}
function confirmmsg()
{
   return confirm("Are you want to conform ther jobcard?");
}
var sm = jQuery.noConflict();
sm().ready(function() 
{ 
	sm("#customer_name").autocomplete("include/autocomplete/cust_name_auto.php", {
	width: 250,
	matchContains: true,
	selectFirst: true
	});	
});


shortcut.add("Alt+l",function() 
{
	document.getElementById("booking_place").focus();
});
shortcut.add("Alt+p",function() 
{
	document.getElementById("pay").focus();
});
shortcut.add("Alt+t",function() 
{
	document.getElementById("to_pay").focus();
});



 
 function jobcard_close_sample()
{
window.location.href="main_fram.php?file=sample_jobcard_creation";
}
</script>
<style> 
.someclass{ 
background:url(img/plus.png) no-repeat 0 0 ; 
} 
  .types_class1 { 
    height: 25px; 
    width: 250px; 
    background-color: transparent;  
    border-style: solid;  
    border-width: 0px 0px 1px 0px;  
    border-color:#CCC; 
    outline:0;
	font-size:13px;
	font-family:Verdana;
	
  }
  input:focus {  border-color:#87BB07; }
select:focus {  border-color:#87BB07; } 
textarea:focus {  border-color:#87BB07; } 
</style> 
<?php
error_reporting(0);
include ("include/db.php");	
	
$from_date=$_POST['from_date'];
$to_date=$_POST['to_date'];
$purchas_ordr_num=$_POST['purchas_ordr_num'];

/******************** Auto Generated ID*********************************************/


$fulldate=date("Y-m-d");
		  $fyear=date("Y");
		  $current_date=$fulldate;
		  $cur_year=$fyear;
	  
		  $acc_from=$cur_year."-04-01"; 
		  if($acc_from<=$current_date)
		  { 
		    	$fyear=date("Y");
		    	$eyear=date("Y")+1;
		  }
		  if($acc_from>$current_date)
		  {
		 		$fyear=date("Y")-1;
		 		$eyear=date("Y");
		  }
		 $start_year=$fyear."-04-01"; 
		 $end_year=$eyear."-03-31"; 

$curyear=date('Y');
$curmon=date('m');
$next_year=$curyear+1;

if(($curmon>=4)&&($curyear==$curyear-1)||($curmon<=3)&&($curyear==$curyear))
{
	$academic=$curyear-1;
}
else
{
	$academic=$curyear;
}

$date=date("Y");
$st_date=substr($date,2);
$month=date("m");	   
$datee=$st_date.$month;

if(!isset($_GET['jobcard_no']))
{
	$rs1=mysql_query("select jobcard_no from sample_jobcard_main where createdate>='$start_year' and createdate<='$end_year' order by main_id desc");
	if($res1=mysql_fetch_assoc($rs1))
	{
		$pur_array=explode('-',$res1['jobcard_no']);
	
	    $year1=$pur_array[1];
        $year2=substr($year1, 0, 2);
	    $year='20'.$year2;
		$jobcard_no=$pur_array[2];
	}
	if($jobcard_no=='')
	{
		$jobcard_number='SJC-'.$datee.'-0001';
	}
	else
	{
		$jobcard_no+=1;
		$jobcard_number='SJC-'.$datee.'-'.str_pad($jobcard_no, 4, '0', STR_PAD_LEFT);
	}
}
   $sql="select * from  booking_sub_list where book_no='$book_number' or book_no='$_GET[book_no]'";
    $rs=mysql_query($sql);
	$rscount_book=mysql_num_rows($rs);
  


 $edit_id=$_GET['main_edit_id'];

ob_start();
session_start();

function get_user_type($login_user_name,$login_pass_word)
{
    $sql_user="select * from  user_creation where user_name='$login_user_name' and password='$login_pass_word'";
	$rs_user=mysql_query($sql_user);
	while($rsdata_user=mysql_fetch_object($rs_user))
	{ 
	$user_type=$rsdata_user->user_type;
	}
	return $user_type;
}

function get_branch_names2($book_branchs1)
{
    $sql_user="select * from  branch_creation where branch_id='$book_branchs1'";
	$rs_user=mysql_query($sql_user);
	while($rsdata_user=mysql_fetch_object($rs_user))
	{ 
	$branch_name=$rsdata_user->branch_name;
	}
	return $branch_name;
}

$login_user_name=$_SESSION['login_user_name'];
$login_pass_word=$_SESSION['login_pass_word'];
$book_branchs1=$_SESSION['branch'];
$get_user_type=get_user_type($login_user_name,$login_pass_word);
$get_branch_names=get_branch_names2($book_branchs1);


function get_branch_place_names($branch_places12)
{
    $sql_user="select * from  place_creation where id='$branch_places12'";
	$rs_user=mysql_query($sql_user);
	while($rsdata_user=mysql_fetch_object($rs_user))
	{ 
	$location=$rsdata_user->location;
	}
	return $location;
}
 $sql="select * from  sample_jobcard_main where main_id='$_GET[main_edit_id]'";
 $sql="select * from  sample_jobcard_main where main_id='$_GET[main_edit_id]'";
	$rs=mysql_query($sql);
	$sno=0;
   		while($rsdata=mysql_fetch_array($rs))
  			{
   				$sno=$sno+1;
				$from=$from+1;
   				$main_edit_id=$rsdata['main_edit_id'];
   				$jobcard_no=$rsdata['jobcard_no'];
				$created_by=$rsdata['created_by'];
	   			$cust_name=$rsdata['cust_name'];
				
	   			$entry_date=$rsdata['entry_date'];
				
				$order_by=$rsdata['order_by'];
	   			$fabric_type=$rsdata['fabric_type'];
	   			$overall_value=$rsdata['overall_value'];
	   			$net_total=$rsdata['net_total'];
				$designer_name=$rsdata['designer_name'];
				$design=$rsdata['design'];
				$color_profile=$rsdata['color_profile'];
			}
?>

<style type="text/css">.style9{ text-align:left;font-family:Tahoma, Arial, Helvetica, sans-serif; font-size: 15px; padding:0px; font-weight: 600;color:#080;letter-spacing: 1px;padding:10px; background-color:#f7f7f7;}
.style4 {border-bottom: solid 1px;border-bottom-color: #CCCCCC;}
.style5 {border-left: solid 1px;border-left-color: #CCCCCC;}
.text {
	font-family: Verdana;
	font-size: 14px;
}

</style>

<div class="container">
<div class="row-fluid">
<div class="span12">
<div class="table-responsive">
<form name="company_form"  id="company_form" method="post" action=""  enctype="multipart/form-data" >

<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" style="border-top:solid 1px; color:#ddd;">
<tr align="left"  style="font-size:14px"><div class="style9">Sample Jobcard Creation Form</div>
<td width="12%" colspan="5" align="left"><img src="img/wrong.png" name="add_button" id="add_button" title="Cancel Booking Order"  onclick="javascript:jobcard_close_sample()" align="top" width="30" height="30" border="0"  style="cursor:pointer; margin-left:96%; margin-top:-34px;" class="button green-button" >
</td>
</tr></table>

<table width="100%" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" >
         
           <tr>
             <td height="38">&nbsp;</td>
             <td colspan="2" align="right" class="text" style="font-size:14px; color:#080;"><span class="text" style="font-size:14px; color:#080;">&nbsp;<strong><span style="color: #F00">J</span>obcard No</strong>&nbsp;&nbsp;&nbsp;
                 <input type="hidden" readonly name="jobcard_no" id="jobcard_no" class="text_box" style="font-size:12px" value="<?php if($edit_id!='') { echo $jobcard_no; } else{ echo $jobcard_number;  } ?>">
                 <input type="hidden" name="edit_id" id="edit_id" value="<?php  echo $edit_id; ?>">
                 <strong> <span style="color:#B30000;">
                 <?php if($edit_id!='') { echo $jobcard_no; } else{ echo $jobcard_number; } ?>
              </span> </strong></span></td>
             <td class="heading ">&nbsp;</td>
             <td align="right" class="text" style="font-size: 14px;">&nbsp;</td>
             <td class="heading ">&nbsp;</td>
           </tr>
           <tr>
    <td width="4%" height="38">&nbsp;</td>
    <td width="8%" align="right" class="text" style="font-size:14px; color:#080;"><strong>&nbsp;&nbsp;<span class="text" style="font-size: 14px;">&nbsp;</span></strong></td>
    <td width="9%" align="right" class="text" style="font-size:14px; color:#080;"><span class="text" style="font-size:14px; color:#080;"><strong> <span class="text" style="font-size: 14px; color: #000000; font-weight: normal;">Date&nbsp;&nbsp;</span></strong></span></td>
    <td width="18%" class="heading "><input type="datetime-local"  name="entry_time" id="entry_time" class="types_class1"  <?php if($_SESSION['user_type']!=1) { ?> readonly <?php } ?>  autofocus onKeyPress="enterevent(event,'order_by','entry_time')" tabindex="1" style="font-size:12px; height:25px; width:200px; " value="<?php if($edit_id!='') { echo $entry_date; }  else{ echo  date('Y-m-d').'T'.date('H:i'); }?>"></td>
    <td width="12%" align="right" class="text" style="font-size: 14px;"><span class="text" style="font-size: 14px;">Sample Order By&nbsp;&nbsp;</span></td>
    <td width="28%" class="heading "><input type="text" class="types_class1" name="order_by" id="order_by"    style="width:200px; height:20px;"  tabindex="7"  value="<?php if($edit_id!='') { echo $order_by; } else { } ?>" onKeyPress="enterevent(event,'customer_name','entry_time')"></td>
  </tr>
  <tr>
    <td height="43">&nbsp;</td>
  <td colspan="2"  align="right" class="text" style="padding-left:15px;font-size: 14px;">Customer Name<span style="color:#FF0000">*</span>&nbsp;&nbsp;</td>
    <td>&nbsp;&nbsp;<input type="text" class="types_class1"  name="customer_name" id="customer_name" autofocus style="width:200px; height:20px;" onKeyUp="samp_jobcard_clear_validation(this.value)" onKeyPress="enterevent(event,'style_no','customer_name')" tabindex="2"  value="<?php if($edit_id!='') { echo $cust_name; } else { } ?>" > <img src="img/add-512-2.png" width="28" height="28" title="ADD PARTY" onClick="javascript:add_new_party1('master_entry/party_creation/party_creation.php?source=<?php echo "Sub";?>&order_no=<?php echo $order_num;?>')">
      <div id="samp_customer_name_validation_div" style="color:#F00"></div></td>
    <td align="right" class="text" style="font-size: 14px;">Designer<span style="color:#FF0000">*</span>&nbsp;&nbsp;</td>
    <td><input type="text" class="types_class1" name="designer" id="designer" style="width:200px; height:20px;"  tabindex="7"  value="<?php if($edit_id!='') { echo $design; } else { } ?>" onKeyPress="samp_jobcard_clear_validation(this.value),enterevent(event,'created_by','style_no')">
    <div id="designer_validation_div" style="color:#F00"></div></td>
  </tr>
        <tr>
    <td height="41">&nbsp;</td>
    <td colspan="2" align="right" class="text" style="font-size: 14px;">Design Name<span style="color:#FF0000">*</span>&nbsp;&nbsp;</td>
    <td class="heading ">&nbsp;&nbsp;<input type="text"  name="designer_name" id="designer_name" class="types_class1"  onKeyPress="enterevent(event,'cust_po_no','created_by'),samp_jobcard_clear_validation(this.value)" tabindex="3" style="font-size:12px; height:25px; width:200px; " value="<?php  if($edit_id!='') { echo $designer_name; }  ?>" >
      <div id="designer_name_validation_div" style="color:#F00"></div></td>
    <td align="right" class="text" style="font-size: 14px;">Color Profile <span style="color:#FF0000">*</span>&nbsp;&nbsp;</td>
    <td><input type="text" class="types_class1" name="color_profile" id="color_profile" style="width:200px; height:20px;" tabindex="8"  value="<?php if($edit_id!='') { echo $color_profile; } else { } ?>" onKeyPress="samp_jobcard_clear_validation(this.value),enterevent(event,'combo','style_name')">
    <div id="color_profile_validation_div" style="color:#F00"></div></td>
  </tr>

 <!-- <tr>
    <td height="35">&nbsp;</td>
    <td colspan="2" align="right" class="text" style="font-size: 14px;">Customer Po No<span style="color:#FF0000">*</span>&nbsp;&nbsp;</td>
    <td>&nbsp;&nbsp;<input type="text" class="types_class1" name="cust_po_no" id="cust_po_no" style="width:200px; height:20px;" tabindex="4"  value="<?php if($edit_id!='') { echo $cust_po_no; } else { } ?>" onKeyPress="jobcard_clear_validation(this.value),enterevent(event,'jobtype','cust_po_no')">
      <div id="cust_po_no_validation_div" style="color:#F00"></div></td>
    <td align="right" class="text" style="font-size: 14px;">Combo<span style="color:#FF0000">*</span>&nbsp;&nbsp;</td>
    <td><input type="text" class="types_class1" name="combo" id="combo" style="width:200px; height:20px;" tabindex="9"  value="<?php if($edit_id!='') { echo $combo; } else { } ?>" onKeyPress="enterevent(event,'jobtype','combo'),jobcard_clear_validation(this.value)">
    <div id="combo_validation_div" style="color:#F00"></div></td>
  </tr>-->

  <tr>
    <td height="34">&nbsp;</td>
    <td colspan="2" align="right" class="text" style="font-size: 14px;">Image Upload &nbsp;&nbsp; </td>
    <td>&nbsp;&nbsp;<a href="javascript:image_upload_jobcard2('jobcard/sample_jobcard/file_upload_sample.php?jobcard_no='+jobcard_no.value+'&customer_name='+customer_name.value)"><img src="img/upload.jpg" alt="" width="37" height="28" border="0" title="Upload"/></a><!--<input type="file" name="jobcard_image" id="jobcard_image" style="height:25px;width:300px;"   onChange="loadFile(event),upload()" value="<?php if($_GET[edit_id]!='') { echo $item_image; } ?>" accept="image/x-png, image/gif, image/jpeg" tabindex="9">
        <input type="hidden" name="photos" id="photos" value="<?php echo $item_image;?>" />--></td>
    <td align="right" class="text"></td>
    <td></td>
  </tr>
  
  <tr>
      <td>&nbsp;</td>
  <td colspan="5" align="center"><div id="sample_jobcard_sublist_div"><?php include("sample_jobcard_sublist.php");?></div></td>
  </tr>
  </table>
  <table width="100%">
     <tr style="padding-top:10px;">
   <td   align="center" ></td>
    <td width="7%"><span class="text" style="font-size: 14px;"><strong><strong></strong></strong></span></td>
    <td width="14%" align="right" class="text" style="font-size: 14px;"><strong></strong>&nbsp;&nbsp;</td>
        <td width="12%"></strong></td>
    <td width="28%"></td>
   </tr>
     <tr style="padding-top:10px;">
   <td   align="center" ></td>
    <td width="7%"><span class="text" style="font-size: 14px;"><strong><strong></strong></strong></span></td>
    <td width="14%" align="right" class="text" style="font-size: 14px;">&nbsp;&nbsp;</td>
        <td width="12%" class="text" style="font-size: 14px;"><strong></strong></td>
    <td width="28%"></td>
   </tr>
   <tr>
  <td colspan="5">&nbsp;</td>
   </tr>
         <tr>
            <td align="center" colspan="5"><input type="button" name="submit" tabindex="20" id="submit" style="background-color: #87BB07;    color: #fff;    border: 0px; font-family:verdana; font-size:14px; width:120px; height:27px; " value="<?php if($_GET['main_edit_id']!='') { echo "UPDATE";  } else { echo "SUBMIT"; } ?>" class="button" onClick="sample_jobcard(jobcard_no.value,entry_time.value,customer_name.value,designer.value,designer_name.value,color_profile.value,order_by.value,net_amt.value,'<?php echo $_GET['main_edit_id'];?>',this.value)" ></td>
          </tr>
        </table>
</form>
</div>
</div>
</div>
</div>