View file ads/templates/ads/index.html

File size: 2.22Kb
<div class="page-content">
	<?php include 'header.html'; ?>
	<div class="ads-cont-wrapper">
		<?php if ($context['user_ads']) { ?>
			<div class="pg_page table-responsive">
				<table class="table sh_pymnt_table sh_ad_main_pymnt_table">
					<thead>
						<tr>
							<th>{{LANG id}}</th>
							<th>{{LANG company}}</th>
							<th>{{LANG bidding}}</th>
							<th>{{LANG clicks}}</th>
							<th>{{LANG views}}</th>
							<th>{{LANG status}}</th>
							<th>{{LANG action}}</th>
						</tr>
					</thead>
					<tbody id="user-ads">
						<?php foreach ($context['user_ads'] as $key => $context['ad']) {
							include 'list.html';
						} ?>
					</tbody>
				</table>
			</div>
		<?php } else{ ?>
			<div class="empty_state">
				<span><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M12,8H4A2,2 0 0,0 2,10V14A2,2 0 0,0 4,16H5V20A1,1 0 0,0 6,21H8A1,1 0 0,0 9,20V16H12L17,20V4L12,8M21.5,12C21.5,13.71 20.54,15.26 19,16V8C20.53,8.75 21.5,10.3 21.5,12Z" /></svg></span>
				<p>{{LANG ad_not_found}}</p>
			</div>
		<?php } ?>
	</div>
</div>

<?php include $context['dirname_theme'].'/main/templates/modals/delete_ad.html'; ?>
<script type="text/javascript">
	$(document).on('click', '.delete-ad', function(event) {
		var self = $(this);	
		var id = self.attr('id');
		$('div.delad--modal').data('id',id).fadeIn(250);
	});
	$(document).on('click','.delete--ad',function(event) {
		var zis = $(this);
		var id  = zis.parents('.confirm--modal').data('id');
		

		if (id) {
			zis.parents('.confirm--modal').data('id',"").fadeOut(200);
			$("#modal-progress").removeClass('hidden');
			$.ajax({
				url: link('profile/delete_ad'),
				type: 'POST',
				dataType: 'json',
				data: {id:id},
			})
			.done(function(data) {
				if (data.status == 200) {
					$("tr[data-ad-id="+id+"]").slideUp(function(){
						$(this).remove();
					})
				}
				else{
					scroll2top();
					$.toast(data.message,{
	                	duration: 5000, 
	                	type: 'success',
	                	align: 'bottom',
	                	singleton: true
	                });
				}
				$("#modal-progress").addClass('hidden');
			});
		}
	});
</script>