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

if (isset($_POST['Save'])) {
 
    //****************  Start Code Generations **********************//  
    $prefixcode = "STSR";
    $siteCode   = $_REQUEST['site'];
    $site_Code  = substr($siteCode, 0, 3);
    $sql        = "select * from mrs_receipt where site = '" . $_REQUEST['site'] . "'";
    $result     = DB_query($sql, $db);
    $numrows    = DB_num_rows($result);
    if ($numrows > 0) {
        $strChar = $site_Code . "/" . $prefixcode . "/" . $year . $Afteryear . "/";
        if ($numrows > 0) {
            $maxval = $numrows;
        } else {
            $maxval = 0;
        } {
            $strChar = $site_Code . "/" . $prefixcode . "/" . $year . $Afteryear . "/";
        }
    } else {
        $strChar = $site_Code . "/" . $prefixcode . "/" . $year . $Afteryear . "/";
    }
    $strFinal     = $maxval + 1;
    $strBothFinal = $strChar . str_pad($strFinal, 6, "0", STR_PAD_LEFT);
    //****************  End Of Code Generations **********************// 
    $qty          = $_REQUEST['itemcode'];
    $qty1         = count($qty);
    $status       = 'N';
    
    
    $data_transfer_receipt['site']             = $_REQUEST['site'];
    $data_transfer_receipt['store_from']        = $_REQUEST['sitecode2'];
    $data_transfer_receipt['store_to']         = $_REQUEST['sitecode3'];
    $data_transfer_receipt['receipt_date']    = FormatDateForSQL($_REQUEST['issuedate']);
    $data_transfer_receipt['receipt_no'] = $strBothFinal;
    $data_transfer_receipt['remarks']          = $_REQUEST['remarks'];
    $data_transfer_receipt['issue_slip_id']     = $_REQUEST['issue_slip_no'];
    $data_transfer_receipt['createdby']        = $_SESSION['UserID'];
    $data_transfer_receipt['transaction_time'] = date("Y-m-d H:i:s");
    $data_transfer_receipt['createddate']      = FormatDateForSQL(date('d/m/Y'));
    
    
    $insertResult = $s->RecordInsert('mrs_receipt', $data_transfer_receipt);
    $Lastreq_id = DB_Last_Insert_ID($db, 'mrs_receipt', 'id');
    
    if ($Lastreq_id != '') {
        
        for ($i = 0; $i < count($_REQUEST['receivedQty']); $i++) {
            if ($_REQUEST['receivedQty'][$i] != '') {
                
                $data_transfer_receipt_details['mrs_receipt_id'] = $Lastreq_id;
                $data_transfer_receipt_details['itemid']              = $_REQUEST['itemdataid'][$i];
                $data_transfer_receipt_details['receive_qty']           = $_REQUEST['receivedQty'][$i];
                $data_transfer_receipt_details['issueqty']           = $_REQUEST['issueqty'][$i];
               // $data_transfer_receipt_details['size_id']             = $_REQUEST['sizesp'][$_REQUEST['itemdataid'][$i]];
              //  $data_transfer_receipt_details['grade_id']            = $_REQUEST['gradesp'][$_REQUEST['itemdataid'][$i]];
               // $data_transfer_receipt_details['issue_slip_no']       = $_REQUEST['issue_slip_no'];
               // $data_transfer_receipt_details['conv_fac']            = $_REQUEST['confac'][$i];
               // $data_transfer_receipt_details['uom']                 = $_REQUEST['uomid'][$i];
                //$data_transfer_receipt_details['uom1']                = $_REQUEST['uomid1'][$i];
                //$data_transfer_receipt_details['stock_qty2']          = $_REQUEST['secondaryqty'][$i];
              //  $data_transfer_receipt_details['item_description']    = $_REQUEST['desc'][$i];
                $data_transfer_receipt_details['batch_no']            = $_REQUEST['batch_no'][$_REQUEST['itemdataid'][$i]];
               // $data_transfer_receipt_details['mfg']                 = ConvertSQLDate($_REQUEST['mfg'][$i]);
               // $data_transfer_receipt_details['expiry']              = ConvertSQLDate($_REQUEST['expiry'][$i]);
                
                
                  
                $insertResult2 = $s->RecordInsert('mrs_receipt_details', $data_transfer_receipt_details);
              
                $dtls_Lastreq_id                       = DB_Last_Insert_ID($db, 'mrs_receipt_details', 'id');
                $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['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['batch_no'][$_REQUEST['itemdataid'][$i]];
                $data_stock['pending_qty']             = $_REQUEST['receivedQty'][$i];
                $data_stock['date_of_mfg']             = ConvertSQLDate($_REQUEST['mfg'][$i]);
                $data_stock['date_of_expiry']          = ConvertSQLDate($_REQUEST['expiry'][$i]);


                $s->RecordInsert('stock_valuation_tbl', $data_stock);

               /*  if($_REQUEST['receivedQty'][$i]<$_REQUEST['issueqty'][$i])
                {
                  $newpendingqty=floatval($_REQUEST['issueqty'][$i]-$_REQUEST['receivedQty'][$i]);
                  DB_query("update stock_valuation_tbl set pending_qty='".$newpendingqty."' where type='STI' and against_voucher_main_id='".$_REQUEST['issue_slip_no']."' and mst_itemid='".$_POST['itemdataid'][$i]."' and batch_no='".$_REQUEST['batch_no'][$_REQUEST['itemdataid'][$i]]."'",$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);  */

            }  
            
        }
        
    }
    

    
    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>";
    }
    
}
?>
<div class="body_contain">
<div class="tab_div">
 <h1><?php echo $s->getField('modules_form', 'id', $_REQUEST['frmid'], 'frm_name'); ?></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">
    <?php
if ($_SESSION['AssignedBranch'] != '') {
    $ss       = "Select loccode, locationname from locations  where CompanyId='" . $_SESSION['ACGCompanyId'] . "' and loccode in('" . $_SESSION['AssignedBranch'] . "')";
    $site_sql = DB_query($ss, $db);
} else {
    $ss       = "Select loccode,locationname from locations where CompanyId='" . $_SESSION['ACGCompanyId'] . "'";
    $site_sql = DB_query($ss, $db);
}
?>
     <select name="site" id="site">
    <option value="0">---Select---</option>
      <?php
while ($site_row = DB_fetch_array($site_sql)) {
?>
     <option value="<?php
    echo $site_row['loccode'];
?>"<?php
    echo ($sitecode == $site_row['loccode'] ? 'selected' : '');
?>><?php
    echo $site_row['locationname'];
?></option>
      <?php
}
?>
   </select></td>    
    <td width="13%" align="right"><strong>SRN No.:</strong></td>
    <td width="20%"><input name="issue_slipno" type="text" id="issue_slipno" readonly="readonly" value="Autogenerate"></td>
    <td width="13%" align="right"><strong>SRN Date:</strong></td>
    <td><input name="issuedate" type="text" id="recieved_date" value="<?php echo date('d/m/Y'); ?>" size="15" class="datepicker" 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" onchange="get_slip_details(this),get_issueslip_received(this);">
           <option value="0">Select</option>
           <?php 
                  echo $sql_issue_slip="select id,issue_slipno from addissue where id not in(select issue_slip_id from mrs_receipt)";
                   $result_issue_slip=DB_query($sql_issue_slip,$db);
                   while($rs_issue_slip=DB_fetch_array($result_issue_slip))
                   {
            ?>
              <option value="<?php echo $rs_issue_slip['id'] ?>"><?php echo $rs_issue_slip['issue_slipno'] ?></option>
               <?php } ?>
      </select></td>     
      <td align="right"><strong>From Store:</strong></td>
      <td><div id="storeTo" style="width:100%;"><input type="text" name="storeTo1" id="storeTo1"></div></td>  
      <td align="right"><strong>To Store:</strong></td>
      <td id="from_branch"><input type="text"> <input type="hidden" name="sitecode3" id="sitecode3"></td>    
  </tr> 
</table>
</div>
<br />
<div id="divShowSiteTransfer"></div><!--divShowSiteTransfer-->
</form>
</div>
</div>



<script type="text/javascript">
$(function() {
$("#recieved_date").datepicker({ dateFormat: 'dd/mm/yy', 
    minDate:'0'});
});
</script>
<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_receipt_details.php",
                        type : "POST",
                        data : {
                        id:$(obj).val()
                        },
                        success : function(data) { //alert(data); 
                           var dataArr=data.split('__');
                            $('#storeTo').html(dataArr[0]);
                            $('#from_branch').html(dataArr[1]);
                            //$('#showTranporter').html(dataArr[2]);
                            //$('#show_vehicle').html(dataArr[3]);
                                                 }
                           });
       get_issueslip_received(obj);
}
function get_issueslip_received(obj)
{
  //alert("hi");

     if($(obj).val()==0)
     { $('#divShowSiteTransfer').html('');
           alert("hello");
         return false;
     }
     /* if($('#storeTo').val()==0)
      {
          alert('Please select store.');
          $('#issue_slip_no').val('0');
          return false;
      } */
      $.ajax({ 
                        url : "get_site_issue_receipt_details.php",
                        type : "POST",
                        data : {
                         id:$(obj).val(),
                         site:$('#site').val(),
                         store:$('#sitecode2').val()
                        },
                        success : function(data) {  //alert(data);
                            $('#divShowSiteTransfer').html(data);
                                                 }
                           });
}

function chk_recived_qty(obj,str)
{


    var stockQty=$(obj).closest('tr').find('td:eq(8)').find('input[type="text"]').val();
   // alert(stockQty);
      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 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;
     }
     //alert();
      $.ajax({
                        url : "get_mrn_by_site.php",
                        type : "POST",
                        data : {
                            action:'getStore1',
                            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 opendata()
{

   var sitecode=document.getElementById("site").value;
   var date=document.getElementById("recieved_date").value;
  
    if(sitecode=='0')
    {
    alert("Must Select Site");
    document.getElementById("site").focus();
    return;
    }
    else if(date=='')
    {
    alert("Must Select Date");
    document.getElementById("recieved_date").focus();
    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)
    {
    document.getElementById("lightbox1").style.display='block';    
    document.getElementById("lightbox1").innerHTML=xmlhttp.responseText;    
   // document.getElementById("textitem").innerHTML=data[1];    
    }
  }
  //var store=document.getElementById("store").value;
 var store='';

  xmlhttp.open("GET","issu_searchpopupfinish.php?store="+store+"&site1="+sitecode+"&date="+date,true);
    xmlhttp.send();    
    
}
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 getItemsList1(id,code,shade,netrate,mrprate,rate,ctr)
{ 
    
  var ctr=$('#dataTable').find('tr:last').find('td:eq(1)').find('input[type="text"]').attr('id');
  var rowCount=$('#dataTable').find('tr').length;
  var rowItem=$('#dataTable').find('tr').find('td:eq(2)').find('input[type="hidden"]').val();
    
  
    var ctr1=parseInt(document.getElementById("rowcount1").value)+1;

  
    var itemcount=parseInt(document.getElementById('hiditemcount').value)+1;
    var edit_cnt=document.getElementById('edit_cnt').value;
    if(edit_cnt==''){var counter=1;} else if(edit_cnt>itemcount){var counter=edit_cnt;
    var itemcount=parseFloat(counter)+parseFloat(itemcount);
    } else  {var counter=edit_cnt;}
      
    if(rowCount==1 && rowItem=='')
    {
            
    if(document.getElementById('itemdataid_1'))
    {
    
    document.getElementById('itemdataid_1').value = id;
    document.getElementById('itemcode_1').value = code;
    document.getElementById('descriptions_1').value = shade;
    document.getElementById('uom_1').value = netrate;
    document.getElementById('stock_1').value = mrprate;
    }
    }
    else
    {
         var i=ctr1;


        //alert(i);
    addRow22('dataTable'); 
    if(document.getElementById('itemdataid_'+i))
    {        
    document.getElementById('itemdataid_'+i).value = id;
    document.getElementById('itemcode_'+i).value = code;
    document.getElementById('descriptions_'+i).value = shade;
    document.getElementById('uom_'+i).value = netrate;
    document.getElementById('stock_'+i).value = mrprate;
    }    
    }    
    //document.getElementById("lightbox1").style.display='none';
    //var data= addRow('dataTable')
    
}
 function addRow22(tableID) 
{
    if(document)
    var table = document.getElementById(tableID);
    var rowCount = table.rows.length;
    var rowCount = table.rows.length;
    if(document.getElementById("hiditemcount").value=='')
    r =rowCount+1;
    else
    {
    var t=document.getElementById("edit_cnt").value;
    var t1=document.getElementById("hiditemcount").value;
    r=parseInt(t1);
    r1=parseInt(t1)+1;
    }
    var row1=document.getElementById("rowcount1").value;
    var rr=parseInt(row1)+1;
    document.getElementById("rowcount1").value=rr;
    var row = table.insertRow(rowCount);
    document.getElementById("hiditemcount").value=rr;
    document.getElementById("edit_cnt").value=rr;
    var colCount = table.rows[0].cells.length;
    for(var i=0; i<colCount; i++) {        
    var newcell = row.insertCell(i);
            newcell.className='tabledata';
                       // newcell.style.background='#ffffff';
            
               newcell.innerHTML = table.rows[0].cells[i].innerHTML;
            

                //alert(newcell.childNodes[0].type);
    switch(newcell.childNodes[0].type) 
    {
    case "text":
    newcell.childNodes[0].value = "";
    var nod_id = newcell.childNodes[0].id.split("_");
    if(!isNaN(nod_id[1]))
    newcell.childNodes[0].id = nod_id[0]+'_'+rr;
    else
    newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+rr;
    break;        
    case "hidden":
    newcell.childNodes[0].value = "";
    var nod_id = newcell.childNodes[0].id.split("_");
    if(!isNaN(nod_id[1]))
    newcell.childNodes[0].id = nod_id[0]+'_'+rr;
    else
    newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+rr;
    break;
    case "button":
    var nod_id = newcell.childNodes[0].id.split("_");
    if(!isNaN(nod_id[1]))
    newcell.childNodes[0].id = nod_id[0]+'_'+rr;
    else
    newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+rr;
    break;
    case "checkbox":
    newcell.childNodes[0].checked = false;
    var nod_id = newcell.childNodes[0].id.split("_");
    if(!isNaN(nod_id[1]))
    newcell.childNodes[0].id = nod_id[0]+'_'+rr;
    else
    newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+rr;
    break;
    case "select-one":
    newcell.childNodes[0].selectedIndex = 0;
    var nod_id = newcell.childNodes[0].id.split("_");
    if(!isNaN(nod_id[1]))
    newcell.childNodes[0].id = nod_id[0]+'_'+rr;
    else
    newcell.childNodes[0].id = nod_id[0]+'_'+nod_id[1]+'_'+rr;
    break;    
    }
        //document.getElementById("stock_perunit_"+rowCount).value=1;
    }
        //document.getElementById(countid).innerHTML=rowCount;

    }


function deleteRow_return(tableID) 
    {
        
     if($('#dataTable').find('input[type="checkbox"][name="delitem[]"]:checked').length > 0)    
         {
        try 
        {
            var table = document.getElementById(tableID);
            //alert(table);
            var rowCount = table.rows.length;
            
            for(var i=0; i<rowCount; i++) 
                {
                    var row = table.rows[i];
                    
                    var chkbox = row.cells[0].childNodes[0];
                  
                    if(null != chkbox && true == chkbox.checked) 
                    {
                        if(rowCount <= 1) 
                        {
                            alert("Cannot delete all the rows.");
                            break;
                        }
                        
                    table.deleteRow(i);
                    rowCount--;
                    i--;
                    }
                }

        }
        catch(e) 
        {
            alert(e);
        }
   }
   else
       alert('Please select at least one row for delete.');
    }

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;
     }

    
      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>

