<link rel="stylesheet" href="css/new_mxerp.css">
<?php
ob_start();
$PageSecurity = 4;
$PageName     = 'Site to Site Transfer Issue';
include('includes/DefinePOClass.php');
include('includes/stockcalculation.php');

if (isset($_POST['Save'])) {
    $sql = "update mrs_receipt set  remarks='" . $_REQUEST['remarks'] . "' where id='" . $_REQUEST['id'] . "' ";
    
    $ErrMsg       = _('An error occurred Record Note Save') . '. ' . _('The error says');
    $insertResult = DB_query($sql, $db, $ErrMsg);
    $Lastreq_id   = $_REQUEST['id'];
    
    if ($Lastreq_id != '') {
        DB_query("delete from mrs_receipt_details where mrs_receipt_id='" . $_REQUEST['id'] . "'", $db);
       
        for ($i = 0; $i < count($_REQUEST['receivedQty']); $i++) {
            if ($_REQUEST['receivedQty'][$i] != '') {
                $sql2          = "INSERT INTO mrs_receipt_details set
                                      mrs_receipt_id='" . $Lastreq_id . "', 
                                      itemid='" . $_REQUEST['itemdataid'][$i] . "', 
                                      receive_qty='" . $_REQUEST['receivedQty'][$i] . "', 
                                      issueqty='" . $_REQUEST['issueqty'][$i] . "', 
                                      batch_no='".$_REQUEST['batch_no'][$_REQUEST['itemdataid'][$i]]."'";
                $ErrMsg        = _('An error occurred Record Note Save') . '. ' . _('The error says');
                $insertResult2 = DB_query($sql2, $db, $ErrMsg);               

     /* $result = DB_query("Select pending_qty from stock_valuation_tbl where against_voucher_main_id='".$Lastreq_id."' and type='STR' and mst_itemid='".$_REQUEST['itemdataid'][$i]."' and batch_no='".$_REQUEST['batch_no'][$_REQUEST['itemdataid'][$i]]."'",$db);

      $data = DB_fetch_array($result);
      
        
      $result1 =DB_query("Select pending_qty from stock_valuation_tbl where against_voucher_main_id='".$_REQUEST['issue_slip_no']."' and type='STI' ",$db);
                
      $data1 = DB_fetch_array($result1);
      $pendingqty=$data1['pending_qty'];

      $newqty=floatval($pendingqty)+floatval($data['pending_qty']);

      DB_query("Update stock_valuation_tbl set pending_qty='".$newqty."' where against_voucher_main_id='".$_REQUEST['issue_slip_no']."' and type='STI' ",$db);  */

      DB_query("delete from stock_valuation_tbl where where against_voucher_main_id='".$Lastreq_id."' and type='STRM' and mst_itemid='".$_REQUEST['itemdataid'][$i]."' and batch_no='".$_REQUEST['batch_no'][$_REQUEST['itemdataid'][$i]]."' ",$db);

                $dtls_Lastreq_id                       = DB_Last_Insert_ID($db, 'mrs_receipt_details', $ErrMsg);
                $primary_unit                          = $s->getField('item_master', 'id', $_POST['itemdataid'][$i], 'mst_unitid');
                $secondary_unit                        = $s->getField('item_master', 'id', $_POST['itemdataid'][$i], 'conv_unit');
                $data_stock['site']                    = $_REQUEST['site'];
                $data_stock['store']                   = $_REQUEST['sitecode3'];
                $data_stock['mst_itemid']              = $_POST['itemdataid'][$i];
                //$data_stock['size_id']                 = $_REQUEST['sizesp'][$_REQUEST['itemdataid'][$i]];
              //  $data_stock['grade_id']                = $_REQUEST['gradesp'][$_REQUEST['itemdataid'][$i]];
                $data_stock['primary_unit']            = $primary_unit;
                $data_stock['secondary_unit']          = $secondary_unit;
                $data_stock['against_voucher_main_id'] = $Lastreq_id;
                $data_stock['against_voucher_dtls_id'] = $dtls_Lastreq_id;
                $data_stock['type']                    = 'STRM';
                $data_stock['inwardqty_primary']       = $_REQUEST['receivedQty'][$i];
                $data_stock['inwardqty_secondary']     = $_REQUEST['secondaryqty'][$i];
                $data_stock['trasaction']              = FormatDateForSQL($_REQUEST['issuedate']) . " " . date('H:i:s', time());
                $data_stock['batch_no']                = $_REQUEST['batchNo'][$i];
                $data_stock['pending_qty']             = $_REQUEST['receivedQty'][$i];
               
                $s->RecordInsert('stock_valuation_tbl', $data_stock);                

               /*  $result1 =DB_query("Select pending_qty from stock_valuation_tbl where against_voucher_main_id='".$_REQUEST['issue_slip_no']."' and type='STI' ",$db);
                
                $data1 = DB_fetch_array($result1);
                $pendingqty=$data1['pending_qty'];

                $newqty=floatval($pendingqty)-floatval($_REQUEST['receivedQty'][$i]);

                 DB_query("Update stock_valuation_tbl set pending_qty='".$newqty."' where against_voucher_main_id='".$_REQUEST['issue_slip_no']."' and type='STI' ",$db);

                if ($_REQUEST['receivedQty'][$i] >= $_REQUEST['pending_qty'][$i])
                    $status_slip = "1";
                else
                    $status_slip = "0";
                $update = DB_query("update transfer_issue_details set status='" . $status_slip . "' where transfer_issue_id='" . $_REQUEST['issue_slip_no'] . "' and itemid='" . $_REQUEST['itemdataid'][$i] . "'", $db);  */
            }
        }        
    }
   /*  $get_num_rows      = DB_query("Select * from transfer_issue_details where transfer_issue_id='" . $_REQUEST['issue_slip_no'] . "'", $db);
    $num_rows          = DB_num_rows($get_num_rows);
    $check_item_stat   = DB_query("Select * from transfer_issue_details where transfer_issue_id='" . $_REQUEST['issue_slip_no'] . "'
    and status='1'", $db);
    $received_num_rows = DB_num_rows($check_item_stat);
    
    if ($num_rows == $received_num_rows) {
        $updatePOStat = DB_query("Update transfer_issue set status='Receive' where 
      id='" . $_REQUEST['issue_slip_no'] . "'", $db);
    } else {
        
        $updatePOStat = DB_query("Update transfer_issue set status='Pending' where 
      id='" . $_REQUEST['issue_slip_no'] . "'", $db);
    }
    exit; */
    if ($insertResult2 == true) {
        $_SESSION['success_msg'] = "Saved Successfully";
        echo "<script>location.href='index.php?route=Inventory/transation/receipt_issue_slip_index&modid=" . $_REQUEST['modid'] . "&frmid=" . $_REQUEST['frmid'] . "'</script>";
    }    
}
?>
 <?php
$resultreceived     = DB_query("select * from mrs_receipt where id='" . $_REQUEST['id'] . "'", $db);
$row                = DB_fetch_array($resultreceived);
$function_filter[0] = $row['site'];
$function_filter[1] = $row['store_to'];
$function_filter[2] = date('Y-m-d');
?>
<div class="body_contain">
<div class="tab_div">
 <h1>To Store Receipt</h1>
<form name="form1" onsubmit="return chkValidate();" method="post">
<div align="center">
<table width="100%" cellpadding="3" cellspacing="0" border="0">
<tr class="row1">
    <td width="13%" align="right"><strong>Branch:</strong></td>
    <td width="20%"><div id="companybranch1"><select name="site" id="site">
    <option value="<?php
echo $row['site'];
?>"><?php
echo $s->getField('locations', 'loccode', $row['site'], 'locationname');
?></option>    
    </select></td>    
    <td width="13%" align="right"><strong>Received Slip No.:</strong></td>
    <td width="20%"><input name="issue_slipno" type="text" id="issue_slipno"  readonly="readonly" value="<?php echo $row['receipt_no']; ?>"></td>
    <td width="13%" align="right"><strong>Date:</strong></td>
    <td><input name="issuedate" type="text"  id="recieved_date" value="<?php echo date('d/m/Y', strtotime($row['receipt_date'])); ?>" size="15" readonly /></td>
</tr>
  <tr class="row1">
    <td align="right"><strong>Issue Slip No.:</strong></td>
    <td><select name="issue_slip_no" id="issue_slip_no" ><option value="<?php
echo $row['issue_slip_id'];
?>"><?php
echo $s->getField('addissue', 'id', $row['issue_slip_id'], 'issue_slipno');
?></option></select></td>
    <td align="right"><strong>From Store:</strong></td>
    <td id="from_branch"><input type="text" value="<?php
//$site = $s->getField('mrs_receipt', 'id', $row['issue_slipno'], 'sitecode');
echo $s->getField('storetype', 'id', $row['store_from'], 'StoreName');
?>">
    <input type="hidden" name="sitecode2" readonly  id="sitecode2" value="<?php echo $row['store_from']; ?>" ></td>      
    <td align="right"><strong>To Store:</strong></td>
    <td id="to_branch"><input type="text" value="<?php
//$site = $s->getField('mrs_receipt', 'id', $row['issue_slipno'], 'sitecode');
echo $s->getField('storetype', 'id', $row['store_to'], 'StoreName');
?>">
    <input type="hidden" name="sitecode3" readonly  id="sitecode3" value="<?php echo $row['store_to']; ?>"   ></td>
  </tr>
  
</table>
</div>
</br>
<div id="divShowSiteTransfer" style="width:100%; height:auto">
<input type="hidden" name="issue_slip_no" value="<?php echo $row['issue_slipno']; ?>"> 
<table width="100%" border="1" cellspacing="0" cellpadding="3" style="border:#808080 1px solid;">      
<tr>
  <th width="9%">Item Code</th>
  <th width="1"></th>
  <th>Item Name</th>
  <th width="12%">Pkg description</th>
  <th width="9%">Batch No.</th>
  <th width="6%">MFG.</th>
  <th width="6%">Expiry</th>
  <th width="6%">Stock Balance</th>
  <th width="6%">Issue Qty.</th>
  <th width="6%">Pending Qty.</th>
  <th colspan="7" style="text-align:center;">Received Qty.</th>        
</tr>
      <?php
$issueQty = array();
$resultIssue = DB_query("select itemid, SUM(issueqty) as issueQty 
              from mrs_receipt_details where mrs_receipt_id='" . $row['id'] . "' group by itemid", $db);
while ($rowrIssue = DB_fetch_array($resultIssue)) {
    $issueQty[$rowrIssue['itemid']] = $rowrIssue['issueQty'];
}

$receivedQty    = array();
$resultRecevied = DB_query("select itemid, SUM(receive_qty) as reciveQty from mrs_receipt_details 
              where mrs_receipt_id='" . $row['id'] . "'   group by itemid", $db);
while ($rowRecevied = DB_fetch_array($resultRecevied)) {
    $receivedQty[$rowRecevied['itemid']] = $rowRecevied['reciveQty'];
}

$i   = 0;
// echo "select * from addmrnqty where id='".$_GET['site']."'";
//echo "select * from mrs_receipt_details where mrs_receipt_id='" . $_REQUEST['id'] . "'";
$sql = DB_query("select * from mrs_receipt_details where mrs_receipt_id='" . $_REQUEST['id'] . "'", $db);
while ($rowre = DB_fetch_array($sql)) {
    $itemcode = $s->getField('item_master', 'id', $rowre['itemid'], 'StockID');
    $itemname = $s->getField('item_master', 'id', $rowre['itemid'], 'item_name');
    $unitid   = $rowre['uom'];
    $unitid1  = $rowre['uom1'];
    // echo item_description
    $unit     = $s->getField('unitsofmeasure', 'unitid', $unitid, 'unitname');
    $unit1    = $s->getField('unitsofmeasure', 'unitid', $unitid1, 'unitname');
     $op            = openingBalance($function_filter, $rowre['itemid']);
    $in_1          = receivedMRN($function_filter, $rowre['itemid']);
    $out_1         = issueSlip($function_filter, $rowre['itemid']);
    $out_2         = issueSiteToSite($function_filter, $rowre['itemid']);
    $in_2          = receivedSiteToSite($function_filter, $rowre['itemid']);
    $out_3         = issueMatarialReturn($function_filter, $rowre['itemid']);
    $in_3          = receivedReturn($function_filter, $rowre['itemid']);
    $out_4         = Rgpchallan($function_filter, $rowre['itemid']);
    $out_5         = Nrgp($function_filter, $rowre['itemid']);
    $in_4          = Rgpreturn($function_filter,$rowre['itemid']);
    $in_5          = FinishedMR($function_filter,$rowre['itemid']);
    $in_6          = MaterialConReceived($function_filter,$rowre['itemid']);
    $out_6         = MaterialConIssue($function_filter,$rowre['itemid']);
    $in_7          = PhysicalStockPlus($function_filter,$rowre['itemid']);
    $out_7         = PhysicalStockMinus($function_filter,$rowre['itemid']);
    $out_8         = dispatchIssue($function_filter,$rowre['itemid']);
    $out_9         = jobWorkChallan57Issue($function_filter,$rowre['itemid']);
    $in_8          = jobWorkChallan57Received($function_filter,$rowre['itemid']);
    $in_9          = directPurchase($function_filter, $rowre['itemid']);
    $in_10         = saleReturn($function_filter,$rowre['itemid']);
    $out_10        = invoice($function_filter, $rowre['itemid']);
    $invalue       = ($op + $in_1 + $in_2 + $in_3 + $in_4 + $in_5 + $in_6 + $in_7 + $in_8 + $in_9 + $in_10);
    $outvalue      = ($out_1 + $out_2 + $out_3 + $out_4 + $out_5 + $out_6 + $out_7 + $out_8 + $out_9 + $out_10);
    $tot           = $invalue - $outvalue;
    $stockallitems = $tot;
    $total_current = $tot;
    
  ?>
   <tr bgcolor="#FFFFFF">
      <td><input type="text" value="<?php  echo $itemcode;?>" readonly></td>
      <td><input  type="hidden"   readonly=""  value="<?php  echo $rowre['itemid'];?>" id="itemdataid_<?php   echo $i;?>"  name="itemdataid[]"/></td>
      <td><input type="text" value="<?php echo $itemname;?>"  readonly></td>
      <td><input type="text"  name="desc[]"  id="desc<?php echo $i;?>" size="25"  value="<?php echo $rowre['item_description']; ?>" readonly/></td>
      <td><input type="text" readonly="" value="<?php  echo $rowre['batch_no'];?>" name="batch_no[<?php echo $rowre['itemid'];?>]"></td>
      <td><input type="text" name="mfg[]" readonly="" value="<?php echo ConvertSQLDate($rowre['mfg']); ?>"></td>
      <td><input type="text" name="expiry[]" readonly="" value="<?php echo ConvertSQLDate($rowre['expiry']); ?>"></td>
      <td><input type="text" name="stock[]"  id="Stockbalance_<?php echo $i;?>" value="<?php echo $total_current;?>" readonly/></td>
      <td><input  type="text" name="issueqty[]" readonly value="<?php echo $issueQty[$rowre['itemid']];?>"  id="issueqty_<?php echo $i;?>"  /></td>
      <td><input  type="text" name="pending_qty[]"  readonly value="<?php echo (($issueQty[$rowre['itemid']] - $receivedQty[$rowre['itemid']]));?>"  /></td>
      <td width="6%"><input  type="text"  onkeyup="chk_recived_qty(this,<?php echo $i;?>)" onkeypress="return isNumberKey(event)" name="receivedQty[]" value="<?php echo $rowre['receive_qty'];?>"  id="receivedQty_<?php echo $i;?>"   /></td>
      <td width="1"><input  type="hidden" name="confac[]"  id="confac_<?php  echo $i;?>" value="<?php echo $rowre['conv_fac'];?>" /></td>
      <td width="5%"><input  type="text" name="uom[]"  id="uom_<?php  echo $i;?>" value="<?php echo $unit;?>"  readonly /></td>
      <td width="6%"><input  type="text" name="secondaryqty[]"  id="secondary_<?php  echo $i;?>" value="<?php echo $rowre['stock_qty2'];?>" /></td>
      <td width="5%"><input  type="text" name="uom1[]"  id="uom1_<?php echo $i;?>" value="<?php echo $unit1;?>" readonly  /></td> 
      <td width="1"><input  type="hidden" name="uomid1[]"  id="uomid1_<?php echo $i;?>" value="<?php  echo $unitid1;?>" /></td>
      <td width="1"><input  type="hidden" name="uomid[]"  id="uomid_<?php  echo $i;?>" value="<?php echo $unitid;?>"   /></td>        
    </tr>
        <?php
    $i++;
}
?>
   
    </table>
    <br>
    <table width="100%" border="0" cellpadding="3" cellspacing="0">
  <tr class="row1">
    <td width="13%" align="right"><strong>Remarks:</strong></td>
    <td><textarea name="remarks" id="remarks" cols="" rows="" style="height:60px;"><?php
echo $row['remarks'];
?></textarea></td>
  </tr>
</table>
   <?php
if ($_REQUEST['action'] == 'Edit') {
?>
   <p align="center"><input type="submit" name="Save" value="Save" class="issu_searchpopupfinish search" /></p>
    <?php
}
?>

</div><!--divShowSiteTransfer-->
</form>
</div>
</div>




<script language="javascript" type="text/javascript">

function get_slip_details(obj)
{
    if($(obj).val()==0)
    {
                            $('#from_branch').find('input').val('');
                            $('#issueDate').find('input').val('');
                            $('#showTranporter').find('input').val('');
                            $('#show_vehicle').find('input').val('');
        return false ;
    } 
    $.ajax({
                        url : "get_issue_slip_details.php",
                        type : "POST",
                        data : {
                        id:$(obj).val()
                        },
                        success : function(data) {//alert(data);
                           var dataArr=data.split('__');
                            $('#from_branch').html(dataArr[0]);
                            $('#issueDate').html(dataArr[1]);
                            $('#showTranporter').html(dataArr[2]);
                            $('#show_vehicle').html(dataArr[3]);
                                                 }
                           });

}
function get_issueslip_received(obj)
{
     if($(obj).val()==0)
     { $('#divShowSiteTransfer').html('');
         return false;
     }
      $.ajax({
                        url : "get_site_received_details.php",
                        type : "POST",
                        data : {
                         id:$(obj).val()
                        },
                        success : function(data) {//alert(data);
                            $('#divShowSiteTransfer').html(data);
                                                 }
                           });
}

function chk_recived_qty(obj,str)
{

    var stockQty=$(obj).closest('tr').find('td:eq(7)').find('input[type="text"]').val();
    //alert(stockQty);  
    //alert($(obj).val());
      if(parseFloat(stockQty) < parseFloat($(obj).val()) )
      {
        alert(' Received quantity should be less issue quantity');
        $(obj).val(stockQty);
        var confac=document.getElementById("confac_"+str).value;
        var secondary_qty=parseFloat(stockQty)*parseFloat(confac);
        document.getElementById("secondary_"+str).value=secondary_qty;
      }
      else
      {
        var confac=document.getElementById("confac_"+str).value;
        var secondary_qty=parseFloat($(obj).val())*parseFloat(confac);
       // alert(secondary_qty);
        document.getElementById("secondary_"+str).value=secondary_qty;

      }
}

/*function chk_recived_qty(obj)
{
    var stockQty=$(obj).closest('tr').find('td:eq(9)').find('input[type="text"]').val();
      if(parseFloat(stockQty) < parseFloat($(obj).val()) )
      {
          alert(' Received quantity should be less stock quantity');
          $(obj).val(stockQty);
      }
}*/
function get_MRN_number(obj)
{
          if($('#site').val()=='0')
          {
              alert('Please select from branch.');
              return false;
          }
            
            if($(obj).val()=='MRN')
            {   $('#divShowSiteTransfer').html('');
              $.ajax({
                        url : "get_mrn_by_site.php",
                        type : "POST",
                        data : {
                        action:'getMRN',    
                        site:$('#site').val()
                        },
                        success : function(data) {//alert(data);
                            $('#tdShowMRN').html(data);
                                                 }
                           });
          }
          else
          {
               $('#tdShowMRN').html('<input name="mrnno" type="text" />');
               $.ajax({
                        url : "get_struct_dirct_transfer.php",
                        type : "POST",
                        data : {
                        },
                        success : function(data) {//alert(data);
                        $('#divShowSiteTransfer').html(data);
                                                 }
                           });
          }

}
function get_store_by_site()
{//getStore
     if($('#site').val()=='0')
     {
       alert('Please select site to.');
       return false;
     }
      $.ajax({
                        url : "get_mrn_by_site.php",
                        type : "POST",
                        data : {
                            action:'getStore',
                            site:$('#site').val()
                        },
                        success : function(data) {//alert(data);
                        $('#storeTo').html(data);
                                                 }
                           });


}
  function get_issue_slip_no()
  {
        $.ajax({
                        url : "get_mrn_by_site.php",
                        type : "POST",
                        data : {
                            action:'get_issue_slip_no',
                            site:$('#site').val()
                        },
                        success : function(data) {//alert(data);
                        $('#issue_slip_no').html(data);
                                                 }
                           });
  }

function showsitename165(str)
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("divShowSiteTransfer").innerHTML=xmlhttp.responseText;
    }
  }
  xmlhttp.open("GET","get_mrnitemdata.php?site="+str,true);
    xmlhttp.send();
}
function issuedetails(str)
{
    var branch=document.getElementById("site").value;
    var godown=document.getElementById("store").value;
    
if (str.length==0)
  {
  document.getElementById("ISSUE").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("ISSUE").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","JobWorkItems.php?q="+str+"&site="+branch+"&store="+godown,true);
xmlhttp.send();

}
function openPopupProfile(i)
{ 
        window.open("issu_searchpopupfinish.php?rowcount="+i,"profiles_popup_window","height=425,width=640,toolbar=no,menubar=no,dependent=yes,resizable=yes");
}
 var xmlHttp

function GetXmlHttpObject()
{
    var xmlHttp=null;
    try
      {
      // Firefox, Opera 8.0+, Safari
      xmlHttp=new XMLHttpRequest();
      }
    catch (e)
      {
      // Internet Explorer
      try
        {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
      catch (e)
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      }
    return xmlHttp;
}



function isNumberKey(evt)
       {
          var charCode = (evt.which) ? evt.which : event.keyCode;
          if (charCode != 46 && charCode > 31 
            && (charCode < 48 || charCode > 57))
             return false;

          return true;
       } 


function hidedata()
{
document.getElementById("lightbox1").style.display='none';
}


 




function showsitename158(str)
{

var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    var data=xmlhttp.responseText.split("__");    
    
    document.getElementById("hid-Godown-div").innerHTML=data[0];
    document.getElementById("workorder").innerHTML=data[1];
    
    }
  }
  xmlhttp.open("GET","GoDownIssueSlip10.php?site="+str,true);
    xmlhttp.send();

//xmlhttp.open("GET","getSort.php?s="+str+"&cat="+cat,true);

    
}


function Get_oderdata(str)
{
    
    
if (str=="")
  {
  document.getElementById("dept").innerHTML="";
  return;
  }
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    var data=xmlhttp.responseText.split("__");    
     if($('#against').val()=='Direct')
    {
        $('#jobcarddata').html('<input name="job_card_no" type="text" id="job_card_no"   size="15" />');
            
          
    }
    else 
    document.getElementById("jobcarddata").innerHTML=data[0];
    document.getElementById("work_order_date").value=data[1];
    
    }
  }
  
xmlhttp.open("GET","get_orderdata9.php?salid="+str,true);
xmlhttp.send();    
    
}



function Get_oderdata1(str)
{
        
    
if (str=="")
  {
  document.getElementById("dept").innerHTML="";
  return;
  }
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    var data=xmlhttp.responseText.split("__");    
    //alert(data[0]);
       //document.getElementById("oderitem").innerHTML=data[0];
    document.getElementById("jobcarddate1").innerHTML=data[1];
    
    }
  }
  
xmlhttp.open("GET","get_joborderdata.php?salid="+str,true);
xmlhttp.send();    
    
}

function calamt(str,str1)
{
var k=str.split("_");
if(k[1]==undefined)
{
if(parseFloat(document.getElementById("reciveqty").value)>parseFloat(document.getElementById("stock").value))
{
alert("Receive Qty Should Be less then Stock Qty");
document.getElementById("reciveqty").value='';
}

}
else
{
var i=k[1];
if(parseFloat(document.getElementById("reciveqty_"+i).value)>parseFloat(document.getElementById("stock_"+i).value))
{
alert("Receive Qty Should Be less then Stock Qty");
document.getElementById("reciveqty_"+i).value='';

}
}


}
 function chkValidate()
 {
      
   if($('#site').val()==0)
   {
       alert('Please select branch.');
       return false;
   }
   if($('#recieved_date').val()=='')
   {
       alert('Please Enter date.');
       return false;
   }
  

     if($('#issue_slip_no').val()==0)
     {
         alert('Please select issue slip no.');
         return false;
     }

     if($('#storeTo').val()==0)
     {
         alert('Please select store to.');
         return false;
     }
    
      return true;
 }


</script>
<style type="text/css">
.body_lightbox1 {
width:100%;
background-color:#e7e7e7;
position:absolute;
left:280px;
top:95px;
padding-left:5px;
padding-right:5px;
border:#666666 solid 3px;
}
</style>
  
