<?php

include("_global.php");
//include("add-ons/Pixel.php");

$decline_link = $configs->path . "upsell2.php?customerId=" . $_GET["customerId"] . "&orderId=" . $_GET["orderId"] . "&declined=1";

// if (isset($_SESSION["added_upsell"]) && $_SESSION["added_upsell"] == true) {
//     header("Location: " . $configs->path . "confirmation.php");
// }

?>
<!doctype html>
<html>
<head>
   <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
   <title><?php echo $configs->page_title; ?></title>
   <meta name="description" content="<?php echo $configs->step1_name; ?>" />

   <meta charset="utf-8" />
   <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
   <meta http-equiv="content-language" content="en-us" />
   <meta name="apple-mobile-web-app-capable" content="yes" />
   <meta name="apple-mobile-web-app-status-bar-style" content="black" />
   <meta name="HandheldFriendly" content="true" />
   <meta name="viewport" content="width=device-width,user-scalable=no" />
   <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />

   <!-- google fonts -->
   <link rel="preconnect" href="https://fonts.googleapis.com/">
   <link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>
   <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;700&amp;display=swap" rel="stylesheet">
   <!-- CSS -->
   <link rel="stylesheet" href="<?php echo $configs->root_path . "/assets/css/loading.css"; ?>">
   <link rel="shortcut icon" type="/assets/image/x-icon" href="<?php echo $configs->root_path . "/assets/brand/favicon.png"; ?>">

   <!-- Bootstrap CSS -->
   <link href="<?php echo $configs->root_path . "/assets/css/upsells/app.css"; ?>" rel="stylesheet">
   <link rel="stylesheet" href="<?php echo $configs->root_path . "/assets/css/upsells/bootstrap.min.css"; ?>">
   <link rel="stylesheet" href="<?php echo $configs->root_path . "/assets/css/upsells/custom.css"; ?>">
   <link rel="stylesheet" href="<?php echo $configs->root_path . "/assets/css/upsells/responsive.css"; ?>">
   <?php include_once('./sentry.php'); ?>
   <style>
      .products_left ul {
         list-style: none;
         }

         .products_left ul li:before {
         content: '✓';
         }

         .capsule-benefits {
            margin-bottom: 20px !important;
         }

         .capsule-benefits p {
            margin: 0;
         }

         .capsule-benefits p:before {
            content: '✓';
         }

   </style>
</head>
<body class="upsell-1"> 
   <div class="header_upsell">
      <div class="container text-center">
         
      </div>
      <!-- <div><img src="<?php echo $configs->root_path . "/assets/images/bonus_2/1.png"; ?>" alt="" class="d-block mx-auto"></div> -->
   </div>
   <div class="body_content text-center upsell2">
      <div class="container">
         <div class="offer_tag"><img src="<?php echo $configs->root_path . "/assets/images/special-offer-tag.png"; ?>" alt=""></div>
         <h5>This Offer Won’t Last — Limited Quantities Available!</h5>
         <h1>Extend Your Blood Sugar Support All Day Long — Even Between Cups of Coffee</h1>
         <p>
            You’ve taken the first step with Hello Healthy Glucose Coffee. Now, get <strong>round-the-clock support</strong> with GlucoTrojan™ Capsules 
            — the same science-backed formula in an easy-to-take capsule for continued support between meals
         </p>
         <div class="product_wrap clearfix">
            <div class="product_left">
               <span class="badge"><img src="<?php echo $configs->root_path . "/assets/images/badge.png"; ?>" alt=""></span>
               <div class="products_left">
                  <img src="<?php echo $configs->root_path . "/assets/brand/coffee_capsule.png"; ?>" class="pack2" style="max-width: 60%;">
                  <!-- <ul class="capsule-benefits">
                     <li>
                        <span style="margin-bottom: 8px;"><strong>Blocks</strong> sugar spikes before they start.</span>
                     </li>
                     <li>
                        <span style="margin-bottom: 8px;"><strong>Supports</strong> insulin sensitivity for better glucose control.</span>
                     </li>
                     <li>
                        <span><strong>Balances</strong> blood sugar all day — even when you’re not drinking coffee.</span>
                     </li>
                  </ul> -->
               </div>
            </div>
            <div class="product_content">
               <h2>ESSENTIAL SUPPORT IN CAPSULE FORM</h2>
               <div class="price_tagD">
                  <!-- <span class="pic1"><img src="<?php echo $configs->root_path . "/assets/images/belly.png"; ?>" alt=""></span> -->
                  <div class="pricepic">Off <br>75%</div>
               </div>
               <div class="pulse">
                  <div class="big_text">PROPRIETARY <span>BLEND</span></div>
               </div>
               <div class="price_area"><strong>Get two bottles for just</strong> <br><span>$<?php echo number_format((float)$configs->upsells[0]['price_per'], 2, '.', ''); ?></span> each</div>
            </div>
            <div class="capsule-benefits">
               <p>
                  <strong>Blocks</strong> sugar spikes before they start.
               </p>
               <p>
                  <strong>Supports</strong> insulin sensitivity for better glucose control.
               </p>
               <p>
                  <strong>Balances</strong> blood sugar all day — even when you’re not drinking coffee.
               </p> 
            </div>
            <p>
               Formulated with the same science-backed ingredients as our best-selling GlucoTrojan™ coffee — including <b>Reducose® White Mulberry, Mangiferin, Banana Stem Extract,</b> and <b>ABALife™ Fig Extract </b>— in an easy-to-take capsule format.
               <br /> Ideal for continued support between meals or before dinner to help maintain stable blood sugar, manage carb absorption, and support insulin sensitivity.* 
            </p>
         </div>
         <div class="left_area">
            <div class="only_text">ONLY 18 BOTTLES LEFT AT THIS PRICE!</div>
            <center><button id="submit-checkout" type="submit" class="checkout_btn pulse" onClick="processUpsell();">YES! ADD CAPSULES TO MY ORDER</button></center>
            <p>Backed by the same satisfaction guarantee as your coffee order — love it or get your money back.</p>
            <br><br>
            <div class="dont_text">
               <i><img src="<?php echo $configs->root_path . "/assets/images/close.png"; ?>" alt=""></i>
               <span><a href="<?php echo $decline_link; ?>"  style="text-decoration: none;color:#8e8e8e;">No, I DON’T WANT TO OPTIMIZE MY BLOOD SUGAR.</a></span>
            </div>
            <div class="pic2"><img src="<?php echo $configs->root_path . "/assets/images/pic3.png"; ?>" alt=""></div>
         </div>
      </div>
   </div>
   <div class="footer text-center">
      <div class="container">
         <ul class="terms-links">
            <li><a href="javascript:void(0);" onclick="openNewWindow('./disclosures/terms.php','modal');">Terms and Conditions |</a></li>
            <li><a href="javascript:void(0);" onclick="openNewWindow('./disclosures/privacy.php','modal');">Privacy Policy |</a></li>
            <li><a href="javascript:void(0);" onclick="openNewWindow('./disclosures/contact.php','modal');">Contact us</a></li>
         </ul>
         <span>
            &copy; <script> var date = new Date(); document.write(date.getFullYear())</script> All Rights Reserved
         </span>
      </div>
   </div>
   <!--popup processing wrapper-->
   <section id="loading-indicator" class="popup-loading-wrapper" style="display: none">
      <div class="popup">
         <img src="<?php echo $configs->root_path . "/assets/images/icon-lock.png"; ?>" alt="" class="lock-image"/>
         <p>Please wait a moment</p>
         <h3>Your Order is Now Being Processed</h3>
         <img src="<?php echo $configs->root_path . "/assets/images/icon-loading.png"; ?>" alt="" class="loading-image"/>
      </div>
   </section>
   <!--end popup processing wrapper-->
   <form method="post" action="<?php echo $configs->path; ?>app/src/add_upsell.php" id="with_upsell_form">
      <input type='hidden' name='token' value='<?php echo $_SESSION["token"]; ?>'>
      <input type="hidden" name="device" value="desktop">
      <input type="hidden" name="customer_id" value="<?php echo $_GET["customerId"]; ?>">
      <input type="hidden" name="previous_order_id" value="<?php echo $_GET["orderId"]; ?>">
      <input type="hidden" name="__next_upsell" value="upsell2">
      <input type="hidden" name="add_upsell" id="add_upsell" value="true">
   </form>
   <script src="<?php echo $configs->root_path . "/assets/js/jquery.min.js"; ?>"></script>
   <script>
      function processUpsell() {
         $('#loading-indicator').css( 'display', 'block' );
         $('#with_upsell_form').submit();
      }
      
      $(document).on('click', '#app_common_modal_close', function() {
         $('#app_common_modal').remove();
      });	

      function openNewWindow(page_url, type, window_name, width, height, top, left, features) {
         if (!type) {
            type = 'popup';
         }
         if (!width) {
            width = 480;
         }
         if (!height) {
            height = 480;
         }
         if (!top) {
            top = 50;
         }
         if (!left) {
            left = 50;
         }
         if (!features) {
            features = 'resizable,scrollbars';
         }

         if (type == 'popup') {
            var settings = 'height=' + height + ',';
            settings += 'width=' + width + ',';
            settings += 'top=' + top + ',';
            settings += 'left=' + left + ',';
            settings += features;

            win = window.open(page_url, window_name, settings);
            win.window.focus();
         } else if (type == 'modal') {
            var html = '';
            html += '<div id="app_common_modal">';
            html += '<div class="app_modal_body"><a href="javascript:void(0);" id="app_common_modal_close">X</a><iframe src="' + page_url + '" frameborder="0"></iframe></div>';
            html += '</div>';

            if (!$('#app_common_modal').length) {

                  $('body').append(html);
            }
            $('#app_common_modal').fadeIn();
         }

      }
   </script>
   <?php
    if ($_SESSION["scrub"] === false) {
        if (!empty($_SESSION['meta_pixel_id']) || !empty($_SESSION['google_pixel_id'])) {

            $pixelID = empty($_SESSION['meta_pixel_id']) ? empty($_SESSION['google_pixel_id']) : $_SESSION['meta_pixel_id'];
            $totalValue = empty($_SESSION['total']) ? 0.00 : $_SESSION['total'];

            echo <<<EOD
        <!-- Meta Pixel Code -->
        <script>
            !function (f, b, e, v, n, t, s) {
                if (f.fbq) return; n = f.fbq = function () {
                    n.callMethod ?
                    n.callMethod.apply(n, arguments) : n.queue.push(arguments)
                };
                if (!f._fbq) f._fbq = n; n.push = n; n.loaded = !0; n.version = '2.0';
                n.queue = []; t = b.createElement(e); t.async = !0;
                t.src = v; s = b.getElementsByTagName(e)[0];
                s.parentNode.insertBefore(t, s)
            }(window, document, 'script',
                'https://connect.facebook.net/en_US/fbevents.js');
            fbq('init', '$pixelID');
            fbq('track', 'PageView');
            fbq('track', 'Purchase', {
                value: '150.00',
                currency: 'USD'
            });
        </script>
        <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=$pixelID&ev=PageView&noscript=1" /></noscript>
        <!-- End Meta Pixel Code -->
        EOD;
        }
    }
    ?>

    <?php
    if (!empty($_SESSION['subaff_cid']) && empty($_SESSION["scrub"])) {
        $subaff_cid = $_SESSION['subaff_cid'];

        echo <<<EOD
            <!-- SubAffiliate Code -->
            <script type="text/javascript" async>
                !function (b, e, v, t, s) {
                t = b.createElement(e); t.async = !0;
                t.src = v; s = b.getElementsByTagName(e)[0];
                s.parentNode.insertBefore(t, s)
                }
                (document, 'script', 'https://cdnwb.com/v1/cdn/$subaff_cid.js');
            </script>
            <!-- End SubAffiliate Code -->
            EOD;
    }
    ?>   
</body>
</html>