<!doctype html>
<html lang="en" class="w-[640px]">
   <head>
      <?php echo view('user/layout/head');?>
   </head>
   <body class="section-overflow">
      <!--banner start -->
      <section class="banner-bg overall-bg ">
         <div class="container">
         <?php echo view('user/layout/header');?>
         </div>
         <section class="dash-wrap referral">
            <div class="container">
               <div class="row">
               <?php 
                  $referral_code=base_url().'/register/'.$user_details->invitation_code;
                  $referral_info = $this->db->table("uusers")->where('uusersid',$user_details->referral_id)->get()->getRow();
                  if($referral_info)
                  {
                     $upline_code=$referral_info->username;
                     $upline_url=base_url().'/register/'.$referral_info->invitation_code;
                  }
                  else
                  {
                     $upline_code='-- NIL --';
                     $upline_url='-- NIL--';
                  }
                  
                  ?>
                  <div class="col-lg-12">
                     <div class="qr-code text-center">
                     <img src="https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=<?php echo $referral_code;?>" alt="referral" style="border:1px solid;margin-bottom:10px;">
                     </div>
                  </div>
                  <div class="col-lg-12">
                     <div class="title text-center">
                        <h4 class="text-white ">Refer Friends To Enjoy More Rewards</h4>
                        <p class="text-white-50"> Invite friends and earn money! When a member you've referred activates their account, you will receive bonuses based on your ranking.</p>
                        <div class="ref-form-list">
                           <div class="ref-form d-flex align-items-center">
                              <div class="ref-content text-start">
                                 <p class="text-white mb-0">My Referral Code</p>
                                 <span id="link1" style="display:none"><?php echo $user_details->invitation_code;?></span>
                                 <h5 class="text-white"><?php echo $user_details->invitation_code;?></h5>
                              </div>
                              <div class="ref-sec-copy ref-copy">
                              <a  href="javascript:void(0)" class="text-decoration-none"  onclick="javascript:copyToClipboard1('#link1')"><i class="fa-regular fa-copy "></i></a>
                              </div>
                           </div>
                           <div class="ref-form d-flex align-items-center mt-4">
                              <div class="ref-content text-start">
                                 <p class="text-white mb-0">My Referral Code</p>
                                 <h5 class="text-white" style="word-break:break-all;"><?php echo base_url();?>/register/<?php echo $user_details->invitation_code;?></h5>
                                 <span id="link" style="display:none"><?php echo base_url();?>/register/<?php echo $user_details->invitation_code;?></span>
                              </div>
                              <div class="ref-sec-copy">
                              <a href="javascript:void(0);" class="text-decoration-none" onclick="javascript:copyToClipboard('#link')"><i class="fa-regular fa-copy "></i></a>
                              </div>
                           </div>
                        </div>


                        <div style="clear:both;"><br></div>
                        <h4 class="text-white">Upline Information</h4>
                        <br>

                        <div class="ref-form-list">
                           <div class="ref-form d-flex align-items-center">
                              <div class="ref-content text-start">
                                 <p class="text-white mb-0">Upline username</p>
                                 <h5 class="text-white"><?php echo $upline_code;?></h5>
                              </div>
                              
                           </div>
                        </div>


                     </div>
                  </div>
               </div>
            </div>
         </section>
         <!--footer start -->
         <?php echo view('user/layout/footer');?>
         <!--footer end -->
      </section>
      <?php echo view('user/layout/footer-script');?>

      <script>
         AOS.init({
         });
      </script>

      <script>

      function copyToClipboard(element) {
      var $temp = $("<input>");
      $("body").append($temp);
      $temp.val($(element).html()).select(); //Note the use of html() rather than text()
      document.execCommand("copy");
      $temp.remove();
      
      }
      

      function copyToClipboard1(element) {
      var $temp = $("<input>");
      $("body").append($temp);
      $temp.val($(element).html()).select(); //Note the use of html() rather than text()
      document.execCommand("copy");
      $temp.remove();
      }
      </script>

   </body>
</html>
