<?php $PageSecurity = 11;
//echo $_SERVER['QUERY_STRING'];exit;
include('includes/DefineSuppTransClass.php');
include('includes/DefinePOClass.php');
include('includes/SQL_CommonFunctions.inc');
 include('includes/session.inc'); include('includes/function_lib.php');
   	 $q=$_GET['q'];
 	?>
	<table width="100%">
    <th width="14%">Item Code</th>
    <th width="21%">Item Description</th>
    <th width="6%">Make</th>
    <th width="6%">Color</th>
    <th width="6%">Grade</th>
    <th width="5%">UOM</th>
    <th width="7%">Quantity</th>
	<th width="8%">Item Rate</th>
	<th width="9%">Total Rate</th>
	 <th width="8%">Tax Name</th>
     <th width="10%"> Tax Amount</th>
  </tr>
 
 <?php
 $i=1;$charges_name="";$mrnqty_ids="";
 
 $cond="issue_id='".$q."'";
		$GetMRN_Qty=$s->GetRecord('addmrnqty ', $cond);
		$GetResultMRN_Qty= DB_query($GetMRN_Qty,$db);
		
 $total_tax_rate=0;
 	 while($Itemrow =DB_fetch_array($GetResultMRN_Qty))
		   {
		  		$charge_details[]=$Itemrow['id'] ;
 		   	 	$itemcode=$Itemrow['itemcode'];
				$desc=$Itemrow['desc'];
				$Make=$Itemrow['Make'];
				$Color=$Itemrow['Color'];
				$Gread=$Itemrow['Gread'];
				$UOM=$Itemrow['UOM'];
				$Gread=$Itemrow['Gread'];
				$reciveqty=$Itemrow['reciveqty'];
				$itemprice=$Itemrow['itemprice'];
				$totalrate=$reciveqty*$itemprice;
				$taxname=$Itemrow['taxname'];
				$taxamount_rate=$Itemrow['taxamount_rate'];
  ?>
              <tr>
       <!--     <td> 
              <input type="button" name="profile_popup" value="+" id="profile_popup_<?php echo $j;?>"  onclick="openPopupProfile(<?php  echo $j;?>);" />
            </td>-->
            <td><input type="hidden"   name="qcreqd[]"size="10" value="<?PHP echo $Itemrow['id'];?>" />
	<input type="text" tabindex=""  readonly="" id="washing_profile_<?php echo $j;?>" name="itemcode[]"size="10" onblur="PO_order(this.value)" value="<?php echo $itemcode; ?>"/>
              <input type="hidden" name="orderno[]"  id="orderno_[<?php echo $j;?>]" onblur="PO_order(this.value)"  value="<?php echo $_REQUEST['orderno'];?>" />
            </td>
            <td ><input name="desc[]"  type="text" id="desc_<?php echo $j;?>" value="<?php echo $desc?>"/>
            </td>
            <td><select name="Make[]" id="Make[]>" >
                <?php  $rs=DB_query("select * from product_manufacture", $db);
					 while($row=DB_fetch_assoc($rs))
					 {
 					 ?>
                <option name ="<?php echo $row['manufacturer'];?>" <?php if($row['manufacturer']==$Make){ echo "Selected"; }  ?> ><?php echo $row['manufacturer'];?></option>
                <?php } ?>
              </select></td>
            <td><select name="Color[]" id="Color[]" >
                <?php  $rs=DB_query("select * from product_color", $db);
					 while($row=DB_fetch_assoc($rs))
					 {
					 ?>
                <option name ="<?php echo $row['id'];?>"  <?php if($row['color']==$Color){ echo "Selected"; }  ?>><?php echo $row['color'];?></option>
                <?php } ?>
              </select></td>
            <td><select name="Gread[]" id="Gread[]" >
                <?php  $rs=DB_query("select * from product_grade", $db);
					  while($row=DB_fetch_assoc($rs))
					  {
					 ?>
                <option name ="<?php echo $row['grade'];?>"  <?php if($row['grade']==$Gread){ echo "Selected"; }  ?>><?php echo $row['grade'];?></option>
                <?php } ?>
              </select></td>
            <td><select name="UOM[]" id="UOM[]">
                <?php  $rs=DB_query("Select unitid,unitname from unitsofmeasure", $db);
						while($row=DB_fetch_assoc($rs))
						{
						?>
                <option name ="<?php echo $row['unitname'];?>"  <?php if($row['unitname']==$UOM){ echo "Selected"; }  ?>><?php echo $row['unitname'];?></option>
                <?php } ?>
              </select></td>
            <td align="center"><input name="reciveqty[]" type="text" id="reciveqty_<?php echo $j; ?>"  value="<?php echo $reciveqty ?>" size="7"  onblur="calculate_short(<?php echo $i ?>)" /></td>
            <td align="center" ><input name="itemprice[]" type="text" id="itemprice_<?php echo $j; ?>" value="<?php echo $itemprice ?>" size="5" onblur="calculate_totalrate_direct(<?php echo $j; ?>)"/>
            </td>
            <td align="center" ><input name="totalrate[]" type="text" id="totalrate_<?php echo $j; ?>" value="<?php echo $totalrate ?>" onblur="calculate_totalamount(<?php echo $j ?>)" size="5" readonly="true"/>
            </td>
            <td>
 			<?php $Taxsql='SELECT taxauthorities.taxid, taxauthorities.description FROM taxauthorities';
			$Taxresult=DB_query($Taxsql,$db);?>
   <select id="taxname_<?php echo $j; ?>" name="taxname[<?php echo $j; ?>]" onchange="tax_calcutate(this.value,<?php echo $j;?>)" >
    <?php 
			while($Taxmyrow=DB_fetch_array($Taxresult)){
			$x='';
			if($Taxmyrow['taxid']==$taxname) 
			$x="selected";
	?>
   <option  value="<?php echo $Taxmyrow['taxid']; ?>"<?php echo $x;?>><?php echo $Taxmyrow['description']; ?></option>
   <?php } ?>
   </select>
   </td>
   <td><div id="divTaxAmount<?php echo $j?>">
   <input name="taxamount_rate[]" type="text" id="taxamount_rate_<?php echo $j; ?>" value="<?php  echo $taxamount_rate?>" size="5" onblur="calculate_total_taxamount(<?php echo $j ?>)" readonly="true" />
   </div></td>
          </tr>
<?php $j++; }  ?>
            <input type="hidden" name="countval" value="<?php echo $j; ?>"  id="rowcount"/>
?>


  <input type="hidden" name="totalrow" id="totalrow" value="<?php echo $i;?>">	
 <input type="hidden" name="charge_details" id="charge_details" value="<?php echo implode(",",$charge_details);?>">	
 <tr>
   <td colspan="5">
    <table width="100%" border="1">
                      <tr>
                        <th width="5%">Description</th>
                        <th width="10%">Inclusive</th>
                        <th width="10%">As Per Actual</th>
                        <th width="20%">Amount</th>
                      </tr>
                      <?php

//$result=DB_query('SELECT Chargesid, Chargesdescription FROM inclusivecharge where Chargesdescription not in("OCT","SUR")',$db);
$CR=1;
$result=DB_query("SELECT * FROM mrn_charges where MRN_id ='".$q."'",$db);
  while($myrow=DB_fetch_array($result))
 {
 //echo "<br>SELECT * FROM mrn_charges where MRN_id ='".$_REQUEST['mrnid']."'";
// $get_mrn_charges=DB_query("SELECT * FROM mrn_charges where MRN_id ='".$_REQUEST['mrnid']."'",$db);
 //$myrow_mrn_charges=DB_fetch_array($get_mrn_charges);
//echo   $myrow_mrn_charges['charges'];
   ?>
  <tr>
  <th>
  <?php 		$mrnqty_ids[]=$myrow['id']?>

  <?php echo $myrow['charges_name'];?></th>
  <td>
  
  <input name="charges_name[]" type="hidden" id="charges_name[]" value="<?php echo $myrow['charges_name'];?>" /> 
 <input name="mrn_charges[]" type="hidden" value="<?php echo $myrow['id'];?>" />
<select name="Charge[]" id="Charge_<?php echo $myrow['Chargesid'];?>" 
onchange="Charge_Amount1(this.value,<?php echo $myrow['Chargesid']; ?>)">
<option value="NO" <?php echo ($myrow['Inclusive']=="NO"? "selected":"")?> >NO</option>
<option value="YES" <?php echo ($myrow['Inclusive']=="YES"? "selected":"")?>>YES</option>
</select>
                        </td>
                        <td colspan="2"><?php $p= "PerActual".$myrow['Chargesid']?>
                          <div id="<?php echo $p?>">
                            <table width="100%" border="1"  >
                              <tr>
                                <td  width="36%"><?php // echo $myrow['Chargesid'];?>
                                  <?php  
 if($_POST[$var]=='YES')
 {
 $visibility='disabled="disabled"';
 }else{
 $visibility='';
 }
?>
 <select name="AsPerActual[]" id="AsPerActual_<?php echo $myrow['Chargesid'];?>" <?php  echo $visibility?>>
                                    <option value="Amount">Amount</option>
                                  </select>
                                </td>
                                <td> 
								
<input name="actual[]" id="actual_<?php echo $myrow['Chargesid'];?>" type="text" size="8" value="<?php  echo $myrow['charges'];?>" <?php  echo $visibility?>  onclick="total_charges(this.value,<?php  echo ($CR)?>)"  >
                                </td>
                              </tr>
                            </table>
                          </div></td>
                      </tr>
 <?php 
							$CR++;
 }
  
   ?>	<input type="hidden" name="mrnqty_ids" id="mrnqty_ids" value="<?php echo implode(",",$mrnqty_ids);?>">		  
                    </table>
    </td>
	<td colspan="5" valign="top">
	
	<table width="100%" border="1" cellspacing="0" cellpadding="0">
<?php 		 $sql = "select * from addmrn  
				 where addmrn.id='".$q."'";
	$result = DB_query($sql, $db); 
	$myrow_addmrn=DB_fetch_array($result)
	 ?>
           <tr>
             <td width="43%" bgcolor="#999999"><div align="center"><b><font color="#FFFFFF"> Basic Amount</font></b></div></td>
             <td width="57%"><label>
               <input name="total_Item_Amount"  type="text"  id="total_Item_Amount" size="30" readonly="true"  value="<?php echo $myrow_addmrn['total_Item_Amount'] ?>" />
              </label></td>
           </tr>
           <tr>
             <td bgcolor="#999999"><div align="center"><b><font color="#FFFFFF">Total Tax Amount</font></b></div></td>
             <td><input name="tax_chargeamount" type="text" id="tax_chargeamount" size="30"  readonly="true"   value="<?php echo $myrow_addmrn['tax_chargeamount'] ?>" />
			  </td>
           </tr>
		   
		   <tr>
    <td>
	<?php if($myrow_addmrn['percent_inclusivecharge']=="SUR")
			  $psur="checked";
			else
		 	$poct="checked";
			
	?>
<input name="percent_inclusivecharge" id="percent_inclusivecharge" type="radio"  value="SUR" onClick="cal_surcharges('SUR')" <?php echo $psur;?>/>SUR 
</td>
			 <td>   <input name="percent_inclusivecharge" id="percent_inclusivecharge" type="radio"  value="OCT" onClick="cal_surcharges('OCT')" <?php echo $poct?>/>OCT 
		   </td>
             </tr>
<tr>
<td >&nbsp;Percent
<input name="hidden_percent_inclusivecharge" id="hidden_percent_inclusivecharge" type="hidden"  value="" />
<input name="percent_inclusive" type="text" id="percent_inclusive" size="5" value="<?php echo $myrow_addmrn['percent_inclusive'] ?>" onBlur="cal_surcharges1();"  maxlength="2" /> %</td>
<td>
<input name="tax_suroct_value" type="text" id="tax_suroct_value" size="30" value="<?php  echo $myrow_addmrn['tax_suroct_value']?>"  readonly="true" />

</td>
</tr>
								
	<tr>
    <td bgcolor="#999999"><div align="center"><b><font color="#FFFFFF">Total Charges</font></b></div></td>
    <td>
<input name="Charge_Amount" type="text" id="chargeamount" size="30"  onblur="Completetotal(this.value)" readonly="true" value="<?php  echo $myrow_addmrn['Charge_Amount']?>" />
	</td>
       </tr>
           <tr>
             <td bgcolor="#999999"><div align="center"><strong><font color="#FFFFFF">Grand Total </font></strong></div></td>
             <td><input name="grandtotal" type="text" id="grandtotal" size="30" value="<?php echo $myrow_addmrn['grandtotal']; ?>"  readonly="true"  /></td>
           </tr>  
         </table>
	
	
	</td>
   </tr>
   <tr>
   <td colspan="10"> <center>  <input type="submit" name="save" value="Save" /></center></td>
   </tr>
 </table>
 
 