<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 = _('Trouble Ticket Creation');
include('includes/SQL_CommonFunctions.inc');
if($_REQUEST['action']=='View')
{
  $getlead=DB_query( "select * from trouble_ticket_creation where id='".$_REQUEST['ttid']."'",$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">Ticket No.</th>
                            <td colspan="2"><?php echo $fetch_tt_qry['ticket_number']?> </td>
                          </tr>
                          <tr>
                            <th class="tabledata1">Party Name</th>
                            <td colspan="2">
							<?php echo $ClientSQL= $s->GetFieldValue('clientmaster', 'id="'.$fetch_tt_qry['part_name'].'"','c_name');
								?>
                            </td>
                            <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>
                          </tr>
						  
						  <tr>
                            <th class="tabledata1">Invoice No</th>
                            <td colspan="2">
								<?php echo $fetch_tt_qry['invoiceNo'];	?>
                            </td>
                            <th class="tabledata1">Invoice Date</th>
                            <td colspan="2"><?php echo $fetch_tt_qry['invoice_date'];	?>
                            </td>
                          </tr>
						  <tr>
                            <th class="tabledata1">Expire Date</th>
                            <td colspan="2">
								<?php echo $fetch_tt_qry['expire_date'];	?>
                            </td>
                            <th class="tabledata1">Closer Date Date</th>
                            <td colspan="2"><?php echo $fetch_tt_qry['closer_date'];	?>
                            </td>
                          </tr>
                          <tr>
                            <th class="tabledata1">Priority</th>
                            <td colspan="2"><?php if($prority=='1'){ echo 'Low'; } 
								 if($prority=='2'){echo 'High'; }
								 if($prority=='3'){echo 'Urgent'; }
							  ?>
                            </td>
                            <th class="tabledata1">Category</th>
                            <td colspan="2"><?php if($category == '1'){echo 'Big Problem';}
								  if($category=='2'){echo 'Small Problem'; }
								  if($category=='3'){echo 'Other Problem'; }
							 ?>
                            </td>
                          </tr>
                          <tr>
                            <th class="tabledata1">Scope of service</th>
                            <td colspan="2"><?php if($scope_compaint == '1'){ echo 'Complaint';}
								if($scope_compaint == '2'){echo 'Installation'; }
								if($scope_compaint == '3'){echo 'De-Installation'; }
								if($scope_compaint == '4'){echo 'Re-Installation'; }
								if($scope_compaint == '5'){echo 'Preventive'; }
								if($scope_compaint == '6'){echo 'Service'; }
								if($scope_compaint == '7'){echo 'Site Survey'; }?>
                            </td>
                            <th class="tabledata1">Mode of complaint</th>
                            <td><?php if($mode_compaint == '1'){echo 'By Call'; }
								if($mode_compaint == '2'){echo 'By Mail';}
								if($mode_compaint == '3'){echo 'Internal Mail Request'; }
								if($mode_compaint == '4'){echo 'Internal Request'; }?>
                            </td>
                          </tr>
                          <tr>
                            <th class="tabledata1">Mode of Contract</th>
                            <td colspan="2">
							<?php if($mode_contract == '1'){echo 'Lease';}
							   if($mode_contract == '2'){echo 'NA'; }
							   if($mode_contract == '3'){echo 'Sold';}?>
                            </td>
                            <th class="tabledata1">Assigned User</th>
                            <td colspan="2"><?php 
							echo $technician = $s->GetFieldValue('technicians', 'id="'.$fetch_tt_qry['assige_user'].'"', 'technician');
				  			?>
                            </td>
                          </tr>
                          <tr>
                            <th class="tabledata1" scope="row">Problem 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="23%" align="center">Item Name</th>
                                  <th width="14%" 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_creation_details where tt_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>
						  <tr><td colspan="6">&nbsp;</td></tr>
						  <tr><td colspan="6">
						<?php  $Service = DB_query("SELECT * FROM add_service where tt_id='".$_REQUEST['ttid']."'",$db);
			 if(DB_num_rows($Service)>0){ ?>
		
		<div style="width:auto; overflow:auto;">
			<div id="back">
					<table width="100%" border="1" cellspacing="0" cellpadding="0" style="border:#666666 solid 1px;">
				   <tr>
					<td width="76" class="tabledata">S. No.</td>
					<td width="229" class="tabledata">Service</td>
					<td width="229" class="tabledata">Service Type</td>
					<td width="251" class="tabledata">Service Description</td>
					<td width="251" class="tabledata">Billable</td>
					<td width="240" class="tabledata">Service Amount</td>
				  </tr>
				   <tbody id="serviceID">
				   <?php $i=0; while($ServiceRow=DB_fetch_array($Service)) { ?>
					<tr bgcolor="#c1c1c1">
				  <td><?php echo $i+1; ?></td>
				  <td><?php echo $ServiceRow['service']; ?></td>
				  <td><?php echo $s->GetFieldValue('services_type',"id='".$ServiceRow['service_type']."'",'service_type'); ?></td>
				  <td><?php echo $s->GetFieldValue('services_description',"id='".$ServiceRow['service_desc']."'",'service_description'); ?></td>
				  <td><?php echo $ServiceRow['billable']; ?></td>
				  <td><?php echo $ServiceRow['service_amt']; ?></td>
					</tr>
					<?php $i++;} ?>
				  </tbody>
			</table>
			</div>
		</div>
		<?php } ?>
    
						  
						  </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;">Material Total Amt.</th>
                              <td><?php echo $fetch_tt_qry['materialAmount']?></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" style="width:120px;">Service Total Amt.</th>
                              <td><?php echo $fetch_tt_qry['serviceAmount']?></td>
                            </tr>
							<tr>
                              <th class="tabledata">Service Tax</th>
                              <td><?php
							$salesSql=DB_query("Select * from service_tax_master where id='".$serviceTax."'",$db);
							$salesRow=DB_fetch_array($salesSql);
							echo $salesRow['tax_code'].'<br/>'; echo $serviceTaxValue;?>
                                <input type="hidden" name="" id="servicerate" value="<?php echo $servicerate;?>" />                              </td>
                            </tr>
                            <tr>
                              <th class="tabledata">Other Amount</th>
                              <td><?php echo $fetch_tt_qry['otherAmount'];?> </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>
