<?php
    // Start the session
    session_start();
    
    require "conn.php";
    include "_functions.php";
    $host   = explode('.', $_SERVER['HTTP_HOST']); 
    $ids    = $_GET['m'];
?>


<!DOCTYPE html>
<html lang="en">
    <head>

        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>WePayYourCost | <?php    if (($host[0] == "vip") && (!isset($_GET['m'])))   { echo 'VIP'; }  elseif ((isset($_GET['m'])) && ($host[0] == "vip"))   { echo 'REDEEM'; } else    { echo 'MERCHANT';} ?></title>

        <!-- CSS -->
        <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:400,100,300,500">
        <link rel="stylesheet" href="assets2/bootstrap/css/bootstrap.min.css">
   <!--     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">  -->
        <link rel="stylesheet" href="/assets2/fontawesome/css/all.css">   
		<link rel="stylesheet" href="assets2/css/form-elements.css">
        <link rel="stylesheet" href="assets2/css/style.css">

        <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
            <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
            <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->

        <!-- Favicon and touch icons -->
        <link rel="shortcut icon" href="assets2/ico/wepayyourcost.png">
        <link rel="apple-touch-icon-precomposed" sizes="144x144" href="assets2/ico/apple-touch-icon-144-precomposed.png">
        <link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets2/ico/apple-touch-icon-114-precomposed.png">
        <link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets2/ico/apple-touch-icon-72-precomposed.png">
        <link rel="apple-touch-icon-precomposed" href="assets2/ico/apple-touch-icon-57-precomposed.png">

<style>
    .card{
	background-color: #fff;
	width: 300px;
	border-radius: 15px;
	box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
    }
    .name{
    	font-size: 15px;
    	color: #403f3f;
    	font-weight: bold;
    }
    .cross{
    	font-size: 11px;
    	color: #b0aeb7;
    }
    .pin{
    	font-size: 14px;
    	color: #b0aeb7;
    }
    .first{
    	border-radius: 8px;
    	border: 1.5px solid #78b9ff;
    	color: #000;
    	background-color: #eaf4ff;
    }
    .second{
    	border-radius: 8px;
    	border: 1px solid #acacb0;
    	color: #000;
    	background-color: #fff;
    }
    .dot{
    
    }
    .head{
    	color: #137ff3;
    	font-size: 12px;
    }
    .dollar{
    	font-size: 18px;
    	color: #097bf7;
    }
    .amount{
    	color: #007bff;
    	font-weight: bold;
    	font-size: 18px;
    
    }

    .back{
    	color: #aba4a4;
    	font-size: 15px;
    	line-height: 73px;
    	font-weight: 400;
    }
    
    .anim {  
        transition: background 5s linear;
    }

    .highlight{
        background: #B3CEE5; 
    }

    .normal {  
        background: transparent;  
    }

</style>


    </head>

    <body>

        <!-- Top content -->
        <div class="top-content">
        	
            <div class="inner-bg">
                <div class="container">
                    <div class="row">
                        <div class="col-sm-8 col-sm-offset-2 text">
                            <a href="" ><img src="wepay1.png" width="360" height="70" alt="WePayYourCost"></a>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-6 col-sm-offset-3 form-box">
                        	<!-- <div class="form-top">
                        		<div class="form-top-left">
                        			<h3>Please login</h3>
                        		</div>
                        		<div class="form-top-right">
                        			<i class="fa fa-key"></i>
                        		</div>
                            </div>   -->
                            
			                   
<?php
         if (isset($_GET['m']))   {


            if (isset($_SESSION["aidi"]))   {
               
                $result_merchant    = mysqli_query($con, "SELECT * FROM merchant WHERE id='$ids'");
                $row_merchant       = mysqli_fetch_array($result_merchant);  
                
                if (($row_merchant['carwash'])      == 1)   { $s1 = "text-primary"; $cb1 = ""; $dis1 = "";} else { $s1 = "text-secondary"; $cb1 = ""; $dis1 = "disabled";} 
                if (($row_merchant['polish'])       == 1)   { $s2 = "text-primary"; $cb2 = ""; $dis2 = "";} else { $s2 = "text-secondary"; $cb2 = ""; $dis2 = "disabled";} 
                if (($row_merchant['repair'])       == 1)   { $s3 = "text-primary"; $cb3 = ""; $dis3 = "";} else { $s3 = "text-secondary"; $cb3 = ""; $dis3 = "disabled";} 
                if (($row_merchant['accessories'])  == 1)   { $s4 = "text-primary"; $cb4 = ""; $dis4 = "";} else { $s4 = "text-secondary"; $cb4 = ""; $dis4 = "disabled";} 
                if (($row_merchant['insurance'])    == 1)   { $s5 = "text-primary"; $cb5 = ""; $dis5 = "";} else { $s5 = "text-secondary"; $cb5 = ""; $dis5 = "disabled";} 

             
?>  
                            <div class="form-bottom" style="background-color : #FFFFFF; opacity: 0.9; border-radius: 30px;" >
                                    <div class="form-group text-center bg-secondary" style="border-width:1px; margin: auto;  width: 50%; display:table;    align-items: center;    background: #C5C6C7;    border-radius: 100%;    text-color: blue;    font-size: 3em;  height:100px;  width:100px;">
                                        <div style="display:table-cell;  vertical-align:middle;  text-align:center;">
                                            <i style="font-size: 50px;	color: #FFFFFF;	font-weight: Thin;" class=" fa-solid fa-store fa-4x"></i>
                                        </div>
                                    </div>
                                    <div class="form-group text-center">
                                        <span style="font-size: 15px;	color: #403f3f;	font-weight: light;"><?php if (isset($_GET['m'])) { echo strtoupper($row_merchant['nama']); } else { echo "Merchant Name";} ?> </span>
                                    </div>
<?php
             
                        $mData                  = $_SESSION['aidi'];
                        $cwallet_carwash        = jumlah("masuk", "cwallet_carwash",$mData      ) - jumlah("keluar", "cwallet_carwash",$mData       );
                        $cwallet_polish         = jumlah("masuk", "cwallet_travel",$mData       ) - jumlah("keluar", "cwallet_travel",$mData        );                 // wax & polish
                        $cwallet_repair         = jumlah("masuk", "cwallet_cash",$mData         ) - jumlah("keluar", "cwallet_cash",$mData          );                     // repair
                        $cwallet_accessories    = jumlah("masuk", "cwallet_accessories",$mData  ) - jumlah("keluar", "cwallet_accessories",$mData   );
                        $cwallet_insurance      = jumlah("masuk", "cwallet_insurance",$mData    ) - jumlah("keluar", "cwallet_insurance",$mData     );

?>
                                <form role="form" action="redeem.php" method="post" class="login-form">
                                    <div class="form-group">
                                            <hr>
                                            <span class="small">Select Redeem Category : </span>
                                            <div class="form-group text-left col-md-12" style="pading-bottom:100px; display:block;">
                                                    <div class="small col-xs-12 col-md-5" style="display:inline-block;  vertical-align:middle;  text-align:left; margin:2px;    ">
                                                        <input type="radio" id="carwash"        onclick="click_carwash(this.value)"       name="redeem_cat"      <?= $cb1." ".$dis1 ?> >       <i class="<?= $s1 ?> fa fa-tint fa-1x"                 title="Carwash"></i>         <span class="small">Carwash            </span>
                                                    </div>             
                                                    <div class="small col-xs-12 col-md-5" style="display:inline-block;  vertical-align:middle;  text-align:left; margin:2px;    ">
                                                        <input type="radio" id="polish"         onclick="click_polish(this.value)"        name="redeem_cat"      <?= $cb2." ".$dis2 ?> >       <i class="<?= $s2 ?> fa fa-star-half-stroke fa-1x"     title="Polish"></i>          <span class="small">Car Wax & Polish       </span>
                                                    </div>             
                                                    <div class="small col-xs-12 col-md-5" style="display:inline-block;  vertical-align:middle;  text-align:left; margin:2px;    ">
                                                        <input type="radio" id="repair"         onclick="click_repair(this.value)"        name="redeem_cat"      <?= $cb3." ".$dis3 ?> >       <i class="<?= $s3 ?> fa fa-wrench fa-1x"               title="Repair"></i>          <span class="small">Car Repair         </span>
                                                    </div>             
                                                    <div class="small col-xs-12 col-md-5" style="display:inline-block;  vertical-align:middle;  text-align:left; margin:2px;    ">
                                                        <input type="radio" id="accessories"    onclick="click_accessories(this.value)"   name="redeem_cat"      <?= $cb4." ".$dis4 ?> >       <i class="<?= $s4 ?> fa fa-magic fa-1x"                    title="Accessories"></i>     <span class="small">Car Accessories    </span>
                                                    </div>             
                                                    <div class="small col-sm-12 col-md-5" style="display:inline-block;  vertical-align:middle;  text-align:left; margin:2px;    ">
                                                        <input type="radio" id="insurance"      onclick="click_insurance(this.value)"     name="redeem_cat"      <?= $cb5." ".$dis5 ?> >       <i class="<?= $s5 ?> fa fa-shield fa-1x"                 title="Insurance"></i>       <span class="small">Car Insurance      </span>
                                                    </div>             
                                            </div>

                                            <div class="input-group" id="div-carwash">
                                                <span class="input-group-addon">
                                                  <div Class="text-left">  
                                                        <strong>Carwash</strong><br><br><span class="small">Availabe Balance</span><br><span style="font-size:20px; color:#FF0000">RM <?= number_format($cwallet_carwash,2)      ?></span>
                                                  </div>
                                                </span>
    			                    		    <input type="number" name="ab_carwash" value="" placeholder="Amount (RM)" class="small form-control input-lg " id="inp-carwash"    >
                                                <button id="btnCarwash" class="btn btn-danger" type="button">+ Add to Redeem</button> 
                                            </div>
                                            <div class="form-group input-group col-sm-12 col-md-12"  id="div-polish">
                                                <span class="input-group-addon">
                                                  <div Class="text-left">  
                                                        <strong>Wax & Polish</strong><br><br><span class="small">Availabe Balance</span><br><span style="font-size:20px; color:#FF0000">RM <?= number_format($cwallet_polish,2)       ?></span>
                                                  </div>
                                                </span>
    			                    		    <input type="number" name="ab_polish" value="" placeholder="Amount (RM)" class="small form-control input-lg " id="inp-polish"    >
                                                <button id="btnPolish" class="btn btn-danger" type="button">+ Add to Redeem</button> 
                                            </div>
                                            <div class="form-group input-group col-sm-12 col-md-12"  id="div-repair">
                                                <span class="input-group-addon">
                                                  <div Class="text-left">  
                                                        <strong>Car Repair</strong><br><br><span class="small">Availabe Balance</span><br><span style="font-size:20px; color:#FF0000">RM <?= number_format($cwallet_repair,2)       ?></span>
                                                  </div>
                                                </span>
    			                    		    <input type="number" name="ab_repair" value="" placeholder="Amount (RM)" class="small form-control input-lg " id="inp-repair"    >
                                                <button id="btnRepair" class="btn btn-danger" type="button">+ Add to Redeem</button> 
                                            </div>
                                            <div class="form-group input-group col-sm-12 col-md-12"  id="div-accessories">
                                                <span class="input-group-addon">
                                                  <div Class="text-left">  
                                                        <strong>Accessories</strong><br><br><span class="small">Availabe Balance</span><br><span style="font-size:20px; color:#FF0000">RM <?= number_format($cwallet_accessories,2)  ?></span>
                                                  </div>
                                                </span>
    			                    		    <input type="number" name="ab_accessories" value="" placeholder="Amount (RM)" class="small form-control input-lg " id="inp-accessories"    >
                                                <button id="btnAccessories" class="btn btn-danger" type="button">+ Add to Redeem</button> 
                                            </div>
                                            <div class="form-group input-group col-sm-12 col-md-12"  id="div-insurance">
                                                <span class="input-group-addon">
                                                  <div Class="text-left">  
                                                        <strong>Car Insurance</strong><br><br><span class="small">Availabe Balance</span><br><span style="font-size:20px; color:#FF0000">RM <?= number_format($cwallet_insurance,2)    ?></span>
                                                  </div>
                                                </span>
    			                    		    <input type="number" name="ab_insurance" value="" placeholder="Amount (RM)" class="small form-control input-lg " id="inp-insurance"    >
                                                <button id="btnInsurance" class="btn btn-danger" type="button">+ Add to Redeem</button> 
       			                            </div>
        			                       
        			                        <hr>

                                            <table class="small table" border="0">
                                                <thead >
                                                    <tr class="small">
                                                        <th scope="col"                     >Redeem Items</th>
                                                        <th scope="col" class="text-right"  >Amount (RM)</th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                  <input name="totalRedeemRow"  type="hidden" value="0" id="redeemRowID"/>
                                                    <tr >
                                                        <td></td>
                                                        <td class="text-right">
                                                            <span class="small text-left">Total  (RM)</span> 
                                                            <strong style="font-size:18px; padding-left:10px;" ><span id="sum_row"></span></strong>
                                                            <input type="hidden" value="" id="sum_value_row" name="sum_value_row">
                                                        </td>
                                                    </tr>
                                                </tbody>    
                                            </table>
        			                        <hr>
        			                        <button type="submit" class="btn btn-danger" style="background-color: #09C;" name="redeem"><i class="fa fa-gift fa-1x"></i> Redeem Now</button>
        			                    
        			                </div>
			                    </form>
<?php
                                echo "<script type=\"text/javascript\">                                                                 \n";
                                echo "          window.onload = function() {                                                            \n";
                                echo "              $('#div-carwash'        ).hide();                                                   \n";
                                echo "              $('#div-polish'         ).hide();                                                   \n";
                                echo "              $('#div-repair'         ).hide();                                                   \n";
                                echo "              $('#div-accessories'    ).hide();                                                   \n";
                                echo "              $('#div-insurance'      ).hide();                                                   \n";
                                echo "                };                                                                                \n";
                                echo "          function click_carwash() {                                                              \n";
                                echo "              $('#div-carwash'        ).show();                                                   \n";
                                echo "              $('#div-polish'         ).hide();                                                   \n";
                                echo "              $('#div-repair'         ).hide();                                                   \n";
                                echo "              $('#div-accessories'    ).hide();                                                   \n";
                                echo "              $('#div-insurance'      ).hide();                                                   \n";
                                echo "          }                                                                                       \n";
                                echo "          function click_polish() {                                                               \n";
                                echo "              $('#div-carwash'        ).hide();                                                   \n";
                                echo "              $('#div-polish'         ).show();                                                   \n";
                                echo "              $('#div-repair'         ).hide();                                                   \n";
                                echo "              $('#div-accessories'    ).hide();                                                   \n";
                                echo "              $('#div-insurance'      ).hide();                                                   \n";
                                echo "          }                                                                                       \n";
                                echo "          function click_repair() {                                                               \n";
                                echo "              $('#div-carwash'        ).hide();                                                   \n";
                                echo "              $('#div-polish'         ).hide();                                                   \n";
                                echo "              $('#div-repair'         ).show();                                                   \n";
                                echo "              $('#div-accessories'    ).hide();                                                   \n";
                                echo "              $('#div-insurance'      ).hide();                                                   \n";
                                echo "          }                                                                                       \n";
                                echo "          function click_accessories() {                                                          \n";
                                echo "              $('#div-carwash'        ).hide();                                                   \n";
                                echo "              $('#div-polish'         ).hide();                                                   \n";
                                echo "              $('#div-repair'         ).hide();                                                   \n";
                                echo "              $('#div-accessories'    ).show();                                                   \n";
                                echo "              $('#div-insurance'      ).hide();                                                   \n";
                                echo "          }                                                                                       \n";
                                echo "          function click_insurance() {                                                            \n";
                                echo "              $('#div-carwash'        ).hide();                                                   \n";
                                echo "              $('#div-polish'         ).hide();                                                   \n";
                                echo "              $('#div-repair'         ).hide();                                                   \n";
                                echo "              $('#div-accessories'    ).hide();                                                   \n";
                                echo "              $('#div-insurance'      ).show();                                                   \n";
                                echo "          }                                                                                       \n";
                                echo "</script>                                                                                         \n";
                
?>                    

		                    </div>
<?php
                }   else    {
?>
                    <script type="text/javascript">
                        window.location.href='https://vip.wepayyourcost.com/?redeem=<?= $_GET['m'] ?>';
                    </script>
 <?php                       
                }   
             
            
        }   else    {
?>
                            <div class="form-bottom" style="background-color : transparent;">
                                <form role="form" action="login.php" method="post" class="login-form">
			                    	<div class="form-group">
			                    		<label class="sr-only" for="form-username">Username</label>
			                        	<input type="text" name="user" placeholder="Username" class="form-username form-control" id="form-username">
			                        </div>
			                        <div class="form-group">
			                        	<label class="sr-only" for="form-password">Password</label>
			                        	<input type="password" name="pass" placeholder="Password" class="form-password form-control" id="form-password">
			                        </div>
<?php
                                if ($host[0] == "vip")      {
                                            
                                    if (isset($_GET['redeem']))      {  
                                                        echo '<input type="hidden" name="redeem" value="'.$_GET['redeem'].'"> ';
                                                        echo '<button type="submit" class="btn btn-danger btn-primary" name="xyz">REDEEM Sign in</button>';
                                    }   else    {
                                                        echo '<button type="submit" class="btn btn-danger" style="background-color: #09C;" name="xyz">Sign in</button>';
                                    }
                                }   else    {
                                                        echo '<button type="submit" class="btn btn-danger" style="background-color: #FF0000;" name="submit_merchant"><span class="text-dark" style="padding-right:20px;">M E R C H A N T </span> Sign in</button>';
                                }
?>
			                    </form>
		                    </div>
<?php   }   ?>		                    
		                    <div class="text-center">
		                        <font align="center"color="#FFF"><strong>Copyright © 2024, WePayYourCost.</strong></font>
		                    </div>
		                        
		                    
                        </div>
                    </div>
                    

                </div>
            </div>


        </div>


        <!-- Javascript -->
        <script src="assets2/js/jquery-1.11.1.min.js"></script>
        <script src="assets2/bootstrap/js/bootstrap.min.js"></script>
        <script src="assets2/js/jquery.backstretch.min.js"></script>
        <script src="assets2/js/scripts.js"></script>
<script>
                                $('#btnCarwash').click(function() {  
                                    var val_carwash = document.getElementById("inp-carwash").value - 0;
                                    var valCarwash  = val_carwash.toFixed(2);    
                                    var redeemRowID = document.getElementById("redeemRowID").value - 0;
                                    var valRowID    = redeemRowID + 1;
                                    document.getElementById("redeemRowID").value = valRowID;
                                    $('<tr class="anim highlight "><td >Carwash</td>      <td class="text-right">' + valCarwash +'        <span onclick="DeleteRedeemRow(this)">  <i style="padding-left:10px;" class="text-danger fa-thin fa-solid fa-remove"></i></span><input type="hidden" class="sum_" value="'+ valCarwash +'" name="total_carwash_' + valRowID + '" ></td></tr>')                            
                                  	    .hide()                                                                            
                                  	    .prependTo('table tbody')                                                          
                                  	    .fadeIn("slow")                                                                    
                                        .addClass('normal'); 
                                    //clear inp carwash
                                        $('#inp-carwash').val('');
                                    // Sum Carwash
                                        var sumL = 0;                                                                                                   
                                        $('.sum_').each(function() {                                                                                    
                                            if(!isNaN(parseFloat($(this).val()))) sumL += Number($(this).val());                                        
                                        });                                                                                                             
                                        document.getElementById('sum_row').innerHTML = sumL.toFixed(2);                                                            
                                        $('#sum_value_row').val(sumL).toFixed(2);
                                });                                                                                 
                                $('#btnPolish').click(function() { 
                                    var val_polish  = document.getElementById("inp-polish").value - 0;
                                    var valPolish   =  val_polish.toFixed(2);
                                    var redeemRowID = document.getElementById("redeemRowID").value - 0;
                                    var valRowID    = redeemRowID + 1;
                                    document.getElementById("redeemRowID").value = valRowID;
                                  $('<tr class="anim highlight "><td >Polish</td>       <td class="text-right">' + valPolish + '        <span onclick="DeleteRedeemRow(this)">  <i style="padding-left:10px;" class="text-danger fa-thin fa-solid fa-remove"></i></span><input type="hidden" class="sum_" value="'+ valPolish +'" name="total_polish_' + valRowID + '" ></td></tr>')                            
                                  	.hide()                                                                            
                                  	.prependTo('table tbody')                                                          
                                  	.fadeIn("slow")                                                                    
                                    .addClass('normal');                                                            
                                    //clear inp polish                                    
                                        $('#inp-polish').val('');
                                    // Sum polish                                    
                                        var sumL = 0;                                                                                                   
                                        $('.sum_').each(function() {                                                                                    
                                            if(!isNaN(parseFloat($(this).val()))) sumL += Number($(this).val());                                        
                                        });                                                                                                             
                                        document.getElementById('sum_row').innerHTML = sumL.toFixed(2);                                                            
                                        $('#sum_value_row').val(sumL).toFixed(2);
                                });                                                                                 
                                $('#btnRepair').click(function() { 
                                    var val_repair  = document.getElementById("inp-repair").value - 0;
                                    var valRepair   = val_repair.toFixed(2);
                                    var redeemRowID = document.getElementById("redeemRowID").value - 0;
                                    var valRowID    = redeemRowID + 1;
                                    document.getElementById("redeemRowID").value = valRowID;
                                  $('<tr class="anim highlight "><td >Repair</td>       <td class="text-right">' + valRepair + '        <span onclick="DeleteRedeemRow(this)">  <i style="padding-left:10px;" class="text-danger fa-thin fa-solid fa-remove"></i></span><input type="hidden" class="sum_" value="'+ valRepair +'" name="total_repair_' + valRowID + '" ></td></tr>')                            
                                  	.hide()                                                                            
                                  	.prependTo('table tbody')                                                          
                                  	.fadeIn("slow")                                                                    
                                    .addClass('normal');                                                            
                                    //clear inp repair
                                        $('#inp-repair').val('');
                                    // Sum repair                                    
                                        var sumL = 0;                                                                                                   
                                        $('.sum_').each(function() {                                                                                    
                                            if(!isNaN(parseFloat($(this).val()))) sumL += Number($(this).val());                                        
                                        });                                                                                                             
                                        document.getElementById('sum_row').innerHTML = sumL.toFixed(2);                                                            
                                        $('#sum_value_row').val(sumL).toFixed(2);
                                });                                                                                 
                                $('#btnAccessories').click(function() {   
                                    var val_accessories = document.getElementById("inp-accessories").value - 0;
                                    var valAccessories  = val_accessories.toFixed(2);
                                    var redeemRowID = document.getElementById("redeemRowID").value - 0;
                                    var valRowID    = redeemRowID + 1;
                                    document.getElementById("redeemRowID").value = valRowID;
                                  $('<tr class="anim highlight "><td >Accessories</td>  <td class="text-right">' + valAccessories + '   <span onclick="DeleteRedeemRow(this)">  <i style="padding-left:10px;" class="text-danger fa-thin fa-solid fa-remove"></i></span><input type="hidden" class="sum_" value="'+ valAccessories +'" name="total_accessories_' + valRowID + '" ></td></tr>')                            
                                  	.hide()                                                                            
                                  	.prependTo('table tbody')                                                          
                                  	.fadeIn("slow")                                                                    
                                    .addClass('normal');                                                            
                                    //clear inp Accessories
                                        $('#inp-accessories').val('');
                                    // Sum Accessories                                    
                                        var sumL = 0;                                                                                                   
                                        $('.sum_').each(function() {                                                                                    
                                            if(!isNaN(parseFloat($(this).val()))) sumL += Number($(this).val());                                        
                                        });                                                                                                             
                                        document.getElementById('sum_row').innerHTML = sumL.toFixed(2);                                                            
                                        $('#sum_value_row').val(sumL).toFixed(2);
                                });                                                                                 
                                $('#btnInsurance').click(function() {    
                                    var val_insurance   = document.getElementById("inp-insurance").value - 0;
                                    var valInsurance    = val_insurance.toFixed(2);
                                    var redeemRowID = document.getElementById("redeemRowID").value - 0;
                                    var valRowID    = redeemRowID + 1;
                                    document.getElementById("redeemRowID").value = valRowID;
                                  $('<tr class="anim highlight "><td >Insurance</td>    <td class="text-right">' + valInsurance + '     <span onclick="DeleteRedeemRow(this)">  <i style="padding-left:10px;" class="text-danger fa-thin fa-solid fa-remove"></i></span><input type="hidden" class="sum_" value="'+ valInsurance +'" name="total_insurance_' + valRowID + '" ></td></tr>')                            
                                  	.hide()                                                                            
                                  	.prependTo('table tbody')                                                          
                                  	.fadeIn("slow")                                                                    
                                    .addClass('normal');                                                            
                                    //clear inp insurance
                                        $('#inp-insurance').val('');
                                    // Sum insurance
                                        var sumL = 0;                                                                                                   
                                        $('.sum_').each(function() {                                                                                    
                                            if(!isNaN(parseFloat($(this).val()))) sumL += Number($(this).val());                                        
                                        });                                                                                                             
                                        document.getElementById('sum_row').innerHTML = sumL.toFixed(2);                                                            
                                        $('#sum_value_row').val(sumL).toFixed(2);
                                });  
                                
                                // Delete Redeem Row
                                function DeleteRedeemRow(o) {
                                    //no clue what to put here?
                                        var p=o.parentNode.parentNode;
                                        p.parentNode.removeChild(p);
                                    //Update Total Amount
                                        var sumL = 0;                                                                                                   
                                        $('.sum_').each(function() {                                                                                    
                                            if(!isNaN(parseFloat($(this).val()))) sumL += Number($(this).val());                                        
                                        });                                                                                                             
                                        document.getElementById('sum_row').innerHTML = sumL.toFixed(2);                                                            
                                        $('#sum_value_row').val(sumL).toFixed(2);
                                }
</script>        
        <!--[if lt IE 10]>
            <script src="assets/js/placeholder.js"></script>
        <![endif]-->

    </body>

</html>