<?php  
ob_start();
ini_set('display_errors', 0); 
session_start();
include_once("../db/connection.php");

include_once("functions.php"); 
include("pathConfig.php");   
 $action=($_REQUEST['action']) ? $_REQUEST['action'] : "";
 //echo"<pre>";print_r($action);die;
$empName=$_SESSION['LOGIN_CREDENTAILS']['EMP_NAME'];
$empDept=$_SESSION['LOGIN_CREDENTAILS']['DEPARTMENT'];
$emptitle=$_SESSION['LOGIN_CREDENTAILS']['DESIGNATION'];
$empNumber=$_SESSION['LOGIN_CREDENTAILS']['EMP_ID'];
$employeeId=$_SESSION['LOGIN_CREDENTAILS']['EMP_ID'];
$bankName=$_SESSION['LOGIN_CREDENTAILS']['BANK_NAME'];
$accountNo=$_SESSION['LOGIN_CREDENTAILS']['BANK_ACCOUNT_NO'];
//echo"<pre>";print_r($_REQUEST);die;
$cliamByWhereClause= " AND ci.employee_id='".$employeeId."'";
$status="Process";
$empIdWhereClause=" AND emp_id='".$employeeId."'";
 ?>
<?php include_once("submitNew.php"); ?>
<?php include_once("processNew.php"); ?>
<?php include("templates/top.php");?>
<?php include("expiry.php"); ?><body style="background:url(image/background.jpg);">
<script type="text/javascript" src="js/wz_tooltip.js"></script> 
<link rel="stylesheet" href="css/calendar.css" type="text/css" media="screen">
<script language="JavaScript" src="js/popcalendar.js"></script>
<div class="<?php if($action=='Add' || $action=='Edit' || $action=='View') echo 'd-flex toggled'; else echo 'd-flex';?>" id="wrapper">
    <!-- /#sidebar-wrapper -->
    <!-- Page Content -->
    <div id="page-content-wrapper">
     <?php include("templates/navbar.php") ?>
      <div class="container-fluid">
       <div class="card mx-auto">
        <!--<div class="card-header  text-white text-center"><h5 class="float-left">YTY Group-Green Prospects-Employee Claim Settlement Form</h5></div>-->
    <?php 
    function moneyFormatIndia($num)
    {
      return number_format($num,2);
    }
    if(count($claimTypeArray)>0){
      $claimTypeName=array();
      foreach($claimTypeArray as $claimTye) 
      {
        $claimTypeName[$claimTye['CLAIM_TYPE_CODE']]=$claimTye['CLAIM_TYPE_NAME']." (".$claimTye['CLAIM_TYPE_CODE'].")";
      }
    }
    //if($action=="")
    //{
    ?>
      <style>
            .form-group{
                margin-bottom:6px;
            }
            </style>
             <table width="99%" border="0" cellspacing="2" cellpadding="0"  style="font-size: 13px;">
              <tbody>
                <tr>
                  <td width="64%" valign="top" style="padding-top:10px;">
                  <table width="100%" cellpadding="2" cellspacing="2">
                  <tr>
                      <td width="30%">
                      <div class="form-group">
                          <label for="code"><b>&nbsp;Employee Code</b></label>
                        </div>
                      </td>
                       <td width="7%" valign="top"><strong>:</strong></td>
                      <td width="63%" valign="top">
                        <div class="form-group">
                          <?= substr($empNumber,3); ?>
                        </div>
                      </td>
                  </tr>
                 
                  <tr>
                      <td width="30%">
                      <div class="form-group">
                          <label for="department"><b>&nbsp;Department Name</b></label>
                        </div>
                      </td>
                        <td valign="top"><strong>:</strong></td>
                     <td width="63%" valign="top">
                        <div class="form-group">
                         <?= $empDept; ?>
                        </div>
                      </td>
                  </tr>
                  <tr>
                       <td width="30%">
                       <div class="form-group">
                        <label for="title"><b>&nbsp;Title</b></label>
                       </div>
                      </td>
                        <td valign="top"><strong>:</strong></td>
                      <td width="63%">
                        <div class="form-group">
                            <?= $emptitle; ?>                 
                       </div>
                      </td>
                  </tr>
                  <tr>
                       <td width="30%">
                       <div class="form-group">
                        <label for="title"><b>&nbsp;Bank Account No </b></label>
                       </div>
                      </td>
                        <td valign="top"><strong>:</strong></td>
                      <td width="63%">
                        <div class="form-group">
                            <?= $bankName."  ".$accountNo; ?>                 
                       </div>
                      </td>
                  </tr>
                </table>
                  </td>
                  <td width="36%" valign="top" align="center">
                     <table width="100%" cellpadding="2" cellspacing="2" style="text-align:center;" class="table table-hover table-bordered table-striped">
                       <thead>
                       </thead>
                       <tbody class="table">
                          <tr class="card-header bg-primary text-white">
                             <td style="border:none !important; text-align:left"><strong>Approval  Sequence</strong></td>
                          </tr>
                          <?php
                              $checkEmp=array();
                              foreach($allEmpArr as $hirechy)
                              {
                                  if(!in_array($hirechy['APPR_LEVEL'],$checkEmp))
                                  {
                                     $checkEmp[]=$hirechy['APPR_LEVEL'];
                                  ?>
                                  <tr>
                                     <td style="text-align:left; border:none !important;">[<?php echo $hirechy['APPR_LEVEL'];?>] &nbsp; <?php echo $hirechy['EMP_NAME'];?></td>
                                  </tr>
                          <?php
                                  }
                              }
                              ?>
                       </tbody>
                    </table>
                  
                  </td>
                </tr>
              </tbody>
            </table>
    <?php
    //}
    ?>
  </div>
    <?php
    //echo"<pre>";print_r($_SESSION);die;
    if($_REQUEST['msg'])
    {
    ?>
       <center> <?= $error; ?><?= $_REQUEST['msg']; ?></center>
     <?php
      }
    ?>
    
<!-- Claim Header -->
    <?php 
    if($action=="")
    {
    ?>
      <div class="card mx-auto">
       <div class="card-header bg-primary text-white text-center" ><h5 class="float-left">Add/Edit Employee Claim Settlement</h5></div>
        <div class="card-body">
        <table class="table table-hover table-bordered table-striped">
          <thead class=" text-white">
          <tr>
            <td style="border:none;"> <a href="settle-form.php?action=Add" class="btn btn-info btn-sm"><i class="fa fa-plus"></i>&nbsp;Add Employee Claim</a></td>
          </tr>
          </thead>
         </table>
        <table class="table table-hover table-bordered table-striped">
          <thead class="bg-success text-white">
          <tr>
            <th>Claim Type</th>
            <th>Description</th>
            <th>Amount(MYR)</th>
            <th>Tax(MYR)</th>
            <th>Total(MYR)</th>
            <th style="width:20%; text-align:center">Action</th>
          </tr>
          </thead>
          <tbody>
          <?php
          if(count($clientClaimData)>0)
          {
            $claimDataArray=array();
            $checkHeaderArr=array();
            if(count($clientClaimData)>0)
            {
              $dateToFrom=array();
              $deleteFileArr=array();
              foreach($clientClaimData as $claimVal){
                $deleteFileArr[$claimVal['CLAIM_HEADER_ID']][]=$claimVal['CLAIM_FILE_EXTENSION'];
                if(!in_array($claimVal['CLAIM_HEADER_ID'],$checkHeaderArr))
                {
                  $checkHeaderArr[]=$claimVal['CLAIM_HEADER_ID'];
                  $claimDataArray[$claimVal['CLAIM_ID']."_".$claimVal['CLAIM_DATE']][]=$claimVal['CLAIM_TYPE_NAME']." (".$claimVal['CLAIM_TYPE_CODE'].")"."_".$claimVal['CLAIM_REMARK']."_".$claimVal['CLAIM_TOT_AMT_MYR']."_".$claimVal['CLAIM_TOT_TAX_AMT']."_".$claimVal['CLAIM_TOTAL_AMT']."_".$claimVal['CLAIM_HEADER_ID'];
                  //$dateToFrom[]=
                }
              }
            }
            //echo"<pre>";print_r($claimDataArray);die;
            $sno=1;
            $claimIds="";
            foreach($claimDataArray as $keyVal=>$claimDetail)
            {
              list($key,$date)=explode("_",$keyVal);
//              if($key<10)
//                $val="0".$key;
//              else
//                $val=$key;
              $mailClaimDetailArr=array();
              foreach($claimDetail as $claim)
              {
                list($type,$desc,$amtMyr,$tax,$totalAmt,$headerId)=explode("_",$claim);
                $mailClaimDetailArr[$key][]=$type."_".$totalAmt;
              }
              //echo"<pre>";print_r($mailClaimDetailArr);
            ?>
              <tr>
                <td align="left" colspan="5"><strong>Claim Id =====> <?php echo $key;?></strong></td>
               <td align="left"> <a data-toggle="modal" data-target="#myModal<?php echo $key;?>" class="btn btn-warning btn-sm"><i class="fa fa-share"></i>&nbsp;Request for Approval</a>
                                    <!-- Modal -->
                                    <div id="myModal<?php echo $key;?>" class="modal fade" role="dialog">
                                      <div class="modal-dialog modal-lg">
                                        <form name="approvalClaim" method="post" action="settle-form.php">
                                            <input type="hidden" name="claimId" id="claimId" value="<?php echo $key;?>" >
                                            <input type="hidden" name="claimFor" id="claimFor" value="<?php echo $empName;?>" >
                                            <input type="hidden" name="claimDate" id="claimDate" value="<?php echo $clientClaimData[0]['CLAIM_DATE'];?>" >
                                            <input type="hidden" name="description" id="description" value="<?php echo $clientClaimData[0]['CLAIM_DESCRIPTION'];?>" >
                                            <input type="hidden" name="mailClaimDetail" id="mailClaimDetail" value="<?php echo implode("@_@",$mailClaimDetailArr[$key]);?>" >
                                        <!-- Modal content-->
                                        <div class="modal-content">
                                          <div class="modal-header" style="background-color:#007bff">
                                            <h4 class="modal-title" style="color:#FFFFFF">Request for Approval</h4>
                                          </div>
                                          <div class="modal-body">
                                            <p><strong>Claim Id :-</strong> <?php echo $key;?></p>
                                          </div>
                                          <div class="modal-body">
                                            <?php
                                            if(count($allEmpArr)>0)
                                            {
                                            ?>
                                              <table align="center">
                                                  <thead>
                                                  </thead>
                                                  <tbody class="table">
                                                      <tr>
                                                          <td>&nbsp;<strong>Level</strong></td>
                                                          <td><strong>Approver&nbsp;Name</strong></td>
                                                          <td><strong>Department</strong></td>
                                                          <td><strong>Designation</strong></td>
                                                      </tr>
                                                        <?php
                            $checkApprvalIdArr=array();
                                                        foreach($allEmpArr as $detailEmp)
                                                        {
                              if(!in_array($detailEmp['APPROVER_EMP_ID']."_".$detailEmp['APPR_LEVEL'],$checkApprvalIdArr))
                              {
                                $checkApprvalIdArr[]=$detailEmp['APPROVER_EMP_ID']."_".$detailEmp['APPR_LEVEL'];
                                                        ?>
                                                          <tr>
                                                              <td><?php echo $detailEmp['APPR_LEVEL'];?></td>
                                                              <td><?php echo $detailEmp['EMP_NAME'];?></td>
                                                              <td><?php echo $detailEmp['DEPARTMENT'];?></td>
                                                              <td><?php echo $detailEmp['DESIGNATION'];?></td>
                                                            <input type="hidden" name="empMailIds[]" id="empMailIds" value="<?php echo $detailEmp['EMP_NAME']."@_@".$detailEmp['EMAIL'];?>" >
                                                            <input type="hidden" name="empIdsArr[]" id="empIdsArr" value="<?php echo $detailEmp['APPROVER_EMP_ID'];?>" >
                                                          </tr>
                                                        <?php
                              }
                                                        }
                                                        ?>
                                                  </tbody>
                                              </table>
                                            <?php
                                            }
                                            else
                                            {
                                                echo  '<font color="#FD0206"><strong>No employee for approval</strong></font>';
                                            }
                                            ?>
                                          </div>
                                          <div class="modal-footer">
                                            <button type="submit" class="btn btn-success" onClick="return confirm('Please Confirm? ok to continue cancel to stop');" <?php if(count($allEmpArr)==0) echo 'disabled';?>>Send</button>
                                            <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
                                          </div>
                                        </div>
                                        </form>
                                      </div>
                                    </div>              
                             </td>
              </tr>
            <?php
              $grandTotal=0;
              foreach($claimDetail as $claim)
              {
                list($type,$desc,$amtMyr,$tax,$totalAmt,$headerId)=explode("_",$claim);
                $grandTotal+=$totalAmt;
            ?>
                <tr>
                  <td align="left"><?php echo $type;?></td>
                  <td align="left"><?php echo $desc;?></td>
                  <td align="left"><?php echo moneyFormatIndia($amtMyr);?></td>
                  <td align="left"><?php echo moneyFormatIndia($tax);?></td>
                  <td align="left"><?php echo moneyFormatIndia($totalAmt);?></td>
                  <td>
                    <a href="settle-form.php?action=View&clmId=<?php echo $headerId;?>" target="_blank" class="btn btn-info btn-sm"><i class="fa fa-eye"></i>&nbsp;View</a>
                    <a href="settle-form.php?action=Edit&clmId=<?php echo $headerId;?>" class="btn btn-info btn-sm"><i class="fa fa-edit"></i>&nbsp;Edit</a>
                    <a href="settle-form.php?action=Delete&clmId=<?php echo $headerId."_".$key;?>&imageIdstr=<?php echo implode("@_@",$deleteFileArr[$headerId]);?>"class="btn btn-danger btn-sm" onClick="return confirm('Please Confirm? ok to continue cancel to stop');"><i class="fa fa-trash"></i>&nbsp;Delete</a>
                  </td>
                </tr>
            <?php
              }
              $sno++;
              ?>
                            <tr>
                              <td colspan="4" style="text-align:right"><strong>Grand Total(MYR)</strong></td>
                              <td colspan="2"><?php echo moneyFormatIndia($grandTotal);?></td>
                             </tr>
            <?php
            }
            $claimIds=ltrim($claimIds,",");
          }
          else
          {
          ?>
          <tr>
            <td colspan="6"><font color="#FF0000">No claim found.</font></td>
           </tr>
          <?php
          }
          ?>
          </tbody>
        </table>
       </div>
      </div><br><br>
    <?php
    }
    ?>
    <script src="//cdnjs.cloudflare.com/ajax/libs/numeral.js/1.4.5/numeral.min.js"></script>
    <script type="text/javascript">
    function calculateTotalAmt(row)
    {
      var amount=0;
      var taxAmt=0;
      var total=0;
      var grandTotal=0;
      var rowAmtTotal=0;
      var rowTaxTotal=0;
      var totalRowAmt=0;  
      var grandTotalHead=0; 
      var currentDate='<?php echo $today_date; ?>';
      var grandTotalRowAmt=0; 
      if(currentDate < changeDateFormat(document.getElementById("bill_date_"+row).value))
      {
        alert('Bill date can not greater than current date at row'+row);
        document.getElementById('bill_amount_'+row).value="";
        document.getElementById('tax_'+row).value="";
        document.getElementById("bill_date_"+row).value="";
        return false
      }
      if(document.getElementById("bill_date_"+row).value=="")
      {
        alert('Firstly select bill date at row '+row);
        document.getElementById('bill_amount_'+row).value="";
        document.getElementById('tax_'+row).value="";
        return false
      }
      if(document.getElementById('bill_amount_'+row).value!="")
      {
        var amount=document.getElementById('bill_amount_'+row).value;
        var totalRowAmt=totalRowAmt+parseFloat(amount.replace(/,/g, ''));
      }
      if(document.getElementById('tax_'+row).value!=""){
        var taxAmt=document.getElementById('tax_'+row).value;
        var totalRowAmt=totalRowAmt+parseFloat(taxAmt.replace(/,/g, ''));
      }
      grandTotalRowAmt=Number(totalRowAmt)*Number(document.getElementById('exchange_rate_'+row).value);
      document.getElementById('total_amount_'+row).value=numeral(grandTotalRowAmt).format('0,0.00');
      var counter=document.getElementById('counter').value;
      for(var i=1;i<=counter;i++)
      {
        document.getElementById('bill_amount_'+i).value=(document.getElementById('bill_amount_'+i).value.replace(/,/g, ''));
        document.getElementById('tax_'+i).value=(document.getElementById('tax_'+i).value.replace(/,/g, ''));
        var grandTotal=grandTotal+parseFloat(document.getElementById('total_amount_'+i).value.replace(/,/g, ''));
        rowAmtTotal+=parseFloat(document.getElementById('exchange_rate_'+i).value.replace(/,/g, '')) * parseFloat(document.getElementById('bill_amount_'+i).value.replace(/,/g, ''));
        if(document.getElementById('tax_'+i).value!=""){
          rowTaxTotal+=parseFloat(document.getElementById('exchange_rate_'+i).value.replace(/,/g, '')) * parseFloat(document.getElementById('tax_'+i).value.replace(/,/g, ''));
        }
      }
      document.getElementById('hidden_bill_amount_'+row).value=numeral(document.getElementById('bill_amount_'+row).value).format('0,0.00');
      document.getElementById('hidden_tax_'+row).value=numeral(document.getElementById('tax_'+row).value).format('0,0.00');
      document.getElementById('totalAmt').value=numeral(rowAmtTotal).format('0,0.00');
      document.getElementById('totalTax').value=numeral(rowTaxTotal).format('0,0.00');
      document.getElementById('grandTotal').value=numeral((rowAmtTotal+rowTaxTotal)).format('0,0.00');
      document.getElementById('totalClaimAmt').value=numeral(grandTotal).format('0,0.00');
      
    }

    function changeDateFormat(inputDate) {
        return inputDate.split("-").reverse().join("-");
    }

    function changeVal(row,type)
    {
      var counter=document.getElementById('counter').value;
      for(var i=1;i<=counter;i++)
      {
        document.getElementById('tax_'+i).value=document.getElementById('hidden_tax_'+i).value;
        document.getElementById('bill_amount_'+i).value=document.getElementById('hidden_bill_amount_'+i).value;
      }
    }
    function autoFillDesc(enterVal,check)
    {
      if(enterVal!="")
      {
        if(check=='1')
        {
          var splitArr=enterVal.split('_');
          document.getElementById('desc_'+count).value=splitArr[1];
          document.getElementById('hideShow_'+splitArr[0]).style.display="";
        }
        else
        {
          if(document.getElementById('checkChange').value > 0)
          {
            submitForm('dropdown');
          }
          else
          {
            if(document.getElementById('NewClaimVal').value!="")
              document.getElementById('NewClaimVal').value=document.getElementById('NewClaimVal').value;
            else
              document.getElementById('NewClaimVal').value=enterVal;
          }
          var splitArr=enterVal.split('_');
          document.getElementById('descClaimType').innerHTML=splitArr[1];
          document.getElementById('desc_1').value=splitArr[1];
          document.getElementById('claimVal_1').innerHTML=splitArr[2]+'('+splitArr[0]+')';
          document.getElementById('oldClaimVal').value=enterVal;
          document.getElementById('checkChange').value=Number(document.getElementById('checkChange').value)+1;
          if(splitArr[0]=='002'){
            document.getElementById('tptData').style.display="";
            document.getElementById("bill_amount_1").readOnly = true;
          }
          else{
            document.getElementById('tptData').style.display="none";
            document.getElementById("bill_amount_1").readOnly = false;
          }
            
          var counter=document.getElementById('counter').value;
          for(var i=1;i<=counter;i++)
          {
            if(document.getElementById('showCliamDiv_'+i))
              document.getElementById('showCliamDiv_'+i).innerHTML="";
          }
          
          document.getElementById('counter').value="1";
        }
      }
      else
      {
        alert('Please select claim type');
        return false;
      }
    }
    function addClaimLines(claimType) {
        var flag=1;
        if(document.getElementById("claimType").value=="")
        {
          alert('Please select claim type');
          return false;
        }
        else
        {
          var counter=document.getElementById("counter").value;
          var claimType=document.getElementById("claimType").value;
          var xmlhttp = new XMLHttpRequest();
          xmlhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
              document.getElementById("showCliamDiv_"+counter).innerHTML =this.responseText;
              document.getElementById("counter").value=(Number(counter)+1);
            }
          };
          xmlhttp.open("GET", "getClaimLinesRow.php?row=" + counter +"&claimType="+claimType, true);
          document.getElementById("showCliamDiv_"+counter).innerHTML ='<img id="loading-image" src="image/Preview.gif" alt="Loading..." />';
          xmlhttp.send();
        }
    }
    function removeClaimLines(claimType)
    {
      var r=document.getElementById("counter").value;
      var a = Number(r)-1;
      var div_id = "showCliamDiv_"+a;
      document.getElementById(div_id).innerHTML = '';
      document.getElementById('counter').value =Number(a);
      calculateTotalAmt(a);
    }
    function submitForm(type)
    {
      if(document.getElementById("claimType").value=="")
      {
        alert('Please select claim type');
        return false;
      }
      var counter=document.getElementById('counter').value;
      var display="";
      for(var i=1;i<=counter;i++)
      {
        if(document.getElementById('bill_date_'+i).value=="") 
        {
          var display=display+'Please select bill date at row '+i+'\n';
        }
        if(document.getElementById('bill_amount_'+i).value==""  || document.getElementById('bill_amount_'+i).value=="0.00")
        {
            var display=display+'Please enter bill amount at row '+i+'\n';
        }
        if(document.getElementById('exchange_rate_'+i).value=="" || document.getElementById('exchange_rate_'+i).value==0)
        {
          var display=display+'Please enter exchange rate at row '+i+'\n';
        }
        if(document.getElementById('attachment_'+i).value!="")
        {
          var fileName=document.getElementById('attachment_'+i).value;
          var file = document.getElementById('attachment_'+i).files[0].size;
          var FileSize = file / 1024 / 1024; // in MB
          if (FileSize > 2) {
            alert('File size should be less than 2 MB at row '+i);
            document.getElementById('attachment_'+i).value="";
            return false;
          } 
          var ext = fileName.split(".").pop().toLowerCase();
          if($.inArray(ext, ["jpg","jpeg","png","pdf","xlsx","txt","pptx","docx","tif","doc","xls","odt","ott"]) == -1) {
            alert('Please upload .jpg,.jpeg,.png,.pdf,.xlsx,.txt,.pptx,.docx,.tif,.doc,.xls,.odt,.ott extension file only at row '+i);
            document.getElementById('attachment_'+i).value="";
            return false;
          }
        }
      }
      if(display!=""){
        alert(display);
        return false;
      }
      else{
          if(type=='dropdown')
          {
            if(confirm('Are you sure to save previous one. ? \n click ok to continue cancel to stop.')) 
            {
              window.onbeforeunload = null;
              document.getElementById('checkChange').value=2;
              document.getElementById('NewClaimVal').value=document.getElementById('claimType').value;
              document.getElementById('claimType').value=document.getElementById('oldClaimVal').value;
              document.getElementById('submitClaimForm').submit();  
              return true;
            }
            else
            {
              document.getElementById('bill_date_1').value="";
              document.getElementById('bill_amount_1').value="";
              document.getElementById('tax_1').value="";
              document.getElementById('exchange_rate_1').value="";
              document.getElementById('total_amount_1').value="";
              document.getElementById('checkChange').value=0;
              document.getElementById('totalAmt').value="";
              document.getElementById('totalTax').value="";
              document.getElementById('grandTotal').value="";
              document.getElementById('totalClaimAmt').value="";
              return false;
            }
          }
          else
          {
            if(confirm('Please Confirm? ok to continue cancel to stop.')) 
            {
              window.onbeforeunload = null;
              document.getElementById('checkChange').value=1;
              return true;
            }
            else
            {
              return false;
            }
          }
      }
    }
    function submitFormEdit(type)
    {
      if(document.getElementById("claimType").value=="")
      {
        alert('Please select claim type');
        return false;
      }
      var counter=document.getElementById('counter').value;
      var display="";
      for(var i=1;i<=counter;i++)
      {
        if(document.getElementById('bill_date_'+i).value=="") 
        {
          var display=display+'Please select bill date at row '+i+'\n';
        }
        if(document.getElementById('bill_amount_'+i).value==""  || document.getElementById('bill_amount_'+i).value=="0.00")
        {
          if((document.getElementById('deleteRow_'+i)) && document.getElementById('deleteRow_'+i).checked==false){
            var display=display+'Please enter bill amount at row '+i+'\n';
          }
        }
        if(document.getElementById('exchange_rate_'+i).value=="" || document.getElementById('exchange_rate_'+i).value==0)
        {
          var display=display+'Please enter exchange rate at row '+i+'\n';
        }
        if(document.getElementById('attachment_'+i).value!="")
        {
          var fileName=document.getElementById('attachment_'+i).value;
          var file = document.getElementById('attachment_'+i).files[0].size;
          var FileSize = file / 1024 / 1024; // in MB
          if (FileSize > 2) {
            alert('File size should be less than 2 MB at row '+i);
            document.getElementById('attachment_'+i).value="";
            return false;
          } 
          var ext = fileName.split(".").pop().toLowerCase();
          if($.inArray(ext, ["jpg","jpeg","png","pdf","xlsx","txt","pptx","docx","tif","doc","xls","odt","ott"]) == -1) {
            alert('Please upload .jpg,.jpeg,.png,.pdf,.xlsx,.txt,.pptx,.docx,.tif,.doc,.xls,.odt,.ott extension file only at row '+i);
            document.getElementById('attachment_'+i).value="";
            return false;
          }
        }
      }
      if(display!=""){
        alert(display);
        return false;
      }
      else{
          if(type=='dropdown')
          {
            if(confirm('Are you sure to save previous one. ? \n click ok to continue cancel to stop.')) 
            {
              window.onbeforeunload = null;
              document.getElementById('checkChange').value=2;
              document.getElementById('NewClaimVal').value=document.getElementById('claimType').value;
              document.getElementById('claimType').value=document.getElementById('oldClaimVal').value;
              document.getElementById('submitClaimForm').submit();  
              return true;
            }
            else
            {
              document.getElementById('bill_date_1').value="";
              document.getElementById('bill_amount_1').value="";
              document.getElementById('tax_1').value="";
              document.getElementById('exchange_rate_1').value="";
              document.getElementById('total_amount_1').value="";
              document.getElementById('checkChange').value=0;
              document.getElementById('totalAmt').value="";
              document.getElementById('totalTax').value="";
              document.getElementById('grandTotal').value="";
              document.getElementById('totalClaimAmt').value="";
              return false;
            }
          }
          else
          {
            if(confirm('Please Confirm? ok to continue cancel to stop.')) 
            {
              window.onbeforeunload = null;
              document.getElementById('checkChange').value=1;
              return true;
            }
            else
            {
              return false;
            }
          }
      }
    }
    function isNumberKey(evt,obj) {
      var charCode = (evt.which) ? evt.which : event.keyCode
            var value = obj.value;
            var dotcontains = value.indexOf(".") != -1;
            if (dotcontains)
                if (charCode == 46) return false;
            if (charCode == 46) return true;
            if (charCode > 31 && (charCode < 48 || charCode > 57))
                return false;
            return true;        
    } 
    function getMYRDetails(currency,row)
    {
      if(document.getElementById("bill_date_"+row).value=="")
      {
        //alert('Firstly select bill date at row '+row);
        return false
      }
      else
      {
        document.getElementById("submitbtn").disabled=true;
        document.getElementById("bill_amount_"+row).disabled=true;
        document.getElementById("tax_"+row).disabled=true;
        var billDate=document.getElementById("bill_date_"+row).value;
        var currencyVal=document.getElementById("currency_"+row).value;
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
          if (this.readyState == 4 && this.status == 200) {
            if(this.responseText==0)
            {
              alert('Exchange rate for this currency for given date is not available. Pls enter manually or contact Oracle department.');
            }
            document.getElementById("exchange_rate_"+row).value =this.responseText;
            document.getElementById("submitbtn").disabled=false;
            document.getElementById("bill_amount_"+row).disabled=false;
            document.getElementById("tax_"+row).disabled=false;
            //calculateTotalAmt(row);
            changeVal(row,"");
            calculateTotalAmt(row);
          }
        };
        xmlhttp.open("GET", "getExchangeRateRow.php?billDate="+billDate +"&currency="+currencyVal, true);
        xmlhttp.send();
      }
    }
    function populateValueBillAmount(row)
    {
      if(document.getElementById("isBillAmt_"+row).checked==true)
      {
        document.getElementById("kilometer_"+row).disabled=false; 
        document.getElementById("ratePerKm_"+row).disabled=false;
        document.getElementById("kilometer_"+row).value=0;  
        document.getElementById("ratePerKm_"+row).value=0.65; 
        document.getElementById("totalKmAmt_"+row).value=0; 
        document.getElementById("bill_amount_"+row).readOnly = true;  
      }
      else
      {
        document.getElementById("bill_amount_"+row).readOnly = true;  
        document.getElementById("kilometer_"+row).disabled=true;  
        document.getElementById("ratePerKm_"+row).disabled=true;  
        document.getElementById("kilometer_"+row).value=""; 
        document.getElementById("ratePerKm_"+row).value=""; 
        document.getElementById("totalKmAmt_"+row).value="";
        document.getElementById("bill_amount_"+row).value='0.00'; 
        document.getElementById("hidden_kilometer_"+row).value=0; 
        document.getElementById("hidden_ratePerKm_"+row).value=0; 
        document.getElementById("hidden_bill_amount_"+row).value='0.00';
      }
      
    }
    function calculateTotalTransportAmt(enterAmt,row)
    {
      document.getElementById("totalKmAmt_"+row).value=(Number(document.getElementById("kilometer_"+row).value)*Number(document.getElementById("ratePerKm_"+row).value));
      
      document.getElementById("bill_amount_"+row).value=Number(document.getElementById("totalKmAmt_"+row).value); 
      document.getElementById("hidden_kilometer_"+row).value=Number(document.getElementById("kilometer_"+row).value); 
      document.getElementById("hidden_ratePerKm_"+row).value=Number(document.getElementById("ratePerKm_"+row).value); 
      calculateTotalAmt(row);
      changeVal(row,"");
    }
    function checkDate(row)
    {
      var currentDate='<?php echo $today_date;?>';
      if(document.getElementById("bill_date_"+row).value=="")
      {
        alert('Firstly select bill date at row '+row);
        document.getElementById('bill_amount_'+row).value="";
        document.getElementById('tax_'+row).value="";
        return false;
      }
      else
      {
        if(currentDate < changeDateFormat(document.getElementById("bill_date_"+row).value))
        {
          alert('Bill date can not greater than current date at row'+row);
          document.getElementById('bill_amount_'+row).value="";
          document.getElementById('tax_'+row).value="";
          document.getElementById("bill_date_"+row).value="";
          return false;
        }
        else
        {
          $('#myModal'+row).modal('show');
          return true;
        }
      }
    }
    function checkFileExt(row)
    {
      var fileName=document.getElementById('attachment_'+row).value;
      var ext = fileName.split(".").pop().toLowerCase();
         alert(ext+"---"+row+"-----"+fileName);
//        var FileSize = file.files[0].size / 1024 / 1024; // in MB
//        if (FileSize > 2) {
//        alert('File size exceeds 2 MB');
//        // $(file).val(''); //for clearing with Jquery
//        } else {
//        
//        }
        if($.inArray(ext, ["jpg","jpeg","png","pdf","xlsx","txt","pptx","docx","tif","doc","xls","odt","ott"]) == -1) {
        alert('Please upload .jpg,.jpeg,.png,.pdf,.xlsx,.txt,.pptx,.docx,.tif,.doc,.xls,.odt,.ott extension file only.');
        document.getElementById('attachment_'+row).value="";
        return false;
      }else{
        alert('Uplaoded');
      }
    }
    function submitfunciton()
    {
      alert('hii deep');  
    }
    </script>    
<!-- Claim Lines -->
        </div>
    </div></div>
    <!-- /#page-content-wrapper -->
    <?php 
    if($action=="Add")
    {
      if(count($clientClaimData)>0){
        $claimIdsArray=array();
        foreach($clientClaimData as $claimVal){
          $claimIdsArray[$claimVal['CLAIM_TYPE']]=$claimVal['CLAIM_TYPE'];
        }
      }
      if(isset($_REQUEST['NewClaimVal'])){
        list($code,$desc,$typeName)=explode("_",$_REQUEST['NewClaimVal']);
      }
    ?>
      <div class="container-fluid"> 
      <form id="submitClaimForm" name="submitClaimForm" action="" method="POST" enctype="multipart/form-data"> 
       <div class="card mx-auto">
      <div class="card-header bg-primary text-white text-center"><h5 class="float-left">YTY Group-Green Prospects-Employee Claim Settlement Form</h5></div><br>
       <center> <?= $error; ?><?= $msg; ?></center>
       <div class="card-body">                
        <input type="hidden" value="<?= $employeeId; ?>" name="emp_id" id="emp_id" />
        <input type="hidden" value="<?= $employeeId; ?>" name="dept_Id" id="dept_Id" />
        <input type="hidden" value="<?php if($code!="") echo "1"; else echo "0";?>" name="checkChange" id="checkChange" />
        <input type="hidden"  name="oldClaimVal" id="oldClaimVal" value="<?php if(isset($_REQUEST['NewClaimVal'])) echo $_REQUEST['NewClaimVal'];?>" />
        <input type="hidden"  name="NewClaimVal" id="NewClaimVal" />
            
        <table width="50%">
          <tr style="display:none;">
            <td>
            <div class="form-group">
              <label for="code"><b>Employee Code:</b></label>
            </div>
            </td>
            <td>
            <div class="form-group">
              <input type="text"  name="code" id="code" value="<?= $empNumber; ?>" style="background:#FFFFFF"  class="form-control" readonly>  
            </div>
            </td>
          </tr>
            <tr style="display:none;">
          <td>
            <div class="form-group">
              <label for="name"><b>Employee Name:</b></label>
            </div>
            </td>
            <td>
            <div class="form-group">
              <input type="text"  name="emp_name" id="name" value="<?= $empName; ?>" class="form-control pull-right" style="background:#FFFFFF"  readonly="">  
            </div>
            </td>
          </tr>
           <tr style="display:none;">
            <td>
            <div class="form-group">
              <label for="department"><b>Department Name:</b></label>
            </div>
            </td>
            <td>
            <div class="form-group">
              <input type="text"  name="department" id="department" value="<?= $empDept; ?>" style="background:#FFFFFF"  class="form-control" readonly>  
            </div>
            </td>
          </tr>
          <tr style="display:none;">
            <td>
             <div class="form-group">
            <label for="title"><b>Title:</b></label>
             </div>
            </td>
            <td>
            <div class="form-group">
              <input type="text"  name="title" id="title" value="<?= $emptitle; ?>" class="form-control" style="background:#FFFFFF" readonly>                  
             </div>
            </td>
          </tr>
          <tr style="display:none;">
            <td>
            <div class="form-group">
              <label for="c_date"><b>Claim Date::</b></label>
            </div>
            </td>
            <td>
            <div class="form-group">
              <input type="date"  name="c_date" id="c_date" value="<?= $today_date; ?>" class="form-control" style="background:#FFFFFF" readonly>  
            </div>
            </td>
          </tr>
          <tr>
            <td align="center">
            <div class="form-group">
              <label for="c_id"><b>Claim ID:</b></label>
            </div>
             </td>
            <td>
            <div class="form-group">
            <?php
              if($maxClaimNo<10)
                $max="0".$maxClaimNo;
              else
                $max=$maxClaimNo;
            ?>
              <input type="text"   name="c_id" id="c_id" class="form-control" readonly style="background:#FFFFFF; background: #0258a3;border: none;color: white;width: 38%; text-align:center;" value="<?php echo $empNumber."".date('ymd',strtotime($today_date))."".$max;?>">
            </div>
            </td>
          </tr>
        </table>
               
          <!-- <input type="submit" class="btn btn-primary float-right" value="Submit & Email" style="background:#013243;"> -->
        </div>
      </div>
  <!-- Claim Header -->
      <div class="card mx-auto">
       <div class="card-header bg-primary text-white text-center" ><h5 class="float-left">Claim Summary</h5></div>
        <div class="card-body">
        <table class="table table-hover table-bordered table-striped" style="table-layout: fixed; width: 180px:">
          <thead class="bg-success text-white">
          <tr>
            <th>Claim Type</th>
            <th>Description</th>
            <th>Amount(MYR)</th>
            <th>Tax(MYR)</th>
            <th>Total(MYR)</th>
          </tr>
          </thead>
          <tbody>
            <tr>
              <td align="left">
                <select name="claimType" id="claimType"  class="form-control" style="width:150px" onChange="autoFillDesc(this.value,0)">
                <option value="">--Select Type--</option>
                <?php
                foreach($claimTypeArray as $claim)
                {
                  if(!in_array($claim['CLAIM_TYPE_CODE'],$claimIdsArray))
                  {
                ?>
                  <option value="<?php echo $claim['CLAIM_TYPE_CODE']."_".$claim['CLAIM_TYPE_DESCRIPTION']."_".$claim['CLAIM_TYPE_NAME'];?>" <?php if($claim['CLAIM_TYPE']==$claim['CLAIM_TYPE_CODE']) echo "selected";?> <?php if($_REQUEST['NewClaimVal']==$claim['CLAIM_TYPE_CODE']."_".$claim['CLAIM_TYPE_DESCRIPTION']."_".$claim['CLAIM_TYPE_NAME']) echo "selected";?>><?php echo $claim['CLAIM_TYPE_NAME']." (".$claim['CLAIM_TYPE_CODE'].")";?></option>
                <?php
                  }
                }
                ?>
                </select> 
              </td>
              <td align="left"><span id="descClaimType"><?php  if($sno==1) echo $claim['CLAIM_TYPE_DESCRIPTION']; else echo $desc;?></span></td>
              <td align="right"><input type="text"  name="totalAmt" id="totalAmt"  style="border:0px; background: none;;width:150px" value="<?php echo $amtMtr;?>" readonly></td>
              <td align="right"><input type="text"  name="totalTax" id="totalTax"  style="border:0px; background: none;;width:150px" value="<?php echo $taxAmt;?>" readonly></td>
              <td align="right"><input type="text"  name="grandTotal" id="grandTotal"  style="border:0px; background: none;;width:150px" value="<?php echo $totalAmt;?>" readonly></td>
            </tr>
          </tbody>
        </table>
       </div>
      </div><br><br>
  <!-- Claim Lines -->
       <div class="card mx-auto mycss">  
        <div class="card-header bg-primary text-white text-center"><h5 class="float-left">Claim Details</h5>
        </div>
         <div  class="card-body"> 
          <table class="table table-hover table-bordered table-striped" style="table-layout: fixed; width: 180px:">  
          <thead class="bg-success text-white">
            <tr>
            <th style="width:12%">Bill&nbsp;Date</th>
            <th style="width:10%">Claim&nbsp;Type</th>
            <th style="width:10%">Description</th>
            <th style="width:10%">Bill&nbsp;Amount</th>
            <th style="width:10%">Tax</th>
            <th style="width:10%">Currency</th>
            <th style="width:10%">Exchange&nbsp;Rate</th>
            <th style="width:10%"><p style="margin-bottom:0px;">Total&nbsp;Amount<br>&nbsp;&nbsp;[MYR]</p></th>
            <th style="width:10%; text-align: center;">Attachment</th>
            <th class="text-right" style="width:8%">Action</th>
            </tr>
          </thead>
          <tbody>
              <tr>
                <td><input type="text"  name="bill_date_1" id="bill_date_1" class="form-control date_bill" style="width:100%;" autocomplete="off" onBlur="getMYRDetails(this.value,'1')" onClick="popUpCalendar('bill_date_1', false, 'dmy', '-');"></td>
                <td id="claimVal_1"><?php if($typeName!="") echo $typeName ." (".$code.")"; ?>
                </td>
                <td align="left"><input type="text"  name="desc_1" id="desc_1"  style="width:100%;" class="form-control"></td>
                <td align="right"><input type="text"  name="bill_amount_1" onkeypress="return isNumberKey(event,this)" onBlur="changeVal('1')" autocomplete="off" id="bill_amount_1" onKeyUp="calculateTotalAmt('1')" class="form-control" style="width:100%;"><a style="position: absolute;margin-left: -22px;margin-top: -35px;height: 34px; display:none;" class="btn btn-info btn-sm" onClick="return checkDate('1')" data-toggle="modal" id="tptData"><i class="fa fa-edit"></i></a>
                                
                                <input type="hidden" name="hidden_kilometer_1" autocomplete="off"  id="hidden_kilometer_1" class="form-control" style="width:100%;">
                                <input type="hidden" name="hidden_ratePerKm_1" autocomplete="off" id="hidden_ratePerKm_1" class="form-control" style="width:100%;">                                
                            <div id="myModal1" class="modal fade" role="dialog">
                              <div class="modal-dialog">
                                <!-- Modal content-->
                                <div class="modal-content"   style="width:120%">
                                  <div class="modal-header" style="background-color:#007bff">
                                    <h4 class="modal-title" style="color:#FFFFFF">Transport Detail</h4>
                                  </div>
                                  <div class="modal-body" style="text-align:center">
                                      <table align="center">
                                          <thead>
                                          </thead>
                                          <tbody class="table">
                                              <tr>
                                                  <td><strong>Show in bill amount ?</strong></td>
                                                  <td><strong>KM</strong></td>
                                                  <td><strong>Rate/Km</strong></td>
                                                  <td><strong>Total</strong></td>
                                              </tr>
                                              <tr>
                                                  <td><input type="checkbox" name="isBillAmt_1" id="isBillAmt_1" onClick="populateValueBillAmount(1)" style="width:20px" ></td>
                                                  <td><input type="text" disabled onkeypress="return isNumberKey(event,this)" onKeyUp="calculateTotalTransportAmt(this.value,'1')"  name="kilometer_1" autocomplete="off"  id="kilometer_1" class="form-control" style="width:100%;"></td>
                                                  <td><input type="text" disabled onkeypress="return isNumberKey(event,this)" onKeyUp="calculateTotalTransportAmt(this.value,'1')"   name="ratePerKm_1" autocomplete="off" id="ratePerKm_1" class="form-control" style="width:100%;"></td>
                                                  <td><input type="text" onkeypress="return isNumberKey(event,this)"  name="totalKmAmt_1" autocomplete="off" id="totalKmAmt_1" class="form-control" style="width:100%;; background:#FFFCFC" readonly></td>
                                              </tr>
                                          </tbody>
                                      </table>
                                  </div>
                                  <div class="modal-footer">
                                    <button type="button" class="btn btn-success" data-dismiss="modal">OK</button>
                                  </div>
                                </div>
                              </div>
                            </div>                                
                <input type="hidden"  name="hidden_bill_amount_1" autocomplete="off" id="hidden_bill_amount_1" class="form-control" style="width:100%;"></td>
                <td align="right"><input type="text"  name="tax_1" onBlur="changeVal('1')"   onkeypress="return isNumberKey(event,this)" autocomplete="off" onKeyUp="calculateTotalAmt('1')" id="tax_1" class="form-control" style="width:100%;" onfocus="this.select();" onmouseup="return false;">
                <input type="hidden"  name="hidden_tax_1" autocomplete="off" id="hidden_tax_1" class="form-control" style="width:100%;">                </td>
                <td align="right">
                  <select name="currency_1" id="currency_1"  class="form-control" style="width:100%;" onChange="getMYRDetails(this.value,'1')">
                  <?php
                  foreach($currencyArray as $currency)
                  {
                  ?>
                    <option value="<?php echo $currency['FROM_CURRENCY'];?>" <?php if($currency['FROM_CURRENCY']=='MYR') echo "selected";?>><?php echo $currency['FROM_CURRENCY'];?></option>
                  <?php
                  }
                  ?>
                  </select> 
                </td>
                <td align="right"><input type="text" autocomplete="off" onKeyUp="calculateTotalAmt('1')"  name="exchange_rate_1" onblur="changeVal('1')" id="exchange_rate_1" class="form-control" style="width:100%;" maxlength="3"></td>
                <td align="right"><input type="text" readonly  name="total_amount_1" id="total_amount_1" class="form-control" style="width:100%;"></td>
                <td align="right">
                    <a style="display:block;width:100%;;height:30px;"  class="btn btn-warning btn-sm"  onclick="document.getElementById('attachment_1').click()"><strong><i class="fa fa-paperclip"></i></strong></a>
                    <input type='file' name="attachment_1" style="display:none;" id="attachment_1">
                                      <!-- <input type="text"  name="claim_url_1" id="claim_url_1" class="form-control" placeholder="Add Url"> -->
                                 </td>              
                <td align="right">
                  <a class="btn btn-info btn-sm"><i class="fa fa-plus" onClick="addClaimLines('<?php echo $claim['CLAIM_TYPE_CODE'];?>','1')"></i></a>
                  <a class="btn btn-danger btn-sm"><i class="fa fa-minus" style="line-height:1.9em !important;" onClick="removeClaimLines('<?php echo $claim['CLAIM_TYPE_CODE'];?>','1')"></i></a>
                </td>
              </tr>
          </tbody>
        </table> 
         <div id="showCliamDiv_1" style="text-align:center"></div>
          <table class="table table-hover table-bordered table-striped" style="table-layout: fixed; width: 180px:">
            <tr>
              <td colspan="5" style="text-align:right"><strong>Total Claim Amount :</strong></td>
              <td align="left" colspan="2"><input type="text" name="totalClaimAmt" readonly id="totalClaimAmt" class="form-control" style="width:250px" /></td>
              <td align="right"><input type="submit" name="submitbtn" id="submitbtn" class="btn btn-primary" value="Save" style="background:#013243;" onClick="return submitForm('form');" /> <a href="settle-form.php" class="btn btn-primary">Back</a></td>
              </tr> 
              <input type="hidden" value="1" name="counter" id="counter" />
          </table>
         </div> 
        </div> 
     </form> 
      </div> 
    <script>
      window.onbeforeunload = function() {
      return "Do you really want to leave our brilliant application?";
        };
        </script>  
    <?php
    }
    if($action=="Edit")
    { 
      $clmId=$_REQUEST['clmId'];
      if(isset($_REQUEST['reject']) && $_REQUEST['reject']=='1')
      {
        $status="Reject";
        include("processNew.php");
      }
      $editClaimDataArray=array();
      foreach($clientClaimData as $value)
      {
        if($clmId!=$value['CLAIM_HEADER_ID'])
          continue;
          $editClaimDataArray[]=$value;
      } 
      //echo"<pre>";print_r($editClaimDataArray);
    ?>   
        <style>
      input[type=checkbox]
      {
        /* Double-sized Checkboxes */
        -ms-transform: scale(2); /* IE */
        -moz-transform: scale(2); /* FF */
        -webkit-transform: scale(2); /* Safari and Chrome */
        -o-transform: scale(2); /* Opera */
        transform: scale(2);
        padding: 10px;
      }
      
      /* Might want to wrap a span around your checkbox text */
      .checkboxtext
      {
        /* Checkbox text */
        font-size: 110%;
        display: inline;
      }
table td .btn-warning 
{
    width: 100% !important;
}
   </style> 
      <form id="claim_form" action="" method="POST" enctype="multipart/form-data">
      <div class="container-fluid">
       <div class="card mx-auto">
      <div class="card-header bg-primary text-white text-center"><h5 class="float-left">YTY Group-Green Prospects-Employee Claim Settlement Form</h5></div><br>
            
       <center> <?= $error; ?><?= $msg; ?></center>
       <div class="card-body">                
        <input type="hidden" value="<?= $employeeId; ?>" name="emp_id" id="emp_id" />
        <input type="hidden" value="<?= $employeeId; ?>" name="dept_Id" id="dept_Id" />
        <input type="hidden" value="<?= $status; ?>" name="status" id="status" />
        <input type="hidden"  name="claimHeaderId" id="claimHeaderId" value="<?php echo $clmId; ?>"  readonly="">
        <input type="hidden"  name="claim_id" id="claim_id" value="<?php echo $editClaimDataArray[0]['CLAIM_ID']; ?>"  readonly="">
        <table width="50%">
           <tr style="display:none;">
            <td>
            <div class="form-group">
              <label for="code"><b>Employee Code:</b></label>
            </div>
            </td>
            <td>
            <div class="form-group">
              <input type="text"  name="code" id="code" value="<?= $empNumber; ?>" style="background:#FFFFFF"  class="form-control" readonly>  
            </div>
            </td>
          </tr>
            <tr style="display:none;">
          <td>
            <div class="form-group">
              <label for="name"><b>Employee Name:</b></label>
            </div>
            </td>
            <td>
            <div class="form-group">
              <input type="text"  name="emp_name" id="name" value="<?= $empName; ?>" style="background:#FFFFFF" class="form-control pull-right"  readonly="">  
            </div>
            </td>
          </tr>
           <tr style="display:none;">
            <td>
            <div class="form-group">
              <label for="department"><b>Department Name:</b></label>
            </div>
            </td>
            <td>
            <div class="form-group">
              <input type="text"  name="department" id="department" value="<?= $empDept; ?>" style="background:#FFFFFF"  class="form-control" readonly>  
            </div>
            </td>
          </tr>
            <tr style="display:none;">
            <td>
             <div class="form-group">

            <label for="title"><b>Title:</b></label>
             </div>
            </td>
            <td>
            <div class="form-group">
              <input type="text"  name="title" id="title" value="<?= $empNumber; ?>" style="background:#FFFFFF" class="form-control" readonly>                  
             </div>
            </td>
          </tr>
          <tr style="display:none;">
            <td>
            <div class="form-group">
              <label for="c_date"><b>Claim Date::</b></label>
            </div>
            </td>
            <td>
            <div class="form-group">
              <input type="text"  name="c_date" id="c_date" style="background:#FFFFFF" value="<?= $editClaimDataArray[0]['CLAIM_DATE']; ?>" class="form-control" readonly>  
            </div>
            </td>
          </tr>
          <tr>
            <td align="center">
            <div class="form-group">
              <label for="c_id"><b>Claim ID:</b></label>
            </div>
             </td>
            <td>
            <div class="form-group">
              <input  type="text"  name="c_id" id="c_id" class="form-control" style="background:#FFFFFF; background: #0258a3;border: none;color: white;width: 38%; text-align:center;" readonly value="<?php echo $editClaimDataArray[0]['CLAIM_ID'];?>">
            </div>
            </td>
          </tr>
        </table>
          <!-- <input type="submit" class="btn btn-primary float-right" value="Submit & Email" style="background:#013243;"> -->
        </div>
      </div>
  <!-- Claim Header -->
      <div class="card mx-auto mycss">
       <div class="card-header bg-primary text-white text-center" ><h5 class="float-left">Claim Summary</h5></div>
        <div class="card-body">
        <table class="table table-hover table-bordered table-striped">
          <thead class="bg-success text-white">
          <tr>
            <th>Claim Type</th>
            <th>Description</th>
            <th>Amount(MYR)</th>
            <th>Tax(MYR)</th>
            <th>Total(MYR)</th>
          </tr>
          </thead>
          <tbody>
            <tr>
              <td align="left">
                <select name="claimType" id="claimType"  class="form-control" style="width:150px" onChange="autoFillDesc(this.value,0)">
                <?php
                foreach($claimTypeArray as $claim)
                {
                  if($editClaimDataArray[0]['CLAIM_TYPE']!=$claim['CLAIM_TYPE_CODE'])
                    continue;
                ?>
                  <option value="<?php echo $claim['CLAIM_TYPE_CODE']."_".$claim['CLAIM_TYPE_DESCRIPTION']."_".$claim['CLAIM_TYPE_NAME'];?>" <?php if($claim['CLAIM_TYPE']==$claim['CLAIM_TYPE_CODE']) echo "selected";?>><?php echo $claim['CLAIM_TYPE_NAME']." (".$claim['CLAIM_TYPE_CODE'].")";?></option>
                <?php
                }
                ?>
                </select> 
              </td>
              <td align="left"><input type="text"  name="descClaimType" id="descClaimType"  style="border:0px; background: none;;width:150px" value="<?php echo $editClaimDataArray[0]['CLAIM_DESCRIPTION'];?>" readonly ></td>
              <td align="right"><input type="text"  name="totalAmt" id="totalAmt"  style="border:0px; background: none;;width:150px" value="<?php echo moneyFormatIndia($editClaimDataArray[0]['CLAIM_TOT_AMT_MYR']);?>" readonly></td>
              <td align="right"><input type="text"  name="totalTax" id="totalTax"  style="border:0px; background: none;;width:150px" value="<?php echo moneyFormatIndia($editClaimDataArray[0]['CLAIM_TOT_TAX_AMT']);?>" readonly></td>
              <td align="right"><input type="text"  name="grandTotal" id="grandTotal"  style="border:0px; background: none;;width:150px" value="<?php echo moneyFormatIndia($editClaimDataArray[0]['CLAIM_TOTAL_AMT']);?>" readonly></td>
            </tr>
          </tbody>
        </table>
       </div>
      </div><br><br>
  <!-- Claim Lines -->
       <div class="card mx-auto">
        <div class="card-header bg-primary text-white text-center"><h5 class="float-left">Claim Lines</h5>
        </div>
         <div  class="card-body">
          <table class="table table-hover table-bordered table-striped" style="table-layout: fixed; width: 180px:">
          <thead class="bg-success text-white">
            <tr>
            <th style="width:12%">Bill&nbsp;Date</th>
            <th style="width:10%">Claim&nbsp;Type</th>
            <th style="width:10%">Description</th>
            <th style="width:10%">Bill&nbsp;Amount</th>
            <th style="width:10%">Tax</th>
            <th style="width:10%">Currency</th>
            <th style="width:10%">Exchange&nbsp;Rate</th>
            <th style="width:10%"><p style="margin-bottom:0px;">Total&nbsp;Amount [MYR]</p></th>
            <th style="width:10%; text-align: center;">Attachment</th>
            <th class="text-right" style="width:8%">Action</th>
            </tr>
          </thead>

          <tbody>
          <tbody>
          <?php
          if(count($editClaimDataArray)>0)
          {
            $sno=1;
            $grandTotal=0;
            foreach($editClaimDataArray as $value)
            { 
              $grandTotal+=(($value['CLAIM_BILL_AMT']+$value['CLAIM_TAX_AMT'])*$value['CLAIM_EXCHANGE_RATE']);
            ?>
              <tr>    
              <td><input type="text" value="<?php echo date('d-m-Y',strtotime($value['CREATION_DATE']));?>" autocomplete="off"   name="bill_date_<?php echo $sno;?>" id="bill_date_<?php echo $sno;?>" class="form-control" style="width:140px" onBlur="getMYRDetails(this.value,'<?php echo $sno;?>')" onClick="popUpCalendar('bill_date_<?php echo $sno;?>', false, 'dmy', '-');"> </td>
              <td align="left" id="claimVal"><?php echo $claimTypeName[$editClaimDataArray[0]['CLAIM_TYPE']];?></td>
              <td align="left" id="claimDesc"><input type="text"  name="desc_<?php echo $sno;?>" id="desc_<?php echo $sno;?>"  style="width:100%;" class="form-control" value="<?php echo $value['CLAIM_DESCRIPTION'];?>"></td>
              <td align="right"><input type="text" onkeypress="return isNumberKey(event,this)" onBlur="changeVal('<?php echo $sno;?>')" autocomplete="off" <?php if($value['KILOMETER']!="") echo "readonly='true'";?>  name="bill_amount_<?php echo $sno;?>" id="bill_amount_<?php echo $sno;?>" onKeyUp="calculateTotalAmt('<?php echo $sno;?>')" class="form-control" style="width:100%;; background:#ffffff" value="<?php echo moneyFormatIndia($value['CLAIM_BILL_AMT']);?>"><input type="hidden"  name="hidden_bill_amount_<?php echo $sno;?>" autocomplete="off" id="hidden_bill_amount_<?php echo $sno;?>" class="form-control" style="width:100%;" value="<?php echo moneyFormatIndia($value['CLAIM_BILL_AMT']);?>">
                              <?php
                if($editClaimDataArray[0]['CLAIM_TYPE']=='002')
                {
                ?>
                                    <a style="position: absolute;margin-left: -22px;margin-top: -35px;height: 34px;" class="btn btn-info btn-sm" onClick="return checkDate('<?php echo $sno;?>')" data-toggle="modal"  id="tptData"><i class="fa fa-edit"></i></a>
                                                                    
                                                                    <input type="hidden" name="hidden_kilometer_<?php echo $sno;?>" autocomplete="off"  id="hidden_kilometer_<?php echo $sno;?>" value="<?php echo $value['KILOMETER'];?>" class="form-control" style="width:100%;">
                                                                    <input type="hidden" name="hidden_ratePerKm_<?php echo $sno;?>" autocomplete="off" id="hidden_ratePerKm_<?php echo $sno;?>" value="<?php echo $value['RATE_PER_KILOMETER'];?>" class="form-control" style="width:100%;">                                
                                <div id="myModal<?php echo $sno;?>" class="modal fade" role="dialog">
                                  <div class="modal-dialog">
                                    <!-- Modal content-->
                                    <div class="modal-content"   style="width:120%">
                                      <div class="modal-header" style="background-color:#007bff">
                                        <h4 class="modal-title" style="color:#FFFFFF">Transport Detail</h4>
                                      </div>
                                      <div class="modal-body" style="text-align:center">
                                          <table align="center">
                                              <thead>
                                              </thead>
                                              <tbody class="table">
                                                  <tr>
                                                      <td><strong>Show in bill amount ?</strong></td>
                                                      <td><strong>KM</strong></td>
                                                      <td><strong>Rate/Km</strong></td>
                                                      <td><strong>Total</strong></td>
                                                  </tr>
                                                  <tr>
                                                      <td><input type="checkbox" name="isBillAmt_<?php echo $sno;?>" id="isBillAmt_<?php echo $sno;?>" <?php if($value['KILOMETER']!="") echo "checked";?> onClick="populateValueBillAmount('<?php echo $sno;?>')" style="width:20px" ></td>
                                                      <td><input type="text" <?php if($value['KILOMETER']=="") echo "disabled";?>  onkeypress="return isNumberKey(event,this)" onKeyUp="calculateTotalTransportAmt(this.value,'<?php echo $sno;?>')"  name="kilometer_<?php echo $sno;?>" autocomplete="off"  id="kilometer_<?php echo $sno;?>" value="<?php echo $value['KILOMETER'];?>" class="form-control" style="width:100%;"></td>
                                                      <td><input type="text"  onkeypress="return isNumberKey(event,this)" <?php if($value['RATE_PER_KILOMETER']=="") echo "disabled";?> onKeyUp="calculateTotalTransportAmt(this.value,'<?php echo $sno;?>')" value="<?php echo $value['RATE_PER_KILOMETER'];?>"  name="ratePerKm_<?php echo $sno;?>" autocomplete="off" id="ratePerKm_<?php echo $sno;?>" class="form-control" style="width:100%;"></td>
                                                      <td><input type="text" onkeypress="return isNumberKey(event,this)"  name="totalKmAmt_<?php echo $sno;?>" value="<?php echo ($value['KILOMETER']*$value['RATE_PER_KILOMETER']);?>" autocomplete="off" id="totalKmAmt_<?php echo $sno;?>" class="form-control" style="width:100%;; background:#FFFCFC" readonly></td>
                                                  </tr>
                                              </tbody>
                                          </table>
                                      </div>
                                      <div class="modal-footer">
                                        <button type="button" class="btn btn-danger" data-dismiss="modal">OK</button>
                                      </div>
                                    </div>
                                  </div>
                                </div> 
                            <?php
                }
               ?>
                            </td>
              <td align="right"><input type="text" onkeypress="return isNumberKey(event,this)" onBlur="changeVal('<?php echo $sno;?>')" autocomplete="off" value="<?php echo moneyFormatIndia($value['CLAIM_TAX_AMT']);?>"  name="tax_<?php echo $sno;?>" onKeyUp="calculateTotalAmt('<?php echo $sno;?>')" id="tax_<?php echo $sno;?>" class="form-control" style="width:100%;" onfocus="this.select();" onmouseup="return false;"> 
              <input type="hidden"  name="hidden_tax_<?php echo $sno;?>" value="<?php echo moneyFormatIndia($value['CLAIM_TAX_AMT']);?>" autocomplete="off" id="hidden_tax_<?php echo $sno;?>" class="form-control" style="width:100%;">
              </td>
              <td align="right">
                <select name="currency_<?php echo $sno;?>" id="currency_<?php echo $sno;?>"  class="form-control" style="width:100%;" onChange="getMYRDetails(this.value,'<?php echo $sno;?>')">
                <?php
                foreach($currencyArray as $currency)
                {
                ?>
                  <option value="<?php echo $currency['FROM_CURRENCY'];?>" <?php if($value['CLAIM_CURRENCY_TYPE']==$currency['FROM_CURRENCY']) echo "selected";?>><?php echo $currency['FROM_CURRENCY'];?></option>
                <?php
                }
                ?>
                </select> 
               </td>
              <td align="right"><input type="text" autocomplete="off" readonly value="<?php echo $value['CLAIM_EXCHANGE_RATE'];?>"  name="exchange_rate_<?php echo $sno;?>" id="exchange_rate_<?php echo $sno;?>" class="form-control" style="width:100%;"> </td>
              <td align="right"><input type="text" readonly value="<?php echo moneyFormatIndia(($value['CLAIM_BILL_AMT']+$value['CLAIM_TAX_AMT'])*$value['CLAIM_EXCHANGE_RATE']);?>"  name="total_amount_<?php echo $sno;?>" id="total_amount_<?php echo $sno;?>" class="form-control" style="width:100%;"> </td>
              <td align="right">
                <p>
                  <a style="display:block;width:100%;;height:30px;" class="btn btn-warning btn-sm"  onclick="document.getElementById('attachment_<?php echo $sno;?>').click()"><strong><i class="fa fa-paperclip"></i></strong></a>
                  <input type='file' name="attachment_<?php echo $sno;?>" id="attachment_<?php echo $sno;?>" style="display:none">
                                      <!-- <input type="text"  name="claim_url_<?php //echo $sno;?>" id="claim_url_<?php //echo $sno;?>" class="form-control" placeholder="Add Url" value="<?php //echo $value['CLAIM_URL'];?>"> -->
                </p>                
              <input type="hidden"  name="claimDetailId_<?php echo $sno;?>" value="<?php echo $value['CLAIM_DETAIL_ID']."@@@".$value['CLAIM_FILE_EXTENSION'];?>" class="form-control" style="width:100px"> 
              <td align="right">
                <a class="btn btn-info btn-sm" style="margin-right: 15px; height:31px"><i class="fa fa-plus" onClick="addClaimLines('<?php echo $claim['CLAIM_TYPE_CODE'];?>','1')"></i></a>
                              <?php
                              if(isset($_REQUEST['reject']) && $_REQUEST['reject']=='1')
                              {
                  ?>
                                    <input type="checkbox" name="deleteRow[]" style="margin-left: 10px;" id="deleteRow_<?php echo $sno;?>" width="20px" onClick="removeParticularRow('<?php echo $value['CLAIM_ID'];?>','<?php echo $value['CLAIM_LINE_NO'];?>','<?php echo $sno;?>')"  value="<?php echo $value['CLAIM_ID'];?>@_@<?php echo $value['CLAIM_LINE_NO'];?>@_@<?php echo $value['CLAIM_FILE_EXTENSION'];?>" />
                               <?php
                }
                else
                {
                ?>
                                    <input type="checkbox" name="deleteRow[]"  id="deleteRow_<?php echo $sno;?>" width="20px" onClick="removeParticularRow('<?php echo $value['CLAIM_ID'];?>','<?php echo $value['CLAIM_LINE_NO'];?>','<?php echo $sno;?>')"   value="<?php echo $value['CLAIM_ID'];?>@_@<?php echo $value['CLAIM_LINE_NO'];?>@_@<?php echo $value['CLAIM_FILE_EXTENSION'];?>" />
                                  <!--<a class="btn btn-danger btn-sm"><i class="fa fa-minus" onclick="removeClaimLines('<?php echo $claim['CLAIM_TYPE_CODE'];?>','1')"></i></a>-->
                                <?php  
                }
                ?>
              </td>
              </tr>
              <tr>
                <td colspan="10" style="padding:0px; width:100%">
                <table class="table table-hover table-bordered table-striped" cellpadding="0" cellspacing="0">
                </table>
                </td>
              </tr> 
            <?php
              $sno++;
            }
          }
           ?>
              <tr>
              <td colspan="10" style="padding:0px; width:100%">
                    <div id="showCliamDiv_<?php echo ($sno-1);?>">
                    </div>
              </td> 
              </tr> 
            <tr>
              <td colspan="6" style="text-align:right"><strong>Total Claim Amount :</strong></td>
              <td align="left" colspan="2"><input type="text" name="totalClaimAmt" readonly value="<?php echo moneyFormatIndia($grandTotal);?>" id="totalClaimAmt" class="form-control" style="width:250px" /></td>
              <td  align="right" colspan="2"><input type="submit" name="submit" id="submitbtn" class="btn btn-primary" value="Save" style="background:#013243;" onClick="return submitFormEdit('form');"> <a href="javascript:history.back(-1)" class="btn btn-primary">Back</a></td>
              </tr> 
              <input type="hidden" value="<?php echo ($sno-1);?>" name="counter" id="counter" />
              <input type="hidden" value="<?php echo ($sno-1);?>" name="chekLast" id="chekLast" />
             </tbody>
          </table>
         </div>
        <!-- <form id="signupform" action="signup.php" method="POST"> -->
          <!-- <input type="submit" class="btn btn-primary float-left" value="Save Draft" style="background:#013243;"> -->
          <!-- <input type="submit" class="btn btn-primary" value="Submit" style="margin-left:350px; background:#013243;"> -->
          <!-- <input type="submit" class="btn btn-primary float-right" value="Submit & Email" style="background:#013243;"> -->
        </div>
      </div>
     </form>
    <script>
    function removeParticularRow(claim_id,line_no,row_no)
    {
      var totalRow=document.getElementById('chekLast').value;
      var checked=0;
      for(var i=1;i<=totalRow;i++)
      {
        if(document.getElementById('deleteRow_'+i).checked==true)
        {
          checked=checked+1;
        }
      }
      if(checked==totalRow)
      {
        alert('Please click OK to reset the row.');
        document.getElementById('bill_amount_'+row_no).value="0.00";
        document.getElementById('tax_'+row_no).value="0.00";
        document.getElementById('bill_amount_'+row_no).disabled=true;
        document.getElementById('tax_'+row_no).disabled=true;
        document.getElementById('bill_date_'+row_no).disabled=true;
        calculateTotalAmt(row_no);
        return true;
      }
      if(document.getElementById('deleteRow_'+row_no).checked==true)
      {
        if(confirm('Please click OK to reset the row'))
        {
          document.getElementById('bill_amount_'+row_no).value="0.00";
          document.getElementById('tax_'+row_no).value="0.00";
          document.getElementById('bill_amount_'+row_no).disabled=true;
          document.getElementById('tax_'+row_no).disabled=true;
          document.getElementById('bill_date_'+row_no).disabled=true;
          calculateTotalAmt(row_no);
        }
        else
        {
          document.getElementById('deleteRow_'+row_no).checked=false;
          document.getElementById('bill_amount_'+row_no).disabled=false;
          document.getElementById('tax_'+row_no).disabled=false;
          document.getElementById('bill_date_'+row_no).disabled=false;
          return false;
        }
      }
      else
      {
        document.getElementById('bill_amount_'+row_no).disabled=false;
        document.getElementById('tax_'+row_no).disabled=false;
        document.getElementById('bill_date_'+row_no).disabled=false;
        return false;
      }
    }
        // Warning before leaving the page (back button, or outgoinglink)
        window.onbeforeunload = function() {
           return "Do you really want to leave our brilliant application?";
           //if we return nothing here (just calling return;) then there will be no pop-up question at all
           //return;
        };
        </script>  
     <?php
    }
    if($action=="View")
    { 
      $clmId=$_REQUEST['clmId'];
      $viewClaimDataArray=array();
      foreach($clientClaimData as $value)
      {
        if($clmId!=$value['CLAIM_HEADER_ID'])
          continue;
          $viewClaimDataArray[]=$value;
      } 
      //echo"<pre>";print_r($viewClaimDataArray);
    ?>    
      <div class="container-fluid">
       <div class="card mx-auto">
      <div class="card-header bg-primary text-white text-center"><h5 class="float-left">YTY Group-Green Prospects-Employee Claim Settlement Form</h5></div><br>
       <div class="card-body">                
        <table width="50%">
          <tr style="display:none;">
            <td>
            <div class="form-group">
              <label for="code"><b>Employee Code:</b></label>
            </div>
            </td>
            <td>
            <div class="form-group">
              <?= $empNumber; ?>
            </div>
            </td>
          </tr>
         <tr style="display:none;">
          <td>
            <div class="form-group">
              <label for="name"><b>Employee Name:</b></label>
            </div>
            </td>
            <td>
            <div class="form-group">
              <?= $empName; ?> 
            </div>
            </td>
          </tr>
          <tr style="display:none;">
            <td>
            <div class="form-group">
              <label for="department"><b>Department Name:</b></label>
            </div>
            </td>
            <td>
            <div class="form-group">
              <?= $empDept; ?> 
            </div>
            </td>
          </tr>
           <tr style="display:none;">
            <td>
             <div class="form-group">
            <label for="title"><b>Title:</b></label>
             </div>
            </td>
            <td>
            <div class="form-group">
              <?= $emptitle; ?>                
             </div>
            </td>
          </tr>
           <tr style="display:none;">
            <td>
            <div class="form-group">
              <label for="c_date"><b>Claim Date::</b></label>
            </div>
            </td>
            <td>
            <div class="form-group">
              <?= $today_date; ?>
            </div>
            </td>
          </tr>
          <tr>
            <td align="center">
            <div class="form-group">
              <label for="c_id"><b>Claim ID:</b></label>
            </div>
             </td>
            <td>
            <div class="form-group" style="background:#FFFFFF;background: #0258a3;border: none;color: white;width: 38%;height: calc(1.5em + .75rem + 2px);padding: .375rem .75rem;border-radius: .25rem; text-align:center;">
            <?php echo $viewClaimDataArray[0]['CLAIM_ID'];?>
            </div>
            </td>
          </tr>
        </table>
          <!-- <input type="submit" class="btn btn-primary float-right" value="Submit & Email" style="background:#013243;"> -->
        </div>
      </div>
  <!-- Claim Header -->
      <div class="card mx-auto">
       <div class="card-header bg-primary text-white text-center" ><h5 class="float-left">Claim Summary</h5></div>
        <div class="card-body">
        <table class="table table-hover table-bordered table-striped">
          <thead class="bg-success text-white">
          <tr>
            <th>Claim Type</th>
            <th>Description</th>
            <th>Amount(MYR)</th>
            <th>Tax(MYR)</th>
            <th>Total(MYR)</th>
          </tr>
          </thead>
          <tbody>
            <tr>
              <td align="left">
                <?php
                //foreach($claimTypeArray as $claim)
                //{
                  //if($viewClaimDataArray[0]['CLAIM_TYPE']!=$claim['CLAIM_TYPE_CODE'])
                    //continue;
                    
                    echo $viewClaimDataArray[0]['CLAIM_TYPE_NAME']." (".$viewClaimDataArray[0]['CLAIM_TYPE_CODE'].")";
                //}
                ?>
              </td>
              <td align="left"><?php echo $viewClaimDataArray[0]['CLAIM_REMARK'];?></td>
              <td align="left"><?php echo moneyFormatIndia($viewClaimDataArray[0]['CLAIM_TOT_AMT_MYR']);?></td>
              <td align="left"><?php echo moneyFormatIndia($viewClaimDataArray[0]['CLAIM_TOT_TAX_AMT']);?></td>
              <td align="left"><?php echo moneyFormatIndia($viewClaimDataArray[0]['CLAIM_TOTAL_AMT']);?></td>
            </tr>
          </tbody>
        </table>
       </div>
      </div><br>
  <!-- Claim Lines -->
       <div class="card mx-auto">
        <div class="card-header bg-primary text-white text-center"><h5 class="float-left">Claim Details</h5>
        </div>
         <div  class="card-body">
          <table class="table table-hover table-bordered table-striped" width="100%">
          <thead class="bg-success text-white">
            <tr>
            <th width="10%">Bill Date</th>
            <th width="10%">Claim Type</th>
            <th width="10%">Description</th>
            <th width="10%">Bill Amount</th>
            <th width="10%">Tax</th>
            <th width="10%">Currency</th>
            <th width="15%">Exchange Rate</th>
            <th width="15%"><p style="margin-bottom:0px;">Total&nbsp;Amount<br>&nbsp;&nbsp;[MYR]</p></th>
            <th width="15%">Attachment</th>
            <th width="15%">URL</th>
            </tr>
          </thead>
          <tbody>
          <tbody>
          <?php
          if(count($clientClaimData)>0)
          {
            $sno=1;
            $thumbnialIcon="";
            $grandTotal=0;
            foreach($viewClaimDataArray as $value)
            {
              $filePath=UPLOAD_URL.CLAIM_DOCUMENT.$value['CLAIM_FILE_EXTENSION'];
              $targetPath=UPLOAD_URL.CLAIM_DOCUMENT;
              //list($fileName,$ext)=explode(".",$value['CLAIM_FILE_EXTENSION']);
              list($fileName, $ext) = [pathinfo($value['CLAIM_FILE_EXTENSION'], PATHINFO_FILENAME), pathinfo($value['CLAIM_FILE_EXTENSION'], PATHINFO_EXTENSION)];

              if(in_array($ext,$convertFileExt))
              {
                 $fileExits=UPLOAD_URL.CLAIM_DOCUMENT.$fileName.".pdf";
                if(!file($fileExits))
                   ChangeFileIntoPdf($value['CLAIM_FILE_EXTENSION'], $targetPath);
                   
                 $thumbnialIcon=$fileExits;
              }
              else
              {
                $thumbnialIcon=$filePath;
              }
            ?>
              <tr>    
              <td width="5%"><?php echo date('Y-m-d',strtotime($value['TEMP_BILL_DATE']));?></td>
              <td align="left"><?php echo $claimTypeName[$value['CLAIM_TYPE']];?></td>
              <td align="left"  width="5%"><?php echo $value['CLAIM_DESCRIPTION'];?></td>
              <td align="left">
                              <?php
                if($viewClaimDataArray[0]['CLAIM_TYPE']=='002')
                {
                  if($value['KILOMETER']!="")
                  {
                ?>
                                    <div id="myModal<?php echo $value['CLAIM_DETAIL_ID'];?>" class="modal fade" role="dialog">
                                      <div class="modal-dialog">
                                        <!-- Modal content-->
                                        <div class="modal-content">
                                          <div class="modal-header" style="background-color:#007bff">
                                            <h4 class="modal-title" style="color:#FFFFFF">Transport Detail</h4>
                                          </div>
                                          <div class="modal-body" style="text-align:center">
                                              <table align="center"  style="table-layout:fixed">
                                                  <thead>
                                                  </thead>
                                                  <tbody class="table">
                                                      <tr>
                                                          <td><strong>Show in bill amount ?</strong></td>
                                                          <td><strong>KM</strong></td>
                                                          <td><strong>Rate/Km</strong></td>
                                                          <td><strong>Total</strong></td>
                                                      </tr>
                                                      <tr>
                                                          <td style="width:130px"> <?php if($value['KILOMETER']!="") echo "Yes"; else echo "No";?></td>
                                                          <td style="width:130px"><?php if($value['KILOMETER']) echo moneyFormatIndia($value['KILOMETER']); else echo "0";?></td>
                                                          <td style="width:130px"><?php if($value['RATE_PER_KILOMETER']) echo moneyFormatIndia($value['RATE_PER_KILOMETER']); else echo "0";?></td>
                                                          <td style="width:130px"><?php if($value['KILOMETER']) echo moneyFormatIndia($value['KILOMETER']*$value['RATE_PER_KILOMETER']); else echo "0";?></td>
                                                      </tr>
                                                  </tbody>
                                              </table>
                                          </div>
                                          <div class="modal-footer">
                                            <button type="button" class="btn btn-success" data-dismiss="modal">OK</button>
                                          </div>
                                        </div>
                                      </div>
                                    </div> 
                                    <a href="javascript:void(0)" data-toggle="modal" data-target="#myModal<?php echo $value['CLAIM_DETAIL_ID'];?>"  id="tptData" onMouseOver="Tip('View to Click')" onMouseOut="UnTip()"><strong><?php echo moneyFormatIndia($value['CLAIM_BILL_AMT']);?></strong></a>
                            <?php
                  }
                  else
                  {
                    echo moneyFormatIndia($value['CLAIM_BILL_AMT']);
                  }
                }
                else
                {
                  echo moneyFormatIndia($value['CLAIM_BILL_AMT']);                          
                }
               ?>
                            </td>
              <td align="left"><?php echo moneyFormatIndia($value['CLAIM_TAX_AMT']);?></td>
              <td align="left"><?php echo $value['CLAIM_CURRENCY_TYPE'];?></td>
              <td align="left"><?php echo $value['CLAIM_EXCHANGE_RATE'];?></td>
              <td align="left"><?php echo moneyFormatIndia(($value['CLAIM_BILL_AMT']+$value['CLAIM_TAX_AMT'])*$value['CLAIM_EXCHANGE_RATE']);?></td>
              <?php
              $grandTotal+=(($value['CLAIM_BILL_AMT']+$value['CLAIM_TAX_AMT'])*$value['CLAIM_EXCHANGE_RATE']);
              if(file($filePath))
              {
                $im = new imagick($thumbnialIcon.'[0]');
                $im->setImageFormat('jpg');
                //header('Content-Type: image/jpeg');
              ?>
                              <style>
                  .imageClass{
                    transform:scale(1); 
                  }
                  .imageClass:hover{
                    transform:scale(4.1); 
                  }
                </style>
                <td align="left"><a href="<?php echo CLAIM_DOCUMENT.$value['CLAIM_FILE_EXTENSION'];?>" target="_blank" onMouseOver="Tip('<img src=\'<?php echo 'data:image/jpeg;base64,'.base64_encode($im);  ?>\' width=\'200\' height=\'200\ style=\'border-radius: 105px; border: 3px solid #498eb1; transform:scale(4.6)\'>')" onMouseOut="UnTip()">View</a></td>
              <?php
              }
              else
              {
              ?>
                <td align="left"><font color="#FF0000">No file found.</font></td>
              <?php
              }
              ?>
              <td align="left"><?php if($value['CLAIM_URL']!="") { ?> <a href="<?php echo $value['CLAIM_URL'];?>" target="_blank">View</a><?php } else { echo "No url found"; } ?></td>
              </tr>
            <?php
              $sno++;
            }
          }
           ?>
              </tr> 
            <tr><td colspan="10"></td></tr>
            <tr>
              <td colspan="7" style="text-align:right"><strong>Total Claim Amount :</strong></td>
              <td align="left" colspan="3"><?php echo moneyFormatIndia($grandTotal);?></td>
              </tr> 
          </table>
         </div>
        <!-- <form id="signupform" action="signup.php" method="POST"> -->
          <!-- <input type="submit" class="btn btn-primary float-left" value="Save Draft" style="background:#013243;"> -->
          <!-- <input type="submit" class="btn btn-primary" value="Submit" style="margin-left:350px; background:#013243;"> -->
          <!-- <input type="submit" class="btn btn-primary float-right" value="Submit & Email" style="background:#013243;"> -->
        </div>
      </div>
     <?php
    }
    ?>
  </div>
<?php require_once("templates/footer.php"); ?>
<style>
.card {
   position: relative !important;
    display: -ms-flexbox !important;
    display: flex!important;
    -ms-flex-direction: column!important;
    flex-direction: column!important;
    min-width: 0!important;
    word-wrap: break-word!important;
    background-color: #fff0!important;
    background-clip: border-box!important;
    border: 0px solid rgba(0,0,0,.125)!important;
    border-radius: .25rem!important;
}

</style>