<?php $this->load->view('header') ?>
<div class="content">
  <div class="container-fluid">
		<div class="row">
			<div class="col-md-12">
	        <div class="card ">
	          <div class="header" style="margin-bottom:15px;">
							<div class="pull-left">
								<h4 class="title"><i class="pe-7s-note2"></i>COUPON CAMPAIGNS</h4>
							</div>
							<div class="pull-right" style="margin-bottom:15px;">
								<a href="<?php echo base_url(); ?>admin/new_capaign" class="btn btn-warning btn-fill"><i class="fa fa-plus"></i> Create New Campaign</a>
							</div>
	          </div>
	           <div class="content">
	              <div class="table-full-width">
                  <table class="table">
                    <tbody>
                    	<?php if($campaign) {
                    	foreach ($campaign as $key => $value) { ?>
                        <tr>
                        	<td><b><?php echo $value->c_name; ?></b></td>
                        	<td class="td-actions text-right">
                        		<button type="button" onclick="showcode('<?php echo $value->c_domain; ?>','<?php echo $value->c_slug; ?>')" rel="tooltip" title="Get Embed Code" class="btn btn-success btn-simple btn-xs">
                        			<i class="fa fa-code"></i>
                        		</button>
                        		<button type="button" onclick="showstats('<?php echo $value->c_slug; ?>')" rel="tooltip" title="Stats" class="btn btn-warning btn-simple btn-xs">
                        			<i class="fa fa-bar-chart"></i>
                        		</button>
                        		<button type="button" rel="tooltip" title="Edit" onclick="showedit('<?php echo $value->c_slug; ?>')" class="btn btn-info btn-simple btn-xs">
                        			<i class="fa fa-pencil"></i>
                        		</button>
                        		<button type="button" rel="tooltip" onclick="showdelete('<?php echo $value->c_slug; ?>')" title="Delete" class="btn btn-danger btn-simple btn-xs">
                        			<i class="fa fa-times"></i>
                        		</button>
                        	</td>
                        </tr>                                        		
                    	<?php } } ?>                  
                    </tbody>
                  </table>
	              </div>
	            </div>
	        </div>
	    </div>
		</div>
</div>
</div>
</div>
</div>

<script src="<?php echo base_url(); ?>assets/js/jquery.min.js" type="text/javascript"></script>
<script src="<?php echo base_url(); ?>assets/js/jquery-ui.min.js" type="text/javascript"></script>
<script src="<?php echo base_url(); ?>assets/js/bootstrap.min.js" type="text/javascript"></script>
<script src="<?php echo base_url(); ?>assets/js/jquery.validate.min.js"></script>
<script src="<?php echo base_url(); ?>assets/js/moment.min.js"></script>
<script src="<?php echo base_url(); ?>assets/js/bootstrap-datetimepicker.js"></script>
<script src="<?php echo base_url(); ?>assets/js/bootstrap-selectpicker.js"></script>
<script src="<?php echo base_url(); ?>assets/js/bootstrap-checkbox-radio-switch-tags.js"></script>
<script src="<?php echo base_url(); ?>assets/js/chartist.min.js"></script>
<script src="<?php echo base_url(); ?>assets/js/sweetalert2.js"></script>
<script src="<?php echo base_url(); ?>assets/js/jquery-jvectormap.js"></script>
<script src="<?php echo base_url(); ?>assets/js/jquery.bootstrap.wizard.min.js"></script>
<script src="<?php echo base_url(); ?>assets/js/bootstrap-table.js"></script>
<script src="<?php echo base_url(); ?>assets/js/jquery.datatables.js"></script>
<script src="<?php echo base_url(); ?>assets/js/fullcalendar.min.js"></script>
<script src="<?php echo base_url(); ?>assets/js/light-bootstrap-dashboard.js"></script>

<script type="text/javascript">
function showerror(msg){
$.notify(
	{
		icon: "pe-7s-bell",
		message: msg
	},
	{
		type: 'danger',
		timer: 5000,
		placement: 
			{
			from: 'top',
			align: 'center'
			}
	});
}
		
function showsuccess(msg){
$.notify(
	{
		icon: "pe-7s-smile",
		message: msg
	},
	{
		type: 'success',
		timer: 5000,
		placement: 
		{
			from: 'top',
			align: 'center'
		}
	});
}
			
function showdelete(slug){
	if (confirm("Are you sure you want to remove this campaign?") == true) {
		document.location="admin/removecampaign/"+slug;
	}	
}
			
function showedit(slug){
	document.location="admin/edit/"+slug;
}

function showstats(slug){
	document.location="admin/stats/"+slug;
}
			
function SelectAll(id){
	document.getElementById(id).focus();
	document.getElementById(id).select();
}
			
function showwp(slug){
	var last5 = "bd89c";
	swal({
	  title: 'Use With Wordpress',
	  imageUrl: 'assets/img/wp.png',
	  html:
		'<div style="text-align:left;">Step 1. Download and the <a target="_blank" href="https://onecode.tech/download/onecode.zip">OneCode Wordpress plugin here.</a><br>Step 2. Install the plugin on your website.<br>Step 3. Use the shortcode below to display the coupon code:<br><textarea class="form-control" rows="2" cols="50" id="cfcode" onclick="SelectAll(\'cfcode\');">[onecode]'+slug+'-'+last5+'[/onecode]</textarea>',
	  showCloseButton: true,
	  confirmButtonText:
		'All Done!'
	});			
}
			
function showcode(domain,slug){
	swal({
	  title: 'Embed Code:',
	  imageUrl: '<?php echo base_url(); ?>assets/img/embed.png',
	  html:
		'<textarea class="form-control" rows="5" cols="50" id="cfcode" onclick="SelectAll(\'cfcode\');"><iframe src="https://'+domain+'/'+slug+'/" style="width: 100%;height: 150px;overflow-y: hidden;" frameborder="0" scrolling="no"></iframe></textarea>',
	  showCloseButton: true,
	  confirmButtonText:
		'All Done!'
	});
}
			
function showtemplate(slug){
	var last5 = "bd89c";
	swal({
	  title: 'Code For The Template',
	  imageUrl: '<?php echo base_url(); ?>assets/img/embed.png',
	  html:
		'<textarea class="form-control" rows="5" cols="50" id="tempcode" onclick="SelectAll(\'tempcode\');">$onecode = "'+slug+'-'+last5+'";</textarea>',
	  showCloseButton: true,
	  confirmButtonText:
		'All Done!'
	});			
}

function showinlinecode(domain,slug){
	swal({
	  title: 'Inline Code',
	  html:
		'<textarea class="form-control" rows="15" cols="100" id="tempcode" onclick="SelectAll(\'tempcode\');">&lt;script&gt;&#13;&#10;var prefix = "USE COUPON CODE:";&#13;&#10;var suffix = "to save 97% off at Amazon checkout.";&#13;&#10;var fontsize="28";&#13;&#10;&lt;/script&gt;&#13;&#10;&lt;center&gt;&lt;span id=&quot;onecode_span&quot;&gt;&lt;span id=&quot;onecode_prefix&quot;&gt;&lt;/span&gt;&amp;nbsp;&lt;span id=&quot;onecode_code&quot; style=&quot;font-weight:bold;color:#f8cf45;&quot;&gt;&lt;/span&gt;&amp;nbsp;&lt;span id=&quot;onecode_suffix&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/center&gt;&#13;&#10;&lt;script src=&quot;https://'+domain+'/'+slug+'/?script=inline&quot;&gt;&lt;/script&gt;</textarea>',
	  showCloseButton: true,
	  confirmButtonText:
		'All Done!'
	});			
}
$(document).ready(function(){});
</script>
</body>
</html>
