<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/delivery_challan_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 deliv_challan_close()
{
window.location.href="main_fram.php?file=delivery_challan_list";
window.location.reaload(true);
}

/*************************** Get job card number ************************************************/
var sm = jQuery.noConflict();
sm().ready(function() 
{ 
	sm("#job_no").autocomplete("include/autocomplete/delivery_jobcard_auto.php", {
	width: 250,
	matchContains: true,
	selectFirst: true
	});	
});
</script>
<script>
function new_win(url)
{

onmouseover= window.open(url,'','height=600,width=900,scrollbars=no,resizable=no,left=100,top=100,toolbar=no,location=no,directories=no,status=no,menubar=no');
}

</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'];
/******************** 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['delivery_no']))
{
	$rs1=mysql_query("select delivery_no from  delivery_challan_main where cr_date>='$start_year' and cr_date<='$end_year' order by id desc");
	if($res1=mysql_fetch_assoc($rs1))
	{
		$pur_array=explode('-',$res1['delivery_no']);
	    $year1=$pur_array[1];
        $year2=substr($year1, 0, 2);
	    $year='20'.$year2;
		$delivery_no=$pur_array[2];
	}
	if($delivery_no=='')
		$delivery_nos='DC-'.$datee.'-0001';

	else
	{
		$delivery_no+=1;
		$delivery_nos='DC-'.$datee.'-'.str_pad($delivery_no, 4, '0', STR_PAD_LEFT);
	}
}
$edit_id=$_GET['edit_id'];
ob_start();
session_start();

if($_GET['edit_id']!='')
{
$table_display_styles1='style="display:inline;"';
} 
else
{
$table_display_stylesss='style="display:none;"';
}
   
  $edit_id1=$_GET['edit_id'];
  $sql="select * from delivery_challan_main where id='$_GET[edit_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'];
	   $delivery_no=$rsdata['delivery_no'];
	   $date_time=$rsdata['date_time'];
	   $job_no=$rsdata['job_no'];
	   $created_by=$rsdata['created_by'];
	   $customer_name=$rsdata['customer_name'];
	   $style_no=$rsdata['style_no'];
	   $style_name=$rsdata['style_name'];
	   $combo=$rsdata['combo'];
       $customer_po_no=$rsdata['customer_po_no'];
	   $job_type=$rsdata['job_type'];
	   $fabric_type=$rsdata['fabric_type'];
	   $remarks=$rsdata['remarks'];
	   $total_qty=$rsdata['total_qty'];
	   $deliv_status=$rsdata['deliv_status'];
	   				 $vehicle_no=$rsdata['vehicle_no'];
				 $delivery_through=$rsdata['delivery_through'];

  }
?>

<style type="text/css">
.style2 {color: #FF0000}
.style7{font-family: Tahoma, Arial, Helvetica, sans-serif;font-size: 13px;}
.style8{ text-align:center;font-family:Tahoma, Arial, Helvetica, sans-serif; font-size: 15px; padding:40px; font-weight: 500;color:#32328e;letter-spacing: 1px;}
.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:13px;}
.style11{font-family:Verdana, Arial, Helvetica, sans-serif; font-size:14px;}

</style>


<div class="container">
<div class="row-fluid">
<div class="span12">
<div class="table-responsive">
<form name="inward_form"  id="inward_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">Fabric Delivery Challan</div></tr>
<td width="12%" align="left"><img src="img/wrong.png" name="add_button" id="add_button" title="Cancel Booking Order"  onclick="javascript:deliv_challan_close()" align="top" width="30" height="30" border="0" tabindex="4" style="cursor:pointer; margin-left:96%; margin-top:-34px;" class="button green-button" >
</td>
<tr></tr></table>
<table width="100%"  cellpadding="0" cellspacing="0" border="0">
<tr height="10px;">
  <td ></td>
  <td ></td>
  <td width="299" ></td>
  <td width="1" ></td>
  <td ></td>
  <td colspan="2"></td>
  <td ></td>
  <td ></td>
</tr>
<tr>
  <td width="32" height="42" align="left" class="txt"></td>
  <td width="140" height="42" align="left"  class="style11">Delivery No </td>
  <td align="left"  class="style7"><input type="hidden"  name="delivery_no" id="delivery_no" class="text_box" style="font-size:14px" value="<?php if($edit_id!='') { echo $delivery_no; } else{ echo $delivery_nos;  } ?>"/>
    <strong>
   <span style="color:#390;"> <?php if($edit_id!='') { echo $delivery_no; } else{ echo $delivery_nos; } ?></span>
    </strong></td>
  <td colspan="2" align="left" valign="top" class="style11">&nbsp;</td>
  <td colspan="2" align="left" valign="top" class="style7">&nbsp;</td>
  <td width="103" align="left"  class="style11">Date &amp; Time</td>
  <td width="263" align="center" >
  <input type="datetime-local"  name="date_time" id="date_time" class="types_class1"  <?php if($_SESSION['user_type']!=1) { ?> readonly <?php } ?>   tabindex="1"  onKeyUp="enterevent(event,'job_no','date_time')"   style="height:25px; width:215px;" value="<?php if($edit_id!='') { echo $date_time; }  else{ echo  date('Y-m-d').'T'.date('H:i'); }?>">
  </td>
  <td width="24" align="left" valign="top">&nbsp;</td>
</tr>
<tr>
  <td height="34" align="left" class="txt"></td>
  <td height="34" align="left"  class="style11">Jobcard No<span style="color:#FF0000"> *</span></td>
  <td align="left"  class="style11"><input type="text" class="types_class1" name="job_no" id="job_no"  autofocus  style="width:250px; height:20px;" tabindex="1" onFocus="get_jobcard_details(this.value)" value="<?php if($edit_id1!='') { echo $job_no; } else { } ?>" onKeyUp="get_jobcard_details(job_no.value),fab_deliv_challan_clear_validation(this.value),enterevent(event,'delivery_dates','job_no')" ><div id="delivery_challan_jobno_validation_div" style="color:#F00"></div></td>
  <td colspan="2" align="center" valign="top" class="style7">&nbsp;</td>
  <td colspan="2" align="left" valign="top" class="style7">&nbsp;</td>
  <td align="left"  class="style11">Created By</td>
  <td align="center" ><div id="deliv_created_by_div"><input type="text" readonly class="types_class1" name="created_by" id="created_by" style="width:215px; height:20px;"   value="<?php if($edit_id1!='') { echo $created_by; } else { } ?>" ></div></td>
  <td align="left" valign="top">&nbsp;</td>
</tr>
<tr>
  <td height="34" align="left" class="txt"></td>
  <td height="34" align="left"  class="style11">Customer Name</td>
  <td align="left"  class="style7"><div id="deliv_cust_name"><input type="text" class="types_class1" name="customer_name" id="customer_name" style="width:250px; height:20px;"   value="<?php if($edit_id1!='') { echo $customer_name; } else { } ?>" readonly ></div></td>
  <td colspan="2" align="left"  class="style11">&nbsp;</td>
  <td colspan="2" align="left" valign="top" class="style7">&nbsp;</td>
  <td align="right"  class="style11">&nbsp;</td>
  <td align="right" valign="top">&nbsp;</td>
  <td align="left" valign="top">&nbsp;</td>
</tr>
<tr>
  <td height="34" align="left" class="txt"></td>
  <td height="34" align="left"  class="style11">Style No</td>
  <td align="left"  class="style7"><div id="deliv_style_no_div"><input type="text" class="types_class1" name="style_no" id="style_no" style="width:250px; height:20px;"   value="<?php if($edit_id1!='') { echo $style_no; } else { } ?>" readonly></div></td>
  <td colspan="2" align="left"  class="style11">Style Name</td>
  <td colspan="2" align="left"  class="style7"><div id="deliv_style_name_div"><input type="text" class="types_class1" name="style_name" id="style_name" style="width:200px; height:20px;"  value="<?php if($edit_id1!='') { echo $style_name; } else { } ?>" readonly></div></td>
  <td align="left"  class="style11">Combo</td>
  <td align="center" ><div id="deliv_combo_type_div"><input type="text" class="types_class1" name="combo" id="combo" style="width:215px; height:20px;"  value="<?php if($edit_id1!='') { echo $combo; } else { } ?>"readonly ></div></td>
  <td align="left" valign="top">&nbsp;</td>
</tr>
<tr>
  <td height="45" align="left" class="txt"></td>
  <td height="45" align="left"  class="style11">Customer PO No</td>
  <td align="left"  ><div id="deliv_customer_po_div">
    <input type="text" class="types_class1" name="cust_po_no" id="cust_po_no" style="width:250px; height:20px;"   value="<?php if($edit_id1!='') { echo $customer_po_no; } else { } ?>" readonly></div>
 </td>
  <td colspan="2" align="left" class="style11">Job Type</td>
  <td colspan="2" align="left"  ><div id="deliv_job_types_div">
  <input type="text" class="types_class1" name="job_type" id="job_type" readonly style="width:200px; height:20px;"  value="<?php if($edit_id1!='') { echo $job_type; } else { } ?>" >
</div></td>
  <td align="left" class="style11">Fabric Type</td>
  <td align="center" ><div id="deliv_fabric_type_div">
  <input type="text" class="types_class1" name="fabric_type" id="fabric_type" style="width:200px; height:20px;"  value="<?php if($edit_id1!='') { echo $fabric_type; } else { } ?>" readonly>
  </div></td>
  <td align="left" >&nbsp;</td>
</tr>
<tr>
  <td colspan="10" align="left" class="txt"></td>
</tr>
<tr>
  <td colspan="10" class="style7" align="center"><div id="delivery_challan_sublist_div"><?php include("delivery_challan_sublist.php"); ?></div></td>
</tr>
<tr>
  <td class="style7"  align="center">&nbsp;</td>
  <td class="style11"  align="center">Delivery status</td>
  <td colspan="2"  align="left" class="style7"><select name="deliv_status" id="deliv_status" class="types_class1" tabindex="6"  style="width:100%; height:32px; font-family:Verdana, sans-serif; font-size:14px" onChange="enterevent(event,'remarks','deliv_status'">
    <option value="Pending" <?php if($deliv_status=='Pending') {echo "Selected";}?> onKeyUp="enterevent(event,'remarks','deliv_status'" >Pending</option>
    <option value="Completed" <?php if($deliv_status =='Completed') {echo "Selected";}?>>Completed</option>
    </option>
  </select>
   </td>
  <td width="105"  align="center" class="style7">&nbsp;</td>
  <td width="134"  align="left" class="style11"></td>
  <td colspan="2"  align="center" class="style7"><span class="style11">Remarks </span></td>
  <td  align="left" class="style7"><textarea name="remarks" id="remarks" cols="50" rows="6" class="types_class" tabindex="7"  style="width:300px; height:75px;" onKeyUp="enterevent(event,'action','remarks')"><?php if($_GET['edit_id']!='') { echo $remarks; } ?>
          </textarea></td>
  <td  align="left" class="style7">&nbsp;</td>
</tr>
<tr>
  <td height="41"  align="center" class="style7">&nbsp;</td>
  <td class="style11"  align="center" > Delivery Through<span style="color:#FF0000"> *</span></td>
  <td colspan="2"  align="left" class="style7"><input type="text" class="types_class1" name="delivery_through" id="delivery_through" style="width:250px; height:20px;"   value="<?php if($edit_id1!='') { echo $delivery_through; } else { } ?>" onKeyUp="fab_deliv_challan_clear_validation(this.value)" >&nbsp;<div id="delivery_through_chal_validation_div" style="color:#F00"></div></td>
  <td class="style7"  align="center">&nbsp;</td>
  <td class="style7"  align="center">&nbsp;</td>
  <td colspan="2"  align="center" class="style11" >Vehicle No<span style="color:#FF0000"> *</span></td>
  <td class="style7"  align="left"><input type="text" class="types_class1" name="vehicle_no" id="vehicle_no" style="width:250px; height:20px;"   value="<?php if($edit_id1!='') { echo $vehicle_no; } else { } ?>" onKeyUp="fab_deliv_challan_clear_validation(this.value)"  >&nbsp;<div id="vehicleno_challan_validation_div" style="color:#F00"></div></td>
  <td class="style7"  align="center">&nbsp;</td>
</tr>

<tr>
  <td colspan="10" class="style7"  align="center"><input type="button" class="add_button" name="action"  id="action" tabindex="8" value="<?php if($_GET['edit_id']!='') { echo "Edit";  } else { echo "Save"; } ?>" style="height:30px; width:100px; font-size:16px; background-color: #87BB07;color: #fff;border: 0px" onClick="delivery_challan_add(delivery_no.value,date_time.value,job_no.value,created_by.value,customer_name.value,style_no.value,style_name.value,combo.value,cust_po_no.value,job_type.value,fabric_type.value,remarks.value,overal_qty.value,deliv_status.value,delivery_through.value,vehicle_no.value,'<?php echo $edit_id;?>',this.value);"  /></td>
</tr>
</table>
<!--Design End--></td>
  </tr>
</table>
</form>
</div>
</div>
</div>
</div>