<?php 
					 
	require_once("connectioni.php");
	
 
?>	

						 
	



<link rel="stylesheet" href="css/table_min.css" type="text/css"/>	
<link rel="stylesheet" type="text/css" media="all" href="css/jsDatePick_ltr.min.css" />
<script type="text/javascript" src="js/jsDatePick.min.1.3.js"></script>


<script language="javascript" type="text/javascript">
<!--
/****************************************************
     Author: Eric King
     Url: http://redrival.com/eak/index.shtml
     This script is free to use as long as this info is left in
     Featured on Dynamic Drive script library (http://www.dynamicdrive.com)
****************************************************/
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}
// -->
</script>

<script type="text/javascript">
function openWin()
{
myWindow=window.open('serach_inv.php','','width=200,height=100');
myWindow.focus();

}
</script>

<script type="text/javascript">
	window.onload = function(){
		new JsDatePick({
			useMode:2,
			target:"dte_dor",
			dateFormat:"%Y-%m-%d"
			/*selectedDate:{				This is an example of what the full configuration offers.
				day:5,						For full documentation about these settings please see the full version of the code.
				month:9,
				year:2006
			},
			yearsRange:[1978,2020],
			limitToToday:false,
			cellColorScheme:"beige",
			dateFormat:"%m-%d-%Y",
			imgPath:"img/",
			weekStartDay:1*/
		});
	};
</script>

</label>
         <form name="form1" id="form1">  
<fieldset>
                                                	<legend>
  <div class="text_forheader">Defective Details</div>
                                               	 </legend>             

                                                 <a href="serach_ord.php?stname=ord" onclick="NewWindow(this.href,'mywin','800','700','yes','center');return false" onfocus="this.blur()">
                                                 <input type="text" disabled="disabled" name="txt_fno" id="txt_fno" value="" class="text_purchase2" onkeypress="keyset('searchcust',event);" onfocus="got_focus('invno');"  onblur="lost_focus('invno');"  />
                                                 </a>
           
  <table width="100%" border="0"  class=\"form-matrix-table\">
  <tr>
    <td width="10%">
    <?php 
		if ($_SESSION['company']=="BEN"){
    		echo "<input type=\"text\"  class=\"label_purchase\" value=\"BDRN No\" disabled=\"disabled\"/>";
		} else if ($_SESSION['company']=="THT"){
			echo "<input type=\"text\"  class=\"label_purchase\" value=\"DGRN No\" disabled=\"disabled\"/>";
		}	
   ?>
   </td>
    <td width="10%" colspan="2"><a href="serach_ord.php?stname=ord" onclick="NewWindow(this.href,'mywin','800','700','yes','center');return false" onfocus="this.blur()">
     
       <a href="search_defective.php?stname=dgrn" onclick="NewWindow(this.href,'mywin','800','700','yes','center');return false" onfocus="this.blur()">
       <input type="button" name="searchinv" id="searchinv" value="..." class="btn_purchase1" />
    </a>
      <input type="text" disabled="disabled" name="txtrefno" id="txtrefno" class="text_purchase2" onkeypress="keyset('searchcust',event);" onfocus="got_focus('invno');"  onblur="lost_focus('invno');" value="<?php echo $txtrefno; ?>"  />
      <a href="search_defective.php?stname=dgrn" onclick="NewWindow(this.href,'mywin','800','700','yes','center');return false" onfocus="this.blur()"></a></td>
    <td width="10%"><a href="search_claim_list.php?stname=DGRN" onclick="NewWindow(this.href,'mywin','800','700','yes','center');return false" onfocus="this.blur()">
      <input type="button" name="searchinv2" id="searchinv2" value="..." class="btn_purchase1" />
    </a></td>
    <td width="10%"><input type="text"  class="label_purchase" value="Date" disabled="disabled"/></td>
    <td width="10%">
      <input type="text" size="20" name="dtdate" id="dtdate" value="<?php echo date("Y-m-d"); ?>" disabled="disabled" class="text_purchase3"/></td>
    <td width="10%"><input type="text"  class="label_purchase" value="Department" disabled="disabled"/></td>
    <td width="10%"><select name="com_dep" id="com_dep" onkeypress="keyset('brand',event);" onchange="setord();" class="text_purchase3">
      <?php
         if ($_SESSION["CURRENT_DEP"] != "") {
           $sql="select * from s_stomas where  act='1' and CODE='".$_SESSION["CURRENT_DEP"] ."' order by CODE";
        }else{
          $sql="select * from s_stomas where  act='1'  order by CODE";
        } 
        $result =mysqli_query($GLOBALS['dbinv'],$sql) ; 
        while($row = mysqli_fetch_array($result)){
        echo "<option value='".$row["CODE"]."'>".$row["CODE"]." ".$row["DESCRIPTION"]."</option>";
        }
        ?>
    </select></td>
    <td width="10%">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td colspan="3"><input type="text" disabled="disabled" name="txtrno" id="txtrno" value="" class="text_purchase2" onkeypress="keyset('searchcust',event);" onfocus="got_focus('invno');"  onblur="lost_focus('invno');"  /></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><input type="text"  class="label_purchase" value="Customer" disabled/></td>
    <td colspan="3"><input type="text" disabled="disabled"  class="text_purchase1" name="txt_cuscode" id="txt_cuscode"/>
      <input type="text" disabled="disabled"  class="text_purchase2" id="txt_cusname" name="txt_cusname" />
      <a href="" onClick="NewWindow('serach_customer.php?stname=defective_item','mywin','800','700','yes','center');return false" onFocus="this.blur()">
        <input type="button" name="searchcust" id="searchcust" value="..."  class="btn_purchase">
      </a></td>
    <td><input type="text"  class="label_purchase" value="Batry No" disabled/></td>
    <td><input type="text" size="15" name="txtbat" id="txtbat" value="" onkeypress="keyset('balance',event);" class="text_purchase3" disabled="disabled"/></td>
    <td><input type="text"  class="label_purchase" value="Cost Center" disabled="disabled"/></td>
    <td><select name="com_costcent" id="com_costcent" onkeypress="keyset('searchitem',event);" class="text_purchase3"  >
     
    </select></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><input type="text"  class="label_purchase" value="Address" disabled/></td>
    <td colspan="2"><input type="text"  class="text_purchase3"  disabled="disabled" id="txtadd" name="txtadd" /></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><input type="text"  class="label_purchase" value="Remarks" disabled="disabled"/></td>
    <td width="10%" colspan="2"><textarea name="txtremark" id="txtremark" cols="45" rows="5"></textarea></td>
    <td><input type="text" name="cl_no1" id="cl_no1" disabled="disabled" /><input type="text" name="def_no" id="def_no" disabled="disabled" /></td>
    <td bgcolor="#00CCCC"><label>
      <input type="radio" name="vatgroup" value="vat" id="vatgroup_0"   />
      VAT Invoice</label></td>
    <td bgcolor="#00CCCC"><label>
      <input type="radio" name="vatgroup" value="non" id="vatgroup_1"   />
      Non VAT Invoice</label></td>
    <td bgcolor="#00CCCC"><label>
      <input type="radio" name="vatgroup" value="svat" id="vatgroup_2"  />
      SVAT Invoice</label></td>
    <td bgcolor="#00CCCC"><label>
      <input type="radio" name="vatgroup" value="evat" id="vatgroup_3"  />
      EVAT Invoice</label></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="41"><input type="text"  class="label_purchase" value="Marketing Executive" disabled="disabled"/></td>
    <td><select name="Com_rep" id="Com_rep" onkeypress="keyset('dte_dor',event);" class="text_purchase3">
      <?php
        require_once("connectioni.php");
        if ($_SESSION["MANAGER"]!="") { 			 						
            $sql="select * from s_salrep where cancel='0' and manager='".$_SESSION["MANAGER"]."'order by REPCODE"; 
            $result =mysqli_query($GLOBALS['dbinv'],$sql) ; 
            while($row = mysqli_fetch_array($result)){
                echo "<option value='".$row["REPCODE"]."'>".$row["REPCODE"]." ".$row["Name"]."</option>";
            }
         }else if ($_SESSION["CURRENT_REP"]=="") { 			 						
            $sql="select * from s_salrep where cancel='0' order by REPCODE";
            $result =mysqli_query($GLOBALS['dbinv'],$sql) ; 
            while($row = mysqli_fetch_array($result)){
                echo "<option value='".$row["REPCODE"]."'>".$row["REPCODE"]." ".$row["Name"]."</option>";
            }
         } else {
             $sql="select * from s_salrep where cancel='0' and repcode = '" . $_SESSION["CURRENT_REP"] ."' order by REPCODE";
             $result =mysqli_query($GLOBALS['dbinv'],$sql) ; 
             while($row = mysqli_fetch_array($result)){
             echo "<option value='".$row["REPCODE"]."'>".$row["REPCODE"]." ".$row["Name"]."</option>";
             }
         }
        ?>
    </select></td>
    <td width="10%"><input type="text"  class="label_purchase" value="Claim No" disabled="disabled"/></td>
    <td colspan="2"><input type="text" size="5" name="txtcl_no" id="txtcl_no" value="" onblur="keyset('discount2',event);" class="text_purchase"/></td>
    <td><select name="Cmbres" id="Cmbres" onkeypress="keyset('searchitem',event);" class="text_purchase3"  >
     <option value=''></option>
     <option value='NO DEFECT'>NO DEFECT</option>
     <option value='DEFECT'>DEFECT</option>
     <option value='CUSTOMER MIS USED'>CUSTOMER MIS USED</option>
     <option value='COMMERCIAL CLAIM'>COMMERCIAL CLAIM</option>
     
    </select></td>
    <td><input type="text"  class="label_purchase" value="Shipment" disabled="disabled"/></td>
    <td><select name="cmbShip" id="cmbShip" onkeypress="keyset('searchitem',event);" class="text_purchase3"  >
      <?php
	  
		 if ($_SESSION["CURRENT_DEP"] != "") {
           $sql="select REFNO from s_purmas where CANCEL=0 and TYPE='Import' and DEPARTMENT='".$_SESSION["CURRENT_DEP"] ."' order by REFNO";
        }else{
          $sql="select REFNO from s_purmas where CANCEL=0 and TYPE='Import' order by REFNO";
        } 
	
        
        $result =mysqli_query($GLOBALS['dbinv'],$sql) ; 
        while($row = mysqli_fetch_array($result)){
        echo "<option value='".$row["REFNO"]."'>".$row["REFNO"]."</option>";
        }
        ?>
    </select></td>
    <td>&nbsp;</td>
  </tr>
  </table>
<input type="hidden" id="c_subcode" name="c_subcode" value="">
  
  <br/>   
<fieldset>               
            
   	<legend><div class="text_forheader">Defective Item Details</div></legend>            
            
  <table width="100%" border="0">
  <tr>
    <td width="10%"><span class="style1">
      <input type="text"  class="label_purchase" value="Item" disabled/>
    </span></td>
    <td  width="30%"><span class="style1">
      <input type="text"  class="label_purchase" value="Description" disabled/>
    </span></td>
    <td  width="10%"><span class="style1">
      <input type="text"  class="label_purchase" value="Part No" disabled/>
    </span></td>
    <td  width="10%"><span class="style1">
      <input type="text"  class="label_purchase" value="Rate" disabled/>
    </span></td>
    <td  width="5%"><span class="style1">
      <input type="text"  class="label_purchase" value="Qty" disabled/>
    </span></td>
    <td  width="7%"><span class="style1">
      <input type="text"  class="label_purchase" value="Discount" disabled/>
    </span></td>
     <td  width="10%"><span class="style1">
      <input type="text"  class="label_purchase" value="Sub Total" disabled/>
    </span></td>
    <td  width="8%"><span class="style1">
      <input type="text"  class="label_purchase" value="Refund" disabled/>
    </span></td>
    <td  width="10%"><span class="style1">
      <input type="text"  class="label_purchase" value="Total" disabled/>
    </span></td>
    <td  width="10%">&nbsp;</td>
    </tr>
  <tr>
    <td><font color="#FFFFFF">
    <div id="test"><font color="#FFFFFF">
      <input type="text"  class="text_purchase3" name="itemno" id="itemno" size="10" disabled="disabled"  onkeypress="keyset('itemd',event);"     />
    </font></div>  </font></td>
    <td><font color="#FFFFFF">
      <input type="text"  class="text_purchase3" size="40" id="item_name" name="item_name" disabled="disabled" onkeypress="keyset('rate',event);" />
    </font></td>
    <td><font color="#FFFFFF">
      <input type="text" size="15" name="partno" id="partno" value="" disabled="disabled" class="text_purchase3" onkeypress="keyset('qty',event);"/>
    </font></td>
    <td><font color="#FFFFFF">
      <input type="text" size="15" name="rate" id="rate" value="" onblur="settotal();" class="text_purchase3" onkeypress="keyset('additem_tmp',event);"/>
    </font></td>
    <td><font color="#FFFFFF">
      <input type="text" size="15" name="qty" id="qty" value="" disabled="disabled" class="text_purchase3" onkeypress="keyset('subtotal',event);"/><input type="hidden" size="15" name="discount" id="discount" value="" disabled class="txtbox" />
    </font></td>
    <td><font color="#FFFFFF">
      <input type="text" size="15" name="discou" id="discou" value="" class="text_purchase3"  onblur="settotal();"/>
    </font></td>
    <td><font color="#FFFFFF">
      <input type="text" size="15" name="subtot" id="subtot" value="" class="text_purchase3" disabled="disabled" onkeypress="keyset('additem_tmp',event);"/>
    </font></td>
    <td><font color="#FFFFFF">
      <input type="text" size="15" name="refund" id="refund" value="" class="text_purchase3" onblur="settotal();"/>
    </font></td>
    <td><font color="#FFFFFF">
      <input type="text" size="15" name="total" id="total" disabled value="" class="text_purchase3" onkeypress="keyset('additem_tmp',event);" onblur="set_tot();"/>
    </font></td>
    </tr>
  <tr>
	<td colspan="6">
    <div class="CSSTableGenerator" id="itemdetails" ></div>                                                 		</td>
                                                		</tr>
  
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><span class="style1">
      <input type="text"  class="label_purchase" value="Amount" disabled="disabled"/>
    </span></td>
    <td><input type="text" size="15" name="txt_net" id="txt_net" value="0" class="text_purchase3" disabled="disabled"/></td>
    <td>&nbsp;</td>
  </tr>
  
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
          

</form>        

</fieldset>    
            
            <table width="765" border="0" cellpadding="0">
<tr>
                	<th height="189" colspan="5" align="left" nowrap="nowrap">
              			<div align="left">
              			    <script>new_inv();</script>