<?php include "header.php"; 
?>

<div id="content" class="main-content">

	<div class="layout-px-spacing">
		<div class="row layout-top-spacing" id="cancel-row">
		<?php
		if($setup == "add-product" || $setup == "edit-product")
		{
			$jwcts = gtAll("ktmmenu_name","", 'mname ASC');
			
			$prd_ft = ""; $gt_ads = "";
			if(!empty($prd))
			{
				$chk_prd_rc = $db_con->prepare("SELECT * FROM kmartstockprds WHERE ksp_id = '$prd' ");
				$chk_prd_rc->execute();
				$prd_ft = $chk_prd_rc->fetch();	 
				$prd_count = $chk_prd_rc->rowCount();
				
				if($prd_count == 0){ echo "<script>window.location.href ='products?preg=manage-stock'</script>"; }
				$gt_ads = gtAll("kprdadditional"," ksp_id = '$prd_ft[ksp_id]' ","ka_id ASC");
				$gt_imgs = gtAll("kprdw_imgs"," prd_rec = '$prd_ft[pqrcode]' ","kmg_id ASC");
				
				$gt_ctg = gtAll("ktmmenu_category"," mn_id = '$prd_ft[mn_id]' ","cname ASC");
				$gt_sbg = gtAll("ktmmenu_subcategory"," mc_id = '$prd_ft[mc_id]' ","sname ASC");
			}	
		?>
		<link href="assets/dropzone.css" rel="stylesheet" type="text/css" />
		<script src="https://cdn.tiny.cloud/1/1mb1rf3spybvgrr1u39vhym6nvfqlmkb7qgm9ym9fixbr3n6/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script>
		<div class="col-xl-12 col-lg-12 col-sm-12 layout-spacing m-auto">
		
		<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 ">
			<h1 class="title-4"><?= ($setup == "add-product") ? 'Add' : 'Edit'; ?> Product</h1>
			
			<div class="btn-toolbar mb-2 mb-md-0">
				<div class="btn-group mr-2">
					<a href="?setup=manage-stock" class="btn btn-icon bg-warning text-white">
					<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-grid"><rect x="3" y="3" width="7" height="7"></rect><rect x="14" y="3" width="7" height="7"></rect><rect x="14" y="14" width="7" height="7"></rect><rect x="3" y="14" width="7" height="7"></rect></svg>
					&nbsp; Manage Posts </a>
				</div>
			</div>
		</div>
		
		<form class="text-left" method="post" action="" id="mksikkaprds_form" autocomplete="" enctype="multipart/form-data">
		<div class="row">
			<div class="col-md-6">
				<div class="widget-content widget-content-area bg-light br-6 mb-3">	
					<h5 class="mb-4 font-weight-bold text-warning">Product Info</h5>
					<div>
					
						<div class="row">
							<div class="col-md-12 form-group">
								<label class="text-dark font-weight-bold">Product Name <code>*</code>  </label>
								<input type="text" name="jewtitle" class="form-control" required value="<?= (!empty($prd_ft)) ? $prd_ft['pname']:''; ?>"/>
								<span id="" class="error_here"></span>
							</div>
							<div class="col-md-12 form-group">
								<label class="text-dark font-weight-bold">Brief Description<code>*</code><small>Very Brief</small> </label>
								<textarea name="jewnote" class="form-control"><?= (!empty($prd_ft)) ? $prd_ft['pbreif']:''; ?></textarea>
								<span id="" class="error_here"></span>
							</div>
							<input type="hidden" value="<?= $setup; ?>" name="post_info" id="stpsinf" />
							<div class="col-md-12 form-group">
								<label class="text-dark font-weight-bold">Detailed Description<code>*</code> </label>
								<textarea name="jewbrief" class="form-control" id="prdscbrief"><?= (!empty($prd_ft)) ? $prd_ft['pdesc']:''; ?></textarea>
								<span id="" class="error_here"></span>
							</div>
						</div>
					</div>
				</div>
				
				<div class="widget-content widget-content-area bg-light br-6 mb-3">
					<h5 class="mb-4 font-weight-bold text-warning">Product Attributes & Tags</h5>
					<div class="w-100 mb-3" id="add_cat">
						<div class="form-group">
								<?php
								if(!empty($prd_ft) && !empty($gt_ads)){
										foreach($gt_ads as $ads)
										{
											$ad_id = $ads['ka_id'];
											?>
											<div class="tr mb-2">
											<input type="hidden" name="dmedame[]" value="<?= $ad_id; ?>" />
											<div class="input-group">
												<input type="text" class="form-control font-weight-bold" name="dmhdn[]" placeholder="Heading" value="<?= $ads['ka_head']; ?>" />
												<input type="text" class="form-control" name="dminfn[]" placeholder="Attribute" value="<?= $ads['ka_info']; ?>" />
												<span id="" class="error_here text-left"></span>
												<div class="input-group-prepend">
													<div class="input-group-text font-weight-bold bg-transparent">
													<button type="button" class="bg-transparent  bs-tooltip border-0 text-danger"  title="Delete"  id="del_<?= $ad_id; ?>" onClick="takeoff(<?= $ad_id; ?>,'pdmytw')"  >
													<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-trash-2 ">
													<polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2">
													</path><line x1="10" y1="11" x2="10" y2="17"></line><line x1="14" y1="11" x2="14" y2="17"></line></svg>
													</button>
													</div>
												</div>
											</div>
											</div>
											<?php
										}
										
										echo '<label class="text-dark font-weight-bold mt-3">Add More</label>';
								}
								?>
								<div class="input-group">
									<input type="text" class="form-control font-weight-bold" name="dmdname[]" id="htn" placeholder="Heading" />
									<input type="text" class="form-control" name="atdname[]" id="atn" placeholder="Attribute" />
									<span id="" class="error_here text-left"></span>
									<div class="input-group-prepend">
										<div class="input-group-text font-weight-bold bg-transparent">
										<button type="button" class="bg-transparent  bs-tooltip border-0 add_cat"  title="Add More"  >
										<svg xmlns="http://www.w3.org/2000/svg" class="text-primary" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" 
										stroke-linecap="round" stroke-linejoin="round" class="feather feather-plus-circle"><circle cx="12" cy="12" r="10"></circle>
										<line x1="12" y1="8" x2="12" y2="16"></line><line x1="8" y1="12" x2="16" y2="12"></line></svg>
										</button>
										</div>
									</div>
								</div>
								
							</div>
					</div>
					<div class="cat_more">
			
					</div>
				</div>

				<div class="widget-content widget-content-area bg-light br-6">
					<?= (!empty($prd_ft)) ? '<input type="hidden" name="pstrec" value="'.$prd_ft['ksp_id'].'" />' : '' ?>
					<h5 class="mb-4 font-weight-bold text-warning">Pricing & Stock</h5>
					<div class="row mb-3">
						<div class="col-lg-3 col-md-6 mb-3">
							<label class="text-dark font-weight-bold">Quantity<code>*</code> </label>
							<div class="input-group">
								<div class="input-group-prepend">
									<div class="input-group-text font-weight-bold">
									<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-hash text-info"><line x1="4" y1="9" x2="20" y2="9"></line><line x1="4" y1="15" x2="20" y2="15"></line><line x1="10" y1="3" x2="8" y2="21"></line><line x1="16" y1="3" x2="14" y2="21"></line></svg>
									</div>
								</div>
								<input type="text" class="form-control" name="jewqty"  placeholder="0" required value="<?= (!empty($prd_ft)) ? $prd_ft['pqty']:''; ?>"/>
								
							</div>
						</div>
						
						<div class="col-lg-3 col-md-6 mb-3">
							<label class="text-dark font-weight-bold">Cost Price <code>*</code> </label>
							<div class="input-group">
								<div class="input-group-prepend">
									<div class="input-group-text font-weight-bold">
									<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-trending-up text-warning"><polyline points="23 6 13.5 15.5 8.5 10.5 1 18"></polyline><polyline points="17 6 23 6 23 12"></polyline></svg>
									</div>
								</div>
								<input type="text" class="form-control" name="jewcost"  placeholder="0.00" required value="<?= (!empty($prd_ft)) ? $prd_ft['pcost']:''; ?>"/>
								
							</div>
						</div>
						
						<div class="col-lg-3 col-md-6">
							<label class="text-dark font-weight-bold">Selling Price <code>*</code> </label>
							<div class="input-group">
								<div class="input-group-prepend">
									<div class="input-group-text font-weight-bold">
									<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-activity text-primary"><polyline points="22 12 18 12 15 21 9 3 6 12 2 12"></polyline></svg>
									</div>
								</div>
								<input type="text" class="form-control" name="jewsell"  placeholder="0.00" required value="<?= (!empty($prd_ft)) ? $prd_ft['psell']:''; ?>"/>
								
							</div>
						</div>
						
						<div class="col-lg-3 col-md-6">
							<label class="text-dark font-weight-bold">Discount Price </label>
							<div class="input-group">
								<div class="input-group-prepend">
									<div class="input-group-text font-weight-bold">
									<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-percent text-danger"><line x1="19" y1="5" x2="5" y2="19"></line><circle cx="6.5" cy="6.5" r="2.5"></circle><circle cx="17.5" cy="17.5" r="2.5"></circle></svg>
									</div>
								</div>
								<input type="text" class="form-control" name="jecdiscount"  placeholder="0.00" value="<?= (!empty($prd_ft)) ? $prd_ft['pdiscount']:'0.00'; ?>"/>
								
							</div>
						</div>
					</div>
				</div>
			</div>	
		
			<div class="col-md-6">
				<input type="submit" name="prdsubs" id="productsubmitted" style="display:none;" />
				<div class="widget-content widget-content-area br-6 mb-3 bg-light">	
					<h5 class="mb-4 font-weight-bold text-warning">Category Selection</h5>
					
					<div class="row">
						<div class="col-md-8 mx-auto form-group">
							<label class="text-dark font-weight-bold">Menu Name <code>*</code> </label>
							<select name="jewkmn" id="kpmnn" class="form-control" required>
								<option value="" disbaled selected > Select category</option>
								<?php 
								if(!empty($jwcts)){
									foreach($jwcts as $cat)
									{
										$cgh = (!empty($prd_ft) && $cat['mn_id'] ==  $prd_ft['mn_id']) ? 'selected' : '' ;
										echo '<option value="'.$cat['mn_id'].'" '.$cgh.'> '.$cat['mname'].'</option>';
									} }
								?>
							</select>
							<span id="" class="error_here"></span>
						</div>
						
						<div class="col-md-8 mx-auto form-group">
							<label class="text-dark font-weight-bold">Main Category </label>
							<select name="jewcnm" id="kpctn" class="form-control">
								<?php 
									if(!empty($prd_ft) && !empty($gt_ctg)){
									foreach($gt_ctg as $cat)
									{
										$cgh = (!empty($prd_ft) && $cat['mc_id'] ==  $prd_ft['mc_id']) ? 'selected' : '' ;
										echo '<option value="'.$cat['mc_id'].'" '.$cgh.'> '.$cat['cname'].'</option>';
									} }
									else{  ?><option value="" disbaled selected > Select Menu First</option><?php 	}
								?>
							</select>
							<span id="" class="error_here"></span>
						</div>
						
						<div class="col-md-8 mx-auto form-group">
							<label class="text-dark font-weight-bold">Sub Category </label>
							<select name="jewsbt" id="kpsbm" class="form-control">
								<?php 
									if(!empty($prd_ft) && !empty($gt_sbg)){
									foreach($gt_sbg as $cat)
									{
										$cgh = (!empty($prd_ft) && $cat['ms_id'] ==  $prd_ft['ms_id']) ? 'selected' : '' ;
										echo '<option value="'.$cat['ms_id'].'" '.$cgh.'> '.$cat['sname'].'</option>';
									} }
									else{  ?><option value="" disbaled selected > Select Main Category First</option><?php 	}
								?>
							</select>
							<span id="" class="error_here"></span>
						</div>
					</div>
					
				</div>
				
			</form>
			
				<div class="widget-content widget-content-area br-6 pb-3">	
					<h5 class="mb-4 font-weight-bold text-warning">Images</h5>
					<input type="hidden" id="pcmgct" value="0" />
					<div class="form-group col-md-12">
						<label class="text-dark font-weight-bold">Upload Gallery<code>*</code> <span id="imgsrr" class="ms-3 text-danger"></span></label>
						
						<?php
						if(!empty($prd_ft) && !empty($gt_imgs)){
								echo '<div class="row">';
								foreach($gt_imgs as $mgs)
								{
									$jm_id = $mgs['kmg_id'];
									
									$prd_img = (!empty($mgs['pjm_pic']) && file_exists('../prdimgs/'.$mgs['pjm_pic'])) ? "../prdimgs/".$mgs['pjm_pic'] : "../img/kmart-icon.png";
									?>
									<div class="col-md-3 col-4 mb-3 tr">
										<div class="mainpcfrm">
											<img src="<?= $prd_img; ?>" alt="product image" class="img-fluid"/>
											<span class="pcfrmcls" id="del_<?= $jm_id; ?>" onClick="takeoff(<?= $jm_id; ?>,'opqdejt')">×</span>
										</div>
									</div>
									<?php
								}
								echo '</div>';
						}
						?>
						<form action="image-add.php?action=save" id="drpzn" class="dropzone dz-clickable primary-dropzone">
							<div class="dz-default dz-message">
								<i class="ti-gallery"></i>
								<span>Drag & Drop To Add Property Image</span>
							</div>
						</form>
					</div>
					
					
					
				</div>
				
				<div class="form-group w-100 text-center mt-3 ">
						<button class="btn bg-warning text-white rounded w-75 font-weight-bold" id="mksubion" type="button"><i class="far fa-paper-plane"></i> Submit</button>
					</div>
			</div>	
			
		</div>
		
	
		</div>
	<script src="assets/dropzone.js"></script>
	<script>
	$("#mksubion").on('click', function(e) { e.preventDefault(); if($("#stpsinf").val() == "add-product" && $("#pcmgct").val() == 0){ $("#imgsrr").text("Images required"); } $("#productsubmitted:hidden").trigger('click'); /*$( "#mksikkaprds_form" ).submit();*/ });
	Dropzone.options.drpzn = { maxFilesize: 2, acceptedFiles: 'image/*', init: function (){ this.on("complete", function (file) { var mkscf = this.getAcceptedFiles().length; $("#pcmgct").val(mkscf); if(mkscf > 0){$("#imgsrr").text(''); } }); }};
	
	var max_fieldxs = 7; var wrappersxs = $(".cat_more"); var add_buttonsxs = $(".add_cat"); var fxs = 1;
    $(add_buttonsxs).click(function(e){ e.preventDefault();
        if(fxs < max_fieldxs){ fxs++;
		$(wrappersxs).append(	
		'<div class="dsrmv"><div class="form-group"><div class="input-group">'+
			'<input type="text" class="form-control font-weight-bold" name="dmdname[]" id="htn" placeholder="Heading" /><input type="text" class="form-control" name="atdname[]" id="atn" placeholder="Attribute" />'+
			'<span id="" class="error_here text-left"></span>'+
			'<div class="input-group-prepend">'+
			'<div class="input-group-text font-weight-bold bg-transparent border-0">'+
			'<button type="button" class="bg-transparent text-primary bs-tooltip border-0 remove_cat"  title="Remove"  >'+
			'<svg xmlns="http://www.w3.org/2000/svg" class="text-danger" width="24" height="24" viewBox="0 0 24 24" fill="none" '+
			'stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" '+
			'class="feather feather-delete"><path d="M21 4H8l-7 8 7 8h13a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2z"></path>'+
			'<line x1="18" y1="9" x2="12" y2="15"></line><line x1="12" y1="9" x2="18" y2="15"></line></svg>'+
			'</button>'+
			'</div>'+
		'</div></div></div></div>')  } 
		});  $(wrappersxs).on("click",".remove_cat", function(e){ e.preventDefault(); $(this).closest('.dsrmv').remove(); fxs--; });
		
	$(document).on('change', '#kpmnn', function(){
        var selclasID = $(this).val();
		$('#kpsbm').html('<option value="" disbaled selected > Select Category First</option>');
        if(selclasID){ $.ajax({ type:'POST', url:'actions/fetch_data.php', data:'selclas_id='+selclasID, dataType:"json", success:function(data) { $('#kpctn').html(data.sub_menu); return; } }); }
		else{ $('#kpctn').html('<option value="" disbaled selected > Select Menu First</option>'); }
	});
	
	$(document).on('change', '#kpctn', function(){
        var selclasID = $(this).val();
        if(selclasID){ $.ajax({ type:'POST', url:'actions/fetch_data.php', data:'selcsubm_id='+selclasID, dataType:"json", success:function(data) { $('#kpsbm').html(data.sub_menu); return; } }); }
		else{ $('#kpsbm').html('<option value="" disbaled selected > Select Category First</option>'); }
	});
	
	$("#mksikkaprds_form").on('submit',function(e) {
		e.preventDefault();
		if( $("#stpsinf").val() == "add-product" && $("#pcmgct").val() == 0){ $("#imgsrr").text("Images required"); return false;}
		var rev = $('#mksikkaprds_form');
			$.ajax({
				url: 'actions/martpostprods.php', type: 'POST', data:  new FormData(this), contentType: false, cache: false, processData:false, dataType:"json",
				beforeSend: function() { $("#mksubion").html('submiting <span class="spinner-grow-sm text-white ml-2 align-self-center loader-sm"></span>'); $("#mksubion").attr('disabled', 'disabled'); },
				success: function(data){
					donejob(data.runstt,data.errorreason); $("#mksubion").html('<i class="far fa-paper-plane"></i> Submit'); $("#mksubion").attr('disabled', false);
					if(data.runstt == "grant" && $("#stpsinf").val() == "add-product"){ rev.trigger('reset'); $("#pcmgct").val('0'); $('#drpzn').removeClass("dz-started");
					$('#drpzn').html('<div class="dz-default dz-message"><i class="ti-gallery"></i><span> Drag &amp; Drop To Add Property Image</span></div>'); }
				}
			});

    });
	
	tinymce.init({ selector: 'textarea#prdscbrief', menubar: false, plugins: 'link image code autolink lists media table ',
	toolbar: 'undo redo | bold italic | alignleft aligncenter alignright | numlist checklist outdent indent | link image table | paragraphgroup',
	toolbar_groups: { paragraphgroup: { icon: 'settings', tooltip: 'Paragraph format', items: 'h3 h4 | blockquote | underline strikethrough superscript subscript', } },
	images_upload_url: 'postimgindetail.php', toolbar_mode: 'floating', tinycomments_mode: 'embedded', tinycomments_author: 'Author name', height : 270, });
	</script>
		<?php
		}
		elseif(empty($setup) || $setup == "manage-stock"){
		?>
		<div class="col-xl-12 col-lg-12 col-sm-12 layout-spacing m-auto">
		
		<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 ">
			<h1 class="title-4">Manage Products</h1>
			
			<div class="btn-toolbar mb-2 mb-md-0">
				<div class="btn-group mr-2">
					<a href="?setup=add-product" class="btn btn-icon bg-warning text-white">
					<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-plus-square"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="12" y1="8" x2="12" y2="16"></line><line x1="8" y1="12" x2="16" y2="12"></line></svg>
					&nbsp; Add Product	</a>
				</div>
			</div>
		</div>

		<div class="row">
			<div class="col-12 m-auto">
				
				<div class="widget-content widget-content-area br-6">	
					<div class="table-responsive mb-4 mt-4">
						<table id="kmtprd_tbrecs" class="table table-stripped caption-top" style="width:100%">
							
							<thead>
								<tr>
									<th width="40%">Product</th>
									<th width="10%" class="text-center vertical-align" data-sortable="false">Qty</th>
									<th width="10%" class="text-center vertical-align" data-sortable="false">Selling</th>
									<th width="10%" class="text-center vertical-align" data-sortable="false">Discount</th>
									<th width="15%" class="text-center vertical-align"> Date</th>
									<th width="15%" class="text-center vertical-align"  data-sortable="false">Action</th>
								</tr>
							</thead>
						</table>
					</div>
				</div>
			
			</div>	
		</div>
	
		</div>
		
<script type="text/javascript" language="javascript" >

$(document).ready(function(){

load_data();
function load_data(setpst){
var userdataTable = $('#kmtprd_tbrecs').DataTable({
		"processing": true,"serverSide": true,"order": [],
		"ajax":{
			url:"actions/fetch_products.php",
			type:"POST",
			data: {setpst: setpst}
		},
		"oLanguage": {
				"oPaginate": { "sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>', "sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>' },
				"sInfo": "Showing _START_ to _END_ of _TOTAL_ Products",
				"sSearch": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>',
				"sSearchPlaceholder": "Search Product Name...",
			   "sLengthMenu": "Results :  _MENU_",	"sInfoFiltered": "",
			},
		"stripeClasses": [], "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]], "pageLength": 10,
		drawCallback: function () { $('.dataTables_paginate > .pagination').addClass(' pagination-style-13 pagination-bordered mb-5'); }
	});
}
$(document).on('click','.dptcn', function(){
	var id = this.id;  var split_id = id.split("_"); var txt = split_id[0]; var deprc = split_id[1]; 
	var data_dp = $("#drp_"+deprc).attr("data-dp"); $("#shwdps").html(data_dp);
	$("#kmtprd_tbrecs").DataTable().destroy();
	if(deprc != ""){ load_data(deprc); } else{ load_data(); }
});


$(document).on('click', '.nwsfts', function(){	
	var id = this.id;   var split_id = id.split("_"); var textnt = split_id[0]; var postid = split_id[1];
	swal({ title: 'Are you sure you want to Feature this Product', html: '', type: 'question', showCancelButton: true, confirmButtonText: 'Yes, Feature', padding: '2em'
	}).then(function(result) {
		if (result.value) {
		$.ajax({
			url: 'actions/fetch_data.php', type: 'POST',
			data:  { 'featuringmenucategory':1, 'pstnt':textnt, 'pstrec':postid },
			dataType:"json",beforeSend: function(){	
			$(".swal2-cancel").attr('disabled', 'disabled');
			$(".swal2-confirm").attr('disabled', 'disabled');
			$(".swal2-confirm").html('processing <svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-aperture fa fa-spin"><circle cx="12" cy="12" r="10"></circle><line x1="14.31" y1="8" x2="20.05" y2="17.94"></line><line x1="9.69" y1="8" x2="21.17" y2="8"></line><line x1="7.38" y1="12" x2="13.12" y2="2.06"></line><line x1="9.69" y1="16" x2="3.95" y2="6.06"></line><line x1="14.31" y1="16" x2="2.83" y2="16"></line><line x1="16.62" y1="12" x2="10.88" y2="21.94"></line></svg>');
			},
			success: function(data) { donejob(data.runstt,data.runsttinfo); return; }
		});	
		}
	});
});

})
</script>
		<?php
		}
		?>

		</div>

	</div>

</div>

<?php include "footer.php"; ?>