<!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 Network 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['ntwuqk']) && isset($_GET['ntwrkfrk'])) {
						$ntw_unqks = $view->decrypt($_GET['ntwuqk']);
						$ntw_frgkys = $view->decrypt($_GET['ntwrkfrk']);
						?>
								 <h4 class="card-title">Update/Edit Network</h4>
								 <?php
								if(isset($_POST['update_network']) && $_POST['update_network'] == "Update Network" && isset($_POST['network_name'])) {
								?>
								
								 <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>Network Name</label>
                                                    </div>
                                                    <div class="col-md-8 form-group">
                                                        <input type="text"  class="form-control" name="network_name" value="<?php echo $_POST['network_name']; ?>"
                                                          placeholder="Network Name">
														  <?php
		                                             $ntwrk_nmx = $isValid->iValid($_POST['network_name'], 'Error. Invalide Text or Blank', 'str');
		
                                                          ?>
														</div>
														<div class="col-md-4 mt-3">
                                                        <label>Privileges</label>
                                                    </div>
                                                    <div class="col-md-8 form-group">
                                                      	<div class="m-2 d-inline-block">
													 <input type="checkbox" class="form-check-input"   name="Category_status" <?php if(isset($_POST['Category_status']) && $_POST['Category_status'] == "on"){?> checked="checked" <?php } ?> />
													 <?php
															if(isset($_POST['Category_status']) && $_POST['Category_status'] == "on"){
															 $status = 1;
															}else{
															 $status = 0;
															 
															}
															
															?>
													 
													
									  <label for="Create User">Status</label>
                                             </div>
	                                    </div>

								<!--catgory module--->											
											<div class="col-sm-12 mt-3 d-flex justify-content-end">
                                                        <button type="submit"
                                                            class="btn btn-primary me-1 mb-1"  name="update_network" value="Update Network" id="frm" >Update Network</button>
                                                        <button type="reset"
                                                            class="btn btn-light-secondary me-1 mb-1">Reset</button>
                                                    </div>
                                                </div>
                                            </div>
                                        </form>
								
								<?php
	if(isset($ntwrk_nmx) && $ntwrk_nmx != ''
	&& isset($ntw_unqks) && $ntw_unqks != ''
	&& isset($ntw_frgkys) && $ntw_frgkys != '' 
	&& isset($status)){
		//if(isset($_POST['Category_status']) && $_POST['Category_status'] == "on"){ $status = 1;}else{ $status = 0;}
		$n = array("netwk_nam", "_nt_status");
		$tab = "copn_netwrk";
		$content = array(
					"netwk_nam" => $ntwrk_nmx,
					"_nt_status" => $status,
					"_unk_ky" => $key->uid(),
					"_frgn_ky" => $key->fid(),
					"_ent_sndr" => $_SESSION['logner_bot']
					);
				$c = array(
					"_unk_ky" => $ntw_unqks,
					"_frgn_ky" => $ntw_frgkys
					);
	//if(mysql_num_rows($query->queryBuilder($n, $tab, $c)) == 0 ) {
		if($query->queryUpdater($tab, $content, $c)) { 
		//echo "<div id='succ_alert'>Network Has Updated</div>";
		echo "<div class='alert alert-success alert-dismissible show fade'>
           Network Has Updated Successfully
           <button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button></div>"; 
		   
		$err->logHandler(" Alert: Network Updated/Edited By: '".$_SESSION['logner_bot']."' IP: '".$_SERVER['REMOTE_ADDR']."' on ".date("d-m-Y")." ".date("H:i:s",time())." {Page: Category}  ) <--> ( ", "cerr.php");
		}else{ 
		echo "<div id='dup_alert'>Q-Error </div>"; 
		}
	//}else{
		
		//$dup =  "<div id='dup_alert'>Error: Duplicate Entry</div>";
		//echo $dup;
		
	//} // dup if   
	

	}
}else{

$needle = array("netwk_nam", "_nt_status");
$tb = "copn_netwrk";
$heystack = array("_unk_ky" => $ntw_unqks, "_frgn_ky" => $ntw_frgkys); 
$editquery = $query->queryBuilder($needle, $tb, $heystack);
while($netview = 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>Network Name</label>
                                                    </div>
                                                    <div class="col-md-8 form-group">
                                                        <input type="text"  class="form-control" name="network_name" value="<?php echo $netview[0]; ?>"
                                                          placeholder="Network Name">
														</div>
														<div class="col-md-4 mt-3">
                                                        <label>Privileges</label>
                                                    </div>
                                                    <div class="col-md-8 form-group">
                                                      	<div class="m-2 d-inline-block">
													 <input type="checkbox" class="form-check-input"  name="Category_status" <?php if(isset($netview[1]) && $netview[1] == 1){ ?> checked="checked" <?php } ?>/>
													 
													
									  <label for="Create User">Status</label>
                                             </div>
	                                    </div>

								<!--catgory module--->											
											<div class="col-sm-12 mt-3 d-flex justify-content-end">
                                                        <button type="submit"
                                                            class="btn btn-primary me-1 mb-1" name="update_network" value="Update Network" id="frm"  >Add New Network</button>
                                                        <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 Network</h4>
									 	
								<?php
								
								if(isset($_POST['admit_network']) && $_POST['admit_network'] == "Add New Network" && isset($_POST['network_name'])) {
								?>
                                </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 mt-3">
                                                        <label>Privileges</label>
                                                    </div>
                                                    <div class="col-md-8 form-group">
                                                      	<div class="m-2 d-inline-block">
													 <input type="checkbox" class="form-check-input"  name="Category_status" <?php if(isset($_POST['Category_status']) && $_POST['Category_status'] == "on"){?> checked="checked" <?php } ?>/> 
													 
									  <label>Status</label>
									            </div>
												<?php
												if(isset($_POST['Category_status']) && $_POST['Category_status'] == "on"){
												 $status = 1;
												}else{
												 $status = 0;
												 
												}
												
												?>
	                                        </div>
										
                                                    <div class="col-md-4">
                                                        <label>Network Name</label>
                                                    </div>
                                                    <div class="col-md-8 form-group">
                                                        <input type="text"  class="form-control" name="network_name" value="<?php echo $_POST['network_name']; ?>" placeholder="Network Name"/>
                                                      <?php
														$ntwrk_nmx = $isValid->iValid($_POST['network_name'], 'Error. Invalide Text or Blank', 'str');
														?>    
																										 
                                                    </div>
                                                    
                                          
								

								<!--catgory module--->											
											<div class="col-sm-12 mt-3 d-flex justify-content-end">
                                                         <input type="submit" name="admit_network" class="col-3 p-2 bg-primary text-white" style="border-radius: 20px; border:1px solid #435ebe;" value="Add New Network" />
                                                    </div>
                                                </div>
                                            </div>
                                        </form>
										
										<?php
	if(isset($ntwrk_nmx) && $ntwrk_nmx != '' && isset($status)){
		//if(isset($_POST['Category_status']) && $_POST['Category_status'] == "on"){ $status = 1;}else{ $status = 0;}
		$n = array("netwk_nam", "_nt_status");
		$tab = "copn_netwrk";
		$content = array(
					"netwk_nam" => $ntwrk_nmx,
					"_nt_status" => $status,
					"_unk_ky" => $key->uid(),
					"_frgn_ky" => $key->fid(),
					"_ent_sndr" => $_SESSION['logner_bot']
					);
				$c = array(
					"netwk_nam" => $_POST['network_name'],
					"_nt_status" => $status
					);
	if(mysqli_num_rows($query->queryBuilder($n, $tab, $c)) == 0 ) {
		if($query->queryhandler($tab, $content)) { 
		
		//echo "<div class='p-2 text-dark'>Network Has Entered</div>";
		echo "<div class='alert alert-success alert-dismissible show fade'>
           Network Has Entered Successfully
           <button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='Close'></button></div>"; 
		
		 }else{ 
		 echo "<div id='dup_alert'>Q-Error </div>";
		 
		 
		  }
	}else{
		
		$dup =  "<div id='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   
	

	}
}else{
?>	

               <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" class="form form-horizontal">
                                            <div class="form-body">
                                                <div class="row">
												   
												   <div class="col-md-4 mt-3">
                                                        <label>Privileges</label>
                                                    </div>
                                                    <div class="col-md-8 form-group">
                                                      	<div class="m-2 d-inline-block">
													 <input type="checkbox" class="form-check-input"  name="Category_status" />
													 
													
									  <label for="">Status</label>
                                             </div>
	                                    </div>
												
												
                                                    <div class="col-md-4">
                                                        <label>Network Name</label>
                                                    </div>
                                                    <div class="col-md-8 form-group">
                                                        <input type="text"  class="form-control" name="network_name"
                                                          placeholder="Network Name">
														</div>
													ok
								<!--catgory module--->											
											<div class="col-sm-12 mt-3 d-flex justify-content-end">
                                                       <input type="submit" name="admit_network" class="col-3 p-2 bg-primary text-white" style="border-radius: 20px; border:1px solid #435ebe;" value="Add New Network" />
                                                    </div>
                                                </div>
                                            </div>
                                        </form>

<?php
} // end if
?>

<?php
} // end get if
?>
										

                                    </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>
	
	<!--summnernot-->
	    <script src="assets/vendors/summernote/summernote-lite.min.js"></script>
    <script>
        $('#summernote').summernote({
            tabsize: 2,
            height: 120,
        })
        $("#hint").summernote({
            height: 100,
            toolbar: false,
            placeholder: 'type with apple, orange, watermelon and lemon',
            hint: {
                words: ['apple', 'orange', 'watermelon', 'lemon'],
                match: /\b(\w{1,})$/,
                search: function (keyword, callback) {
                    callback($.grep(this.words, function (item) {
                        return item.indexOf(keyword) === 0;
                    }));
                }
            }
        });

    </script>
	
	<!--summmernote-->
</body>

</html>