<?php
session_start();
$key = md5(date("Y-m-d").":".$_SERVER['REMOTE_ADDR']);
if (isset($_SESSION['aW1iZXN0cmEuY29tLm15']) <> $key) {
    header("location:".$_SERVER['REQUEST_SCHEME']."://".$_SERVER['SERVER_NAME']); // cara baru !
} else {
    require "conn.php";
    $title          = 'Print Merchant Pay';
    $certTITLE      = $title;
    $id             = $_GET['id']; 
} 
?>

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>WePayYourCost | Merchant <?= ucwords(strtolower($id)) ?></title>

    <link rel="shortcut icon" href="assets2/ico/wepayyourcost.png">
    <!-- BOOTSTRAP STYLES-->
    <link href="assets/css/bootstrap.css" rel="stylesheet" />
     <!-- FONTAWESOME STYLES-->
    <link rel="stylesheet" href="/assets2/fontawesome/css/all.css">  
<!--    <link href="assets/css/font-awesome.css" rel="stylesheet" />    -->
     <!-- MORRIS CHART STYLES-->
    <link href="assets/js/morris/morris-0.4.3.min.css" rel="stylesheet" />
        <!-- CUSTOM STYLES-->
    <link href="assets/css/custom.css" rel="stylesheet" />


     <!-- Google Font: Source Sans Pro -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">

<style>
    @media print {
   body {
      -webkit-print-color-adjust: exact;
   }
}
</style>

</head>
<body>
<div class="wrapper">
  <!-- Main content -->
  
<?php
    
    $id     = mysqli_real_escape_string($con, $_GET['id']);
    $result = mysqli_query($con, "SELECT * FROM merchant WHERE id='".$id."'");
    $rows   = mysqli_fetch_array($result);  

    $resultCheck    = mysqli_num_rows($result);


	if ($resultCheck < 1) {
?>
            <div class="row">
                <div class="col-12">
                    <div class="callout callout-info">
                        <h5><i class="fas fa-info"></i> <span style="padding-left:20px;">Sorry, no record found. </span></h5>
                    </div>
                </div><!-- /.col -->
            </div><!-- /.row -->
             <!-- /.container-fluid -->
<?php	    
	} else  {


// if (isset($_SESSION['u_id'])) {
?>


   


                    <!-- Main content -->
    <section class="invoice">
        <div class="p-3 mb-3">
                      <!-- title row -->
            <div class="inner-bg">
                <div class="container">
                    <div class="row">                      
                        <div class="col-12 bg-secondary" >
                            <img src="wepaylogo.png" width="650" height="auto" alt="WePayYourCost" style="  display: block;  margin-left: auto;  margin-right: auto;  width: 50%;">
                       
                            <!-- Table row -->
                            <div class="row pt-5" style="position: relative;  text-align: center;">

                                        <img  style="padding-top:100px;" width="100%" height="auto" src="temp/<?= $id ?>.png" >
                                
                                      <div class="form-group col-md-12" style="position: absolute;  top: 30px; width: 100%;" >
        <?php

                                        if (($rows['carwash'])      == 1)   { $s1 = "background-color:#ff0000; "; $T1 = "  text-decoration: underline solid red 25%; "; } else { $s1 = "background-color:#000000; "; $T1 = "";} 
                                        if (($rows['polish'])       == 1)   { $s2 = "background-color:#ff0000; "; $T2 = "  text-decoration: underline solid red 25%; "; } else { $s2 = "background-color:#000000; "; $T2 = "";}
                                        if (($rows['repair'])       == 1)   { $s3 = "background-color:#ff0000; "; $T3 = "  text-decoration: underline solid red 25%; "; } else { $s3 = "background-color:#000000; "; $T3 = "";} 
                                        if (($rows['accessories'])  == 1)   { $s4 = "background-color:#ff0000; "; $T4 = "  text-decoration: underline solid red 25%; "; } else { $s4 = "background-color:#000000; "; $T4 = "";}
                                        if (($rows['insurance'])    == 1)   { $s5 = "background-color:#ff0000; "; $T5 = "  text-decoration: underline solid red 25%; "; } else { $s5 = "background-color:#000000; "; $T5 = "";} 

                                         echo '<div class="col-md-2" style="display:inline-block; margin:5px; " > <div class="col-md-12 " style="border:1px solid; padding:20px; border-radius: 25px; color:#FFFFFF; '.$s1.'"> <label for="carwash">       <i class="fa fa-tint fa-3x" style="padding-left:10px; padding-right:10px;"               ></i> </label>    </div> <h5 style="'.$T1.'" >Carwash        </h5></div>'; 
                                         echo '<div class="col-md-2" style="display:inline-block; margin:5px; " > <div class="col-md-12 " style="border:1px solid; padding:20px; border-radius: 25px; color:#FFFFFF; '.$s2.'"> <label for="polish">        <i class="fa fa-star-half-stroke fa-3x"                                                  ></i> </label>    </div> <h5 style="'.$T2.'" >Wax & Polish   </h5></div>'; 
                                         echo '<div class="col-md-2" style="display:inline-block; margin:5px; " > <div class="col-md-12 " style="border:1px solid; padding:20px; border-radius: 25px; color:#FFFFFF; '.$s3.'"> <label for="repair">        <i class="fa fa-wrench fa-3x"                                                            ></i> </label>    </div> <h5 style="'.$T3.'" >Car Repair     </h5></div>'; 
                                         echo '<div class="col-md-2" style="display:inline-block; margin:5px; " > <div class="col-md-12 " style="border:1px solid; padding:20px; border-radius: 25px; color:#FFFFFF; '.$s4.'"> <label for="accessories">   <i class="fa fa-magic fa-3x"                                                             ></i> </label>    </div> <h5 style="'.$T4.'" >Accessories    </h5></div>'; 
                                         echo '<div class="col-md-2" style="display:inline-block; margin:5px; " > <div class="col-md-12 " style="border:1px solid; padding:20px; border-radius: 25px; color:#FFFFFF; '.$s5.'"> <label for="insurance">     <i class="fa fa-shield fa-3x"                                                            ></i> </label>    </div> <h5 style="'.$T5.'" >Insurance      </h5></div>'; 
        ?>
                                    </div>
                            </div>
                        </div>
                      
                       <footer style="position: fixed; padding: 10px 10px 0px 10px; bottom: 0; width: 100%; height: 100%px; ">
                                      <div class="row">
                                      <!-- info row -->
                                      <div class="row invoice-info pt-5 text-center">
                                        <div class="col-sm-12 invoice-col">
                                          <span class="small">Merchant :</span> <br>
                                          <address>
                                            <strong><?= strtoupper($rows['nama']) ?> </strong>(<?= $rows['roc']  ?>) <br>
                                                <div style="display:inline-block;">
                                                    <span class="small"><i class="fa fa-envelope"   style="padding-right:5px;"></i><?= $rows['email']         ?>       </span>       <br>
                                                    <span class="small"><i class="fa fa-phone"      style="padding-right:5px;"></i><?= $rows['telefon']         ?>    </span>  
                                                </div>
                                         </address>
                                        </div>
                                        <!-- /.col -->
                                      </div>
                                        </div>
                                        <!-- /.col -->
                      </footer>    
                      <!-- /.row -->

                      <!-- this row will not appear when printing -->
                    </div>
                </div>
            </div>
        </div>
    </section> 
  <!-- /.content -->
  
 <?php
	}
 ?>
</div>
<!-- ./wrapper -->
<!-- Page specific script -->
<script>
  window.addEventListener("load", window.print());
</script>
</body>
</html>