	<link rel="stylesheet" href="/css/jquery.ui.all.css">
	<script src="js1/jquery-1.7.2.js"></script>
	<script src="js1/jquery.ui.widget.js"></script>
	<script src="js1/jquery.ui.tabs.js"></script>

<script>
	$(function() {
		$( "#tabs" ).tabs();
	});
	</script>

<?php
$PageSecurity = 1;
$tabindex=0;
include('includes/DefinePaymentClass.php');
$title = _('Telephonic Order Memo');
include('includes/SQL_CommonFunctions.inc');
//echo $_REQUEST['SOrderId'];
if($_REQUEST['action']=='View')
{
 //echo $_REQUEST['SOrderId'];
  $getlead=DB_query( "select * from salesorder where id='".$_REQUEST['SOrderId']."'",$db);
	 while($row_lead=DB_fetch_array($getlead))
	 {
		$mst_branchid=$row_lead['branch'];
		$leads_no=$row_lead['orderNo'];
  	    $leaddate=ConvertSQLDate($row_lead['orderDate']);
		$PORefNo=$row_lead['PORefNo'];
		$customerDate=ConvertSQLDate($row_lead['customerPODate']);
		$client=$row_lead['client'];
		$Sale_Key_Exec=$row_lead['Sale_Key_Exec'];
		$SalesId=$row_lead['id'];
		$ContactPerson=$row_lead['ContactPerson'];
		$DeliveryDate=$row_lead['DeliveryDate'];
		$RoadPermit=$row_lead['RoadPermit'];
		$Transport=$row_lead['Transport'];
		$freight=$row_lead['freight'];
		$TelStatus=$row_lead['TelStatus'];
		$PendingPayment=$row_lead['PendingPayment'];
		$order_type=$row_lead['order_type'];		
 		$basicAmount=$row_lead['basicAmount'];
		$exciseValue=$row_lead['TotalExciseValue'];
		$ECessPercentage=$row_lead['ECessPercentage'];
		$ECessValue=$row_lead['ECessValue'];
		$SAHCessPercentage=$row_lead['SAHCessPercentage'];
		$SAHCessValue=$row_lead['SAHCessValue'];
		
		
		$taxableAmount=$row_lead['taxableAmount'];
		$VatCst=$row_lead['VatCst'];
		$VatCstValue=$row_lead['VatCstValue'];
		$ser_per=$row_lead['ser_per'];
		$service_amt=$row_lead['service_amt'];
		$train_chages=$row_lead['train_chages'];
		$dsl_charges=$row_lead['dsl_charges'];
		$install_charges=$row_lead['install_charges'];
		$insurance_charges=$row_lead['insurance_charges'];
		$frieght_charges=$row_lead['frieght_charges'];
		$frd_charges=$row_lead['frd_charges'];
		$pkg_charges=$row_lead['pkg_charges'];		
		$sparekit=$row_lead['sparekit'];
		
		$grandTotal=$row_lead['grandTotal'];
	 
		$created_date=date('Y-m-d');
		$description=trim($row_lead['description']);
 	 }
	 
}
?>
<div style="width:945px;">


<h1>View Sales Order </h1>


<div style="z-index:-1000em;">
	<div class="demo">
	<?php 
   $appstatus=$s->GetFieldValue('salesorder_details',"masterId='".$_REQUEST['SOrderId']."' ",'ApprovalStatus');
		if($appstatus=='3' || $appstatus=='2')
		{
	?>
	
	 <a href="index.php?route=CRM/ConvertSaleOrder_Into_Dispatch&SID=<?php  echo $_REQUEST['SOrderId'].$rurl;?>">
<input type="button" name="Create" value="Convert into Dispatch " style="background-color:#d1d4be; color:#006699; font-weight:800; padding-top:3px; padding-bottom:3px;" />
</a><?php  }else{
echo "Approval Pending";
}?> 
<div id="tabs">
	<ul>
		<li><a href="#tabs-1">Order Details</a></li>
		<li><a href="#tabs-2">More Information</a></li>


	</ul>
	<div id="tabs-1">
		<form action="" method="post"  >
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
<?php if(count($msgErr)>0){?>
   <tr>
   <td colspan="4"><?php
   for($i=0;$i<count($msgErr);$i++)
   {
     echo "<div class='error'>".$msgErr[$i].'</div>';
   }
    ?></td>
   </tr>
   <?php } ?>
 
 
    <tr>
        <td>
        <table width="100%" cellpadding="0" cellspacing="0" border="0" align="center" bgcolor="#ffffff" style="border:1px solid #ccc;">
        <tr>
            <td>
                <table width="100%" border="0" cellspacing="1" cellpadding="3" align="center">
				 <tr bgcolor="#e7e7e7">
                    <td width="28%" colspan="4">
						<table width="55%" border="0" cellspacing="2" cellpadding="0" align="center">
				 <tr bgcolor="#e7e7e7">
                    <th width="21%" align="left">Branch<label><font color="#FF0000">*</font></label></th>
                    <td width="28%">
						<?php
						echo $s->GetFieldValue('locations',"loccode='".$mst_branchid."'",'locationname');
						
						?>					</td>
                  </tr>
				</table>					</td>
                  </tr>
				 <tr bgcolor="#e7e7e7">
                    <th width="21%" align="left">SOP No</th>
                    <td width="28%"><?php echo $leads_no;?></td>
                    <th width="24%" align="left">Date</th>
                    <td width="27%"><?php echo $leaddate;?></td>
                  </tr>
				 <tr bgcolor="#e7e7e7">
                    <th align="left">Client</th>
                    <td>
                    	<?php
                    $ClientSQL="Select * from clientmaster where id='".$client."'";
					$ClientRes=DB_query($ClientSQL,$db);
					$ClientRow=DB_fetch_array($ClientRes);
					echo $ClientRow['c_name'] ?>                     </td>
                    <th align="left">Sales Key Executive</th>
                    <td><?php echo $s->GetFieldValue('www_users',"id='".$Sale_Key_Exec."'",'userid'); ?></td>
                  </tr>
				 <tr bgcolor="#e7e7e7">
                  	<?php 
                  	$Telephonesql=DB_query("Select * from telephonicordermemo where SalesId='".$SalesId."'",$db);
					$TelephoneRes=DB_fetch_array($Telephonesql);
					$clientDetails=DB_query("select * from clientmaster where id='".$client."'",$db);
					$ClientRow=DB_fetch_array($clientDetails);
                  	?>
                    <th align="left">Address</th>
                    <td><?php echo $ClientRow['pre_address1']?></td>
                    <th align="left">Contact Person</th>
                    <td><?php echo $s->GetFieldValue('contact_information_master',"id='".$ContactPerson."'",'Person'); ?></td>
                  </tr>
				 <tr bgcolor="#e7e7e7">
                    <th align="left">&nbsp;</th>
                    <?php
                    	$Telephonesql=DB_query("Select * from telephonicordermemo where SalesId='".$SalesId."'",$db);
					$TelephoneRes=DB_fetch_array($Telephonesql);
                    ?>
                    <td><?php echo $ClientRow['pre_address2']?></td>
                    <th align="left">Phone No</th>
                    <td><?php echo $s->GetFieldValue('contact_information_master',"id='".$ContactPerson."'",'phone'); ?></td>
                  </tr>
				 <tr bgcolor="#e7e7e7">
               	 <?php
                    $Telephonesql=DB_query("Select * from telephonicordermemo where SalesId='".$SalesId."'",$db);
					$TelephoneRes=DB_fetch_array($Telephonesql);?>
                    <th align="left">&nbsp;</th>
                    <td><?php echo $ClientRow['pre_address3']?></td>
                    <th align="left">&nbsp;</th>
                    <td>&nbsp;</td>
                  </tr>
				 <tr bgcolor="#e7e7e7">
                    <th align="left">Client P.O. No. </th>
                    <td><?php echo $PORefNo?></td>
                    <th align="left">P.O. Date<label><font color="#FF0000">*</font></label></th>
                    <td><?php echo $customerDate?></td>
                  </tr>
				 <tr bgcolor="#e7e7e7">
    <?php
	//echo "Select * from telephonicordermemo where SalesId='".$SalesId."'";
                    	$Telephonesql=DB_query("Select * from telephonicordermemo where SalesId='".$SalesId."'",$db);
					$TelephoneRes=DB_fetch_array($Telephonesql);
                    ?>
  <th width="21%" align="left" nowrap="nowrap">Delivery Date</th>
                  <td  width="28%"><?php echo ConvertSQLDate($DeliveryDate);?></td>
                       <th width="24%"  align="left" nowrap="nowrap">Road Permit</th>
                       <td width="27%"><?php echo $RoadPermit;?></td>
                  </tr>
				 <tr bgcolor="#e7e7e7">
                  <th align="left">Transport</th>
                  <td>
                  	<?php
                echo $s->GetFieldValue('transport_master',"id=".$Transport."",'TransportName');?>                  	</td>
                  <th>Freight</th>
                   <td width="27%"><?php  if($freight=='topay'){echo 'To Pay';}else{echo $freight;} ?> </td>
                  </tr>
				  <tr bgcolor="#e7e7e7">
				  <th>Status</th>
				  <td width="27%"><?php echo $TelStatus; ?> </td>
				  <td>&nbsp;</td>
				<td>&nbsp;</td>
				  </tr>
				  
				 <tr bgcolor="#e7e7e7">
               <th width="21%" align="left" nowrap="nowrap">Pending Payments (if any)</th>
               <td  width="28%"><?php echo $PendingPayment; ?></td>
               <th width="21%" align="left" nowrap="nowrap">Order Type</th>
               <td><?php  if($order_type=='MRP_Item') echo "MRN Item Wise"; else echo 'TBI'; ?></td>
                  </tr>
				  
				  <!----------------AMMOUNT AND TAXES SECTION-------------!>
				  
	<tr><!-- c6c6c6 -->
			<td valign="top" colspan="4">
 			<table width="100%" border="0" cellspacing="2" cellpadding="2">
              <tr>
                <th width="8%" align="center">S.No</th>
				<th width="8%" align="center">Code</th>
				<th width="29%" align="center">Item/Shade Name</th>
                <th width="24%" align="center">Item Desc. </th>
                <th width="17%" align="center">Qty</th>
				<th width="17%" align="center">Approved Qty</th>
                <th width="9%" align="center">Price</th>
                <th width="13%" align="center">Total Amt</th>
               
                  <th align="center">Remarks</th>
              </tr>
	<?php 
$i=1;
  $ItemSQL=DB_query("Select * from salesorder_details where masterId='".$SalesId."'",$db);
  while($item_row1=DB_fetch_array($ItemSQL))
  {
 
	
	 $itemquery=DB_query("select * from item_master where id='".$item_row1[ItemCode]."'" , $db);
	$item_row=DB_fetch_array($itemquery);
	 //echo "select StockID,item_name,unit, make ,grade, color from item_master where StockID='".$itemlist[$i]."'" ;
	
		if($i%2==0)
		{$bg="#CCCCCC";}
		else
		$bg="#C8BECB";
	
	?>
	
	<tr bgcolor="<?php echo $bg;?>">
	<td width="8%"><?php echo $i++;?></td>
	<td><?php echo $item_row['StockID'];?></td>	
   <td width="20%">
                	<input type="hidden" name="itemid[]" value="<?php echo $item_row['id'];?>" />
				<?php echo $item_row['item_name'];?>
				<input type="hidden" name="item_code[<?php echo $i;?>]" id="item_code_<?php echo $i;?>" value="<?php echo $itemlist[$i];?>">	
				<input type="hidden" value="" tabindex=""  readonly="" id="washing_profile" name="itemcode[]"size="20"   />                </td>
   <td><?php echo $item_row['item_desc'];?></td>
   <td><?php echo $item_row1['Quantity']?></td>
   <td><?php echo $item_row1['Approved_qty']?></td>
   <td><?php echo $item_row1['Rate']?></td>
   <td><?php echo $item_row1['Amount']?></td>
  
   <td><?php echo $item_row1['remarks']; ?></td>
  </tr>
  <?php }  ?>
</table>      </td>
	</tr>
	<?php if($sparekit=='yes') { ?>
	<tr><td colspan="4"><strong>Spare part kit details</strong>
	<table width="100%" border="0" cellspacing="2" cellpadding="2">
              <tr>
                <th width="8%" align="center">S.No</th>
				<th width="8%" align="center">Kit Code</th>
				<th width="29%" align="center">Item/Shade Name</th>
                <th width="24%" align="center">Kit Desc. </th>
                <th width="17%" align="center">Qty</th>
				 <th width="9%" align="center">Price</th>
                <th width="13%" align="center">Total Amt</th>
               
                 
              </tr>
	<?php 
$i=1;
  $ItemSQL2=DB_query("Select * from salesorder_kit_details where masterId='".$SalesId."'",$db);
  while($item_row2=DB_fetch_array($ItemSQL2))
  {
 
	
	 $itemquery=DB_query("select * from spare_part_kits where id='".$item_row2[kitid]."'" , $db);
	$item_row=DB_fetch_array($itemquery);
	 //echo "select StockID,item_name,unit, make ,grade, color from item_master where StockID='".$itemlist[$i]."'" ;
	
		if($i%2==0)
		{$bg="#CCCCCC";}
		else
		$bg="#C8BECB";
	
	?>
	
	<tr bgcolor="<?php echo $bg;?>">
	<td width="8%"><?php echo $i++;?></td>
	<td><?php echo $item_row['kit_code'];?></td>	
   <td width="20%">
                	<input type="hidden" name="itemid[]" value="<?php echo $item_row['id'];?>" />
				<?php echo $item_row['kit_name'];?>
				<input type="hidden" name="item_code[<?php echo $i;?>]" id="item_code_<?php echo $i;?>" 
				value="<?php echo $itemlist[$i];?>">	
				<input type="hidden" value="" tabindex=""  readonly="" id="washing_profile" name="itemcode[]"size="20"   />                </td>
   <td><?php echo $item_row['kit_desc'];?></td>
   <td><?php echo $item_row2['Quantity']?></td>
   <td><?php echo $item_row2['Rate']?></td>
   <td><?php echo $item_row2['Amount']?></td>
  
  
  </tr>
  <?php }  ?>
</table></td></tr>
<?php } ?>
 </table>
<div style="width:330px; float: right;">
<table width="100%" border="0" cellspacing="1" cellpadding="0" align="right" bgcolor="#FFFFFF" style="border:1px solid #ccc;">
    		<tr>
    	<th style="text-align:center;" colspan="2">Amount And Taxes</th>
    </tr>
				 <tr bgcolor="#e7e7e7">
    	    <th>Value Of Goods<label><font color="#FF0000">*</font></label></th>
    	    <td><?php echo $basicAmount?></td>
  	    </tr>
		<tr>
		<th>PACKING CHARGES</th>
		<td><?php echo $pkg_charges;?></td>
		
		</tr>
				 <tr bgcolor="#e7e7e7">
    	    <th nowrap="nowrap">FORWARDING CHARGES</th>
    	    <td><?php echo $frd_charges;?></td>
  	    </tr>
				 <tr bgcolor="#e7e7e7">
    	    <th>FREIGHT TO DESTINATION</th>
    	    <td>
    	    	<?php echo $frieght_charges;?> </td>
    	    </tr>
				 <tr bgcolor="#e7e7e7">
            <th nowrap="nowrap">INSURANCE CHARGES </th>
    	    <td>
    	    	<?php echo $insurance_charges;?> </td>
  	    	</tr>
				 <tr bgcolor="#e7e7e7">
   	<th>INSTALLATION & COMMISSIONG CHARGES FOR CRANE</th>
   	<td><?php echo $install_charges?></td>
	
   </tr>
   <tr bgcolor="#e7e7e7">
   	<th>CHARGES FOR DSL</th>
   	<td><?php echo $dsl_charges?></td>
	
   </tr>
   <tr bgcolor="#e7e7e7">
   	<th>TRAINING CHARGES</th>
   	<td><?php echo $train_chages?></td>
	
   </tr>
				 <tr bgcolor="#e7e7e7">
    	    <th>VAT/CST</th>
    	    <td>
    	    	<?php
    	    	$salesSql=DB_query("Select * from sales_tax_master where salestax_id='".$VatCst."'",$db);
				$salesRow=DB_fetch_array($salesSql);
echo $salesRow['tax_code'].'<br/>'; echo $VatCstValue;?> </td>
    	    
  	    </tr>
		<tr bgcolor="#e7e7e7">
    	    <th>SERVICE TAX</th>
    	    <td>
    	    	<?php
				
    	    	$salesSql=DB_query("Select * from service_tax_master where id='".$ser_per."'",$db);
				$salesRow=DB_fetch_array($salesSql);
echo $salesRow['tax_code'].'<br/>'; echo $service_amt;?> </td>
    	    
  	    </tr>
    	 
				 <tr bgcolor="#e7e7e7">
    	    <th>Grand Total<label><font color="#FF0000">*</font></label></th>
    	    <td><?php echo $grandTotal;?></td>
    	    
  	    </tr>
  	    </table>
  	    </div>


<br/>
<div style="clear: both"></div>
<br/>


		</table>
		</td>
	</tr>
</table>

		
		
		</form>
	</div><!-- Tab 1 Close -->
	
	<div id="tabs-2">
		
<?php 
	$comment="select * from salesorder_comments where sopno='".$_REQUEST['SOrderId']."'";
	$comment1=DB_query($comment,$db);
	$i=0;
	while($comment1Row=DB_fetch_array($comment1))
	{
	?>
	
			<div style="width:auto;">
			<p style="margin:0px; padding:0px; text-align:left; font-weight:bold">Comment </p>
			<p style="margin:0px; padding:0px; text-align:left;"><textarea readonly="readonly" name="comt" style="width:700px;" ><?php echo $comment1Row['comment']; ?></textarea></p>
			<p style="margin:0px; padding:0px; text-align:left; color:#003366"><?php echo 'By '.$s->GetFieldValue('www_users',"id='".$comment1Row['user']."'",'realname'); ?>&nbsp;&nbsp;<?php echo ConvertSQLDate($comment1Row['posted_date']); ?></p>
			 </div>
	<!--<table width="100%" border="0">
		  <tr>
			<td rowspan="2" width="10%"><img src="images/langmanager.png"  width="30px" height="30px" /> </td>
			<td width="90%"><?php echo $comment1Row['comment']; ?><br />
			
			<?php echo 'By '.$s->GetFieldValue('www_users',"id='".$comment1Row['user']."'",'realname'); ?>(
			
			)
			
			</td>
		  </tr><tr><td colspan="2"  height="20px"></td></tr>
		  
		</table>-->
	<?php 
	
$i++; } ?>
	</div><!-- Tab 2 Close -->



</div></div></div>


</div>