<!doctype html>
<html lang="en" translate="no" class="w-[640px] mx-auto md:w-full">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Referral</title>
     <?php echo view('user/layout/head');?>
   </head>
   <body class="reg-overflow">
      <section class="dash-banner-bg banner-bg">
         <div class="container">
         <!---header start---->
       <?php echo view('user/layout/header');?>
         <!---header end---->
         <!---banner start---->
<div class="dash-wrap">
   <div class="title text-center py-2">
      <h2 class="text-primary ">Referral</h2>
   </div>
   <div class="row">
      <div class="col-lg-12">
         <div class="qr-code text-center">
            <?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--';
             }
             
            ?>
            <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>
                     <h5 class="text-white" ><?php echo $user_details->invitation_code;?></h5>
                  </div>
                  <span id="link1" style="display:none"><?php echo $user_details->invitation_code;?></span>
                  <div class="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 copy" style="word-break:break-all;" ><?php echo base_url();?>/register/<?php echo $user_details->invitation_code;?></h5>
                  </div>
                  <span id="link" style="display:none"><?php echo base_url();?>/register/<?php echo $user_details->invitation_code;?></span>
                  <div class="ref-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>
</div>
      </section>
      <?php echo view('user/layout/footer');?> 
      <?php echo view('user/layout/footer-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>

<?php echo view('user/layout/footer-script');?>
   </body>
</html>