<?php

$pageTitle = 'Share Links';

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

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

?>
<!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'); ?>

<script type="text/javascript">
 function doActionFn(action,id){
	 if(action == 'edit' || action == 'view'){
			window.location= '<?php echo base_url('admin/'.$categoryFor.'/manager/'); ?>/'+action+'/'+id;
	}else{
		 $('#doAction').val(action);	
		 if(action == 'delete'){
			if (confirm("Are you sure you want to delete?")) {
				$('#listFrm').submit();
			}	
		} else{
			$('#listFrm').submit();
		}
	}
 }
function validateAccountForm(){
	clrErr();
	$errStaus = false; 
	var action = '<?php echo $action ?>';
	
   	// if(validateFormFields('android_play_store_url','Please enter the android_play_store_url.',''))$errStaus=true;
   	// if(validateFormFields('ios_app_store_url','Please enter the ios_app_store_url.',''))$errStaus=true;
   	// if(validateFormFields('website_url','Please enter the website_url.',''))$errStaus=true;
    
    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 =='' || ios_app_store_url =='' ||  website_url ==''){
   	         if(validateFormFields('website_url','Please enter Atleast website url ',''))$errStaus=true;
    }
    
	
  	if($errStaus) {
		return false;
	} else {
	return true;		
	}
	
}
 function showPImgBox(value){
     
// 	$('#logo_img_url1').hide();
	$('#div_logo_img_url').hide(); $('#div_logo_img_url1').hide();
	if(value == 2){
		$('#div_logo_img_url1').show();$('#div_logo_img_url').hide();
	}else if(value == 1){
		$('#div_logo_img_url1').hide();$('#div_logo_img_url').show();
	}
	
}

	
</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.'/share_link');?>"><?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'){
                    	    //add, edit card
                	    ?>
                    	    <div class="row">
						        <div class="col-md-12">
    							<div class="card">
    							    
    								<div class="card-header">
    									<h4 class="card-title"><?php echo $pageTitle_Forpage; ?></h4>
    								</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 class="form-group form-inline" id="div_android_play_store_url">
    												<label for="android_play_store_url" class="col-md-3 col-form-label">Android Play Store URL </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-3 col-form-label">IOS Play Store URL </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 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_ios_app_store_url"></small>
    												</div>
    											</div>
    											
    											
    											 <div class="form-group form-inline" id="div_website_url">
    												<label for="website_url" class="col-md-3 col-form-label">Website URL </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>
    											
    											 
    											
                                                <br>
    											
    											<div class="form-group form-inline">
        												<label for="inlineinput" class="col-md-3 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>
        									    
    								        <?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">Plan Info</h4>
        									</div>
        								</div>
							            <div class="card-body">
        							        <div class="table-responsive">
        										<table id="" class="table table-bordered">
        									    	<tr>
        											    <th>Share Link</th><td><?php echo ( (isset($blogRow->share_link)&&(!empty($blogRow->share_link))) ? $blogRow->share_link:'-');  ?></td>
        										    </tr>
        										    <tr>
        											    <th>Android Play Store 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 App Store 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>Website URL</th><td><?php echo ( (isset($blogRow->website_url)&&(!empty($blogRow->website_url))) ? $blogRow->website_url:'-');  ?></td>
        										    </tr>
        										    <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>
                    	    <?php
                    	}
                	?>
				</div>
			</div>
		    <!--<footer class="footer">-->
			    <?php //footer();?>
			<!--</footer>-->
		</div>
		
	</div>

</body>

<script>

    function show_field(value=null)
    {
        if(value == 'android')
        {
            $("#show_a_field").show();
            $("#show_ios_field").hide();
            $("#ios_bundle_id").val('');
        }
        else if(value == 'ios')
        {
            $("#show_a_field").hide();
            $("#show_ios_field").show();
            $("#package_name").val('');
        }
        else
        {
            $("#show_a_field").hide();
            $("#show_ios_field").hide();
            $("#package_name").val('');
            $("#ios_bundle_id").val('');
        }
    }
    
</script>
<?php
    // echo "<script> show_field('".$cheked_at_value."'); </script>";
?>
</html>