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


<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 = _('Material Requirement against Job Card');
include('includes/SQL_CommonFunctions.inc');
if($_REQUEST['action']=='View')
{
  $getlead=DB_query( "select * from trouble_ticket_jobcard_material where id='".$_REQUEST['reqid']."'",$db);
  $fetch_tt_qry= DB_fetch_array($getlead);
  extract($fetch_tt_qry);
}
?>

<div class="body_contain">
<div class="tab_div">
  <h1><?php echo $title;?></h1>
  <div style="z-index:-1000em;">
    <div class="demo">
      <?php 
   $appstatus=$s->GetFieldValue('salesorder_details',"masterId='".$_REQUEST['SOrderId']."' ",'ApprovalStatus');
		if($appstatus=='Approved')
		{
	?>
      <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 "<h3>Approval Pending</h3>";
}?>
      <div id="tabs">
        <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="1" cellspacing="0" cellpadding="3" style="border:#999999 solid 1px;">
                          <tr>
                            <th class="tabledata1">Branch</th>
                            <td colspan="2">
							<?php $location = DB_query("SELECT * FROM locations where CompanyId = '".$_SESSION['ACGCompanyId']."'",$db);
                    
								$loc = DB_fetch_array($location);
								$p='';
								$p='selected';
								echo  $loc['locationname']?>
                            </td>
                            <th class="tabledata1">Requirement No.</th>
                            <td colspan="2"><?php  echo $s->GetFieldValue('trouble_ticket_jobcard',"id='".$fetch_tt_qry['job_card_number']."'",'job_card_number'); ?></td>
                          </tr>
						  <tr>
                            <th class="tabledata1">Requirement No.</th>
                            <td colspan="2">
							<?php echo $fetch_tt_qry['requirement_id'];?>
                            </td>
                            <th class="tabledata1">Technician Name</th>
                            <td colspan="2"><?php  echo $s->GetFieldValue('technicians',"id='".$fetch_tt_qry['technician_id']."'",'technician'); ?>
                            </td>
                          </tr>
                          <tr>
						  <th class="tabledata1">TT No.</th>
                            <td colspan="2">
							<?php  echo $s->GetFieldValue('trouble_ticket_jobcard',"id='".$fetch_tt_qry['job_card_number']."'",'job_card_number'); ?>
                            </td>
                            <th class="tabledata1">Party Name</th>
                            <td colspan="2">
							<?php echo $ClientSQL= $s->GetFieldValue('clientmaster', 'id="'.$fetch_tt_qry['party_name'].'"','c_name');
								?>
                            </td>
                            
                          </tr>
						  
						  <tr>
						  <th class="tabledata1">Product Name</th>
                            <td colspan="2"><?php 
							$item = DB_query("SELECT item_name FROM item_master where id='".$fetch_tt_qry['product_name']."' ",$db);?>
                              <?php $Item_name = DB_fetch_array($item);
									echo $Item_name['item_name'];?>
                            </td>
                            <th class="tabledata1">Invoice Date</th>
                            <td colspan="2"><?php echo $fetch_tt_qry['serial_number'];	?>
                            </td>
                          </tr>
						 
                          <tr>
                            <th class="tabledata1" scope="row">Fault Desc.</th>
                            <td colspan="5"><?php echo $fetch_tt_qry['prob_desc']?></td>
                          </tr>
                          <tr>
                            <td colspan="6" class="tabledata1" scope="row"><table width="100%" border="0" cellspacing="2" cellpadding="2">
                                <tr>
                                  <th width="8%" align="center">S.No</th>
                                  <th width="8%" align="center">Item Name</th>
                                  <th width="29%" align="center">Req. Qty.</th>
                                  <th width="24%" align="center">Price</th>
                                  <th width="17%" align="center">Total amount</th>
                                </tr>
                                <?php 
									$i=1;
									  $ItemSQL=DB_query("Select * from trouble_ticket_jobcard_material_details where req_id='".$fetch_tt_qry['id']."'",$db);
									  while($item_row1=DB_fetch_array($ItemSQL))
									  {
										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_row1['itemname'];?></td>
                                  <td width="20%"><input type="hidden" name="itemid[]" value="<?php echo $item_row1['id'];?>" />
                                    <?php echo $item_row1['rqty'];?>
                                    <input type="hidden" name="itemname[]" id="item_code_<?php echo $i;?>" value="<?php echo $itemlist[$i];?>">
                                    
                                  </td>
                                  <td><?php echo $item_row1['price'];?></td>
                                  <td><?php echo $item_row1['amt']?></td>
                                </tr>
                                <?php }  ?>
                              </table></td>
                          </tr>
                        </table>
                        <div style="width:330px; float: right;">
                          <table width="100%" border="1" cellspacing="0" cellpadding="3" style="border:#999999 solid 1px;">
						  <tr><th colspan="2" align="center">Amount And Taxes</th>
					  		</tr>
                            <tr>
                              <th class="tabledata" style="width:120px;">Basic Amt.</th>
                              <td><?php echo $fetch_tt_qry['basicAmount']?></td>
                            </tr>
                            <tr>
                              <th class="tabledata">Excise Duty</th>
                              <td><?php echo $fetch_tt_qry['totalDiscountedPrice'];?> </td>
                            </tr>
                            <tr>
                              <th class="tabledata">E-cess</th>
                              <td><?php  
								$SQl=DB_query("SELECT * FROM excise_tax WHERE caption LIKE '%Edu Cess%'",$db);
								$RESULT=DB_fetch_array($SQl);
								echo $fetch_tt_qry['SAHCessPercentage'];
				  			  ?>
                                <br />
                                <?php echo $fetch_tt_qry['ECessValue'];?>
                                <input type="hidden" name="ECessID" value="<?php echo $RESULT['id']?>" style="width:107px;">                              </td>
                            </tr>
                            <tr>
                              <th class="tabledata">She-cess</th>
                              <td><input type="hidden" name="SHECessId" value="<?php echo $fetch_tt_qry['id']?>" style="width:107px;">
                                <?php echo $fetch_tt_qry['SAHCessPercentage'];?><br />
                                <?php echo $fetch_tt_qry['SAHCessValue'];?> </td>
                            </tr>
                            <tr>
                              <th class="tabledata">Total Taxable</th>
                              <td><?php echo $fetch_tt_qry['taxableAmount']?></td>
                            </tr>
                            <tr>
                              <th class="tabledata">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;?>
                                <input type="hidden" name="" id="rate" value="<?php echo $rate;?>" />                              </td>
                            </tr>
                            <tr>
                              <th class="tabledata">Grand Total</th>
                              <td><?php echo $fetch_tt_qry['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;"><?php echo $comment1Row['comment']; ?></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>
          <?php 
	$i++; } ?>
        </div>
        <!-- Tab 2 Close -->
      </div>
    </div>
  </div>


</div></div>
