<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vertical Navbar - Mazer Admin Dashboard</title>

    <link rel="preconnect" href="https://fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;600;700;800&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="assets/css/bootstrap.css">
	
	<link rel="stylesheet" href="assets/vendors/toastify/toastify.css">
	<link href="https://unpkg.com/filepond/dist/filepond.css" rel="stylesheet">
<link rel="stylesheet" href="assets/vendors/toastify/toastify.css">

    <link rel="stylesheet" href="assets/vendors/perfect-scrollbar/perfect-scrollbar.css">
    <link rel="stylesheet" href="assets/vendors/bootstrap-icons/bootstrap-icons.css">
    <link rel="stylesheet" href="assets/css/app.css">
    <link rel="shortcut icon" href="assets/images/favicon.svg" type="image/x-icon">
</head>

<!--summernote library------>
<link rel="stylesheet" href="assets/vendors/summernote/summernote-lite.min.css">
<script src="assets/vendors/jquery/jquery.min.js"></script>



<!--summer note library--->

<body>
 <?php
include_once("hooks/_config_.php");
$conf = new config();
?>
        
		<?php include_once("assets/resources/side-includer.php"); ?>
			
       
		
            
			
			<?php include_once("assets/resources/top_navigator.php"); ?>
			<!-- body content -->
            <div id="main-content">




                <div class="page-heading">
                    <div class="page-title">
                        <div class="row">
                            <div class="col-12 col-md-6 order-md-1 order-last">
                                <h3>Add Store Page</h3>
                                <p class="text-subtitle text-muted">Navbar will appear in top of the page.</p>
                            </div>
                            <div class="col-12 col-md-6 order-md-2 order-first">
                                <nav aria-label="breadcrumb" class="breadcrumb-header float-start float-lg-end">
                                    <ol class="breadcrumb">
                                        <li class="breadcrumb-item"><a href="index.html">Dashboard</a></li>
                                        <li class="breadcrumb-item active" aria-current="page">Layout Vertical Navbar
                                        </li>
                                    </ol>
                                </nav>
                            </div>
                        </div>
                    </div>
								
					<section id="basic-horizontal-layouts">
                    <div class="row match-height">
                        <div class="col-md-12 col-12">
                            <div class="card">
                                <div class="card-header">
								
								<?php
								if(isset($_GET['edtuk']) && isset($_GET['rfk'])) {
								$rcd_unky = $_GET['edtuk'];
								$rcd_frgnky = $_GET['rfk'];
								?>
								   <h4 class="card-title">Update /Edit Store</h4>
								<?php
			if(isset($_POST['update_store']) && $_POST['update_store'] == "Update Record"){ 
			?>

								  <form  action="<?php $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" class="form form-horizontal">
                                            <div class="form-body">
                                                <div class="row">
                                                    
													<div class="col-md-4">
                                                        <label>Store Name</label> 
                                                    </div>
                                                    <div class="col-md-8 form-group">
                                                        <input type="text"  class="form-control" 
                                                         name="store_name" value="<?php echo $_POST['store_name']; ?>" placeholder="Store Name"/>
													 <?php
												$stro_anme =  $isValid->iValid($_POST['store_name'], 'Error. Invalide Text or Blank', 'str');
											?>
                                                    </div>
                                                    
													<div class="col-md-4 mt-3">
                                                        <label>Description</label>
                                                    </div>
                                                    <div class="col-md-8 form-group mt-3">
                                                        <input type="Text" id="titleimage" class="form-control" name="store_descpr" value="<?php echo $_POST['store_descpr']; ?>"
                                                            placeholder="Description">
															<?php
													$stro_xdctpn =  $isValid->iValid($_POST['store_descpr'], 'Error. Invalide Text or Blank', 'str');
												?>

                                                    </div>
                                                   
												   
												    <div class="col-md-4 mt-3">
                                                        <label>URL</label>
                                                    </div>
                                                    <div class="col-md-8 form-group mt-3">
                                                        <input type="text"  class="form-control" name="sto_url" value="<?php echo $_POST['sto_url']; ?>"
                                                          placeholder="URL">
														  <?php
													$stro_lcurl =  $isValid->iValid($_POST['sto_url'], 'Wrong URL Pattern', 'url');
												?>

                                                    </div>
													
													 <div class="col-md-4 mt-3">
                                                        <label>Destination URL</label>
                                                    </div>
                                                    <div class="col-md-8 form-group mt-3">
                                                        <input type="text"  class="form-control" name="dstn_store" value="<?php echo $_POST['dstn_store']; ?>"
                                                          placeholder="Destination URL">
														 <?php
													$stro_dstnurl =  $isValid->iValid($_POST['dstn_store'], 'Wrong URL Pattern', 'url');
												?>

                                                    </div>
                                                    
                                                     <!--8 end--->
                                    <div class="col-md-4 mt-3">
                        <label>Store Image</label>
                      </div>
					    	<div class="col-md-8 bg-light form-group mt-3">
                                    <div class="col-md-3 form-group mt-3">
                        <div class="mb-3">
                       <label for="formFile" class="form-label">Upload Image From Your Gallery </label>
        <!-- <input class="with-validation-filepond" required multiple data-max-file-size="1MB" data-max-files="3"  type="file" id="formFile" name="ttlimg_keys">  -->
			                 <input data-max-files="3"  type="file" id="formFile" name="sto_rimgs"> 
								<p><small class="text-muted">JPEG, JPG Size: 600px X 400px</small></p>
								<?php
							
								if($_FILES['sto_rimgs'] != ''){
								 
								$uplo = storlog_upl($_FILES['sto_rimgs']['name'], $_FILES['sto_rimgs']['size'], $_FILES['sto_rimgs']['tmp_name']);
								//echo "<div id='success_alert'>Image Accepted</div>";
									
								}else{
								$uplo = '';
								echo "<div class'alert alert-light-danger color-danger'>Please Upload An Images</div>"; 
								}// end if
								?>
								<input type="hidden" name="img_namext" value="<?php echo $_POST['img_namext']; ?>" />
									
								<?php
								if($uplo == '') { $uplo = $_POST['img_namext']; }
								?>   
                                      </div>
                     			 </div>
					 		 <div class="col-md-4 form-group mt-3"><img src="../../assets/shared/shops/<?php echo $_POST['img_namext']; ?>" width="125" height="auto" /></div>
					  </div>									
													<!--catgory module--->	
													
														<div class="col-md-4 mt-3">
                                                        <label>Choose Category</label>
                                                    </div>
                                                    <div class="col-md-8 form-group">
                                                      
													<div id="txtHint">
													<?php echo $view->subcatelist(); ?>
													</div>
													
													<div id="valtxtHint">
													
													<?php
													
													if(isset($_POST['subctag']) && $_POST['subctag'] != '') {
														echo $view->subcatelistValidated($_POST['subctag']);
													
														$sub_arrayx = $_POST['subctag'];
														
														$view->deleteOldCate($sub_arrayx);
													 echo "<div id='success_alert'>".count($_POST['subctag'])." Sub Categories Selected</div>";
													}else{
													$sub_arrayx = '';
													$null_cat =  $_POST['cat_detalsky'];
													echo "<div id='err_alert'>Error: 0 Selected</div>";
													}
													?>
													</div>
                                               
													</div>
													
													<!--catgory module--->											
													
													
													
													
														<div class="col-md-4 mt-3">
                                         <label>Newtwork</label>
                                         </div>
                                       <div class="col-md-8 form-group mt-3">
								         
										   <select name="stor_Network" class="form-group col-12 p-2">
											<?php
											if(isset($_POST['stor_Network']) && $_POST['stor_Network'] != ''){
											?>
											<option value="<?php echo $_POST['stor_Network']; ?>"><?php echo $_POST['stor_Network']; ?></option>
											<?php
											$stor_relnetw = $_POST['stor_Network'];
											}
											?>
											</select>
                                      </div>
													
													
									<div class="col-md-4 mt-3">
                                         <label>Placement</label>
                                      </div>
                                       <div class="col-md-8 form-group">
									   
									     <div class='form-check d-inline-block'>
                                                            <div class="m-2 checkbox d-inline-block">
                                                                <input type="checkbox" 
															class='form-check-input' name="stor_featurd" <?php if(isset($_POST['stor_featurd']) && $_POST['stor_featurd'] == "on"){?> checked="checked" <?php } ?>/>
														<?php
														if(isset($_POST['stor_featurd']) && $_POST['stor_featurd'] == "on"){
														 $fstr_status = 1;
														}else{
														 $fstr_status = 0;
														}
														?>
																																			
			
                                                                <label for="checkbox1">Featured Store</label>
                                                            </div>
                                                        </div><!--sec checkbox--->
														
                                                        <div class='m-2 form-check d-inline-block'>  
                                                            <div class="checkbox d-inline-block">
                                                                <input type="checkbox" class='form-check-input'  name="top_store" <?php if(isset($_POST['top_store']) && $_POST['top_store'] == "on"){?> checked="checked" <?php } ?>  />
															<?php
														if(isset($_POST['top_store']) && $_POST['top_store'] == "on"){
														 $tpstr_status = 1;
														}else{
														 $tpstr_status = 0;
														}
														// $fstr_status  $tpstr_status  $stro_anme  $stro_avgds  $stro_lcurl   $sto_rimgs $stro_dstnurl  $stro_mtte  $stro_mtdscp  $stro_mtkyd  $stor_gtry  $stor_relnetw
														?>
																

                                                                <label for="checkbox1">Recommended Store</label>
                                                            </div>
                                                        </div><!--first checkbox--->
														
														 <div class='m-2 form-check d-inline-block'>
                                                            <div class="checkbox d-inline-block">
                                                                <input type="checkbox" class='form-check-input'  name="populr_store" <?php if(isset($_POST['populr_store']) && $_POST['populr_store'] == "on"){?> checked="checked" <?php } ?>/>
															<?php
																	if(isset($_POST['populr_store']) && $_POST['populr_store'] == "on"){
																	 $plrstr_sttus = 1;
																	}else{
																	 $plrstr_sttus = 0;
																	}
																	
																	?>
																																		
                                                                <label for="checkbox1">Popular Store</label>
                                                            </div>
                                                        </div><!--sec checkbox--->
			
														
														
														
														<div class='m-2 form-check d-inline-block '>
                                                            <div class="checkbox d-inline-block">
                                                                <input type="checkbox" class='form-check-input' name="disabl_store"  <?php if(isset($_POST['disabl_store']) && $_POST['disabl_store'] == "on"){?> checked="checked" <?php } ?>/>
															<?php
													if(isset($_POST['disabl_store']) && $_POST['disabl_store'] == "on"){
													 $strds_abler = 1;
													}else{
													 $strds_abler = 0;
													}
													?>
                                                                <label for="checkbox1">Location: Uk</label>
                                                            </div>
                                                        </div><!--sec checkbox--->	
                                                    </div><!--check box ended-->
												
								
                                       </div><!--col- 8 end-->
														
								
													
                                                   
												   
												    <div class="col-sm-12 mt-3 d-flex justify-content-end">
                                                         <input type="submit" name="update_store" class="col-4 p-2 bg-primary text-white" style="border:1px solid #fff; border-radius: 15px;" value="Update Record" />  
                                                    </div>
                                                </div>
                                            </div>
                                        </form>
										
<?php
	if(isset($fstr_status) && isset($tpstr_status) 
	&& isset($stro_anme) && $stro_anme != ''
	&& isset($stro_xdctpn) && $stro_xdctpn != ''
	&& isset($plrstr_sttus) && isset($strds_abler)
	&& isset($stro_lcurl) && $stro_lcurl != ''
	&& isset($stro_dstnurl) && $stro_dstnurl != '' 
	&& isset($uplo) && $uplo != ''
	//&& isset($stro_mtte) && $stro_mtte != ''
	//&& isset($stro_mtdscp) && $stro_mtdscp != ''
	//&& isset($stro_mtkyd) && $stro_mtkyd != ''
	//&& isset($stor_gtry) && $stor_gtry != ''
	&& isset($stor_relnetw) && $stor_relnetw != ''
	&& isset($rcd_unky) && $rcd_unky != ''
	&& isset($rcd_frgnky) && $rcd_frgnky != ''
	&& isset($sub_arrayx) && $sub_arrayx != ''
	) {
	
	 foreach($sub_arrayx as $subeach)
	{
	list($categoryname, $mastcategoryid) = explode(':#:', $subeach);
	// cate inputer
	$subc_tb = "blg_ctg_listdt";
	$subc_content = array("cate_nam" => $categoryname, "_top_ctg" => 1, "sort_ord" => 0, "cpn_unkkid" => md5($stro_anme), "_unk_ky" => $key->uid(), "_frgn_ky" => $mastcategoryid, "_ent_sndr" => $_SESSION['logner_bot']);
	$query->queryhandler($subc_tb, $subc_content);
	}

	$stro_mtte = "promo codes, deals, coupon codes, discounts";
	$stro_mtdscp = $stro_xdctpn;
	$stro_mtkyd =  $stro_anme. ", Deals, Coupon and Discount";
	
	  
	
		$s_tab = "copn_storbnk";
		$s_content = array("_stor_nam" => $stro_anme, "_top_sto" => $tpstr_status, "_featr_sto" => $fstr_status, "_stor_savng" => $plrstr_sttus, "_stor_rlurl" => $stro_lcurl, "_str_dstnurl" => $stro_dstnurl, 	"_str_mgzs" => $uplo, "_strmt_ttl" => $stro_mtte, "_strmt_desp" => $stro_mtdscp, "_mt_kiywrd" => $stro_mtkyd, "_stor_categ" => $strds_abler, 
	"st_sbctgy" => md5($stro_anme), "_stor_netwrk" => $stor_relnetw,   "_ent_sndr" => $_SESSION['logner_bot'], "_strdes_ptn" => $stro_xdctpn);
		$s_needle = array("_stor_nam");
		$s_heystack = array("_stor_nam" => $stro_anme);
		$update_heystack = array("_unk_ky" => $rcd_unky, "_frgn_ky" => $rcd_frgnky);

		//if(mysql_num_rows($query->queryBuilder($s_needle, $s_tab, $s_heystack)) == 0 ) {
		 if($query->queryUpdater($s_tab, $s_content, $update_heystack)) {
		 
		 echo "<div class='alert alert-success alert-dismissible show fade'>
		  
         Store ( ".strtoupper($stro_anme)." ) Has Updated Successfully
           <button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button></div>"; 
		
		 
		 // echo "<div id='str_succ_alert'>Store ( ".strtoupper($stro_anme)." ) Has Updated Successfully</div>"; 
		  
		  $err->logHandler(" Alert: Record Updated/changed By: '".$_SESSION['logner_bot']."' IP: '".$_SERVER['REMOTE_ADDR']."' on ".date("d-m-Y")." ".date("H:i:s",time())." {Page: Edit Store}  ) <--> ( ", "cerr.php");
		  }else{ 
		  echo "<div id='str_dup_alert'>Q-Error </div>"; 
		  
		  }
			//}else{
			
			//$dup =  "<div id='str_dup_alert'>Error: Duplicate Entry</div>";
			//echo $dup;
			//$err->logHandler(" Error: Duplicate Entry By: '".$_SESSION['logner_bot']."' on ".date("d-m-Y")." ".date("H:i:s",time())." {Page: Store}  ) <--> ( ", "cerr.php");
			//} // dup if

	} // end 2nd if

}else{

$needle = array("_stor_nam", "_top_sto", "_featr_sto", "_stor_savng", "_stor_rlurl", "_str_dstnurl", "_str_mgzs", "_strmt_ttl", "_strmt_desp", "_mt_kiywrd", "_stor_categ", "_stor_netwrk", "_unk_ky", "_frgn_ky", "_ent_sndr", "_strdes_ptn");
$tb = "copn_storbnk";
$heystack = array("_unk_ky" => $rcd_unky, "_frgn_ky" => $rcd_frgnky); 
$editquery = $query->queryBuilder($needle, $tb, $heystack);
while($editview = mysqli_fetch_array($editquery, MYSQLI_NUM)){
?>

  <form  action="<?php $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" class="form form-horizontal">
                                            <div class="form-body">
                                                <div class="row">
                                                    
													<div class="col-md-4">
                                                        <label>Store Name</label>
                                                    </div>
                                                    <div class="col-md-8 form-group">
                                                        <input type="text"  class="form-control"  placeholder="Store Name" name="store_name" value="<?php echo $editview[0]; ?>"/>
                                                    </div>
                                                    
													<div class="col-md-4 mt-3">
                                                        <label>Description</label>
                                                    </div>
                                                    <div class="col-md-8 form-group mt-3">
                                                        <input type="Text"  class="form-control" 
                                                            placeholder="Description" name="store_descpr" value="<?php echo $editview[15]; ?>">
														
                                                    </div>
                                                   
												   
												    <div class="col-md-4 mt-3">
                                                        <label>URL</label>
                                                    </div>
                                                    <div class="col-md-8 form-group mt-3">
                                                        <input type="text"  class="form-control" placeholder="URL" name="sto_url" value="<?php echo $editview[4]; ?>">
														
                                                    </div>
													
													 <div class="col-md-4 mt-3">
                                                        <label>Destination URL</label>
                                                    </div>
                                                    <div class="col-md-8 form-group mt-3">
                                                       <input type="text"  class="form-control" placeholder="Destination URL" name="dstn_store" value="<?php echo $editview[5]; ?>">  </div>
													
												
												 <div class="col-md-4 mt-3">
                                        <label>Store Image</label>
                                      </div>
                                    <div class="col-md-4 form-group mt-3">
                                        <div class="mb-3">
                                        <label for="formFile" class="form-label">Upload Page Title Image</label>
                  <!--  <input type="file"  class="with-validation-filepond" required multiple data-max-file-size="1MB" data-max-files="3" id="formFile" name="ttlimg_keys">  -->
					
					 				 <input type="file" id="formFile" name="sto_rimgs">
									 <input type="hidden" name="img_namext" value="<?php echo $editview[6]; ?>" />
										<p><small class="text-muted">JPEG, JPG Size: 600px X 400px</small></p>
                                      </div>
									
                                      </div>
									   <div class="col-md-4 form-group mt-3">
									  <img src="../../assets/shared/shops/<?php echo $editview[6]; ?>" width="125" height="auto" />
									   </div>
                                    <!--catgory module--->
												
												
										
	

									
									
									
									
										<!--catgory module--->	
													
														<div class="col-md-4 mt-3">
                                                        <label>Choose Category</label>
                                                    </div>
                                                    <div class="col-md-8 form-group">
                                                      	
													<div id="txtHint">
											<?php 
												//echo $view->subcatelist(); 
												echo $view->editablecatelist($editview[14]);
											?>
											</div>
											<input type="hidden" name="cat_detalsky" value="<?php echo $editview[14];?>" />
											
                                              
                                                    
													</div>
													
													<!--catgory module--->											
													
													
													
													
														<div class="col-md-4 mt-3">
                                         <label>Newtwork</label>
                                         </div>
                                       <div class="col-md-8 form-group mt-3">
									   <select name="stor_Network" class="form-group col-12 p-2">
									<option value="">Choose Network</option>
									<?php
									$needle = array("netwk_nam", "_frgn_ky");
									$tb = "copn_netwrk";
									$heystack = ''; 
									$qu = $query->queryBuilder($needle, $tb, $heystack);
									while($network = mysqli_fetch_array($qu, MYSQLI_NUM)) {
									?>
									
									<option value="<?php echo $network[0]; ?>" <?php if($network[0] == $editview[11]) { ?> selected="selected" <?php }?> ><?php echo $network[0]; ?></option>
									<?php
									} // end whl
									?>
									</select>
									<div id='listview'>
									<font color="#FF6600">Already Assigned Network:</font><br /><br />
									<ul>
									<?php
									echo $editview[11];
									?>
									</ul>
									</div>
															 
                                       </div>
													
													
									<div class="col-md-4 mt-3">
                                         <label>Placement</label>
                                      </div>
                                       <div class="col-md-8 form-group">
									   
									     <div class='form-check d-inline-block'>
                                                            <div class="m-2 checkbox d-inline-block">
                                                                <input type="checkbox" 
															class='form-check-input' name="stor_featurd" <?php if(isset($editview[2]) && $editview[2] == 1){ ?> checked="checked" <?php } ?>/>
												 <label for="checkbox1">Featured Store</label>
                                                            </div>
                                                        </div><!--sec checkbox--->
														
                                                        <div class='m-2 form-check d-inline-block'>  
                                                            <div class="checkbox d-inline-block">
                                                                <input type="checkbox" class='form-check-input'  name="top_store" <?php if(isset($editview[1]) && $editview[1] == 1){ ?> checked="checked" <?php } ?> />
															
                                                                <label for="checkbox1">Recommended Store</label>
                                                            </div>
                                                        </div><!--first checkbox--->
														
														 <div class='m-2 form-check d-inline-block'>
                                                            <div class="checkbox d-inline-block">
                                                                <input type="checkbox" class='form-check-input'  name="populr_store" <?php if(isset($editview[3]) && $editview[3] == 1){ ?> checked="checked" <?php } ?>/>
																																	
                                                                <label for="checkbox1">Popular Store</label>
                                                            </div>
                                                        </div><!--sec checkbox--->
			
														
														
														
														<div class='m-2 form-check d-inline-block '>
                                                            <div class="checkbox d-inline-block">
                                                                <input type="checkbox" class='form-check-input' name="disabl_store"  <?php if(isset($editview[10]) && $editview[10] == 1){ ?> checked="checked" <?php } ?>/>
															
                                                                <label for="checkbox1">Location: Uk</label>
                                                            </div>
                                                        </div><!--sec checkbox--->	
                                                    </div><!--check box ended-->
												
								
                                       </div><!--col- 8 end-->

												    <div class="col-sm-12 mt-3 d-flex justify-content-end">
                                                        <input type="submit" name="update_store" class="col-4 p-2 bg-primary text-white" style="border:1px solid #fff; border-radius: 15px;" value="Update Record" />  
														
                                                       
                                                    </div>
                                                </div>
                                            </div>
                                        </form>
										
										
							<?php
								} // while
							} // end if
							
							}else{
							?>



										
										
										
								
								
								
                                    <h4 class="card-title">Add New Store</h4>
                                </div>
                                <div class="card-content">
                                    <div class="card-body">
									  <?php
					######################################################################################## new store ###########################################################
					
					if(isset($_POST['admit_store']) && $_POST['admit_store'] == "Add New Store"){ 
					?>
                                        <form  action="<?php $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" class="form form-horizontal" enctype="multipart/form-data">
                                            <div class="form-body">
                                                <div class="row">
                                                    
													<div class="col-md-4">
                                                        <label>Store Name</label>
                                                    </div>
                                                    <div class="col-md-8 form-group">
                                                        <input type="text"  class="form-control"  value="<?php echo $_POST['store_name']; ?>" 
                                                           name="store_name" placeholder="Store Name">
													 <?php
													$stro_anme =  $isValid->iValid($_POST['store_name'], 'Error. Invalide Text or Blank', 'str');
												?>
                                                    </div>
                                                    
													<div class="col-md-4 mt-3">
                                                        <label>Description</label>
                                                    </div>
                                                    <div class="col-md-8 form-group mt-3">
                                                        <input type="Text" id="titleimage" class="form-control" name="store_descpr" value="<?php echo $_POST['store_descpr']; ?>"
                                                            placeholder="Description">
															<?php
													$stro_xdctpn =  $isValid->iValid($_POST['store_descpr'], 'Error. Invalide Text or Blank', 'str');
												?>

                                                    </div>
                                                   
												   
												    <div class="col-md-4 mt-3">
                                                        <label>URL</label>
                                                    </div>
                                                    <div class="col-md-8 form-group mt-3">
                                                        <input type="text"  class="form-control" name="sto_url" value="<?php echo $_POST['sto_url']; ?>"
                                                          placeholder="URL">
														  <?php
													$stro_lcurl =  $isValid->iValid($_POST['sto_url'], 'Wrong URL Pattern', 'url');
												?>

                                                    </div>
													
													 <div class="col-md-4 mt-3">
                                                        <label>Destination URL</label>
                                                    </div>
                                                    <div class="col-md-8 form-group mt-3">
                                                        <input type="text"  class="form-control" name="dstn_store" value="<?php echo $_POST['dstn_store']; ?>"
                                                          placeholder="Destination URL">
														  <?php
														$stro_dstnurl =  $isValid->iValid($_POST['dstn_store'], 'Wrong URL Pattern', 'url');
													?>

                                                    </div>
                                                    
                                                 
                   
                         <!--8 end--->
                                    <div class="col-md-4 mt-3">
                        <label>Store Image</label>
                      </div>
                                    <div class="col-md-8 form-group mt-3">
                        <div class="mb-3">
                       <label for="formFile" class="form-label">Upload Store Image From Your Gallery </label>
        <!-- <input class="with-validation-filepond" required multiple data-max-file-size="1MB" data-max-files="3"  type="file" id="formFile" name="ttlimg_keys">  -->
			                 <input data-max-files="3"  type="file" id="formFile" name="sto_rimgs"> 
								<p><small class="text-muted">JPEG, JPG Size: 600px X 400px</small></p>
								<?php
							
								if($_FILES['sto_rimgs'] != ''){
								    
								
								 
								$uplo = storlog_upl($_FILES['sto_rimgs']['name'], $_FILES['sto_rimgs']['size'], $_FILES['sto_rimgs']['tmp_name']);
								//echo "<div id='success_alert'>Image Accepted</div>";
									
								}else{
								$uplo = '';
								echo "<div class'alert alert-light-danger color-danger'>Please Upload An Images</div>"; 
								}// end if
								?>
                                      </div>
                      </div>
                      
                   
														
													<!--catgory module-->
													
														<div class="col-md-4 mt-3">
                                                        <label>Choose Category</label>
                                                    </div>
                                                    <div class="col-md-8 form-group">
                                                       <?php echo $view->subcatelist(); ?>
                        <?php
									if(isset($_POST['subctag']) && $_POST['subctag'] != '') {
										echo $view->PageSubCatelistValidated($_POST['subctag']);
									
									$sub_arrayx = $_POST['subctag'];
									 echo "<div class='text-success'>".count($_POST['subctag'])." Categories Selected</div>";
									 
									}else{
									echo "<div class='alert alert-light-danger color-danger'><i class='bi bi-exclamation-circle'></i> Alert: 0 Selected</div>";
									}
									?>
														
													</div>
													
													<!--catgory module--->											
													
													
													
													
														<div class="col-md-4 mt-3">
                                         <label>Newtwork</label>
                                         </div>
                                       <div class="col-md-8 form-group mt-3">
									    
										<select name="stor_Network" class="form-control col-12 p-2">
										<?php
										if(isset($_POST['stor_Network']) && $_POST['stor_Network'] != ''){
										?>
										<option value="<?php echo $_POST['stor_Network']; ?>"><?php echo $_POST['stor_Network']; ?></option>
										<?php
										$stor_relnetw = $_POST['stor_Network'];
										}
										?>
										</select>										
                                      </div>
													
													
									<div class="col-md-4 mt-3">
                                         <label>Placement</label>
                                      </div>
                                       <div class="col-md-8 form-group">
									   
									     <div class='form-check d-inline-block'>
                                                            <div class="m-2 checkbox d-inline-block">
                                                                <input type="checkbox" 
															class='form-check-input' name="stor_featurd" <?php if(isset($_POST['stor_featurd']) && $_POST['stor_featurd'] == "on"){?> checked="checked" <?php } ?> />
															<?php
													if(isset($_POST['stor_featurd']) && $_POST['stor_featurd'] == "on"){
													 $fstr_status = 1;
													}else{
													 $fstr_status = 0;
													}
													?>
																					
			
                                                                <label for="checkbox1">Featured Store</label>
                                                            </div>
                                                        </div><!--sec checkbox--->
														
                                                        <div class='m-2 form-check d-inline-block'>  
                                                            <div class="checkbox d-inline-block">
                                                                <input type="checkbox" name="top_store" <?php if(isset($_POST['top_store']) && $_POST['top_store'] == "on"){?> checked="checked" <?php } ?>
                                                                    class='form-check-input'  />
																<?php
														if(isset($_POST['top_store']) && $_POST['top_store'] == "on"){
														 $tpstr_status = 1;
														}else{
														 $tpstr_status = 0;
														}
														
														?>
																

                                                                <label for="checkbox1">Recommended Store</label>
                                                            </div>
                                                        </div><!--first checkbox--->
														
														 <div class='m-2 form-check d-inline-block'>
                                                            <div class="checkbox d-inline-block">
                                                                <input type="checkbox" name="populr_store" <?php if(isset($_POST['populr_store']) && $_POST['populr_store'] == "on"){?> checked="checked" <?php } ?> class='form-check-input' />
																<?php
													if(isset($_POST['populr_store']) && $_POST['populr_store'] == "on"){
													 $plrstr_sttus = 1;
													}else{
													 $plrstr_sttus = 0;
													}
													
													?>
																	
                                                                <label for="checkbox1">Popular Store</label>
                                                            </div>
                                                        </div><!--sec checkbox--->
			
														
														
														
														<div class='m-2 form-check d-inline-block '>
                                                            <div class="checkbox d-inline-block">
                                                                <input type="checkbox" class='form-check-input' name="disabl_store"  <?php if(isset($_POST['disabl_store']) && $_POST['disabl_store'] == "on"){?> checked="checked" <?php } ?>/>
																<?php
															if(isset($_POST['disabl_store']) && $_POST['disabl_store'] == "on"){
															 $strds_abler = 1;
															}else{
															 $strds_abler = 0;
															}
															
															?>
                                                                <label for="checkbox1">Location: Uk</label>
                                                            </div>
                                                        </div><!--sec checkbox--->	
                                                    </div><!--check box ended-->
												
								
                                       </div><!--col- 8 end-->
														
								
													
                                                   
												   
												    <div class="col-sm-12 mt-3 d-flex justify-content-end">
                                                        <input type="submit" name="admit_store" class="col-4 p-2 bg-primary text-white" style="border:1px solid #fff; border-radius: 15px;" value="Add New Store" />
                                                        
                                                    </div>
                                                </div>
                                            </div>
                                        </form>
										
<?php
	if(isset($fstr_status) && isset($tpstr_status) 
	&& isset($stro_anme) && $stro_anme != ''
	&& isset($stro_xdctpn) && $stro_xdctpn != ''
	&& isset($plrstr_sttus) && isset($strds_abler)
	&& isset($stro_lcurl) && $stro_lcurl != ''
	&& isset($stro_dstnurl) && $stro_dstnurl != '' 
	&& isset($uplo) 
	//&& isset($stro_mtte) && $stro_mtte != ''
	//&& isset($stro_mtdscp) && $stro_mtdscp != ''
	//&& isset($stro_mtkyd) && $stro_mtkyd != ''
	//&& isset($stor_gtry) && $stor_gtry != '' 
	&& isset($stor_relnetw) && $stor_relnetw != ''
	&& isset($sub_arrayx) && $sub_arrayx != '') {
	
	 foreach($sub_arrayx as $subeach)
	{
	list($categoryname, $mastcategoryid) = explode(':#:', $subeach);
	// cate inputer
	$subc_tb = "blg_ctg_listdt";
	$subc_content = array("cate_nam" => $categoryname, "_top_ctg" => 1, "sort_ord" => 0, "cpn_unkkid" => md5($stro_anme), "_unk_ky" => $key->uid(), "_frgn_ky" => $mastcategoryid, "_ent_sndr" => $_SESSION['logner_bot']);
	$query->queryhandler($subc_tb, $subc_content);
	}

	$stro_mtte = "promo codes, deals, coupon codes, discounts";
	$stro_mtdscp = $stro_xdctpn;
	$stro_mtkyd =  $stro_anme. ", Deals, Coupon and Discount";
	
	
	
		$s_tab = "copn_storbnk";
		$s_content = array("_stor_nam" => $stro_anme, "_top_sto" => $tpstr_status, "_featr_sto" => $fstr_status, "_stor_savng" => $plrstr_sttus, "_stor_rlurl" => $stro_lcurl, "_str_dstnurl" => $stro_dstnurl, 
		 "_strmt_ttl" => $stro_mtte, "_strmt_desp" => $stro_mtdscp, "_mt_kiywrd" => $stro_mtkyd, "_str_mgzs" => $uplo,  "_stor_categ" => $strds_abler, "_stor_netwrk" => $stor_relnetw, "_unk_ky" => $key->uid(), "_frgn_ky" => $key->fid(), "st_sbctgy" => md5($stro_anme), "_ent_sndr" => $_SESSION['logner_bot'], "_strdes_ptn" => $stro_xdctpn);
	
		//$s_content = array("_stor_nam" => $stro_anme, "_top_sto" => $tpstr_status, "_featr_sto" => $fstr_status, "_stor_savng" => $plrstr_sttus, "_stor_rlurl" => $stro_lcurl, "_str_dstnurl" => $stro_dstnurl, "_str_mgzs" => $uplo, "_strmt_ttl" => $stro_mtte, "_strmt_desp" => $stro_mtdscp, "_mt_kiywrd" => $stro_mtkyd, "_stor_categ" => $strds_abler, "_stor_netwrk" => $stor_relnetw, "_unk_ky" => $key->uid(), "_frgn_ky" => $key->fid(), "_ent_sndr" => $_SESSION['logner_bot'], "_strdes_ptn" => $stro_xdctpn);
		$s_needle = array("_stor_nam");
		$s_heystack = array("_stor_nam" => $stro_anme);
	
		
		if(mysqli_num_rows($query->queryBuilder($s_needle, $s_tab, $s_heystack)) == 0 ) {
		
		 if($query->queryhandler($s_tab, $s_content)) { 
		 
	
		echo "<div class='alert alert-success alert-dismissible show fade'>
		  
         Store ( ".strtoupper($stro_anme)." ) Has Entered Successfully
           <button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button></div>"; 
		
		 }else{ 
		 echo "<div id='str_dup_alert'>Q-Error </div>"; }
			}else{
			
			$dup =  "<div id='str_dup_alert'>Error: Duplicate Entry</div>";
			echo $dup;
			$err->logHandler(" Error: Duplicate Entry By: '".$_SESSION['logner_bot']."' on ".date("d-m-Y")." ".date("H:i:s",time())." {Page: Store}  ) <--> ( ", "cerr.php");
			} // dup if

	} // end 2nd if

}else{
?>


<form  action="<?php $_SERVER['PHP_SELF']; ?>" method="post" class="form form-horizontal" enctype="multipart/form-data">
                                            <div class="form-body">
                                                <div class="row">
                                                    
													<div class="col-md-4">
                                                        <label>Store Name</label>
                                                    </div>
                                                    <div class="col-md-8 form-group">
                                                        <input type="text"  class="form-control" 
                                                           name="store_name" placeholder="Store Name">
													 
                                                    </div>
                                                    
													<div class="col-md-4 mt-3">
                                                        <label>Description</label>
                                                    </div>
                                                    <div class="col-md-8 form-group mt-3">
                                                        <input type="Text" id="titleimage" class="form-control" name="store_descpr" 
                                                            placeholder="Description">
                                                    </div>
                                                   
												   
												    <div class="col-md-4 mt-3">
                                                        <label>URL</label>
                                                    </div>
                                                    <div class="col-md-8 form-group mt-3">
                                                        <input type="text"  class="form-control" name="sto_url" 
                                                          placeholder="URL">
														  </div>
													
													 <div class="col-md-4 mt-3">
                                                        <label>Destination URL</label>
                                                    </div>
                                                    <div class="col-md-8 form-group mt-3">
                                                        <input type="text"  class="form-control" name="dstn_store" 
                                                          placeholder="Destination URL">
											
                                                    </div>
											<div class="col-md-4 mt-3">
                                        <label>Store Image</label>
                                      </div>
                                    <div class="col-md-8 form-group mt-3">
                                        <div class="mb-3">
                                        <label for="formFile" class="form-label">Upload Page Title Image</label>
                  <!--  <input type="file"  class="with-validation-filepond" required multiple data-max-file-size="1MB" data-max-files="3" id="formFile" name="ttlimg_keys">  -->
					
					 				 <input type="file" id="formFile" name="sto_rimgs">
										<p><small class="text-muted">JPEG, JPG Size: 600px X 400px</small></p>
                                      </div>
                                      </div>
	                                       
													<!--catgory module--->	
													
														<div class="col-md-4 mt-3">
                                                        <label>Choose Category</label>
                                                    </div>
                                                    <div class="col-md-8 form-group">
                                                      	 <div id="txtHint">
														<?php echo $view->subcatelist(); ?>
														</div>
                                                      
                                                 
													</div>
													
													<!--catgory module--->											
													
													
													
													
														<div class="col-md-4 mt-3">
                                         <label>Newtwork</label>
                                         </div>
                                       <div class="col-md-8 form-group mt-3">
								         <select name="stor_Network" class="form-control col-12 p-2">
											<option value="">Choose Network</option>
											<?php
											$needle = array("netwk_nam", "_frgn_ky");
											$tb = "copn_netwrk";
											$heystack = ''; 
											$qu = $query->queryBuilder($needle, $tb, $heystack);
											while($network = mysqli_fetch_array($qu, MYSQLI_NUM)) {
											?>
											
											<option value="<?php echo $network[0]; ?>"><?php echo $network[0]; ?></option>
											<?php
											} // end whl
											?>
										</select>
                                             </div>
													
													
									<div class="col-md-4 mt-3">
                                         <label>Placement</label>
                                      </div>
                                       <div class="col-md-8 form-group">
									   
									     <div class='form-check d-inline-block'>
                                                            <div class="m-2 checkbox d-inline-block">
                                                                <input type="checkbox" 
															class='form-check-input' name="stor_featurd" />
														
                                                                <label for="checkbox1">Featured Store</label>
                                                            </div>
                                                        </div><!--sec checkbox--->
														
                                                        <div class='m-2 form-check d-inline-block'>  
                                                            <div class="checkbox d-inline-block">
                                                                <input type="checkbox" name="top_store"
                                                                    class='form-check-input'  />
													
                                                                <label for="checkbox1">Recommended Store</label>
                                                            </div>
                                                        </div><!--first checkbox--->
														
														 <div class='m-2 form-check d-inline-block'>
                                                            <div class="checkbox d-inline-block">
                                                                <input type="checkbox" name="populr_store" class='form-check-input' />
													
                                                                <label for="checkbox1">Popular Store</label>
                                                            </div>
                                                        </div><!--sec checkbox--->
			
														
														
														
														<div class='m-2 form-check d-inline-block '>
                                                            <div class="checkbox d-inline-block">
                                                                <input type="checkbox" class='form-check-input' name="disabl_store"/>
																
                                                                <label for="checkbox1">Location: Uk</label>
                                                            </div>
                                                        </div><!--sec checkbox--->	
                                                    </div><!--check box ended-->
												
								
                                       </div><!--col- 8 end-->
														
								
													
                                                   
												   
												    <div class="col-sm-12 mt-3 d-flex justify-content-end">
                                                       
													    <input type="submit" name="admit_store" class="col-4 p-2 bg-primary text-white" style="border:1px solid #fff; border-radius: 15px;" value="Add New Store" />
													    
                                                        
                                                    </div>
                                                </div>
                                            </div>
                                        </form>
									<?php
								} // end if
								} // sec
								?>


										
                                    </div>
                                </div>
                            </div>
                        </div>
                        
                    </div>
                </section>
					
                </div><!---- page-head ---->

			
            </div><!-- main-content -->
			
			 <?php include_once("assets/resources/footer_includer.php"); ?>
  

    <script src="assets/vendors/perfect-scrollbar/perfect-scrollbar.min.js"></script>
    <script src="assets/js/bootstrap.bundle.min.js"></script>

   <!-- <script src="assets/js/main.js"></script>-->
	
	
	
	<!--summmernote-->
</body>

</html>