<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/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_party(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_jobcard(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 jobcard_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 style_no = document.getElementById("style_no").value;
	if(style_no=='')
	{
		document.getElementById("style_no_validation_div").innerHTML="* This field is Required.";
		document.getElementById("style_no").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 design_name = document.getElementById("design_name").value;
	if(design_name=='')
	{
		document.getElementById("design_name_validation_div").innerHTML="* This field is Required.";
		document.getElementById("design_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 order_entry_search(from_date,to_date,customer_name)
 {
  jQuery.ajax({
  type: "POST",
  url: "order/order_entry/order_entry_list.php",
  data: "from_date="+from_date+"&to_date="+to_date+"&customer_name="+customer_name,
  success: function(msg){jQuery("#order_main_list_div").html(msg);
 }
    });
 }
 
 function jobcard_close()
{
window.location.href="main_fram.php?file=jobcard_creation_list";
}
var loadFile = function(event) {
    var output = document.getElementById('image_name');
	document.getElementById('image_name').style.display = 'block';
	var test = document.getElementById('image_names');
    output.src = URL.createObjectURL(event.target.files[0]);
};
function upload() 
{
    jQuery.ajax({
        url: "jobcard/jobcard_entry/file_upload.php",
		type: "POST",             
		data: new FormData(this), 
		contentType: false,      
		cache: false,           
		processData:false,
        success: function(msg){
        }
    });
    return false;
}
jQuery(document).on("click", "#upload", function() {
	var file_data = jQuery("#jobcard_image").prop("files")[0];   // Getting the properties of file from file field
	var form_data = new FormData();                  // Creating object of FormData class
	form_data.append("file", file_data)              // Appending parameter named file with properties of file_field to form_data
	form_data.append("user_id", 123)                 // Adding extra parameters to form_data
	jQuery.ajax({
                url: "jobcard/jobcard_entry/file_upload.php",
                dataType: 'script',
                cache: false,
                contentType: false,
                processData: false,
                data: form_data,                         // Setting the data attribute of ajax with file_data
                type: 'post'
       })
})
</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);
date_default_timezone_set('Asia/Kolkata');
include ("include/db.php");	
	
$from_date=$_POST['from_date'];
$to_date=$_POST['to_date'];
$purchas_ordr_num=$_POST['purchas_ordr_num'];


function get_jobcard_number()
{

	$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"; 

		//   $start_year="2022-04-01"; 
		//   $end_year="2023-05-31"; 

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

		$sql="select jobcard_no  from jobcard_main where createdate BETWEEN '$start_year' AND '$end_year' order by main_id desc limit 0,1";	

		$rs=mysql_query($sql);
		$rscount=mysql_num_rows($rs);
		
		if($rscount!=0)
		{
			while($rsdata=mysql_fetch_object($rs))
			{			
				$jobcard_noo=$rsdata->jobcard_no;
				$pur_array=explode('-',$jobcard_noo);
				$job_nos=$pur_array[2]+1;
				$jobcard_no='JC-'.$datee.'-'.str_pad($job_nos, 4, '0', STR_PAD_LEFT);
			}
		}
		else
		{
			$job_nos="0001";
			$jobcard_no='JC-'.$datee.'-'.$job_nos;
		}
		
		return $jobcard_no;
}

/******************** 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  jobcard_main where jobcard_no like '%JC-$datee-%' order by main_id desc");
	//echo "select jobcard_no from  jobcard_main where jobcard_no like '%JC-$datee-%' 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($end_year > $start_year)
	{
		$jobcard_no+=1;
		$jobcard_number='JC-'.$datee.'-'.str_pad($jobcard_no, 4, '0', STR_PAD_LEFT);
	}
	else
	{
		$jobcard_no+=1;
		$jobcard_number='JC-'.$datee.'-'.str_pad($jobcard_no, 4, '0', STR_PAD_LEFT);
	}
	if ($jobcard_no == 1){
		$jobcard_number = get_jobcard_number();
	}
	
}
	//}
	
// }
	// if($edit_id1!='')
 //  {
	//   $estimation_num= $invoice_nosss;
 //  }


//echo $jobcard_number;

   $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['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;
}

if($_GET['edit_id']!='')
{
$table_display_styles1='style="display:inline;"';
} 
else
{
$table_display_stylesss='style="display:none;"';
}

   $query12="select * from  booking_main_list where booking_no='$book_number'";
   $rs=mysql_query($query12);
   $book_no_count=mysql_num_rows($rs);
   
   
  $edit_id=$_GET['main_id'];
  // echo $edit_id;
    // $edit_id=$_GET['main_id'];
if($_GET['source_frm']=='jobcard_quotation')
{ 
 $sql="select * from jobcard_quotation where jobcard_quot_no='$_GET[quotation_no]'";

}
else
{
  $sql="select * from jobcard_main where main_id='$_GET[main_id]'";
}
  $rs=mysql_query($sql);
  $rscount=mysql_num_rows($rs);
 
  while($rsdata=mysql_fetch_array($rs))
  {
	   $sno=$sno+1;
	   $from=$from+1;
	   $id=$rsdata['id'];
	   $jobcard_no=$rsdata['jobcard_no'];
	      $jobcard_quot_no=$rsdata['jobcard_quot_no'];
	   $entry_date=$rsdata['entry_date'];
	   $created_by=$rsdata['created_by'];
	   $cust_name=$rsdata['cust_name'];
	   $style_no=$rsdata['style_no'];
	   $style_name=$rsdata['style_name'];
	   $cust_po_no=$rsdata['cust_po_no'];
	   $job_type=$rsdata['job_type'];
       $fabric_type=$rsdata['fabric_type'];
	   $combo=$rsdata['combo'];
	   $hsn_code=$rsdata['hsn_code'];
	   $design_name=$rsdata['design_name'];
	   $overall_value=$rsdata['overall_value'];
	   $tax=$rsdata['tax'];
	   $net_total=$rsdata['net_total'];
	   $item_image1=$rsdata['item_image'];
       $order_by=$rsdata['order_by'];
	          $mistake=$rsdata['mistake'];
       $reason=$rsdata['reason'];


  }
  
  
function getExtension($str)
{
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
$errors=0;
$item_image=$_FILES['jobcard_image']['name']; 
if ($item_image) 
{
$filename = stripslashes($_FILES['jobcard_image']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension != "jpg") && ($extension != "jpeg") && ($extension !="png") && ($extension != "gif")) 
{
echo "<script>alert('Unknown extension!')</script>";
$errors=1;
}
else
{
$size=filesize($_FILES['jobcard_image']['tmp_name']);
if (($size > 200000))
{
$errors=1;
}
$newname="item_upload/".$item_image;
$copied = copy($_FILES['jobcard_image']['tmp_name'], $newname);
}
}
 function get_jobcard_check($jobcard_no)
{
	$Isql=mysql_query("select * from jobcard_main where jobcard_no='$jobcard_no'");
    $rscount=mysql_num_rows($Isql);
	return $rscount;
}
if($_POST['submit']=='SUBMIT')
{
$create_date=date(strtotime($_POST['entry_time']));
$entry_time=$_POST['entry_time'];
$a=explode("T",$entry_time);
$b=$a[0];
$c=$a[1];
$explodes=explode("-",$b);
$year1=$explodes[0];
$year2=$explodes[1];

$year=$year1."-".$year2;
//echo "bb".$year;
function get_jobcard_no($acc_year)
{
	$date=date("Y",strtotime($_POST['entry_time']));
$st_date=substr($date,2);
$month=date("m",strtotime($_POST['entry_time']));	   
$datee=$st_date.$month;
	// $date=date("Y");
	// $st_date=substr($date,2);
	// $month=date("m");	   
	// $datee=$st_date.$month;
	//$sql="select max(jobcard_no) as jobcard_no from jobcard_main where academic_yr='$acc_year' ";
$sql="select jobcard_no  from jobcard_main where academic_yr='$acc_year' order by main_id desc limit 0,1";
	$rs=mysql_query($sql);
	$rscount=mysql_num_rows($rs);
	if($rscount!=0)
	{
		while($rsdata=mysql_fetch_object($rs))
		{			
			$jobcard_noo=$rsdata->jobcard_no;
			$pur_array=explode('-',$jobcard_noo);
			$job_nos=$pur_array[2]+1;
			$jobcard_no='JC-'.$datee.'-'.str_pad($job_nos, 4, '0', STR_PAD_LEFT);
		}
	}
	else
	{
		$job_nos=0001;
		$jobcard_no='JC-'.$datee.'-'.$job_nos;
	}
	
	return $jobcard_no;
}//echo $jobcard_no;
// $entry_time=$_POST['entry_time'];
// $aa=explode("T",$entry_time);
// $bb=$aa[0];
// $c=$a[1];
// $explodess=explode("-",$bb);
// $year11=$explodess[0];
// $year22=$explodess[1];
// $st_date=substr($year11,2);
// $dte=$year22;
// $acc_names=$st_date.$dte;
// $jobcard_no+=1;
// echo "CFGH".$jobcard_nos='ccJC-'.$acc_names.'-'.str_pad($job_nos, 4, '0', STR_PAD_LEFT);
//$year22=$explodess[1];

//$jobcard_number=get_dsb_no($jobcard_nos);
    
$item_image=$_FILES['jobcard_image']['name']; 
$jobcard_no=$_POST['jobcard_no'];
$entry_time=$_POST['entry_time'];
$customer_name=$_POST['customer_name'];
$style_no=$_POST['style_no'];
$created_by=$_POST['created_by'];
$style_name=$_POST['style_name'];

$design_name=$_POST['design_name'];

$cust_po_no=$_POST['cust_po_no'];
$combo=$_POST['combo'];
$jobtype=$_POST['jobtype'];
$fabric_type=$_POST['fabric_type'];
$overal_tot=$_POST['overal_tot'];
$net_amt=$_POST['net_amt'];
$order_by=$_POST['order_by'];
 $mistake=$_POST['mistake'];
 $reason=$_POST['reason'];
  $quotation_no=$_GET['quotation_no'];
$hsn_code=$_POST['hsn_code'];

$create_date1=date('Y-m-d');
$acadamic_yr=explode("-",$create_date1);
$acdmc_yr_res=$acadamic_yr[0];
$check_item=get_jobcard_check($jobcard_no);


// $create_date=date('Y-m-d');
// $explodes=explode("-",$create_date);
// $year1=$explodes[0];
// $year2=$explodes[1];
// $year=$year1."-".$year2;

if($year2>3){$acc=$year1+1;}elseif ($year2<=3) {$acc=$year1;}
//echo $acc;
if(($year=='2014-04')||($year=='2014-05')||($year=='2014-06')||($year=='2014-07')||($year=='2014-08')||($year=='2014-09')||($year=='2014-10')||($year=='2014-11')||($year=='2014-12')||($year=='2015-01')||($year=='2015-02')||($year=='2015-03'))
{
$acc_year='2015';
}

if(($year=='2015-04')||($year=='2015-05')||($year=='2015-06')||($year=='2015-07')||($year=='2015-08')||($year=='2015-09')||($year=='2015-10')||($year=='2015-11')||($year=='2015-12')||($year=='2016-01')||($year=='2016-02')||($year=='2016-03'))
{
$acc_year='2016';
}

if(($year=='2016-04')||($year=='2016-05')||($year=='2016-06')||($year=='2016-07')||($year=='2016-08')||($year=='2016-09')||($year=='2016-10')||($year=='2016-11')||($year=='2016-12')||($year=='2017-01')||($year=='2017-02')||($year=='2017-03'))
{
$acc_year='2017';
}

if(($year=='2017-04')||($year=='2017-05')||($year=='2017-06')||($year=='2017-07')||($year=='2017-08')||($year=='2017-09')||($year=='2017-10')||($year=='2017-11')||($year=='2017-12')||($year=='2018-01')||($year=='2018-02')||($year=='2018-03'))
{
$acc_year='2018';
}


if(($year=='2018-04')||($year=='2018-05')||($year=='2018-06')||($year=='2018-07')||($year=='2018-08')||($year=='2018-09')||($year=='2018-10')||($year=='2018-11')||($year=='2018-12')||($year=='2019-01')||($year=='2019-02')||($year=='2019-03'))
{
$acc_year='2019';
}



if(($year=='2019-04')||($year=='2019-05')||($year=='2019-06')||($year=='2019-07')||($year=='2019-08')||($year=='2019-09')||($year=='2019-10')||($year=='2019-11')||($year=='2019-12')||($year=='2020-01')||($year=='2020-02')||($year=='2020-03'))
{
$acc_year='2020';
}



if(($year=='2020-04')||($year=='2020-05')||($year=='2020-06')||($year=='2020-07')||($year=='2020-08')||($year=='2020-09')||($year=='2020-10')||($year=='2020-11')||($year=='2020-12')||($year=='2021-01')||($year=='2021-02')||($year=='2021-03'))
{
$acc_year='2021';
}



if(($year=='2021-04')||($year=='2021-05')||($year=='2021-06')||($year=='2021-07')||($year=='2021-08')||($year=='2021-09')||($year=='2021-10')||($year=='2021-11')||($year=='2021-12')||($year=='2022-01')||($year=='2022-02')||($year=='2022-03'))
{
$acc_year='2022';
}

if(($year=='2022-04')||($year=='2022-05')||($year=='2022-06')||($year=='2022-07')||($year=='2022-08')||($year=='2022-09')||($year=='2022-10')||($year=='2022-11')||($year=='2022-12')||($year=='2023-01')||($year=='2023-02')||($year=='2023-03'))
{
$acc_year='2023';
}

if(($year=='2023-04')||($year=='2023-05')||($year=='2023-06')||($year=='2023-07')||($year=='2023-08')||($year=='2023-09')||($year=='2023-10')||($year=='2023-11')||($year=='2023-12')||($year=='2024-01')||($year=='2024-02')||($year=='2024-03'))
{
$acc_year='2024';
}

if(($year=='2024-04')||($year=='2024-05')||($year=='2024-06')||($year=='2024-07')||($year=='2024-08')||($year=='2024-09')||($year=='2024-10')||($year=='2024-11')||($year=='2024-12')||($year=='2025-01')||($year=='2025-02')||($year=='2025-03'))
{
$acc_year='2025';
}

if($check_item==0)
{
if($_GET['source_frm']=='jobcard_quotation');
//echo $acc_year;
if($acc==$acc_year){
$jobcard_no1=get_jobcard_no($acc_year);
$Insql1=mysql_query("insert into jobcard_main(jobcard_no,entry_date,created_by,cust_name,style_no,style_name,design_name,cust_po_no,job_type,fabric_type,combo,overall_value,net_total,item_image,academic_yr,createdate,order_by,mistake,reason,quotation_no,hsn_code)values('$jobcard_no1','$entry_time','$created_by','$customer_name','$style_no','$style_name','$design_name','$cust_po_no','$jobtype','$fabric_type','$combo','$overal_tot','$net_amt','$item_image','$acc_year','$create_date1','$order_by','$mistake','$reason','$quotation_no','$hsn_code')");
//echo "insert into jobcard_main(jobcard_no,entry_date,created_by,cust_name,style_no,style_name,cust_po_no,job_type,fabric_type,combo,overall_value,net_total,item_image,academic_yr,createdate,order_by,mistake,reason,quotation_no,hsn_code)values('$jobcard_no1','$entry_time','$created_by','$customer_name','$style_no','$style_name','$cust_po_no','$jobtype','$fabric_type','$combo','$overal_tot','$net_amt','$item_image','$acc_year','$create_date1','$order_by','$mistake','$reason','$quotation_no','$hsn_code')";

if($_GET['source_frm']=='jobcard_quotation')
{
$Upsql100="update jobcard_sublist set entry_time='$entry_time',created_by='$created_by',customer_name='$customer_name',cust_po_no='$cust_po_no',jobtype='$jobtype',fabric_type='$fabric_type',jobcard_no='$jobcard_no',hsn_code='$hsn_code' where quotation_no='$_GET[quotation_no]'";
mysql_query($Upsql100);

  }
  else
  {
   $Upsql100="update jobcard_sublist set entry_time='$entry_time',created_by='$created_by',customer_name='$customer_name',cust_po_no='$cust_po_no',jobtype='$jobtype',fabric_type='$fabric_type' where jobcard_no='$jobcard_no'";
      mysql_query($Upsql100);

  }
   mysql_query($Upsql100);

 echo "<script>window.location.href='main_fram.php?file=jobcard_creation_list';</script>";
}
	
	}else{}

	
	}


if($_POST['submit']=='UPDATE')
{
	
$item_image=$_FILES['jobcard_image']['name']; 
$edit_id=$_POST['edit_id']; 
$jobcard_no=$_POST['jobcard_no'];
$entry_time=$_POST['entry_time'];
$customer_name=$_POST['customer_name'];
$style_no=$_POST['style_no'];
$created_by=$_POST['created_by'];
$style_name=$_POST['style_name'];

$design_name=$_POST['design_name'];

$cust_po_no=$_POST['cust_po_no'];
$combo=$_POST['combo'];
$jobtype=$_POST['jobtype'];
$fabric_type=$_POST['fabric_type'];
$overal_tot=$_POST['overal_tot'];
$net_amt=$_POST['net_amt'];
$order_by=$_POST['order_by'];
 $mistake=$_POST['mistake'];
 $reason=$_POST['reason'];
 $hsn_code=$_POST['hsn_code'];

$entry_time=$_POST['entry_time'];
$a=explode("T",$entry_time);
$b=$a[0];
$c=$a[1];
$explodes=explode("-",$b);
$year1=$explodes[0];
$year2=$explodes[1];


// $create_date1=date('Y-m-d');
// $acadamic_yr=explode("-",$create_date1);
// $acdmc_yr_res=$acadamic_yr[0];  
if($year2>3){$acc=$year1+1;}elseif ($year2<=3) {$acc=$year1;}

  $Upsq12="update jobcard_main set jobcard_no='$jobcard_no',entry_date='$entry_time',created_by='$created_by',cust_name='$customer_name',style_no='$style_no',style_name='$style_name',design_name='$design_name',cust_po_no='$cust_po_no',job_type='$jobtype',fabric_type='$fabric_type',hsn_code='$hsn_code',combo='$combo',overall_value='$overal_tot',net_total='$net_amt',item_image='$item_image',academic_yr='$acc',createdate='$create_date1',order_by='$order_by',mistake='$mistake',reason='$reason' where main_id='$edit_id'";
 mysql_query($Upsq12) or die(error);
 
   $Upsql1002="update jobcard_sublist set entry_time='$entry_time',created_by='$created_by',customer_name='$customer_name',cust_po_no='$cust_po_no',jobtype='$jobtype',fabric_type='$fabric_type',hsn_code='$hsn_code' where jobcard_no='$_POST[jobcard_no]'";
   mysql_query($Upsql1002);
   
      $Upsql1="update inward_main set job_type='$jobtype',fabric_type='$fabric_type' where jobcard_no='$_POST[jobcard_no]'";
   mysql_query($Upsql1);
   
   $Upsql2="update inward_sub_list set job_types='$jobtype',fabric_type='$fabric_type' where jobcard_no='$_POST[jobcard_no]'";
   mysql_query($Upsql2);
   
   $Upsql3="update delivery_challan_main set job_type='$jobtype',fabric_type='$fabric_type' where job_no='$_POST[jobcard_no]'";
   mysql_query($Upsql3);
   
    $Upsql4="update delivery_challan_sub set job_type='$jobtype',fabric_type='$fabric_type' where job_no='$_POST[jobcard_no]'";
   mysql_query($Upsql4);
   
   $Upsql5="update fusing_production_main set job_type='$jobtype',fabric_type='$fabric_type' where job_card_no='$_POST[jobcard_no]'";
   mysql_query($Upsql5);
      
$Upsql7="update printer_production_main set job_type='$jobtype',fabric_type='$fabric_type' where job_card_no='$_POST[jobcard_no]'";
   mysql_query($Upsql7);
   
echo "<script>window.location.href='main_fram.php?file=jobcard_creation_list';</script>";
}
?>

<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" onSubmit="return jobcard_validation(),confirmmsg();">

<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">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()" 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 }else if($_SESSION['user_type']==1) {if($edit_id!=''){?> 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;">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!='')||($_GET['quotation_no']!='')) { 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" style="width:200px; height:20px;" onKeyUp="jobcard_clear_validation(this.value)" onKeyPress="enterevent(event,'style_no','customer_name')" tabindex="2"  value="<?php if(($edit_id!='')||($_GET['quotation_no']!='')) { echo $cust_name; } else { } ?>" > <img src="img/add-512-2.png" width="28" height="28" title="ADD PARTY" onClick="javascript:add_new_party('master_entry/party_creation/party_creation.php?source=<?php echo "Sub";?>&order_no=<?php echo $order_num;?>')">
      <div id="customer_name_validation_div" style="color:#F00"></div></td>
    <td align="right" class="text" style="font-size: 14px;">Style No<span style="color:#FF0000">*</span>&nbsp;&nbsp;</td>
    <td><input type="text" class="types_class1" name="style_no" id="style_no"    style="width:200px; height:20px;"  tabindex="7"  value="<?php if(($edit_id!='')||($_GET['quotation_no']!='')) { echo $style_no; } else { } ?>" onKeyPress="jobcard_clear_validation(this.value),enterevent(event,'created_by','style_no')">
    <div id="style_no_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;">Job Created By<span style="color:#FF0000">*</span>&nbsp;&nbsp;</td>
    <td class="heading ">&nbsp;&nbsp;<input type="text"  name="created_by" id="created_by" class="types_class1" autofocus onKeyPress="enterevent(event,'cust_po_no','created_by'),jobcard_clear_validation(this.value)" tabindex="3" style="font-size:12px; height:25px; width:200px; " value="<?php  if(($edit_id!='')||($_GET['quotation_no']!='')) { echo $created_by; }  else{ echo $_SESSION['login_user_name']; }?>" readonly>
      <div id="job_created_by_validation_div" style="color:#F00"></div></td>
    <td align="right" class="text" style="font-size: 14px;">Style Name <span style="color:#FF0000">*</span>&nbsp;&nbsp;</td>
    <td><input type="text" class="types_class1" name="style_name" id="style_name" style="width:200px; height:20px;" tabindex="8"  value="<?php if(($edit_id!='')||($_GET['quotation_no']!='')) { echo $style_name; } else { } ?>" onKeyPress="jobcard_clear_validation(this.value),enterevent(event,'combo','style_name')">
    <div id="style_name_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!='')||($_GET['quotation_no']!='')) { 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!='')||($_GET['quotation_no']!='')) { 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;">Job Type &nbsp;&nbsp; </td>
    <td>&nbsp;&nbsp;<select id="jobtype" name="jobtype" style="width:200px; height:26px;" class="types_class1" onChange="get_fabric_type1(this.value),enterevent(event,'style_no','jobtype')"  tabindex="">
      
     <option value="">Select</option>
	 <?php 
	 include ("../../include/db.php");
	  $sql="select * from job_type_creation order by job_type ASC";
								$sql123 = mysql_query($sql);
							while($fetch_sql123=mysql_fetch_array($sql123))
								{
									
									$job_type1=$fetch_sql123['job_type'];
									?>
									<option value="<?php echo $job_type1?>"<?php if($job_type1==$job_type ) { echo "selected"; } ?>><?php echo $job_type1; ?></option>
									<?php
									}
									?>
      
      
    </select></td>
    <td align="right" class="text">Image Upload&nbsp;&nbsp;</td>
    <td><a href="javascript:image_upload_jobcard('jobcard/jobcard_entry/file_upload_sample.php?jobcard_no='+jobcard_no.value+'&customer_name='+customer_name.value+'&quotation_no='+'<?php echo $_GET['quotation_no']; ?>')"><img src="img/upload.jpg" alt="" width="37" height="28" border="0" title="Upload"/></a></td>
  </tr>
  <td colspan="3" align="right" class="text" style="font-size: 14px;">Designer Name <span style="color:#FF0000">*</span>&nbsp;&nbsp;</td>
    <td><input type="text" class="types_class1" name="design_name" id="design_name" style="width:200px; height:20px;" tabindex="8"  value="<?php if(($edit_id !='')||($_GET['quotation_no']!='')) { echo $design_name; } else { echo " ";} ?>" onKeyPress="jobcard_clear_validation(this.value),enterevent(event,'combo','design_name')">
    <div id="design_name_validation_div" style="color:#F00"></div></td>
	<td class="text" align="right">HSN Code&nbsp;&nbsp;</td>
    <td><input type="text" name="hsn_code" id="hsn_code" readonly class="types_class1" style="width:200px; height:20px;"  value="<?php if(($edit_id!='')||($_GET['quotation_no']!='')) {echo $hsn_code;} else { echo "998821"; }?> "></td>
  </tr>
  
  <tr id='fabric_type_main'>
  <?php
  if($edit_id!=''){?>
	<td>&nbsp;</td>
	<td colspan="2" align="right" class="text"><div id="fabric_type_div1">Fabric Type</div></td>
	  <td style="padding-left:10px;"><div id="fabric_type_div"><select id="fabric_type" name="fabric_type" style="width:200px; height:26px;" class="types_class1" onChange="enterevent(event,'style_no','fabric_type')"  tabindex="6">
	  
	  <?php
	  
	  $sql_user="select * from  fabric_type_creation where fabric_type='$fabric_type' ";
		  $rs_user=mysql_query($sql_user);
			  while($rsdata_user=mysql_fetch_object($rs_user))
			  { 
			  $fabric_types=$rsdata_user->fabric_type;
			  $id=$rsdata_user->id;?>
	  <option value="<?php echo $fabric_types;?>"><?php echo $fabric_types;?></option>
	  <?php } ?> 
	  </select></div></td>

  </tr>
  <?php
  } ?>
  <tr>
    <td height="10">&nbsp;</td>
  <td colspan="2" align="right" class="text"></td>
    <td style="padding-left:10px;"></td>
  </tr>
  <tr>
      <td>&nbsp;</td>
  <td colspan="5" align="center"><div id="jobcard_sublist_div"><?php include("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="right" class="text" style="font-size: 14px;">New Job Card Mistake&nbsp;&nbsp;</td>
    <td><input type="text" class="types_class1" name="mistake" id="mistake" style="width:200px; height:20px;" tabindex="8"  value="<?php if($edit_id!='') { echo $mistake; } else { } ?>">
    </td>
    
    
    <td align="right" class="text" style="font-size: 14px;">Reason&nbsp;&nbsp;</td>
    <td><textarea name="reason" id="reason" class="types_class1"><?php if($edit_id!='') { echo $reason; } else { } ?></textarea>
    </td>
    </tr>
   
      <tr>
  <td colspan="5">&nbsp;</td>
   </tr>

         <tr>
            <td align="center" colspan="5"><input type="submit" 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_id']!='') { echo "UPDATE";  } else { echo "SUBMIT"; } ?>" class="button"  ></td>
          </tr>
        </table>
</form>
</div>
</div>
</div>
</div>