<link href="{{CONFIG theme_url}}/js/lib/jquery-datatable/skin/bootstrap/css/dataTables.bootstrap.min.css" rel="stylesheet">
<script src="{{CONFIG theme_url}}/js/lib/jquery-datatable/jquery.dataTables.js"></script>
<script src="{{CONFIG theme_url}}/js/lib/jquery-datatable/skin/bootstrap/js/dataTables.bootstrap.js"></script>
<?php echo PT_LoadPage('third-party/paypal-demo'); ?>


<div class="container-home">
<h3 class="recent-articles heading_all_sections_top">
	<span>
		<svg xmlns="http://www.w3.org/2000/svg" width="15" height="13.5" viewBox="0 0 15 13.5">
				  <path id="Path_30540" data-name="Path 30540" d="M15.763,5.782A2.77,2.77,0,0,1,13.805,8.43,4.433,4.433,0,0,0,14,7.125a4.493,4.493,0,0,0-2.2-3.862A2.827,2.827,0,0,1,12.987,3,2.78,2.78,0,0,1,15.763,5.782ZM15.2,9.225a1.235,1.235,0,0,0-.937.112,2.5,2.5,0,0,1-1.043.308,3.825,3.825,0,0,1-.525.637A4.069,4.069,0,0,1,15.44,13.5h.517a.921.921,0,0,0,.818-.472A1.914,1.914,0,0,0,17,12.12v-.532A2.431,2.431,0,0,0,15.2,9.225Zm-8-5.962A2.827,2.827,0,0,0,6.012,3,2.777,2.777,0,0,0,5.2,8.43,4.433,4.433,0,0,1,5,7.125,4.493,4.493,0,0,1,7.2,3.263ZM6.3,10.283a3.825,3.825,0,0,1-.525-.637,2.5,2.5,0,0,1-1.042-.308A1.235,1.235,0,0,0,3.8,9.225,2.431,2.431,0,0,0,2,11.587v.532a1.914,1.914,0,0,0,.225.908.918.918,0,0,0,.81.472H3.56A4.069,4.069,0,0,1,6.3,10.283Zm5.88,1.02a1.75,1.75,0,0,0-.4-.053,1.525,1.525,0,0,0-.743.195,3.2,3.2,0,0,1-3.09,0,1.525,1.525,0,0,0-.742-.195,1.75,1.75,0,0,0-.4.053,2.966,2.966,0,0,0-2.19,2.872v.653A2.305,2.305,0,0,0,4.9,15.922a1.091,1.091,0,0,0,.982.578h7.23a1.091,1.091,0,0,0,.983-.578,2.305,2.305,0,0,0,.278-1.095v-.653A2.966,2.966,0,0,0,12.185,11.3Zm.69-4.178A3.375,3.375,0,1,0,9.5,10.5,3.375,3.375,0,0,0,12.875,7.125Z" transform="translate(-2 -3)" fill="currentColor"></path>
				</svg>
		{{LANG ads}}
	</span>

	<div class="right_balance_custom_ads">
		<div class="balance_c_div">
			<span> {{LANG wallet}} </span>
			<span>({{CURRENCY}}{{ME wallet}})</span>
		</div>
		<div class="balance_c_div">
			<span> {{LANG balance}} </span>
			<span>({{CURRENCY}}{{ME balance}})</span>
		</div>
	</div>
</h3>

<div class="upload_video_bg_color">
	<div class="custom_datatables">
		
	<div class="form-group">
		<div class="show_button_search_custom">
			
			<div class="cus_dtb_searchbox">
				<input type="text" name="search" id="searchcustomdb" class="custom_dt_search" placeholder="search for advertising">
			</div>
			<a href="{{LINK ads/create}}" data-load="?link1=create_ads">
				<button class="btn btn-main btn_upld_vid_next upload_custom_new" style="margin: 0 !important;">{{LANG create_ad}}</button>
			</a>
		</div>
	</div>

	<table class="table" id="pt-user-ads-table">
		<thead>
			<th>
				{{LANG status}}
			</th>
			<th>
				{{LANG category}}
			</th>
			<th>
				{{LANG name}}
			</th>
			<th>
				{{LANG results}}
			</th>
			<th>
				{{LANG spent}}
			</th>
			<th>
				{{LANG action}}
			</th>
		</thead>
		<tbody>
			{{ADS_LIST}}
		</tbody>
	</table>
</div>
</div>
</div>







<script>






	$(document).ready( function () {
	    var oTable = $('#pt-user-ads-table').DataTable(
	    	{
            "info": false,
            "bFilter": false,
            "sDom": "rtipl",
            language: {
			        searchPlaceholder: "search for advertising"
			    }
        	}
        );
	    $('#searchcustomdb').keyup(function(){
		      oTable.search($(this).val()).draw() ;
		})

		$('#pt-user-ads-table').on( 'page.dt', function () {
		    PT_Delay(function(){
		    	$('#pt-user-ads-table').find('[type="checkbox"]').each(function(index, el) {
			    	$(el).bootstrapToggle();
			    });
		    },50)
		});
	});


	function PT_ReplenishBalance() {
		swal({
		  html:$('.replenish-balance-form').clone().addClass('clone').removeClass('hidden'),
		  showCloseButton: true,
		  showCancelButton: false,
		  focusConfirm: false,
		  confirmButtonText:"{{LANG replenish}}",
		  buttonsStyling:false,
		  confirmButtonClass:'btn btn-success',
		  allowOutsideClick:false,
		  showLoaderOnConfirm: true,
		  preConfirm: function () {
		    return new Promise(function (resolve, reject) {
		    	amount = $(".replenish-balance-form.clone").find('input').val();
		    	if ({{ME balance_or}} < 1) {
		    		reject("{{LANG no_balance_to_move}}!");
		    	}
		    	else if (!amount || amount < 1){
		    		reject("{{LANG please_check_details}}!");
		    	}
		    	else if(amount > {{ME balance_or}}){
		    		reject("{{LANG more_than_balance}}!");
		    	}
		    	else{
		    		$.post('{{LINK aj/wallet/move_to_wallet}}', {amount: amount}, function(data, textStatus, xhr) {
		    			if (data.status == 200) {
		    				location.reload();
		    			}
		    			else{
		    				reject(data.message);
		    			}
		    		});
		    	}
		    })
		  }
		}).then(function(){/*pass*/},function(){/*pass*/});
	}

	function PT_DeleteAd(id){
		if (!id) {
			return false;
		}
		swal({
		  title: '{{LANG confirmation}}',
		  text: "{{LANG confirm_delete_ad}}",
		  type: 'warning',
		  showCloseButton: true,
		  showCancelButton: true,
		  focusConfirm: false,
		  confirmButtonText:"<i class='material-icons'>delete</i> {{LANG delete}}!",
		  cancelButtonText:"<i class='fa fa-ban'></i> {{LANG cancel}}",
		  buttonsStyling:false,
		  confirmButtonClass:'btn btn-success margin-right',
		  cancelButtonClass:"btn btn-default",
		  allowOutsideClick:false,
		}).then(function (){
			$.post('{{LINK aj/ads/delete}}', {id:id}, function(data, textStatus, xhr) {/* pass */});
			$("tr[data-ads-list='"+id+"']").slideUp(function(){
				$(this).remove();
				swal({
					title:'{{LANG deleted}}',
				    type:'success',
				    buttonsStyling:false,
				    confirmButtonClass:'btn btn-success',
				});
			});
		});
	}

	function PT_ToggleAdsStatus(id){
		if (!id) {
			return false;
		}
		$.post('{{LINK aj/ads/toggle-stat}}', {id:id}, function(data, textStatus, xhr) {/* pass */});
	}


</script>

<form class="replenish-wallet-form hidden">
	<div class="form-group">
		<label>
			<span>{{LANG my_balance}}</span> <strong>{{CURRENCY}}{{ME wallet}}</strong>
		</label>
	</div>
	<div class="form-group">
		<small>{{LANG replenish_my_balance}}</small>
		<input type="number" class="form-control" placeholder="{{LANG amount}}">
	</div>
</form>
<form class="replenish-balance-form hidden">
	<div class="form-group">
		<label>
			<span>{{LANG my_balance}}</span> <strong>{{CURRENCY}}{{ME balance}}</strong>
		</label>
	</div>
	<div class="form-group">
		<small>{{LANG move_balance_to_wallet}}</small>
		<input type="number" class="form-control" placeholder="{{LANG amount}}">
	</div>
</form>


