<link rel="stylesheet" href="css/new_mxerp.css">

<?php
$PageSecurity = 2;
$title = _('View Purchase Order');
$query="select PO_Orderno from purchorders where orderno='".$_GET['OrderNumber']."' ";
$res=DB_query($query,$db);
$row=DB_fetch_array($res);

if(isset($_GET['OrderNumber']) && $_GET['daction']=='view')
{
	$sql = "Select * from purchorders where orderno='".$_GET['OrderNumber']."'";
	$result=DB_query($sql,$db);
	$myrow=DB_fetch_array($result);
	//echo "<pre>";
	//print_r($myrow);
	$purchat_sql=DB_query("Select intostocklocation from materialrequisitions where Reqno='".$myrow['requisitionno']."'",$db);
	$purchat_res=DB_fetch_array($purchat_sql);
	
	$sur_sql="select sur_oct from venderquotations where vernder_quotation='".$myrow['vendor_quotation_no']."'";
	$sur_result=DB_query($sur_sql,$db);
	$row=DB_fetch_array($sur_result);
	
	$orddate=$myrow['orddate'];
	$PO_Orderno=$myrow['PO_Orderno'];
	$version1=$myrow['version1'];
	$revised=$myrow['revised'];
	$deliveryby=$myrow['deliveryby'];
	$deliverydate=$myrow['deliverydate'];
	$initiator=$myrow['initiator'];
	$requisitionno=$myrow['requisitionno'];
	$vendor_quotation_no=$myrow['vendor_quotation_no'];
	$dateprinted=$myrow['dateprinted'];
	$stat_comment=$myrow['stat_comment'];
	$sitecode=$myrow['sitecode'];
	$supplierno=$myrow['supplierno'];
	$basic_amt=$myrow['basic_amt'];  
	$total_tax_amt=$myrow['total_tax_amt'];  
	$sur_oct_perc=$myrow['sur_oct_perc'];  
	$sur_oct_amt=$myrow['sur_oct_amt'];
}
?>


<div class="body_contain">
<div class="tab_div">
<h3>Modify Purchase Order - <?php echo $myrow['PO_Orderno'];?></h3>
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center">
    <tr>
    <td width="50%"><table width="100%" border="0" cellspacing="0" cellpadding="3">
      <tr class="row1">
        <td class="tabledata1">PO Date </th>
        <td>
		<input type="text" value="<?php echo ConvertSQLDate($orddate);?>" size="15" readonly="true"/>		</td>
      </tr>
      <tr class="row1">
        <td class="tabledata1">PO Number </th>
        <td><input name="text" type="text" value="<?php echo $PO_Orderno;?>" size="30" readonly="true"/>          </td>
      </tr>
      <tr class="row1">
        <td class="tabledata1">Delivery Date </th>
        <td><input name="text2" type="text" value="<?php echo ConvertSQLDate($deliverydate);?>" size="30" readonly="true"/>          </td>
      </tr>
      <tr class="row1">
        <td class="tabledata1">Initiated By </th>
        <td><input name="text3" type="text" value="<?php echo $initiator;?>" size="30" readonly="true"/>          </td>
      </tr>
      <tr class="row1">
        <td class="tabledata1">Requisition Number </th>
        <td><input name="text4" type="text" value="<?php echo $requisitionno;?>" size="30"readonly="true" />
        </td>
      </tr>
      <tr class="row1">
        <td class="tabledata1">Requisition Date </th>
		<?php $req_sql=DB_query("Select prdate from materialrequisitions where Reqno='".$requisitionno."'",$db);
			$req_row=DB_fetch_array($req_sql);
		?>
        <td><input name="text4" type="text" value="<?php echo ConvertSQLDate($req_row['prdate']);?>" size="30"readonly="true" />          </td>
      </tr>
      <tr class="row1">
        <td class="tabledata1">Vendor Quotation Number </th>
        <td><input name="text5" type="text" value="<?php echo $vendor_quotation_no;?>" size="30" readonly="true"/>          </td>
      </tr>
    </table></td>
    <td width="50%" valign="top"><table width="100%" border="0" cellspacing="1" cellpadding="2">
      <tr class="row1">
        <td class="tabledata1">Status</th>
        <td><input type="text" name="Input28" value="" id="Input28" readonly="true"></td>
      </tr>
      <tr class="row1">
        <td class="tabledata1" scope="row">Status Comments </th>
        <td><input type="text" name="Input29" value="<?php echo $stat_comment1;?>" id="Input29" readonly="true"></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <?php 
	  		$site_sql="Select * from locations where loccode='".$sitecode."'";
			$site_res=DB_query($site_sql,$db);
			$site_row=DB_fetch_array($site_res);
	  ?>
	  <tr class="row1">
        <td class="tabledata1">Site Code</th>
        <td><input name="text6" type="text" value="<?php echo $sitecode;?>" size="30" readonly="true"/>
          </td>
      </tr>
      <tr class="row1">
        <td class="tabledata1">Site Name </th>
        <td><input name="text7" type="text" value="<?php echo $site_row['locationname'];?>" size="30" readonly="true"/>
         </td>
      </tr>
      <tr class="row1">
        <td class="tabledata1" rowspan="3">Address</th>
        <td><input name="text8" type="text" value="<?php echo $site_row['deladd1'];?>" size="30" readonly="true"/>
          </td>
      </tr>
      <tr class="row1">
        <td><input name="text9" type="text" value="<?php echo $site_row['deladd2'];?>" size="30" readonly="true"/>
          </td>
      </tr>
      <tr class="row1">
        <td><input name="text10" type="text" value="<?php echo $site_row['deladd3'];?>" size="30" readonly="true"/>
         </td>
      </tr>
      <tr class="row1">
        <td class="tabledata1">Phone</th>
        <td><input name="text11" type="text" value="<?php echo $site_row['phone1'];?>" size="30" readonly="true"/>
          </td>
      </tr>
      <tr class="row1">
        <td class="tabledata1">Mobile</th>
        <td><input name="text12" type="text" value="<?php echo $site_row['mobile'];?>" size="30" readonly="true"/>
          </td>
      </tr>
      <tr class="row1">
        <td class="tabledata1">Tin No. </th>
        <td><input name="text13" type="text" value="<?php echo $site_row['tin_no'];?>" size="30" readonly="true"/>
          </td>
      </tr>
      <tr class="row1">
        <td class="tabledata1">Delivery By </th>
        <td><input name="text14" type="text" value="<?php echo $deliveryby;?>" size="30" readonly="true"/>
          </td>
      </tr>
    </table></td>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <?php 
	  		$vendor_sql="Select * from suppliers where vendor_code='".$supplierno."'";
			$vendor_res=DB_query($vendor_sql,$db);
			$vendor_row=DB_fetch_array($vendor_res);
	  ?>
	  <tr class="row1">
        <td class="tabledata1">Vendor Code </th>
        <td><input name="text15" type="text" value="<?php echo $supplierno;?>" size="30" readonly="true"/>          </td>
      </tr>
      <tr class="row1">
        <td class="tabledata1">Vendor Name </th>
        <td><input name="text16" type="text" value="<?php echo $vendor_row['vendor_name'];?>" size="30" readonly="true"/>          </td>
      </tr>
      <tr class="row1">
        <td class="tabledata1" rowspan="3">Adddress</th>
        <td><input name="text18" type="text" value="<?php echo $vendor_row['adrress1'];?>" size="30" readonly="true"/>          </td>
      </tr>
      <tr class="row1">
        <td><input name="text19" type="text" value="<?php echo $vendor_row['adrress2'];?>" size="30" readonly="true"/>          </td>
      </tr>
      <tr class="row1">
        <td><input name="text20" type="text" value="<?php echo $vendor_row['address3'];?>" size="30" readonly="true"/>          </td>
      </tr>
      <tr class="row1">
        <td class="tabledata1">Phone</th>
        <td><input name="text21" type="text" value="<?php echo $vendor_row['phone1'];?>" size="30" readonly="true"/>          </td>
      </tr>
      <tr class="row1">
        <td class="tabledata1">Mobile</th>
        <td><input name="text22" type="text" value="<?php echo $vendor_row['mobile'];?>" size="30" readonly="true"/>         </td>
      </tr>
      <tr class="row1">
        <td class="tabledata1" scope="row">Tin No. </th>
        <td><input name="text23" type="text" value="<?php echo $vendor_row['tin_no'];?>" size="30" readonly="true"/>          </td>
      </tr>
      <tr class="row1">
        <td class="tabledata1" scope="row">Payment Terms </th>
		<?php 
			$pay_sql="Select terms from paymentterms where termsindicator='".$vendor_row['payterms']."'";
			$pay_res=DB_query($pay_sql,$db);
			$pay_row=DB_fetch_array($pay_res);
		?>
        <td><input name="text24" type="text" value="<?php echo $pay_row['terms'];?>" size="30" readonly="true"/>          </td>
      </tr>
    </table></td>
  </tr>
</table>
<br>
<br>
<?php 
$sql2="select * from purchorderdetails where orderno='".$_GET['OrderNumber']."' ";
$result2=DB_query($sql2,$db);
?>
<h3>Item Details<br>
</h2>
<div style="overflow:auto; width:810px ; height:150px"  >
  <table width="100%" border="1" cellspacing="0" cellpadding="3">
    <tr>
      <td class="tabledata">Item Code </td>
      <td class="tabledata" style="white-space:nowrap;">Item Name </td>
      <td class="tabledata">Description</td>
      <td class="tabledata">Item No. </td>
      <td class="tabledata">Make</td>
      <td class="tabledata">Color</td>
      <td class="tabledata">Grade</td>
      <td class="tabledata">Flexo Offset</td>
      <td class="tabledata">Od</td>
      <td class="tabledata">Length</td>
      <td class="tabledata">Width</td>
      <td class="tabledata">Unit</td>
      <td class="tabledata">Serial No.</td>
      <td class="tabledata">Orignal/Local</td>
      <td class="tabledata">Type</td>
      <td class="tabledata">Shade</td>
      <td class="tabledata">Running Meter/Roll</td>
      <td class="tabledata">Volume</td>
      <td class="tabledata">Teeth</td>
      <td class="tabledata">Bcm</td>
      <td class="tabledata">Ups</td>
      <td class="tabledata">Quality</td>
      <td class="tabledata">Quantity</td>
      <td class="tabledata">Rate</td>
      <td class="tabledata">Discount Type</td>
      <td class="tabledata">Discount</td>
      <td class="tabledata">Discount Amount</td>
      <td class="tabledata">Sub Total </td>
      </tr>
    <?php 
  $i=1;
  while($myrow2=DB_fetch_array($result2))
  {
  $Query=DB_query("select * from item_master where StockID='".$myrow2['itemcode']."'",$db);
  $Query_row=DB_fetch_array($Query);
  if($i%2==0)
{$bg="#CCCCCC";}
else
$bg="#C8BECB";
  ?>
    <tr bgcolor="#c1c1c1">
      <td height="24"><?php echo $myrow2['itemcode'];?></td>
      <td><?php echo $Query_row['item_name'];?></td>
      <td><?php echo $Query_row['item_desc'];?></td>
      <td><?php echo $Query_row['item_no'];?></td>
     <td><?php 
	$makename=$s->getField('product_manufacture','id',$myrow2['make'],'manufacturer');
	echo $makename;?></td>
      <td><?php $colorname=$s->getField('product_color','id',$myrow2['color'],'color');
	echo $colorname;?></td>
      <td><?php $gradename=$s->getField('product_grade','id',$myrow2['grade'],'grade');
	echo $gradename;?></td>
	  <td><?php echo $Query_row['flexo_offset'];?></td>
      <td><?php echo $Query_row['od'];?></td>
      <td><?php echo $Query_row['length'];?></td>
      <td><?php echo $Query_row['width'];?></td>
      <td><?php $unit=$s->getField('unitsofmeasure','unitid',$Query_row['unit'],'unitname'); echo $unit;?></td>
      <td><?php echo $Query_row['serial_no'];?></td>
      <td><?php echo $Query_row['orig_local'];?></td>
      <td><?php echo $Query_row['type_name'];?></td>
      <td><?php echo $Query_row['shade'];?></td>
      <td><?php echo $Query_row['running_roll'];?></td>
      <td><?php echo $Query_row['volume'];?></td>
      <td><?php echo $Query_row['teeth'];?></td>
      <td><?php echo $Query_row['bcm'];?></td>
      <td><?php echo $Query_row['ups'];?></td>
       <td><?php echo $Query_row['quality'];?></td>
      <td><?php echo $myrow2['quatity'];?></td>
      <td><?php echo $myrow2['Rate'];?></td>
      <td><?php echo $myrow2['discount_type'];?></td>
      <td><?php 
	if($myrow2['discount_type']=='PercentAmt')
	{echo $myrow2['Discount']."%";}else
	echo $myrow2['Discount'];?></td>
      <td><?php echo $myrow2['discount_amount'];?></td>
      <td><?php echo $myrow2['Sub_total'];?></td>
    </tr>
    <?php $i++;}  ?>
  </table>
</div>
<br>

<div align="right">
<table width="35%" cellpadding="3" cellspacing="0" border="1" style="border:#666666 solid 1px;">
<?php 
$excise_tax_vendor="Select * from venderquotations where vernder_quotation='".$myrow['vendor_quotation_no']."'";
$excise_result=DB_query($excise_tax_vendor,$db);
$excise_row1=DB_fetch_array($excise_result);
?>
			<tr>
			<td class="tabledata">Basic Amount</td>
			<td><?php echo $excise_row1['basic_amt'];?></td>
			</tr>
			
			
			<tr>
    <td class="tabledata">Excise Duty </td>
    <td nowrap="nowrap">
    	    <select name="exciseDuty" id="exciseDuty" style="width:48%;" onchange="claculateExcise(this.value)">
    	    <?php 
    	    $excise_sql=DB_query("Select * from excise_tax where id='".$excise_row1['Excise_Duty']."'",$db);
			while($excise_row=DB_fetch_array($excise_sql))
			{?>
				<option value="<?php echo $excise_row['id'];?>"><?php echo $excise_row['caption'];?></option>
			<?php 	
			}
    	    ?> 
  	      </select><div id="exciseId"><input name="exciseValue" id="exciseValue" type="text" value="<?php echo $excise_row1['Excise_Duty_value'];?>" size="25" style="width:48%;" /></div>
    	   </td></td>
  </tr>
  <tr>
    <td class="tabledata">Edu Cess </td>
    <td><input name="rate3" type="text" value="<?php echo $excise_row1['Edu_Cess_perc'];?>" size="3" />
      % = 
      <?php echo $excise_row1['Edu_Cess'];?>
        <input type="hidden" name="edu_cess" id="edu_cess" value="<?php echo $excise_row1['Edu_Cess'];?>" /></td>
  </tr>
  <tr>
    <td class="tabledata">SHE Cess </td>
    <td><input name="rate" type="text" value="<?php echo $excise_row1['SHE_Cess_perc'];?>" size="3" readonly="true"/>
      % = <?php echo $excise_row1['SHE_Cess'];?>
        <input type="hidden" name="she_cess" id="she_cess" value="<?php echo $excise_row1['SHE_Cess'];?>" /></td>
  </tr>
			
			
			
			<tr>
			<td class="tabledata">Taxable Amount </td>
			<td><?php echo $excise_row1['taxable_amt'];?></td>
			</tr>
			<tr>
    <td class="tabledata">VAT/CST</td>
    <td><?php 
	$tax_sql=DB_query("Select tax_code from sales_tax_master where salestax_id='".$excise_row1['taxname']."'",$db);
	$tax_row=DB_fetch_array($tax_sql);
	echo $tax_row['tax_code']
	;?>
        <input type="hidden" name="taxid" id="taxid" value="<?php echo $excise_row1['taxname'];?>" /></td>
  </tr>
  <tr>
  <td class="tabledata">VAT/CST Amount</td>
	<td><?php echo $excise_row1['taxvalue'];?> %
      <input type="hidden" name="tax_rate" id="tax_rate" value="<?php echo $excise_row1['taxvalue'];?>" /></td>
  </tr>
			<tr>
		  <td class="tabledata">Surcharge
		    <input type="hidden" name="hidden_suroct" id="hidden_suroct" value="SUR" /></td>
			<td><?php echo $excise_row1['sur_oct_perc'];?> % </td>
			</tr>
			<tr>
			<td class="tabledata">Surcharge Amount </td>
			<td><?php echo $excise_row1['sur_oct_amt'];?></td>
			</tr>
			
			<tr>
  <td class="tabledata">Freight</td>
	<td><?php echo $excise_row1['totalcharge'];?>
	  <input type="hidden" name="totalcharge" id="totalcharge" value="<?php echo $excise_row1['totalcharge'];?>" /></td>
  </tr>
  
  <tr>
    	    <td class="tabledata">Pkg Charges</td>
    	    <td><?php echo $excise_row1['pkg_charges'];?><input name="pkg_charges" id="packagingCharges" type="hidden" value="<?php echo $excise_row1['pkg_charges'];?>" size="25" style="width:98%;" /></td>
    	    
  	    </tr>
  	    <tr>
    	    <td class="tabledata">Additional Charges</td>
    	    <td><?php echo $excise_row1['add_charges'];?><input name="add_charges" id="additionalCharges" type="hidden" value="<?php echo $excise_row1['add_charges'];?>" size="25" style="width:98%;" /></td>
    	    
  	    </tr>
			
		<tr><td class="tabledata">Grand Total</td>
		<td><?php echo $excise_row1['grand_total'];?></td>
		</tr>
	  </table>
	  
</div> 
</div></div>

<?php 
//include('includes/footer.inc');
?>