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

		
		<!-- 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>Category 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 Category Page
                                        </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" style=" background-color:#FFFFFF;" >
                                <div class="card-header">
														<?php
if(isset($_GET['cteuk']) && isset($_GET['catefk'])) {
$ctg_unqky = $view->decrypt($_GET['cteuk']);
$ctg_frgnky = $view->decrypt($_GET['catefk']);
?>	
	
							<h4 class="card-title">Edit/Update Category</h4>
							<?php
						if(isset($_POST['update_category']) && $_POST['update_category'] == "Update Category" 
						&& isset($_POST['Category_name'])
						&& isset($_POST['Categorymeta_title'])
						&& isset($_POST['Categorymeta_descp'])
						&& isset($_POST['Category_metakeywrds'])) {
						?>
						<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post"  class="form form-horizontal">
                                            <div class="form-body">
                                                <div class="row">
                                                    <div class="col-md-4">
                                                        <label>Category Name</label>
                                                    </div>
                                                    <div class="col-md-8 form-group">
                                                        <input type="text"  class="form-control"
                                                           name="Category_name" value="<?php echo $_POST['Category_name']; ?>" placeholder="Category Name"/>
														   <?php
		$ctg_nme = $isValid->iValid($_POST['Category_name'], 'Error. Invalide Text or Blank Field', 'str');
?>
                                                    </div>
                                                    <div class="col-md-4 mt-3">
                                                        <label>Meta Tittle</label>
                                                    </div>
                                                    <div class="col-md-8 form-group mt-3">
                                                        <input type="Text" id="titleimage" class="form-control"
                                                          name="Categorymeta_title" value="<?php echo $_POST['Categorymeta_title']; ?>" placeholder="Meta Tittle"/>
														  <?php
		$ctg_tlt = $isValid->iValid($_POST['Categorymeta_title'], 'Error. Invalide Text or Blank Field', 'str');
?>

								</div>
                                                   
                                                    <div class="col-md-4 mt-3">
                                                        <label>Meta Description</label>
                                                    </div>
                                                    <div class="col-md-8 form-group mt-3">
                                                        <input type="text"  class="form-control"
                                                            name="Categorymeta_descp" value="<?php echo $_POST['Categorymeta_descp']; ?>" placeholder="Meta Description"/>
															<?php

		$ctg_mtdsp = $isValid->iValid($_POST['Categorymeta_descp'], 'Error. Invalide Text or Blank Field', 'str');

?>
                                                    </div>
												
												 <div class="col-md-4 mt-3">
                                                        <label>Meta Keywords</label>
                                                    </div>
                                                    <div class="col-md-8 form-group mt-3">
                                                        <input type="Text" id="titleimage" class="form-control"
                                                           name="Category_metakeywrds" value="<?php echo $_POST['Category_metakeywrds']; ?>" placeholder="Meta Keywords"/>
														  <?php
		$ctgmt_kwrd = $isValid->iValid($_POST['Category_metakeywrds'], 'Error. Invalide Text or Blank Field', 'str');
?>
                                                    </div>
													
                                                    <div class="col-12 col-md-8 mt-3 offset-md-4 form-group">
													
													  		<div class='form-check d-inline-block'>
                                                            <div class="checkbox d-inline-block">
                                                                <input type="checkbox" id="checkbox1" 
															class='form-check-input' name="top_Category"<?php if(isset($_POST['top_Category']) && $_POST['top_Category'] == "on"){?> checked="checked" <?php } ?>/>
																<?php
														if(isset($_POST['top_Category']) && $_POST['top_Category'] == "on"){
														 $cg_status = 1;
														}else{
														 $cg_status = 0;
														 
														}
														?>		
																	
                                                                <label for="checkbox1">Top Category</label>
                                                            </div>
                                                        </div><!--sec checkbox--->

												   
												   	    <div class="col-sm-12 d-flex justify-content-end">
                                                            <input type="submit" class="btn btn-primary me-1 mb-1" name="update_category" value="Update Category">
                                                        <button type="reset"
                                                            class="btn btn-light-secondary me-1 mb-1">Reset</button>
                                                    </div>
													
												 
                                                </div>
                                            </div>
                                        </form>
										<?php
if(isset($ctg_nme) && $ctg_nme != ''
&& isset($ctg_tlt) && $ctg_tlt != ''
&& isset($ctg_mtdsp) && $ctg_mtdsp != ''
&& isset($ctgmt_kwrd) && $ctgmt_kwrd != ''
&& isset($ctg_unqky) && $ctg_unqky != ''
&& isset($ctg_frgnky) && $ctg_frgnky != '' && isset($cg_status)){

	$tab = "cop_categ";
	$content = array("cate_nam" => $ctg_nme,
					"_top_ctg" => $cg_status, "_mt_ttl" => $ctg_tlt, "_mt_descp" => $ctg_mtdsp, 
					"_mt_kiywrd" => $ctgmt_kwrd, "_unk_ky" => $key->uid(),"_frgn_ky" => $key->fid(),
					"_ent_sndr" => $_SESSION['logner_bot']);
	$needle = array("cate_nam");
	$update_heystack = array("_unk_ky" => $ctg_unqky, "_frgn_ky" => $ctg_frgnky);
	// check heystack. can we use content array here too just like $content[0] for heystack
					
	//if(mysql_num_rows($query->queryBuilder($needle, $tab, $heystack)) == 0 ) {
		if($query->queryUpdater($tab, $content, $update_heystack)) { 
		
			echo "<div class='alert alert-success alert-dismissible show fade'>
          Category Has Updated Successfully
           <button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button></div>";  
		
		//echo "<div id='cg_succ_alert'>Category Has Updated Successfully</div>";
		
		$err->logHandler(" Alert: Record Updated By: '".$_SESSION['logner_bot']."' IP: '".$_SERVER['REMOTE_ADDR']."' on ".date("d-m-Y")." ".date("H:i:s",time())." {Page: Edit Category}  ) <--> ( ", "cerr.php");
		}else{ 
		echo "<div id='dup_alert'>Q-Error </div>"; 
		}
	//}else{
		
		//$dup =  "<div id='cg_dup_alert'>Error: Duplicate Entry</div>";
		//echo $dup;
		
	//} // dup if

}// end 2nd if

}else{
// $ctg_unqky = $view->decrypt($_GET['cteuk']);
// $ctg_frgnky

$needle = array("cate_nam", "_top_ctg", "_mt_ttl", "_mt_descp", "_mt_kiywrd");
$tb = "cop_categ";
$heystack = array("_unk_ky" => $ctg_unqky, "_frgn_ky" => $ctg_frgnky); 
$editquery = $query->queryBuilder($needle, $tb, $heystack);
while($categview = mysqli_fetch_array($editquery, MYSQLI_NUM)){

?>


<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post"  class="form form-horizontal">
                                            <div class="form-body">
                                                <div class="row">
                                                    <div class="col-md-4">
                                                        <label>Category Name</label>
                                                    </div>
                                                    <div class="col-md-8 form-group">
                                                        <input type="text"  class="form-control" value="<?php echo $categview[0]; ?>"
                                                           name="Category_name"  placeholder="Category Name"/>
														   
                                                    </div>
                                                    <div class="col-md-4 mt-3">
                                                        <label>Meta Tittle</label>
                                                    </div>
                                                    <div class="col-md-8 form-group mt-3">
                                                        <input type="Text" id="titleimage" class="form-control" value="<?php echo $categview[2]; ?>"
                                                          name="Categorymeta_title"  placeholder="Meta Tittle"/>
								                  </div>
                                                   
                                                    <div class="col-md-4 mt-3">
                                                        <label>Meta Description</label>
                                                    </div>
                                                    <div class="col-md-8 form-group mt-3">
                                                        <input type="text"  class="form-control" value="<?php echo $categview[3]; ?>"
                                                            name="Categorymeta_descp"  placeholder="Meta Description"/>
                                                    </div>
												
												 <div class="col-md-4 mt-3">
                                                        <label>Meta Keywords</label>
                                                    </div>
                                                    <div class="col-md-8 form-group mt-3">
                                                        <input type="Text" id="titleimage" class="form-control" value="<?php echo $categview[4]; ?>"
                                                           name="Category_metakeywrds"  placeholder="Meta Keywords"/>
                                                    </div>
													
                                                    <div class="col-12 col-md-8 mt-3 offset-md-4 form-group">
													
													  		<div class='form-check d-inline-block'>
                                                            <div class="checkbox d-inline-block">
                                                                <input type="checkbox" id="checkbox1" 
															class='form-check-input' name="top_Category" <?php if(isset($categview[1]) && $categview[1] == 1){ ?> checked="checked" <?php } ?> />
																
                                                                <label for="checkbox1">Top Category</label>
                                                            </div>
                                                        </div><!--sec checkbox--->

												   
												     
												    <div class="col-sm-12 d-flex justify-content-end">
                                                            <input type="submit" class="btn btn-primary me-1 mb-1" name="update_category" value="Update Category">
                                                        <button type="reset"
                                                            class="btn btn-light-secondary me-1 mb-1">Reset</button>
                                                    </div>
												   
												 
                                                </div>
                                            </div>
                                        </form>


<?php
	} // end while
} // end if
?>


<?php
}else{
?>

										
										
										
						
						
						
						
						
							

                                    <h4 class="card-title">Add New Category</h4>
									<?php
								if(isset($_POST['admit_category']) && $_POST['admit_category'] == "Add Category" 
								&& isset($_POST['Category_name'])
								&& isset($_POST['Categorymeta_title'])
								&& isset($_POST['Categorymeta_descp'])
								&& isset($_POST['Category_metakeywrds'])) {
								?>
                                </div>
                                <div class="card-content">
                                    <div class="card-body ">
                                        <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>Category Name</label>
                                                    </div>
                                                    <div class="col-md-8 form-group">
                                                        <input type="text"  class="form-control"
                                                           name="Category_name" value="<?php echo $_POST['Category_name']; ?>" placeholder="Category Name"/>
														   <?php
														$ctg_nme = $isValid->iValid($_POST['Category_name'], 'Error. Invalide Text or Blank Field', 'str');
												?>
                                                    </div>
                                                    <div class="col-md-4 mt-3">
                                                        <label>Meta Tittle</label>
                                                    </div>
                                                    <div class="col-md-8 form-group mt-3">
                                                        <input type="Text" id="titleimage" class="form-control"
                                                          name="Categorymeta_title" value="<?php echo $_POST['Categorymeta_title']; ?>" placeholder="Meta Tittle"/>
														  <?php
										$ctg_tlt = $isValid->iValid($_POST['Categorymeta_title'], 'Error. Invalide Text or Blank Field', 'str');
								?>
								</div>
                                                   
                                                    <div class="col-md-4 mt-3">
                                                        <label>Meta Description</label>
                                                    </div>
                                                    <div class="col-md-8 form-group mt-3">
                                                        <input type="text"  class="form-control"
                                                            name="Categorymeta_descp" value="<?php echo $_POST['Categorymeta_descp']; ?>" placeholder="Meta Description"/>
															<?php

		$ctg_mtdsp = $isValid->iValid($_POST['Categorymeta_descp'], 'Error. Invalide Text or Blank Field', 'str');

?>
                                                    </div>
												
												 <div class="col-md-4 mt-3">
                                                        <label>Meta Keywords</label>
                                                    </div>
                                                    <div class="col-md-8 form-group mt-3">
                                                        <input type="Text" id="titleimage" class="form-control"
                                                           name="Category_metakeywrds" value="<?php echo $_POST['Category_metakeywrds']; ?>" placeholder="Meta Keywords"/>
														   <?php
		$ctgmt_kwrd = $isValid->iValid($_POST['Category_metakeywrds'], 'Error. Invalide Text or Blank Field', 'str');
?>
                                                    </div>
													
                                                    <div class="col-12 col-md-8 mt-3 offset-md-4 form-group">
													
													  		<div class='form-check d-inline-block'>
                                                            <div class="checkbox d-inline-block">
                                                                <input type="checkbox" id="checkbox1" 
															class='form-check-input' name="top_Category" <?php if(isset($_POST['top_Category']) && $_POST['top_Category'] == "on"){?> checked="checked" <?php } ?> />
																<?php
														if(isset($_POST['top_Category']) && $_POST['top_Category'] == "on"){
														 $cg_status = 1;
														}else{
														 $cg_status = 0;
														 
														}
														?>					
			
                                                                <label for="checkbox1">Top Category</label>
                                                            </div>
                                                        </div><!--sec checkbox--->

												   
												    <div class="col-sm-12 d-flex justify-content-end">
                                                            <input type="submit" class="btn btn-primary me-1 mb-1" name="admit_category" value="Add Category">
                                                        <button type="reset"
                                                            class="btn btn-light-secondary me-1 mb-1">Reset</button>
                                                    </div>
                                                </div>
                                            </div>
                                        </form>
<?php
if(isset($ctg_nme) && $ctg_nme != ''
&& isset($ctg_tlt) && $ctg_tlt != ''
&& isset($ctg_mtdsp) && $ctg_mtdsp != ''
&& isset($ctgmt_kwrd) && $ctgmt_kwrd != '' && isset($cg_status)){

	$tab = "cop_categ";
	$content = array("cate_nam" => $ctg_nme,
					"_top_ctg" => $cg_status, "_mt_ttl" => $ctg_tlt, "_mt_descp" => $ctg_mtdsp, 
					"_mt_kiywrd" => $ctgmt_kwrd, "_unk_ky" => $key->uid(),"_frgn_ky" => $key->fid(),
					"_ent_sndr" => $_SESSION['logner_bot']);
	$needle = array("cate_nam");
	$heystack = array("cate_nam" => $ctg_nme);
	// check heystack. can we use content array here too just like $content[0] for heystack
					
	if(mysqli_num_rows($query->queryBuilder($needle, $tab, $heystack)) == 0 ) {
		if($query->queryhandler($tab, $content)) { 
		
		echo "<div class='alert alert-success alert-dismissible show fade'>
          Category Has Been Added Successfully
           <button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button></div>";  
		
		//echo "<div id='cg_succ_alert'>Category Has Entered Successfully</div>"; 
		
		
		}else{ echo "<div id='dup_alert'>Q-Error </div>"; }
	}else{
		
		$dup =  "<div id='cg_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: Category}  ) <--> ( ", "cerr.php");
	} // dup if

}// end 2nd if

}else{
?>

<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>Category Name</label>
                                                    </div>
                                                    <div class="col-md-8 form-group">
                                                        <input type="text"  class="form-control"
                                                           name="Category_name"  placeholder="Category Name"/>
														   
                                                    </div>
                                                    <div class="col-md-4 mt-3">
                                                        <label>Meta Tittle</label>
                                                    </div>
                                                    <div class="col-md-8 form-group mt-3">
                                                        <input type="Text" id="titleimage" class="form-control"
                                                          name="Categorymeta_title"  placeholder="Meta Tittle"/>
								                  </div>
                                                   
                                                    <div class="col-md-4 mt-3">
                                                        <label>Meta Description</label>
                                                    </div>
                                                    <div class="col-md-8 form-group mt-3">
                                                        <input type="text"  class="form-control"
                                                            name="Categorymeta_descp"  placeholder="Meta Description"/>
                                                    </div>
												
												 <div class="col-md-4 mt-3">
                                                        <label>Meta Keywords</label>
                                                    </div>
                                                    <div class="col-md-8 form-group mt-3">
                                                        <input type="Text" id="titleimage" class="form-control"
                                                           name="Category_metakeywrds"  placeholder="Meta Keywords"/>
                                                    </div>
													
                                                    <div class="col-12 col-md-8 mt-3 offset-md-4 form-group">
													
													  		<div class='form-check d-inline-block'>
                                                            <div class="checkbox d-inline-block">
                                                                <input type="checkbox" id="checkbox1" 
															class='form-check-input' name="top_Category" />
																
                                                                <label for="checkbox1">Top Category</label>
                                                            </div>
                                                        </div><!--sec checkbox--->

												   
												    <div class="col-sm-12 d-flex justify-content-end">
                                                        <input type="submit" class="btn btn-primary me-1 mb-1" name="admit_category" value="Add Category">
                                                        <button type="reset"class="btn btn-light-secondary me-1 mb-1">Reset</button>
                                                    </div>
                                                </div>
                                            </div>
                                        </form>

<?php
} // end if
}
?>






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

			
            </div><!-- main-content -->


    <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>
	

