<?php  session_start(); error_reporting(0); ?>
<?php if(!isset($_SESSION['j_admin'])){ 
    $url = urlencode("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"); header('location:../login/?url='.$url.'');  
} ?>
<!doctype html>
<html lang="en"> 
<head>
	<?php
    require_once("../j_conn/url.php");
    require_once("../j_conn/dbc.php");
    require_once("../j_incs/functions.php");
    $page_name="My Referral Link";
    $page_desc="$page_name";
    $page_img="".$dir."j_files/j_img/logo/logo-meta.png";
    $page_author="$company";
    $page_keywords="".$company.", $page_name, $page_desc, ".$company_motto.", $company_desc";
    $page_url="".$dir."referral-link/";
    require_once("../j_incs/metas.php");
    require_once("../j_incs/scripts-top.php");
    ?>
</head>
<body>
    
    <div class="app">
        <div class="layout">
            <?php 
            require_once("../j_incs/header.php");
            require_once("../j_incs/nav.php");
            ?>
            <!-- Page Container START -->
            <div class="page-container">
                

                <!-- Content Wrapper START -->
                <div class="main-content">
                    <div class="container">
                        <div class="row">
                            <div class="col-md-8">
                                <div class="page-header">
									<?php /*<h2 class="header-title"><?php echo $page_name; ?></h2>*/ ?>
									<div class="header-sub-title">
										<nav class="breadcrumb breadcrumb-dash">
											<a href="<?php echo $dir; ?>" class="breadcrumb-item"><i class="anticon anticon-dashboard m-r-5"></i>Dashboard</a>
											<!--<a class="breadcrumb-item" href="#"> </a>-->
											<span class="breadcrumb-item active"><?php echo $page_name; ?></span>
										</nav>
									</div>
								</div>
                            </div>
                        </div>
                    </div>
                     
                     
                    <div class="container">
                        <div class="tab-content m-t-15">
                            <div class="tab-pane fade show active" id="tab-account">
                                
                                
                                <div class="card">
                                    
                                    <div class="card-body">
                                        <form method="POST" action="" id="form">
                                            
                                            <div class="form-row">
                                                <div class="form-group col-md-3"></div>
                                                <div class="form-group col-md-6">
                                                    
                                                    <p align="center">
                                                        <i class="fas fa-link" style="font-size:30px;"></i> <br/>
                                                        My Referral Link
                                                    </p>

                                                    <p class="text_sm_gray text-center">
                                                        Copy your Referral Link, Use this link to refer others and earn <?php echo $company_referral_perc; ?>% on your referrals.
                                                        <a href="<?php echo $dir; ?>referrals/">My Referrals</a>
                                                    </p>
                                            
                                                    
                                                    <p class="s-text8">
                                                    <?php $r_url = "".$dir."register?u=$username"; ?>
                                                    <input type="text" value="<?php echo $r_url; ?>" id="myURL" style="font-size:2px; width:100%; border:0px; display:none;">
                                                    </p>
                                                    <script>
                                                    function copyFunction() {
                                                        $("#myURL").show();
                                                      var copyText = document.getElementById("myURL");
                                                      copyText.select();
                                                      copyText.setSelectionRange(0, 99999);
                                                      document.execCommand("copy");
                                                        $("#myURL").hide();
														$("#refLink").modal();
														$(".refLink").html(copyText.value);
                                                      //alert('Link has been Copied: ' + copyText.value +'');
                                                    } 

                                                    </script>
                                                </div>
                                            </div>
                                            
                                            <div class="form-row">
                                                <div class="form-group col-md-3"></div>
                                                <div class="form-group col-md-6">
                                                     <button type="button"  onclick="copyFunction()" id="submit"  name="submit" class="btn btn-primary btn-block">Copy Link </button>
                                                </div>
                                            </div>
                                         
                                            
                                            
                                        </form>
                                    </div>
                                </div>
                             
                            </div>
                            
                        </div>
                    </div>
                </div>
                <!-- Content Wrapper END -->
				
				<!-- Modal -->
				<div class="modal fade" id="refLink">
					<div class="modal-dialog modal-dialog-centered">
						<div class="modal-content">
							<div class="modal-header">
								<h5 class="modal-title" id="exampleModalCenterTitle">Copy Referral Link</h5>
								<button type="button" class="close" data-dismiss="modal">
									<i class="anticon anticon-close"></i>
								</button>
							</div>
							<div class="modal-body">
								<div class="responseBox success">
									<i class="anticon anticon-check"></i>
								</div>
								<p class="text-center">
									 Referral Link has been copied <b class="text-primary">copied</b>;
									 <br/>
									<b class="refLink"></b>
								 </p>
							</div>
							<?php 
							/*
							<div class="modal-footer">
								<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
							</div>
							*/
							?>
						</div>
					</div>
				</div>
				

                <?php
                require_once("../j_incs/footer.php");
                ?>

            </div>
            <!-- Page Container END -->
        </div>
    </div>
    
    
    <?php
    require_once("../j_incs/scripts-bottom.php");
    ?>

   
</body>
</html>