<?php

$pageTitle = 'One Link';
$pageTitle_Forpage = ucfirst($action).' '.$pageTitle; 

$actUrl = 'admin/'.$categoryFor.'/manager';
if(!empty($id)){
	$actUrl = 'admin/'.$categoryFor.'/manager/'.$action.'/'.$id;
}

$base_url_append = $base_url_set;

$ajax_url = base_url().'admin/'.$categoryFor.'/get_c_list_data';
$ajax_url_2 = base_url().'admin/'.$categoryFor.'/get_c_list_dropd';
$ajax_url_3 = base_url().'admin/'.$categoryFor.'/ping_url';
$ajax_url_4 = base_url().'admin/'.$categoryFor.'/isExist_onelink';
$editor_ckediter_file_upload_path_base = base_url().'admin/'.$categoryFor.'/ckeditor_upload';

$app_keyword = $this->admin_onelink_model->uniqidReal(8);

if($action == 'duplicate'){
    $blogRow->link_name = (isset($blogRow->link_name))&&!empty($blogRow->link_name)? $blogRow->link_name.'_d_'.time():'';
}
$country_Data = $this->admin_onelink_model->get_Country_List();
$ARR_COUNTRY = array('' =>'Select Country');
if(!empty($country_Data)){
    $ARR_COUNTRY +=$country_Data;
// 	foreach($country_Data as $subblogRow){
// 		$ARR_COUNTRY[$subblogRow->iso] = $subblogRow->nicename;
// 	}
}
$cat_Data = $this->admin_onelink_model->getCategoryList();
$ARR_CATEGORY = array('' =>'Select Category');
if(!empty($cat_Data)){
    // $ARR_CATEGORY +=$cat_Data;
	foreach($cat_Data as $subblogRow){
	   // print_r($subblogRow);exit;
		$ARR_CATEGORY[$subblogRow->categoryId] = $subblogRow->categoryTitle;
	}
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title><?php echo $pageTitle; ?> - ACP - <?php echo site_name(); ?></title>
<?php $this->load->view('admin/ap_top'); ?>
<style type="text/css">
.table td
{
    white-space: normal;
}
.d_inline_custom
{
    padding: unset;
    flex-flow: column;
    align-items: normal;
    /*margin-left: 0%;*/
}
.d_inline_custom_div
{
    padding: 1rem;border: 1px solid #ccc;
    border-radius: 3px;
}
.fieldGroup_c{
     padding: 0.5rem 0 0.5rem  0;
     /*border: 1px solid #ccc;*/
    /*border-radius: 3px;*/
}
.fieldGroup_r2_c{
padding: 1rem 0 0 0;
}
.fieldGroup_sl3_c{
padding: 1rem 0 0 0;
}
.vertical-scrollable {
    border: 1px solid #cccccc;
    float: left;
    margin-bottom: 20px;
    max-height: 100%;
    overflow-x: auto;
    overflow-y: auto;
    width: 80%;
    padding: 10px;
    position: absolute;
    display: block;
}
.select2-container--default
{
    width:100% !important;
}
.has-error .input-group-text {
    /*border-color: unset !important; */
    background: unset !important; 
    color: unset !important; 
}
</style>
<style>
.form_control_cus{
    background-clip: padding-box;border: 1px solid #ced4da;border-radius: 0.25rem;transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}
.btn_curom{color: #000 !important;border: 1px solid #dde1e4!important;}
.form-control:disabled, .form-control[readonly] {opacity: 1 !important; }
</style>
<script type="text/javascript">

var base_URL_app = '<?php echo $base_url_append; ?>';
function doActionFn(action,id,sublinkid=null){
	 if(action == 'edit' || action == 'view' || action == 'duplicate'){
		window.location= '<?php echo base_url('admin/'.$categoryFor.'/manager/'); ?>/'+action+'/'+id;
	}
	else if(action == 'view_analytics'){
	    window.location= '<?php echo base_url('admin/'.$categoryFor.'/statistics'); ?>?link_id='+id+'&sub_link_id='+sublinkid;
	}
	else{
	    $('#doAction').val(action);	
	    if(action == 'delete'){
			if (confirm("Are you sure you want to delete?")) {
				$('#listFrm').submit();
			}	
		} else{
			$('#listFrm').submit();
		}
	}
 }

var $errStaus = false;  
function validateAccountForm(){
    
    // if($("#form_div").hasClass("err_there")){
    //     return false
    // }
    
    $('#form_div').addClass('is-loading');
    
	clrErr();
	$errStaus = false; 
	var action = '<?php echo $action ?>';
	
	if(validateFormFields('link_name','Please enter the link name .',''))$errStaus=true;
	
	if(action == 'add' || action == 'duplicate'){
	    if(validateFormFields('share_link','Please enter the share link.',''))$errStaus=true;
	}
	
	if(validateFormFields('destination_default_link','Please Enter Default Destination Link.','')){
	    $errStaus=true;
	}
	else{
	    destination_default_link = $("#destination_default_link").val();
	  
	   //console.log("rr"+test);
	    if( validate_url(destination_default_link) == 'false' ){
	        validateFormFields('destination_default_link','Please Enter Valid URL.','invalid_url');
	        $errStaus=true;
	    }
	}
	
	if(validateFormFields('target_type','Please Select Target type tab.',''))$errStaus=true;
    
    target_type = $("#target_type").val();
    if(target_type == 'Device'){
        android_play_store_url = $("#android_play_store_url").val();
        ios_app_store_url = $("#ios_app_store_url").val();
        website_url = $("#website_url").val();
        if(android_play_store_url != ''){
            if( validate_url(android_play_store_url) == 'false' ){
    	        validateFormFields('android_play_store_url','Please Enter Valid Android URL.','invalid_url');
    	        $errStaus=true;
    	    }
        }
        if(ios_app_store_url != ''){
            if( validate_url(ios_app_store_url) == 'false' ){
    	        validateFormFields('ios_app_store_url','Please Enter Valid iOS URL.','invalid_url');
    	        $errStaus=true;
    	    }
        }
        if(website_url != ''){
            if( validate_url(website_url) == 'false' ){
    	        validateFormFields('website_url','Please Enter Valid Windows URL.','invalid_url');
    	        $errStaus=true;
    	    }
        }
    }
    else if(target_type == 'Country'){
        var inps = document.getElementsByName('c_d_link[]');
        for (var i = 0; i <inps.length; i++) {
            var inp=inps[i];
            let sin_v = inp.value;
            if(sin_v != ''){
                $('body').find('.spl_c_msg').remove();
                if( validate_url(sin_v) == 'false' ){
                    inp.parentElement.classList.add("has-error");
                    inp.insertAdjacentHTML('afterend', '<small class="form-text text-muted text-danger spl_c_msg"> Invalid URL</small>');
        	        $errStaus=true;
        	        break;
        	    }else{
        	       // inp.insertAdjacentHTML('afterend', '<small class="form-text text-muted text-danger"></small>');
        	    }
            }
        }
    }
    else if(target_type == 'Rotate'){
        var inps = document.getElementsByName('r_link[]');
        for (var i = 0; i <inps.length; i++) {
            var inp=inps[i];
            let sin_v = inp.value;
            if(sin_v != ''){
                $('body').find('.spl_c_msg_r2').remove();
                if( validate_url(sin_v) == 'false' ){
                    inp.parentElement.classList.add("has-error");
                    inp.insertAdjacentHTML('afterend', '<small class="form-text text-muted text-danger spl_c_msg_r2"> Invalid URL</small>');
        	        $errStaus=true;
        	        break;
        	    }else{
        	       // inp.insertAdjacentHTML('afterend', '<small class="form-text text-muted text-danger"></small>');
        	    }
            }
        }
    }
    else if(target_type == 'SEO'){
        var page_content = CKEDITOR.instances.page_content.document.getBody().getHtml();
	    if(validateFormFields('page_content','Please enter page_content.','CKEDITOR',page_content))$errStaus=true;
    }
	
	utm_flag = $("#utm_flag").val();
	if(utm_flag == 1){
	    validateFormFields('utm_source','Please Enter UTM Source.','');
	    validateFormFields('utm_medium','Please Enter UTM Medium.','');
	    validateFormFields('utm_campaign','Please Enter UTM Campaign.','');
	}
	
	
	$('#form_div').removeClass('is-loading');
	
  	if($errStaus) {
  	    $('#form_div').addClass('err_there');
  	    
		return false;
	} else {
	    $('#form_div').removeClass('err_there');
	    return true;		
	}

}
    //group add limit
    var maxGroup = 100;
    var count='1';
    //add more fields group
    $(document).on("click",".addMore",function(){
        
        // console.log("fh");
        // $('.total_count').text('Total List : '+count);
         
        if($('body').find('.fieldGroup').length < maxGroup){
            // console.log($('body').find('.fieldGroup').length);
            // var count =$('body').find('.fieldGroup').length+1;
            var fieldHTML = ''+$(".fieldGroupCopy").html()+'';
            
            $('body').find('.fieldGroup:last').after(fieldHTML);
            count =  $('body').find('.fieldGroup').length;
            
        }else{
            alert('Maximum '+maxGroup+' groups are allowed.');
        }
        
        //  $(".ccsel2").select2();
        //  $('.ccsel2:last').select2();
         
        //   $(".ccsel2").each(function() {
        //     initializeSelect2($(this));
        //   });
  
        // $('.total_count').text('Total List : '+count);
        
    });
    // function initializeSelect2(selectElementObj) {
    //     alert()
    //     selectElementObj.select2({
    //       width: "100%",
    //     //   tags: true
    //     });
    //   }

    
    //remove fields group
    $(document).on("click",".remove",function(){
        // alert()
        // $(this).parents(".fieldGroup").remove();
        // $('.total_count').text($('body').find('.fieldGroup').length);
        // // a= $(this).parents(".fieldGroup").find('.dlis').text();
        // // console.log($('body').find('.fieldGroup').length +a);
        //  count =  $('body').find('.fieldGroup').length;
        // $('.total_count').text('Total List : '+count);
        
        $(this).parents(".fieldGroup_c").remove();
        $('.total_count').text($('body').find('.fieldGroup_c').length);
        // a= $(this).parents(".fieldGroup").find('.dlis').text();
        // console.log($('body').find('.fieldGroup').length +a);
         count =  $('body').find('.fieldGroup_c').length;
        // $('.total_count').text('Total List : '+count);
        
    });
    
    //add more fields group
    $(document).on("click",".addMore_r2",function(){
        
        if($('body').find('.fieldGroup_r2').length < maxGroup){
            // console.log($('body').find('.fieldGroup').length);
            // var count =$('body').find('.fieldGroup').length+1;
            var fieldHTML = ''+$(".fieldGroupCopy_r2").html()+'';
            
            $('body').find('.fieldGroup_r2:last').after(fieldHTML);
            count =  $('body').find('.fieldGroup_r2').length;
        }else{
            alert('Maximum '+maxGroup+' groups are allowed.');
        }
        
    });
    //remove_r2 fields group
    $(document).on("click",".remove_r2",function(){
        $(this).parents(".fieldGroup_r2_c").remove();
        $('.total_count').text($('body').find('.fieldGroup_r2_c').length);
        // a= $(this).parents(".fieldGroup").find('.dlis').text();
        // console.log($('body').find('.fieldGroup').length +a);
         count =  $('body').find('.fieldGroup_r2_c').length;
        // $('.total_count').text('Total List : '+count);
        
    });
    
    function makeRandomid(length) {
        var result           = '';
        var characters       = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
        var charactersLength = characters.length;
        for ( var i = 0; i < length; i++ ) {
            result += characters.charAt(Math.floor(Math.random() * 
            charactersLength));
        }
        return result;
    }


    //add more fields group
    $(document).on("click",".addMore_sl3",function(){
        
        if($('body').find('.fieldGroup_sl3').length < maxGroup){
            // console.log($('body').find('.fieldGroup').length);
            // var count =$('body').find('.fieldGroup').length+1;
            var fieldHTML = ''+$(".fieldGroupCopy_sl3").html()+'';
            
            $('body').find('.fieldGroup_sl3:last').after(fieldHTML);
            count =  $('body').find('.fieldGroup_sl3_c').length;
            
            var  share_link_val = $("#share_link").val();
            sublink_temp  = base_URL_app+share_link_val+'-'+count + makeRandomid(3);
            // alert(sublink_temp);
            // $('[name=share_link_2]').eq(count-1).val(sublink_temp);
            $('body').find('.sharelink2_val_s').eq(0).attr('value', sublink_temp)
            
        }else{
            alert('Maximum '+maxGroup+' groups are allowed.');
        }
        
    });
    
    //remove_r2 fields group
    $(document).on("click",".remove_sl3",function(){
        
        if($(this).hasClass('rem_restrct')){
            alert('Sublinks delete option will be disabled. \nBecause this link might be in live.')
        }else{
            $(this).parents(".fieldGroup_sl3_c").remove();
            $('.total_count').text($('body').find('.fieldGroup_sl3_c').length);
            // a= $(this).parents(".fieldGroup").find('.dlis').text();
            // console.log($('body').find('.fieldGroup').length +a);
            count =  $('body').find('.fieldGroup_sl3_c').length;
            // $('.total_count').text('Total List : '+count);
        }
    });
    

function tab_active_set(contentId){
    if(contentId == 'Country'){
        $("#country_code").attr("required", true);
        $("#c_d_link").attr("required", true);
        $(".lpseo_inp_cls").attr("required", false);
        $("#r_link").attr("required", false);
    }
    else if(contentId == 'Rotate'){
        $("#r_link").attr("required", true);
        $(".lpseo_inp_cls").attr("required", false);
        $("#country_code").attr("required", false);
        $("#c_d_link").attr("required", false);
    }
    else if(contentId == 'SEO'){
        $(".lpseo_inp_cls").attr("required", true);
         $("#country_code").attr("required", false);
        $("#c_d_link").attr("required", false);
        $("#r_link").attr("required", false);
    }
    else{
        $("#country_code").attr("required", false);
        $("#c_d_link").attr("required", false);
        $(".lpseo_inp_cls").attr("required", false);
        $("#r_link").attr("required", false);
    }
}

</script>

</head>

<body>
    <div class="wrapper" >
        <?php $this->load->view('admin/navbar'); ?>
		<div class="main-panel main-panel-custom">
		    <div class="content">
				<div class="page-inner">
					<div class="page-header">
						<h4 class="page-title"><?php echo $categoryForPage ; ?></h4>
						<ul class="breadcrumbs">
							<li class="nav-home">
								<a href="<?php echo base_url('admin/dashboard');?>">
									<i class="flaticon-home"></i>
								</a>
							</li>
							<li class="separator">
								<i class="flaticon-right-arrow"></i>
							</li>
							<li class="nav-item">
								<a href="<?php echo base_url('admin/'.$categoryFor);?>"><?php echo $pageTitle; ?> List</a>
							</li>
							<li class="separator">
								<i class="flaticon-right-arrow"></i>
							</li>
							<li class="nav-item">
								<a href="#"><?php echo $pageTitle_Forpage; ?></a>
							</li>
						</ul>
					</div>
					
					 <?php
                    	if($action == 'edit' || $action == 'add' || $action == 'duplicate'){
                    	    //add, edit card
                	    ?>
                    	    <div class="row">
						        <div class="col-md-12">
    							<div class="card">
                                    <div class="card-header">
    								    <div class="card-head-row">
    									    <h4 class="card-title"><?php echo $pageTitle_Forpage; ?></h4>
    									    <div class="card-tools">
    											<ul class="nav nav-pills nav-secondary nav-pills-no-bd " role="tablist">
    											    <li class="nav-item">
    										            <a class="nav-link active btn-success"  href="<?php echo base_url('admin/one_link/manager/view/'.$id) ?>"> <i class="fas fa-info"></i>&nbsp; View </a>
    									            </li>
    									            <li class="nav-item">
    										            <a class="nav-link active btn-secondary"  href="<?php echo base_url('admin/one_link/statistics?link_id='.$id) ?>"> <i class="fas fa-chart-bar fa-lg"></i>&nbsp; Report</a>
    									            </li>
    									            <!--<li class="nav-item">-->
    									                <!--<a class="nav-link active btn-refresh-card" style="background: #007bff;!important">Reload</a>-->
    										           <!-- <button id="table-refresh" class="nav-link active btn-refresh-card btn-refresh-card" ><span class="fa fa-sync-alt"></span></button>-->
    									            <!--</li>-->
    											</ul>
    										</div>
    									</div>
    								</div>

    								<!--notifiactions-->
        							<div class="container" id="">
                                        <?php 
                                 		$errMsg = validation_errors('* ');
                                		if(empty($errMsg)){ $errMsg = $this->session->flashdata('errMsg');  }
                                		$warningMsg = $this->session->flashdata('warningMsg');
                                		$successMsg = $this->session->flashdata('successMsg');
                                		if(isset($errMsg) && !empty($errMsg)){ echo showMessage($errMsg,'error'); }  
                                		if(isset($warningMsg) && !empty($warningMsg)){ echo showMessage($warningMsg,'warning'); }
                                		if(isset($successMsg) && !empty($successMsg)){ echo showMessage($successMsg,'success'); }
                                	?>
                                    </div>
    								
									<div class="card-body">
    							        <?php echo form_open_multipart( $actUrl,array('name' => 'accAdminFrm', 'id' => 'accAdminFrm','onSubmit' => 'return validateAccountForm()'));?>
                                        <div id="form_div">
                                            <div class="form-group form-inline" id="div_share_link">
                                                <label for="share_link" class="col-md-2 col-form-label">Share Link </label>
                                                <div class="col-md-6 p-0" >
                                                     <?php
                                                        if(isset($blogRow->share_link) && !empty($blogRow->share_link) && $action == 'edit') {
                                                            // 
                                                            ?>
    												        <div class="form_control_cus input-group">
                                                                <input readonly="" type="text" id="copytext" class="form-control" value="<?php echo $blogRow->share_link; ?>">
                                                                <span class="input-group-append">
                                                                    <button type="button" onClick="copyToClipboard_URL_2(this)" data-copy_url="<?php echo $blogRow->share_link; ?>" class="btn btn_curom btn-border">
                                                                    <i class="fa fa-copy"></i> Copy</button>
                                                                </span>
                                                            </div>
                                                            <input type="hidden" id="share_link" name="share_link" value="<?php echo $blogRow->app_keyword; ?>">
                                                          <?php
                                                        }else{
                                                            ?>
                                                            <div class=" input-group">
        													    <div class="input-group-prepend">
        														<span class="input-group-text" id="basic-addon3"><?php echo $base_url_append; ?> </span>
        													</div>
        													<?php
    													
    														$s_disabled='';
    												// 		if(isset($blogRow->app_keyword) && $action == 'edit') {
    												// 		    $set_app_keyword=$blogRow->app_keyword;
    												// 		    $s_disabled='pointer-events: none;opacity: 0.9;background: #e4e7eb!important;';
    												// 		}else
    												
    												
    												        if( isset($app_keyword) ){
    														    $set_app_keyword = $app_keyword;
    														}
    														else {
    														    $set_app_keyword='';
    														}
    													    
                                                            $data = array( 'name' => 'share_link',
                                                            'value' => set_value('share_link',$set_app_keyword), 'style'=>$s_disabled, 'pattern' => '(^[a-zA-Z0-9-]{0,85})$',
                                                            'id' => 'share_link', 'placeholder'   => $set_app_keyword , 'class' => ' div_share_link form-control', "aria-describedby"=>"basic-addon3" );
                                                            echo form_input($data);
                                                           
                                                        }
                                                      ?>
    												</div>
    												
    												<small id="err_share_link" class="text-danger err_msg"></small>
                                                    <small id="share_link_note" style="display:none">Note: Special characters not allowed except Hypen(-). Sample value: test-bible</small>
        											
											    </div>
											</div>
											
                                            <div>
                                            <!--<label class="col-md-12 col-form-label pl-4"><h4>Essential Link</h4></label>-->
                                            <div class="form-group form-inline" id="div_link_name">
        										<label for="link_name" class="col-md-2 col-form-label"> Link Name <span style="color:red;">&nbsp;*</span> </label>
        										<div class="col-md-6 p-0" >
        										    <?php   
        										        $data = array( 'name' => 'link_name',
        										        'value' => set_value('link_name',isset($blogRow->link_name)?$blogRow->link_name:$this->input->post('link_name')), 
        										        'id' => 'link_name',  'placeholder'   => 'Link name', 'class' => 'form-control input-full required', );
                              						    echo form_input($data);
                                					?>
        											<small class="form-text text-muted text-danger err_msg" id="err_link_name"></small>
        										</div>
        									</div>
        									
                                            <div class="form-group form-inline" id="div_destination_default_link">
        										<label for="destination_default_link" class="col-md-2 col-form-label">Default <br>Destination Link <span style="color:red;">&nbsp;*</span> </label>
        										<div class="col-md-6 p-0" >
        										    <?php   
        										        $data = array( 'name' => 'destination_default_link',
        										        'value' => set_value('destination_default_link',isset($blogRow->destination_default_link)?$blogRow->destination_default_link:$this->input->post('destination_default_link')), 
        										        'id' => 'destination_default_link',  'placeholder'   => 'Default Destination Link', 'class' => 'validate_p_url form-control input-full required', );
                              						    echo form_input($data);
                                					?>
        											<small class="form-text text-muted text-danger err_msg" id="err_destination_default_link"></small>
        										</div>
        									</div>
        									<div class="form-group form-inline" id="div_category_id">
        										<label for="category_id" class="col-md-2 col-form-label">Category <span style="color:red;">&nbsp;*</span> </label>
        										<div class="col-md-6 p-0" >
        										    <?php   
        										      //  $data = array( 'name' => 'category_id',
        										      //  'value' => set_value('category_id',isset($blogRow->category_id)?$blogRow->category_id:$this->input->post('category_id')), 
        										      //  'id' => 'category_id',  'placeholder'   => 'Default Destination Link', 'class' => 'validate_p_url form-control input-full required', );
                              						    
                              						    $js = 'class="form-control input-full required" id="category_id"  '; 
                                         			
                          						    	if(isset($blogRow->category_id)){
                                         			        $set_category_id = $blogRow->category_id;
                                         			    }
                                         			    // else if($this->session->userdata('categoryLangTemp'))
                                         			    // {
                                         			    //     $set_v_lang =   $this->session->userdata('categoryLangTemp');
                                         			    // }
                                         			    else{
                                         			        $set_category_id =  $this->input->post('category_id');
                                         			    }
                                         			    // print_r($ARR_CATEGORY);exit;
                                        				echo form_dropdown('category_id',$ARR_CATEGORY,
                                        				set_value('category_id',$set_category_id),
                                        				$js); 
                                					?>
        											<small class="form-text text-muted text-danger err_msg" id="err_category_id"></small>
        										</div>
        									</div>
    									</div>
        								
            								<hr></hr>		
                                            <div class="form-group form-inline" id="div_android_play_store_url">
    											<label for="android_play_store_url" class="col-md-2 col-form-label">Target </label>
    											<div class="col-md-6 p-0" >
    											    <?php
    												    $none_act ="false";$dev_act="false";$country_act="false";$rotate_act = "false";$seo_act="false";
    												    $tab_none_act ="";$tab_dev_act="";$tab_country_act="";$tab_rotate_act = "";$tab_seo_act="false";
    												    $set_target_type = '';
    												    if(isset($blogRow->target_type) && $blogRow->target_type == 'None'){
    												        $none_act ="true";$tab_none_act = "active show";
    												        $set_target_type = 'None';
    												    }
    												    else if(isset($blogRow->target_type)  && $blogRow->target_type == 'Device'){
    												        $dev_act="true"; $tab_dev_act = "active show";
    												        $set_target_type = 'Device';
    												    }else if(isset($blogRow->target_type)  && $blogRow->target_type == 'Country'){
    												        $country_act="true"; $tab_country_act = "active show";
    												        $set_target_type = 'Country';
    												    }else if(isset($blogRow->target_type)  && $blogRow->target_type == 'Rotate'){
    												        $rotate_act="true"; $tab_rotate_act = "active show";
    												        $set_target_type = 'Rotate';
    												    }else if(isset($blogRow->target_type)  && $blogRow->target_type == 'SEO'){
    												        $seo_act="true"; $tab_seo_act = "active show";
    												        $set_target_type = 'SEO';
    												    }
    												    else{
    												        $none_act ="true";$tab_none_act = "active show";
    												         $set_target_type = 'None';
    												    }
    												    
    												    echo "<script> tab_active_set('$set_target_type'); </script>";
    									            ?>
    									            <input type="hidden" name="target_type" id="target_type" value="<?php echo $set_target_type;?>">
    									            
                                                    <div>
                                                        <ul class="nav nav-pills nav-secondary" id="pills-tab" role="tablist">
                    										<li class="nav-item submenu">
                    											<a class="nav-link <?php echo $tab_none_act; ?>" data-tabv="None" id="pills-home-tab" data-toggle="pill" href="#pills-home" role="tab" aria-controls="pills-home" aria-selected="<?php echo $none_act; ?>">None</a>
                    										</li>
                    										<li class="nav-item submenu">
                    											<a class="nav-link <?php echo $tab_dev_act; ?>" data-tabv="Device" id="pills-profile-tab" data-toggle="pill" href="#pills-profile" role="tab" aria-controls="pills-profile" aria-selected="<?php echo $dev_act; ?>">Device</a>
                    										</li>
                    										<li class="nav-item submenu">
                    											<a class="nav-link <?php echo $tab_country_act; ?>" data-tabv="Country" id="pills-contact-tab" data-toggle="pill" href="#pills-contact" role="tab" aria-controls="pills-contact" aria-selected="<?php echo $country_act; ?>">Country</a>
                    										</li>
                											<li class="nav-item submenu">
                    											<a class="nav-link <?php echo $tab_rotate_act; ?>" data-tabv="Rotate" id="pills-rotate-tab" data-toggle="pill" href="#pills-rotate" role="tab" aria-controls="pills-rotate" aria-selected="<?php echo $rotate_act; ?>">Rotate</a>
                    										</li>
                    										<li class="nav-item submenu">
                    											<a class="nav-link <?php echo $tab_seo_act; ?>" data-tabv="SEO" id="pills-seo-tab" data-toggle="pill" href="#pills-seo" role="tab" aria-controls="pills-seo" aria-selected="<?php echo $seo_act; ?>">SEO </a>
                    										</li>
                    									</ul>
        									        </div>
    											</div>
    										</div>
											
                                            <div class="tab-content mt-2 mb-3" id="pills-tabContent">
                                                
        										<div class="tab-pane fade <?php echo $tab_none_act ?>" id="pills-home" role="tabpanel" aria-labelledby="pills-home-tab"></div>
        										
        										<div class="tab-pane fade <?php echo $tab_dev_act ?>" id="pills-profile" role="tabpanel" aria-labelledby="pills-profile-tab">
        										    
        										    <label class="col-md-12 col-form-label pl-4"><h4>Device based redirect</h4></label>
        										   
        											<div class="form-group form-inline" id="div_android_play_store_url">
        												<label for="android_play_store_url" class="col-md-2 col-form-label">Android</label>
        												<div class="col-md-6 p-0" >
        												    <?php   
        												        $data = array( 'name' => 'android_play_store_url',
        												        'value' => set_value('android_play_store_url',isset($blogRow->android_play_store_url)?$blogRow->android_play_store_url:$this->input->post('android_play_store_url')), 
        												        'id' => 'android_play_store_url',  'placeholder'   => 'Android Play Store URL', 'class' => 'form-control input-full required', );
                                      						    echo form_input($data);
                                        					?>
        													<small class="form-text text-muted text-danger err_msg" id="err_android_play_store_url"></small>
        												</div>
        											</div>
        											
        											 <div class="form-group form-inline" id="div_ios_app_store_url">
        												<label for="ios_app_store_url" class="col-md-2 col-form-label">iOS</label>
        												<div class="col-md-6 p-0" >
        												    <?php   
        												        $data = array( 'name' => 'ios_app_store_url', 
        												        'value' => set_value('ios_app_store_url',isset($blogRow->ios_app_store_url)?$blogRow->ios_app_store_url:$this->input->post('ios_app_store_url')), 
        												        'id' => 'ios_app_store_url',  'placeholder'   => 'IOS App Store URL ', 'class' => 'form-control input-full required', );
                                      						    echo form_input($data);
                                        					?>
        													<small class="form-text text-muted text-danger err_msg" id="err_ios_app_store_url"></small>
        												</div>
        											</div>
        											
        											<div class="form-group form-inline" id="div_website_url">
        												<label for="website_url" class="col-md-2 col-form-label"> Windows </label>
        												<div class="col-md-6 p-0" >
        												    <?php   
        												        $data = array( 'name' => 'website_url',
        												        'value' => set_value('website_url',isset($blogRow->website_url)?$blogRow->website_url:$this->input->post('website_url')), 
        												        'id' => 'website_url',  'placeholder'   => 'Website URL', 'class' => 'form-control input-full required', );
                                      						    echo form_input($data);
                                        					?>
        													<small class="form-text text-muted text-danger err_msg" id="err_website_url"></small>
        												</div>
        											</div>
        											
        											<div class="form-group form-inline" id="div_website_url">
        												<label for="website_url" class="col-md-2 col-form-label"> Sub-links </label>
        												<div class="p-0" >
        												    <div class="form-check" >
        												        <?php
        												        $sublink_flag_check = isset($blogRow->sub_link_flag)&&!empty($blogRow->sub_link_flag)?'checked':'';
        												        
                                            					?>
                												<label class="form-check-label" for="sub_link_flag">
                													<input class="form-check-input" name="sub_link_flag" type="checkbox" value="1"  id="sub_link_flag" onChange="show_field_sublink()" <?php echo $sublink_flag_check ?> >
                													<span class="form-check-sign" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Enable Sub-links</span>
                												</label>
                											</div>
        													<small class="form-text text-muted text-danger err_msg" id="err_sub_link_flag"></small>
        												</div>
        											</div>
        											
        											<div id="sublink_fields_div">
        											    
        											    <div class="form-group form-inline col-md-12" >
                                                            <label class="col-md-2 col-form-label" > Name <span style="color:red;">&nbsp;*</span></label>
                                                            <div class="col-md-10 form-inline d_inline_custom_div" id="">
                                                               
                                                               <?php
                        								            if(isset($set_target_type) && !empty($set_target_type) 
                        								             && isset($sub_link_list) && !empty($sub_link_list) )
                        								            {
                                                                        $i=0;
                                                                        foreach($sub_link_list as $ck){
                                                                            
                                                                            if($i==0){
                                                                                echo '<div class="col-md-12 form-inline fieldGroup_sl3" style="display: contents;">';
                                                                            }else{
                                                                                echo '<div class="col-md-12 form-inline fieldGroup_sl3_c" style="display: inline-flex;">';
                                                                            }
                                                                                
                                                                                echo '<input type="hidden" name="sl_id['.']" value="'. $ck->id .'" >';
                                                                                
                                                                                echo ' <div class="form-group col-md-4 d_inline_custom" >';
                                                                                    echo '<input type="text" class="form-control input-full share_link_2_reqcls" readonly name="share_link_2['.']" value="'. $ck->share_link .'" >';
                                                                                echo '</div>';
                                                                                echo'&nbsp;&nbsp;';
                                                                                echo '<div class="form-group col-md-5 d_inline_custom" >';           
                                                                                    echo '<input type="text" class="input-full form-control sublink_name_reqcls" name="sublink_name['.']" value="'.$ck->sublink_name .'" id="sublink_name" placeholder="Link Name" required>'; 
                                                                                echo '</div>';
                                                                                
                                                                                echo '<div class="col-md-2 text-center">';
                                                                                if($i==0){
                                                                                    echo  '<a href="javascript:void(0)" class="btn btn-success btn-sm addMore_sl3"><i class="fa fa-plus"></i> Add </a>';
                                                                                }else{
                                                                                    echo '<a href="javascript:void(0)" class="btn btn-danger btn-sm remove_sl3 rem_restrct"><i class="fa fa-trash"></i> Remove </a>';
                                                                                }
                                                                                echo '</div>';
                                                                            echo '</div>';
                                                                        
                                                                        $i++;
                                                                        }
                        								            }
                        								            else
                        								            {
                        								                ?>
                        								                <div class="fieldGroup_sl3" style="display: contents;">
                        								                    <input type="hidden" name="sl_id[]" >
                        								                    <div class="form-group col-md-4 d_inline_custom" >
                                                                                <input type="text" class="form-control input-full share_link_2_reqcls" readonly id="share_link_2_a1" name="share_link_2[]" >
                                                                            </div>
                                                                            &nbsp;&nbsp;
                                                                            <div class="form-group col-md-5 d_inline_custom" >
                                                                                <?php   
                            												        $data = array( 'name' => 'sublink_name[]',
                            												        'value' => set_value('sublink_name[]',isset($blogRow->sublink_name)?$blogRow->sublink_name:$this->input->post('sublink_name')),
                                                                                    'id' => 'sublink_name',  'placeholder'   => 'Sub Link Name', 'class' => 'form-control input-full sublink_name_reqcls' );
                                                          						     echo form_input($data);
                                                            					?>
                            													<small class="form-text text-muted text-danger err_msg" id="err_sublink_name"></small>
                                                                            </div>
                                                                            <div class="col-md-2 text-center">
                                                                                <a href="javascript:void(0)" class="btn btn-success btn-sm addMore_sl3"><i class="fa fa-plus"></i> Add</a>
                                                                            </div>
                                                                        </div>
                        								                <?php
                        								            }
                        								        ?>
                                                            </div>
                                                        </div>
        											    
        											</div>
    											    <br>
        										</div>
        										
        										<div class="tab-pane fade <?php echo $tab_country_act ?>" id="pills-contact" role="tabpanel" aria-labelledby="pills-contact-tab">
        											
    											    <label class="col-md-12 col-form-label pl-4"><h4>Redirect users by Country</h4></label>
											        
										            <div class="form-group form-inline col-md-12" id="">
										            
										            <!--<div id="">-->
                                                        <div class="form-group form-inline  col-md-12" >
                                                            
                                                            <label class="col-md-2 col-form-label" > Country <span style="color:red;">&nbsp;*</span></label>
                                                            <div class="col-md-10 form-inline d_inline_custom_div" id="list_div">
                                                               
                                                               <?php
                        								            if(isset($set_target_type) && !empty($set_target_type) 
                        								            && $set_target_type == 'Country' && !empty($country_redi_list) && !empty($ARR_COUNTRY))
                        								            {
                                                                        $i=0;
                                                                        foreach($country_redi_list as $ck){
                                                                            
                                                                            if($i==0){
                                                                                echo '<div class="col-md-12 form-inline fieldGroup" style="display: contents;">';
                                                                            }else{
                                                                                echo '<div class="col-md-12 form-inline fieldGroup_c" style="display: inline-flex;">';
                                                                            }
                                                                            
                                                                                echo '<input type="hidden" name="id['.']" value="'. $ck->id .'" >';
                                                                        
                                                                                echo '<div class="form-group col-md-2 d_inline_custom" >';
                                                                                    echo '<select class="form-control input-full " name="country_code[]" id="country_code" required>';
                                                                                    foreach($ARR_COUNTRY as $cck=>$ccv){
                                                                                        if($cck == $ck->country_code) $selected='selected';
                                                                                        else $selected='';
                                                                                        echo '<option value="'.$cck.'" '.$selected.'>'.$ccv.'</option>';
                                                                                    }
                                                                                    echo '</select>';
                                                                                echo '</div>';
                                                                                
                                                                                echo '&nbsp; &nbsp; &nbsp; &nbsp;';
                                                                        
                                                                                echo '<div class="form-group col-md-7 d_inline_custom" >';           
                                                                                    echo '<input type="text" class="input-full form-control validate_p_url" name="c_d_link['.']" value="'.$ck->c_d_link .'" id="c_d_link" placeholder="URL" required>'; 
                                                                                echo '</div>';
                                                                                
                                                                                echo '<div class="col-md-2 text-center">';
                                                                                if($i==0){
                                                                                    echo  '<a href="javascript:void(0)" class="btn btn-success btn-sm addMore"><i class="fa fa-plus"></i> Add</a>';
                                                                                }else{
                                                                                    echo '<a href="javascript:void(0)" class="btn btn-danger btn-sm remove"><i class="fa fa-trash"></i> Remove </a>';
                                                                                }
                                                                                echo '</div>';
                                                                        
                                                                            echo '</div>';
                                                                        
                                                                        $i++;
                                                                           
                                                                        }
                        								            }
                        								            else
                        								            {
                        								                ?>
                        								                <div class="fieldGroup" style="display: contents;">
                                                                    
                                                                            <input type="hidden" name="id[]" value="" >
                                                                             
                                                                            <div class="form-group col-md-2 d_inline_custom" >
                                                                                <select class="form-control input-full" name="country_code[]" id="country_code" >
                                                                                    <?php
                                                                                    if(!empty($ARR_COUNTRY)){
                                                                                        foreach($ARR_COUNTRY as $ck=>$cv){
                                                                                            ?>
                                                                                            <option value="<?php echo $ck ?>"><?php echo $cv; ?></option>
                                                                                            <?php
                                                                                        }
                                                                                    }
                                                                                    ?>
                                                                                </select>
                                                                            </div>
                                                                            &nbsp; &nbsp; &nbsp; &nbsp;
                                                                            <div class="form-group col-md-7 d_inline_custom" >
                                                                                <?php   
                            												        $data = array( 'name' => 'c_d_link[]',
                            												        'value' => set_value('c_d_link',isset($blogRow->c_d_link)?$blogRow->c_d_link:$this->input->post('c_d_link')),
                                                                                    'id' => 'c_d_link',  'placeholder'   => 'URL', 'class' => 'form-control input-full validate_ctry_url' );
                                                          						    echo form_input($data);
                                                            					?>
                            													<small class="form-text text-muted text-danger err_msg" id="err_c_d_link"></small>
                                                                            </div>
                                                                            <div class="col-md-2 text-center">
                                                                                <!--<label class="col-md-6 " style="padding: unset;"  for="inputEmail"></label>-->
                                                                                <a href="javascript:void(0)" class="btn btn-success btn-sm addMore"><i class="fa fa-plus"></i> Add</a>
                                                                            </div>
                                                                        </div>
                        								                <?php
                        								            }
                        								        ?>
                                                                
                                                            </div>
                                                        </div>
        										    <!--</div>-->
    											    
        										</div>
        										
        									    </div>
        									    
        									    <div class="tab-pane fade <?php echo $tab_rotate_act ?>" id="pills-rotate" role="tabpanel" aria-labelledby="pills-rotate-tab">
        											
    											    <label class="col-md-12 col-form-label pl-4"><h4>Randomly redirect [ Evenly Traffic Distribution ]</h4>
    											        <text>Including Default Destination Link</text></label>
    											    <!--<label>Distribute Traffic Evenly</label>-->
											        
										            <div class="form-group form-inline col-md-12" id="">
										            
                                                        <div class="form-group form-inline col-md-12" >
                                                            <label class="col-md-2 col-form-label" > Destination <span style="color:red;">&nbsp;*</span></label>
                                                            <div class="col-md-10 form-inline d_inline_custom_div" id="">
                                                               
                                                               <?php
                        								            if(isset($set_target_type) && !empty($set_target_type) 
                        								            && $set_target_type == 'Rotate' && isset($rotate_redi_list) && !empty($rotate_redi_list) )
                        								            {
                                                                        $i=0;
                                                                        foreach($rotate_redi_list as $ck){
                                                                            
                                                                            if($i==0){
                                                                                echo '<div class="col-md-12 form-inline fieldGroup_r2" style="display: contents;">';
                                                                            }else{
                                                                                echo '<div class="col-md-12 form-inline fieldGroup_r2_c" style="display: inline-flex;">';
                                                                            }
                                                                                echo '<input type="hidden" name="r_id['.']" value="'. $ck->r_id .'" >';
                                                                                
                                                                                echo '<div class="form-group col-md-7 d_inline_custom" >';           
                                                                                    echo '<input type="text" class="input-full form-control validate_p_url" name="r_link['.']" value="'.$ck->r_link .'" id="r_link" placeholder="URL" required>'; 
                                                                                echo '</div>';
                                                                                
                                                                                echo '<div class="col-md-2 text-center">';
                                                                                if($i==0){
                                                                                    echo  '<a href="javascript:void(0)" class="btn btn-success btn-sm addMore_r2"><i class="fa fa-plus"></i> Add</a>';
                                                                                }else{
                                                                                    echo '<a href="javascript:void(0)" class="btn btn-danger btn-sm remove_r2"><i class="fa fa-trash"></i> Remove </a>';
                                                                                }
                                                                                echo '</div>';
                                                                            echo '</div>';
                                                                        
                                                                        $i++;
                                                                        }
                        								            }
                        								            else
                        								            {
                        								                ?>
                        								                <div class="fieldGroup_r2" style="display: contents;">
                                                                            <input type="hidden" name="r_id[]" value="">
                                                                            <div class="form-group col-md-7 d_inline_custom" >
                                                                                <?php   
                            												        $data = array( 'name' => 'r_link[]',
                            												        'value' => set_value('r_link',isset($blogRow->r_link)?$blogRow->r_link:$this->input->post('r_link')),
                                                                                    'id' => 'r_link',  'placeholder'   => 'URL', 'class' => 'form-control input-full validate_ctry_url' );
                                                          						     echo form_input($data);
                                                            					?>
                            													<small class="form-text text-muted text-danger err_msg" id="err_r_link"></small>
                                                                            </div>
                                                                            <div class="col-md-2 text-center">
                                                                                <a href="javascript:void(0)" class="btn btn-success btn-sm addMore_r2"><i class="fa fa-plus"></i> Add</a>
                                                                            </div>
                                                                        </div>
                        								                <?php
                        								            }
                        								        ?>
                                                            </div>
                                                        </div>
        										   
        										    </div>
        										
        									    </div>
        									    
        									    <div class="tab-pane fade <?php echo $tab_seo_act ?>" id="pills-seo" role="tabpanel" aria-labelledby="pills-seo-tab">
        										    
        										    <label class="col-md-12 col-form-label pl-4"><h4>Dynamic Web page Creation with SEO</h4></label>
        										    <?php
        										  //  var_dump($pageSeoRow);
        										    ?>
        										    <input type="hidden" name="p_id" value="<?php echo isset($pageSeoRow->id)?$pageSeoRow->id:''?>" >
        										    
        											<div class="form-group form-inline" id="div_page_name">
        												<label for="page_name" class="col-md-2 col-form-label">Page Name </label>
        												<div class="col-md-8 p-0" >
        												    <?php
        												    if($action =="edit" && isset($pageSeoRow->page_name) && !empty($pageSeoRow->page_name)){
        												        $readonly='readonly';
        												    }else{
        												        $readonly='';
        												    }
        												        $data = array( 'name' => 'page_name',
        												        'value' => set_value('page_name',isset($pageSeoRow->page_name)?$pageSeoRow->page_name:$this->input->post('page_name')), 'pattern' => '(^[0-9A-Za-z\s\-]+)$', 
        												        'id' => 'page_name',  'placeholder'   => 'Page Name', 'class' => 'form-control input-full lpseo_inp_cls ', $readonly =>true  );
                                      						    echo form_input($data);
                                        					?>
                                        					<small class="form-text text-muted text-default " id="msgalr_page_name">Note: Special characters not allowed except Hypen(-). Sample value: Sample Page</small>
        													<small class="form-text text-muted text-danger err_msg" id="err_page_name"></small>
        												</div>
        											</div>
        											
        											 <div class="form-group form-inline" id="div_page_title">
        												<label for="page_title" class="col-md-2 col-form-label">Page Title </label>
        												<div class="col-md-8 p-0" >
        												    <?php   
        												        $data = array( 'name' => 'page_title',
        												        'value' => set_value('page_title',isset($pageSeoRow->page_title)?$pageSeoRow->page_title:$this->input->post('page_title')), 
        												        'id' => 'page_title',  'placeholder'   => 'Page Title', 'class' => 'form-control input-full lpseo_inp_cls ', );
                                      						    echo form_input($data);
                                        					?>
        													<small class="form-text text-muted text-danger err_msg" id="err_page_title"></small>
        												</div>
        											</div>
        											
        											<div class="form-group form-inline" id="div_meta_description">
        												<label for="meta_description" class="col-md-2 col-form-label">Meta Description</label>
        												<div class="col-md-8 p-0" >
        												    <?php   
        												        $data = array( 'name' => 'meta_description',
        												        'value' => set_value('meta_description',isset($pageSeoRow->meta_description)?$pageSeoRow->meta_description:$this->input->post('meta_description')), 
        												        'id' => 'meta_description',  'placeholder'   => 'Meta Description', 'class' => 'form-control input-full lpseo_inp_cls ','rows'=>'2');
                                      						    echo form_textarea($data);
                                        					?>
        													<small class="form-text text-muted text-danger err_msg" id="err_meta_description"></small>
        												</div>
        											</div>
        											
        											<div class="form-group form-inline" id="div_promo_link">
        												<label for="promo_link" class="col-md-2 col-form-label">Promotion Link</label>
        												<div class="col-md-8 p-0" >
        												    <?php   
        												        $data = array( 'name' => 'promo_link',
        												        'value' => set_value('promo_link',isset($pageSeoRow->promo_link)?$pageSeoRow->promo_link:$this->input->post('promo_link')), 
        												        'id' => 'promo_link',  'placeholder'   => 'Promotion Link', 'class' => 'form-control input-full lpseo_inp_cls ', );
                                      						    echo form_input($data);
                                        					?>
        													<small class="form-text text-muted text-danger err_msg" id="err_promo_link"></small>
        												</div>
        											</div>
        											
        											<div class="form-group form-inline" id="div_page_content">
        												<label for="page_content" class="col-md-2 col-form-label">Page Body Content </label>
        												<div class="col-md-8 p-0" >
        												    
        												    <textarea name="page_content" id="page_content"  class="form-control input-full" rows="5" ><?php if(isset($pageSeoRow->page_content) && !empty($pageSeoRow->page_content)) {echo $pageSeoRow->page_content;}else{echo '';}?></textarea>		
        												    <?php   
        												        // $data = array( 'name' => 'page_content',
        												        // 'value' => set_value('page_content',isset($pageSeoRow->page_content)?$pageSeoRow->page_content:$this->input->post('page_content')), 
        												        // 'id' => 'page_content',  'placeholder'   => 'Page Content', 'class' => 'form-control input-full lpseo_inp_cls','rows'=>'3' );
                            //           						    echo form_textarea($data);
                                        					?>
        													<small class="form-text text-muted text-danger err_msg" id="err_page_content"></small>
        												</div>
        											</div>
    											
        										</div>
        									    
        									</div>
											
										    <hr></hr>
                                            
                                            
                                            
                                            <div class="" >
                                                <div class="form-group form-inline" id="div_utm_flag">
    												<label for="utm_flag" class="col-md-2 col-form-label"> UTM Tags </label>
    												<div class="p-0" >
    												    <div class="form-check" >
    												       <?php
            									             $utm_flag_check = isset($blogRow->utm_flag)&&!empty($blogRow->utm_flag)?'checked':'';
                                					        ?>
            												<label class="form-check-label" for="utm_flag" <?php echo !empty($utm_flag_check)? 'style="ser-select: none !important;pointer-events: none !important;"' :''?>>
            													<input class="form-check-input" name="utm_flag" type="checkbox" value="1"  id="utm_flag" onChange="show_field_utm()" <?php echo $utm_flag_check ?> >
            													<span class="form-check-sign" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Automatically add UTM tags to destination links.</span>
            												</label>
            											</div>
    													<small class="form-text text-muted text-danger err_msg" id="err_utm_flag"></small>
    												</div>
    											</div>
    											
                                                <div id="utm_fields_div">
                                                     <!--<p class="toggcustom_2">  </p>-->
                                                    <!--<p><strong>Source</strong>, <strong>Medium</strong> and <strong>Campaign Name</strong> are compulsory.</p>-->
                                                    <div>
                                                        <input type="hidden" name="utm_id" value="<?php echo isset($utm_tags_row->utm_id)&&!empty($utm_tags_row->utm_id)?$utm_tags_row->utm_id:''?>">
                                                        <div class="row col-md-12">
                                                            <div class="col-md-6 form-group form-inline" id="div_utm_source">
                    										    <label for="utm_source" class="col-md-4 col-form-label">Source <span style="color:red;">&nbsp;*</span> </label>
                    										    <div class="col-md-8" >
                        										    <?php
                        										        if(isset($utm_tags_row->utm_source)){
                        										            $utm_source = $utm_tags_row->utm_source;
                        										        }else if($this->input->post('utm_source')){
                        										             $utm_source = $this->input->post('utm_source');
                        										        }else{
                        										            $utm_source = 'onelink';
                        										        }
                        										        $data = array( 'name' => 'utm_source',
                        										        'value' => set_value('utm_source',$utm_source),
                        										        'id' => 'utm_source',  'placeholder'   => 'UTM Source', 'class' => 'form-control input-full required', );
                                              						    echo form_input($data);
                                                					?>
                        											<small class="form-text text-muted text-danger err_msg" id="err_utm_source"></small>
                        											<small class="form-text text-muted text-default">The referrer: (e.g. google, facebook, instagram )</small>
                        										</div>
                        									</div>
                                                            <div class="col-md-6 form-group form-inline" id="div_utm_medium">
                        										<label for="utm_medium" class="col-md-4 col-form-label" style="text-align-last: right;align-self: normal;">Medium <span style="color:red;">&nbsp;*</span> </label>
                        										<div class="col-md-8 p-0" >
                        										    <?php
                        										        if(isset($utm_tags_row->utm_medium)){
                        										            $utm_medium = $utm_tags_row->utm_medium;
                        										        }else if($this->input->post('utm_medium')){
                        										             $utm_medium = $this->input->post('utm_medium');
                        										        }else{
                        										            $utm_medium = 'downly-onelink';
                        										        }
                        										        $data = array( 'name' => 'utm_medium',
                        										        'value' => set_value('utm_medium',$utm_medium), 
                        										        'id' => 'utm_medium',  'placeholder'   => 'UTM Source', 'class' => 'form-control input-full required', );
                                              						    echo form_input($data);
                                                					?>
                        											<small class="form-text text-muted text-danger err_msg" id="err_utm_medium"></small>
                        											<small class="form-text text-muted text-default">Marketing medium: (e.g. socialmedia,xyz-onelink,cpc)</small>
                        										</div>
                        									</div>
                                                        </div>
                                                        <!--<label class="col-md-12 col-form-label pl-4"><h4>UTM tags are automatically add params to destination links</h4></label>-->
                                                        
                                                        <div class="row col-md-12">
                        									<div class="col-md-6 form-group form-inline" id="div_utm_campaign">
                        										<label for="utm_campaign" class="col-md-4 col-form-label">Campaign <span style="color:red;">&nbsp;*</span></label>
                        										<div class="col-md-8" >
                        										    <?php   
                        										        if(isset($utm_tags_row->utm_campaign)){
                        										            $utm_campaign = $utm_tags_row->utm_campaign;
                        										        }else if($this->input->post('utm_campaign')){
                        										             $utm_campaign = $this->input->post('utm_campaign');
                        										        }else{
                        										            $utm_campaign = 'app-promotion';
                        										        }
                        										        $data = array( 'name' => 'utm_campaign',
                        										        'value' => set_value('utm_campaign',$utm_campaign), 
                        										        'id' => 'utm_campaign',  'placeholder'   => 'UTM Campaign', 'class' => 'form-control input-full required', );
                                              						    echo form_input($data);
                                                					?>
                        											<small class="form-text text-muted text-danger err_msg" id="err_utm_campaign"></small>
                        											<small class="form-text text-muted text-default">Product, promo code, or slogan (e.g. app-promotion, 20percentpromocode )</small>
                        										</div>
                        									</div>
                        									<div class="col-md-6 form-group form-inline" id="div_utm_term">
                        										<label for="utm_term" class="col-md-4 col-form-label" style="text-align-last: right;align-self: flex-start;">Term  </label>
                        										<div class="col-md-8 p-0" >
                        										    <?php
                        										        if(isset($utm_tags_row->utm_term)){
                        										            $utm_term = $utm_tags_row->utm_term;
                        										        }else if($this->input->post('utm_term')){
                        										             $utm_term = $this->input->post('utm_term');
                        										        }else{
                        										            $utm_term = '';
                        										        }
                        										        $data = array( 'name' => 'utm_term',
                        										        'value' => set_value('utm_term',$utm_term), 
                        										        'id' => 'utm_term',  'placeholder'   => 'UTM Term', 'class' => 'form-control input-full required', );
                                              						    echo form_input($data);
                                                					?>
                        											<small class="form-text text-muted text-danger err_msg" id="err_utm_term"></small>
                        											<small class="form-text text-muted text-default">ldentify the paid keywords (e.g. ppc, marketing-software )</small>
                        										</div>
                        									</div>
                    									</div>
                    									
                    									<div class="row col-md-12">
                        									<div class="col-md-6 form-group form-inline" id="div_utm_content">
                        										<label for="utm_content" class="col-md-4 col-form-label">Content</label>
                        										<div class="col-md-8" >
                        										    <?php
                        										        if(isset($utm_tags_row->utm_content)){
                        										            $utm_content = $utm_tags_row->utm_content;
                        										        }else if($this->input->post('utm_content')){
                        										             $utm_content = $this->input->post('utm_content');
                        										        }else{
                        										            $utm_content = '';
                        										        }
                        										        $data = array( 'name' => 'utm_content',
                        										        'value' => set_value('utm_content',$utm_content), 
                        										        'id' => 'utm_content',  'placeholder'   => 'UTM Content', 'class' => 'form-control input-full required', );
                                              						    echo form_input($data);
                                                					?>
                        											<small class="form-text text-muted text-danger err_msg" id="err_utm_content"></small>
                        											<small class="form-text text-muted text-default">Use to differentiate ads (e.g. sidebarlink,headerlink )</small>
                        										</div>
                        									</div>
                    									</div>
                									</div>
                                                </div>
                                            </div>
        								
            								<hr></hr>	
            								
                                        <br><br>
											
										<div class="form-group form-inline">
											<label for="inlineinput" class="col-md-2 col-form-label "></label>
											<div class="col-md-6 p-0">
										    <?php
										        $data = array( 'name' => 'menuBtn','value' => 'true', 'id' => 'menuBtn',  'type' => 'submit','content' => 'Submit', 'class' => 'btn btn-success',   );
                             				    echo form_button($data);
                            				    $data = array( 'name' => 'resetBtn','value' => 'true', 'id' => 'resetBtn', 
                            				    'type' => 'reset','content' => 'Cancel', 'class' => 'btn btn-warning' , 'onclick' => 'window.location.href=document.referrer'  );
                            				    echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                             				    echo form_button($data) ;
                                 			?>
											</div>
										</div>
								    </div>
								        <?php echo form_close(); ?>
    								</div>
    							</div>
    						</div>
					        </div>
                    	    
                	    <?php
                    	}
                    	else
                    	{
                    	    //view card
                    	    ?>
                    	    <div class="row">
        						<div class="col-md-12">
        							<div class="card">
        								<div class="card-header">
        								    <div class="card-head-row">
        									    <h4 class="card-title">Link Info</h4>
        									    <div class="card-tools">
        											<ul class="nav nav-pills nav-secondary nav-pills-no-bd " role="tablist">
        											    <li class="nav-item">
        										            <a class="nav-link active btn-primary" href="<?php echo base_url('admin/one_link/manager/edit/'.$id) ?>"> <i class="fas fa-pencil-alt"></i>&nbsp; Edit </a>
        									            </li>
        									            <li class="nav-item">
        										            <a class="nav-link active btn-secondary" href="<?php echo base_url('admin/one_link/statistics?link_id='.$id) ?>"> <i class="fas fa-chart-bar fa-lg"></i>&nbsp; Report</a>
        									            </li>
        									            <!--<li class="nav-item">-->
        									                <!--<a class="nav-link active btn-refresh-card" style="background: #007bff;!important">Reload</a>-->
        										           <!-- <button id="table-refresh" class="nav-link active btn-refresh-card btn-refresh-card" ><span class="fa fa-sync-alt"></span></button>-->
        									            <!--</li>-->
        											</ul>
        										</div>
        									</div>
        								</div>
							            <div class="card-body">
        							        <div class="table-responsive">
        							            <?php
        							                $one_link = isset($blogRow->share_link)&&(!empty($blogRow->share_link)) ? $blogRow->share_link:'';
        							                $target_type = isset($blogRow->target_type)&&(!empty($blogRow->target_type)) ? $blogRow->target_type:'';
        							            ?>
        							            <div class="col-md-10 align-items-center">
                                                    <p>This is your one link. Use this link in place of the one you provided.</p>
                                                    
                                                    <div class="form_control_cus input-group">
                                                      <input readonly="" type="text" id="copytext" class="form-control" value="<?php echo $one_link; ?>">
                                                      <span class="input-group-append">
                                                        <button onClick="copyToClipboard_URL(this)" data-copy_url="<?php echo $one_link; ?>" class="btn btn_curom btn-border">
                                                            <i class="fa fa-copy"></i> Copy</button>
                                                      </span>
                                                      <a target="_blank" class="twitter-share-button btn btn_curom btn-border" href="<?php echo "https://twitter.com/intent/tweet?url=".$one_link; ?>">
                                                        <i class="fab fa-twitter"></i>&nbsp;Tweet</a> 
                                                      <a target="_blank" class="twitter-share-button btn btn_curom btn-border" href="<?php echo "https://www.facebook.com/sharer/sharer.php?u=".$one_link; ?>">
                                                        <i class="fab fa-facebook"></i>&nbsp;Facebook</a> 
                                                  </div>
                                                </div>
                                                <br>
                                                
                                                <div class="col-md-12 table-responsive" >
                                                     <table id="" class="display table table-bordered ">
        									    	<tr>
        											    <th>Link Name</th><td><?php echo ( (isset($blogRow->link_name)&&(!empty($blogRow->link_name))) ? $blogRow->link_name:'-');  ?></td>
        										    </tr>
        										    <tr>
        											    <th>Default Destination Link </th><td><?php echo ( (isset($blogRow->destination_default_link)&&(!empty($blogRow->destination_default_link))) ? $blogRow->destination_default_link:'-');  ?></td>
        										    </tr>
        										    <tr>
        											    <th>Target Type</th><td><?php echo '<button class="btn btn-primary btn-sm btn-round">'.$target_type.'</button>';
        											     echo isset($blogRow->sub_link_flag)&&!empty($blogRow->sub_link_flag)? '&nbsp;&nbsp;<button type="button" class="btn btn-secondary btn-sm btn-round">Sub-links</button>':'';
        											     ?></td>
        										    </tr>
        										    <?php 
        										    if( $target_type == 'None'){
        										    }else if ($target_type == 'Device') {
        										        ?>
            										    <tr>
        										        <?php
            										       if(!empty($sub_link_list) && 1){
        										            ?>
    										                <tr>
                											    <th>Sub-links <br></th>
                											    <td>
                                                                    <table>
                                                                        <tr>
                                                                          <th>Name</th>
                                                                          <th>Links</th>
                                                                          <th>Hits</th>
                                                                          <th>Report</th>
                                                                        </tr>
                                                                        
                                                                        <?php 
                            											    $ii=1;
                            											    foreach($sub_link_list as $ck){
                            											        echo "<tr>";
                            											        echo "<td>".( (isset($ck->sublink_name)&&(!empty($ck->sublink_name))) ? $ck->sublink_name:'-')."</td>";
                            											        echo "<td>";
                            											        if( (isset($ck->share_link)&&(!empty($ck->share_link))) ? $ck->share_link:'-')
                            											        {
                            											            $share_link = $ck->share_link;
                            											            echo $share_link;
                            											            ?>
                                											        <span class="input-group-append">
                                                                                        <button type="button" onClick="copyToClipboard_URL_2(this)" data-copy_url="<?php echo $share_link; ?>" class="btn btn-sm">
                                                                                        <i class="fa fa-copy"></i> Copy</button>
                                                                                    </span>
                                											        <?php
                            											        }
                            											        echo "</td>";
                            											        
                            											        echo "<td>".( (isset($ck->hits)&&(!empty($ck->hits))) ? $ck->hits:'0')."</td>";
                            											        ?><td>
                            											        <button type="button" onclick="doActionFn('view_analytics','<?php echo $blogRow->id;?>','<?php echo $ck->id;?>');" data-toggle="tooltip" title="" class="btn btn-link btn-warning " style="padding: 0.65rem 1rem;" data-original-title="View Analytics">
                                                            						<i class="fas fa-chart-bar fa-lg"></i>
                                                            					</button>
                                                            					</td>
                            											        <?php
                            											        echo "</tr>";
                            											        $ii++;
                    										                }
            											                ?>
                                                                    </table>
                										        </td>
            											    </tr>
            											    
        										            <?php
        										            
        										        }
        										        else{
        										            echo "No data";
        										        }
        										        ?>
            										    </tr>
            										    <tr>
            											    <th>Android URL </th><td><?php echo ( (isset($blogRow->android_play_store_url)&&(!empty($blogRow->android_play_store_url))) ? $blogRow->android_play_store_url:'-');  ?></td>
            										    </tr>
            										    <tr>
            											    <th>iOS URL</th><td><?php echo ( (isset($blogRow->ios_app_store_url)&&(!empty($blogRow->ios_app_store_url))) ? $blogRow->ios_app_store_url:'-');  ?></td>
            										    </tr>
            										    <tr>
            											    <th>Windows URL</th><td><?php echo ( (isset($blogRow->website_url)&&(!empty($blogRow->website_url))) ? $blogRow->website_url:'-');  ?></td>
            										    </tr>
            										    
        										        <?php
        										    }
        										    else if ($target_type == 'Country') {
        										        if(!empty($country_redi_list)){
        										            
        										            ?>
    										                <tr>
                											    <th>Country List </th>
                											    <td><?php 
                											    $ii=1;
                											    foreach($country_redi_list as $ck){
                											        $tcc= ( (isset($ck->country_code)&&(!empty($ck->country_code))) ? $ARR_COUNTRY[$ck->country_code]:'-');
                											        $tccl= ( (isset($ck->c_d_link)&&(!empty($ck->c_d_link))) ? $ck->c_d_link:'-');
                											        
                											        echo "If the country is <strong>".$tcc."</strong> then go to <strong>".$tccl."</strong>";
                											        
                											        echo '<br>';
                											        $ii++;
        										                }
                											    ?>
                											    </td>
                										    </tr>
        										            <?php
        										        }
        										        else{
        										            echo "No data";
        										        }
        										    }
        										    else if ($target_type == 'Rotate') {
        										        if(!empty($rotate_redi_list)){
        										            ?>
    										                <tr>
                											    <th>Lists <br> [ Equally Traffic Distribution ] </th>
                											    <td><?php 
                											    $ii=1;
                											    foreach($rotate_redi_list as $ck){
                											        $tccl= ( (isset($ck->r_link)&&(!empty($ck->r_link))) ? $ck->r_link:'-');
                											        echo "Link : <strong>".$tccl."</strong>";
                											        echo '<br>';
                											        $ii++;
        										                }
                											    ?>
                											    </td>
                										    </tr>
        										            <?php
        										        }
        										        else{
        										            echo "No data";
        										        }
        										    }
        										    else if ($target_type == 'SEO') {
        										        if(isset($pageSeoRow) && !empty($pageSeoRow)){
        										            ?>
    										                <tr>
                											    <th>Page Name</th>
                											    <td><?php 
                											    echo isset($pageSeoRow->page_name) && !empty($pageSeoRow->page_name) ? $pageSeoRow->page_name: "-";
                											    ?>
                											    </td>
                										    </tr>
                										    <tr>
                											    <th>Page Title</th>
                											    <td><?php 
                											    echo isset($pageSeoRow->page_title) && !empty($pageSeoRow->page_title) ? $pageSeoRow->page_title: "-";
                											    ?>
                											    </td>
                										    </tr>
                										     <tr>
                											    <th>Promo Link</th>
                											    <td><?php 
                											    echo isset($pageSeoRow->promo_link) && !empty($pageSeoRow->promo_link) ? $pageSeoRow->promo_link: "-";
                											    ?>
                											    </td>
                										    </tr>
        										            <?php
        										            
        										        }
        										        else{
        										            echo "No data";
        										        }
        										    }
        										    
        										    ?>
        										    
        										    <tr>
        											    <th>Total hits</th><td><?php echo ( (isset($blogRow->hits)&&(!empty($blogRow->hits))) ? $blogRow->hits:'0');  ?></td>
        										    </tr>
        										    <tr>
        											    <th>Is Active </th><td><?php echo ( (isset($blogRow->is_active)&&(empty($blogRow->is_active))) ?'Active':'In Active');  ?></td>
        										    </tr>
        										    <tr>
        											    <th>Created At</th><td><?php echo ( (isset($blogRow->created_at)&&(!empty($blogRow->created_at))) ? $blogRow->created_at:'-');  ?></td>
        										    </tr>
        										    <tr>
        											    <th>Updated At</th><td><?php echo ( (isset($blogRow->updated_at)&&(!empty($blogRow->updated_at))) ? $blogRow->updated_at:'-');  ?></td>
        										    </tr>
                								</table>
                                                </div>
        									</div>
        								</div>
        							</div>
        						</div>
        					</div>
                    	    <?php
                    	}
                	?>
				</div>
			</div>
		    <!--<footer class="footer">-->
			    <?php //footer();?>
			<!--</footer>-->
		</div>
	</div>
</body>

<!-- copy of input fields for removebutton group -->
<div class="fieldGroupCopy" style="display: none;">
    <div class="col-md-12 form-inline fieldGroup_c">
        <input type="hidden" name="id[]" value="">
        <div class="form-group col-md-2 d_inline_custom" >
            <select class="form-control input-full ccsel2" name="country_code[]" id="country_code" required>
                <?php
                if(!empty($ARR_COUNTRY)){
                    foreach($ARR_COUNTRY as $ck=>$cv){
                        ?>
                        <option value="<?php echo $ck ?>"><?php echo $cv; ?></option>
                        <?php
                    }
                }
                ?>
            </select>
        </div>
        &nbsp; &nbsp; &nbsp; &nbsp;
        <div class="form-group col-md-7 d_inline_custom" >
            <input type="text" name="c_d_link[]" id="c_d_link"  placeholder="URL" class="form-control input-full validate_ctry_url" >
			<!--<small class="form-text text-muted text-danger err_msg" id="err_c_d_link"></small>-->
        </div>
        <div class="col-md-2 text-center">
            <a href="javascript:void(0)" class="btn btn-danger btn-sm remove"><i class="fa fa-trash"></i> Remove </a>
        </div>
    </div>
</div>

<!-- copy of input fields for rotate -->
<div class="fieldGroupCopy_r2" style="display: none;">
    <div class="col-md-12 form-inline fieldGroup_r2_c">
        <input type="hidden" name="r_id[]" value="">
        <div class="form-group col-md-7 d_inline_custom" >
            <input type="text" name="r_link[]" id="r_link"  placeholder="URL" class="form-control input-full validate_ctry_url" >
        </div>
        <div class="col-md-2 text-center">
            <a href="javascript:void(0)" class="btn btn-danger btn-sm remove_r2"><i class="fa fa-trash"></i> Remove </a>
        </div>
    </div>
</div>


<!-- copy of input fields for sublink -->
<div class="fieldGroupCopy_sl3" style="display: none;">
    <div class="col-md-12 form-inline fieldGroup_sl3_c">
        <input type="hidden" name="sl_id[]" >
        <div class="form-group col-md-4 d_inline_custom">
            <input type="text" readonly class="form-control input-full sharelink2_val_s share_link_2_reqcls" name="share_link_2[]" required >
        </div>
        &nbsp;&nbsp;
        <div class="form-group col-md-5 d_inline_custom" >
            <input type="text" name="sublink_name[]" id="sublink_name"  placeholder="Sub Link Name" class="form-control input-full sublink_name_reqcls" required >
        </div>
        <div class="col-md-2 text-center">
            <a href="javascript:void(0)" class="btn btn-danger btn-sm remove_sl3"><i class="fa fa-trash"></i> Remove </a>
        </div>
    </div>
</div>


<script>

$(document).ready(function(){
    $(document).on('shown.bs.tab', 'a[data-toggle="pill"]', function (e) {
        
        var tab = $(e.target);
        var contentId = tab.attr("data-tabv");
        //This check if the tab is active
        if (tab.hasClass('active')) {
            // alert('the tab with the content id ' + contentId + ' is visible');
            $("#target_type").val(contentId);
            if(contentId == 'Country'){
                $("#country_code").attr("required", true);
                $("#c_d_link").attr("required", true);
                $(".lpseo_inp_cls").attr("required", false);
                $("#r_link").attr("required", false);
                
            }
            else if(contentId == 'Rotate'){
                $("#r_link").attr("required", true);
                $(".lpseo_inp_cls").attr("required", false);
                $("#country_code").attr("required", false);
                $("#c_d_link").attr("required", false);
            }
            else if(contentId == 'SEO'){
                $(".lpseo_inp_cls").attr("required", true);
                 $("#country_code").attr("required", false);
                $("#c_d_link").attr("required", false);
                $("#r_link").attr("required", false);
            }
            else{
                $("#country_code").attr("required", false);
                $("#c_d_link").attr("required", false);
                $(".lpseo_inp_cls").attr("required", false);
                $("#r_link").attr("required", false);
            }
        } else {
            $("#target_type").val('');
            //  alert('the tab with the content id ' + contentId + ' is NOT visible');
        }
        
    });
});



    $("#country_code").select2();
    // $(".ccsel2").select2();
    var  share_link_val = $("#share_link").val();
    
//     $(document).on('change', "#custom_keyword", function() {
        
// 	 	if($(this).is(':checked') == true){
// 			$('.changePass').show();
// 			$("#share_link").val('');
// 		}else {
// 			$('.changePass').hide();
			
// 			$("#share_link").val(share_link_val);
// 		}
// 	});
	
	
	$(document).on('keyup', "#app_keyword", function() {
    	$("#share_link").val(this.value);
	});
    
	$(document).on('change', "#share_link", function() {
    	
    	$("#share_link_note").show();
        $errStaus=true;
        
 	    if($errStaus){
    	 	var url = $('#share_link').val(); 
			var baseURL = "<?php echo $ajax_url_4 ?>";
			if(url != ''){
			    	$.ajax({
    				url:baseURL, async: false, type: 'POST',cache: false,
    				data: 'url='+url+'&test_url_k=msdkyiNCys5@eShdbs^iAd8^SbndunkJmc3s2',
    				success:function (resdata) {
    				    
    				    // $("#share_link_note").hide();
    					var resObj = jQuery.parseJSON( resdata );
    					if(resObj.msg == 'exists') {
    					    setMsg('share_link','Keyword already being used!');$errStaus=true;
    					}
     					else {
    					    $('#div_share_link').removeClass('has-error').addClass('has-success');$('#err_share_link').html('');	
    					    $errStaus=false;
     					}
    				}
    			});
			}else if(share_link_val != ''){
			    $('#share_link').val(share_link_val); 
			    $('#div_share_link').removeClass('has-error').addClass('has-success');$('#err_share_link').html('');	
			 //   $("#share_link_note").show();
			}else{
			    $('#share_link').val('');
			 //   $("#share_link_note").hide();
			}
    	 }
	});
	
    function validate_url(url){
        
        sub_url =  '<?php echo $ajax_url_3 ?>';
        var settings = {
        	cache: false,
        	dataType: 'JSON',
    	    data: {url:url ,test_url_k:'m&knsd$^%&^8yiNCys5@&Shdbs^iAd8^SbndunkJmc&s2'},
        	async: false,
        	crossDomain: true,
        	url: sub_url,
        	method: "POST",
	    };
	    var res_u='false';
        $.ajax(settings).done(function (response) {
        // 	console.log("ww"+response);
        	if(response.res == true){
        	   // alert()
                res_u= 'true';
            }else{
                // alert(false)
                res_u= 'false';
            }
        });
        return res_u;
    }
    
    
    CKEDITOR.config.extraAllowedContent = true;
    CKEDITOR.config.toolbarGroups = [
		{ name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
		{ name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
		{ name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
		{ name: 'forms', groups: [ 'forms' ] },
		{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
		{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
		{ name: 'links', groups: [ 'links' ] },
		{ name: 'insert', groups: [ 'insert' ] },
		{ name: 'styles', groups: [ 'styles' ] },
		{ name: 'colors', groups: [ 'colors' ] },
		{ name: 'tools', groups: [ 'tools' ] },
		{ name: 'others', groups: [ 'others' ] },
		{ name: 'about', groups: [ 'about' ] }
	];
    CKEDITOR.config.removeButtons = 'Anchor,HorizontalRule,CopyFormatting,RemoveFormat,Cut,Copy,Paste,PasteText,PasteFromWord,Undo,Redo,Find,Replace,SelectAll,Scayt,Form,Checkbox,Radio,TextField,Textarea,Select,Button,ImageButton,HiddenField,Templates,Save,NewPage,ExportPdf,Print,Strike,Language,Flash,Smiley,PageBreak,TextColor,BGColor,Maximize,About,ShowBlocks,CreateDiv,Blockquote,Styles';
    CKEDITOR.config.allowedContent = true;
    var editor = CKEDITOR.replace( 'page_content', {
        extraPlugins: 'image, image2, uploadimage, preview',
        filebrowserUploadUrl: '<?php echo $editor_ckediter_file_upload_path_base; ?>',
        filebrowserUploadMethod: 'form',
        height: 200,
        allowedContent: true,
    });
</script>
<script>
    function copyToClipboard_URL(event)
    {
        c_url = $(event).data('copy_url');
        const input = document.createElement('input')
        
        input.value = c_url;
        document.body.appendChild(input)
        input.select()
        document.execCommand('Copy')
        document.body.removeChild(input)

        // $(".copy_txtc_u").css("font-weight",'900');
        // $(".copy_txtc_u").text("Copied!");
        // $(event).attr('title', 'Copied');
        // $(event).attr('data-original-title','Copied');
        $(event).html('<i class="fas fa-check"></i> Copied');
        // $(event).tooltip('show');
        // setTimeout(() => { $(".copy_txtc_u").text("Copy URL"); $(".copy_txtc_u").css("font-weight",'400'); }, 1500);(event).attr('title', 'Copy'); $(event).attr('data-original-title','Copy');
        setTimeout(() => { $(event).html('<i class="fa fa-copy"></i> Copy'); }, 2000);
        
    }
    
    function copyToClipboard_URL_2(event)
    {
        c_url = $(event).data('copy_url');
        const input = document.createElement('input')
        input.value = c_url;
        document.body.appendChild(input)
        input.select()
        document.execCommand('Copy')
        document.body.removeChild(input)

        // $(".copy_txtc_u").css("font-weight",'900');
        // $(".copy_txtc_u").text("Copied!");
        // $(event).attr('title', 'Copied');
        // $(event).attr('data-original-title','Copied');
        $(event).html('<i class="fas fa-check"></i> Copied');
        // $(event).tooltip('show');
        // setTimeout(() => { $(".copy_txtc_u").text("Copy URL"); $(".copy_txtc_u").css("font-weight",'400'); }, 1500);(event).attr('title', 'Copy'); $(event).attr('data-original-title','Copy');
        setTimeout(() => { $(event).html('<i class="fa fa-copy"></i> Copy'); }, 2000);
    }
    
    
    function show_field_sublink()
    {
        $("#err_sub_link_flag").css("display","none");
    	var action = '<?php echo $action ?>';
	    if($('#sub_link_flag').is(":checked"))
        {
            $("#share_link_2_a1").val( base_URL_app + $("#share_link").val()+ "-1" + makeRandomid(3) );
            $("#sublink_fields_div").show();
            $(".share_link_2_reqcls").attr("required", true);$(".sublink_name_reqcls").attr("required", true);
        }
        else
        {
            $("#sublink_fields_div").hide();
            $(".share_link_2_reqcls").attr("required", false);$(".sublink_name_reqcls").attr("required", false);
        }
    }
    show_field_sublink();
    
    function show_field_utm()
    {
        $("#err_utm_flag").css("display","none");
	    if($('#utm_flag').is(":checked")){
            $("#utm_fields_div").show();
            $("#utm_source").attr("required", true);$("#utm_medium").attr("required", true);$("#utm_campaign").attr("required", true);
        }
        else{
            $("#utm_fields_div").hide();
            $("#utm_source").attr("required", false);$("#utm_medium").attr("required", false);$("#utm_campaign").attr("required", false);
        }
    }
    show_field_utm();

$("#category_id").select2();
</script>
</html>