<?php require('includes/head.php');
require 'connection/conn.php';
 if(isset($_POST['submit']))
 {
  
	 $id=$_POST['id'];
	 $n=$_POST['n'];
	 $u=$_POST['u'];
	 $p=$_POST['p'];
	 $t=$_POST['t'];

	 $add="UPDATE `user`  set `full_name`='$n', `user_mobile`='$u', `user_password`='$p', `user_position`='$t' where `user_id`=$id";
	 $conn->query($add);
	  echo "<script type='text/javascript'>
		           window.location.href='user_list.php'
		        </script>";
 }
$id=$_GET['id'];
$user="select * from `user` where `user_id`=$id";
  $user_r=$conn->query($user);
  $row=mysqli_fetch_array($user_r);
?>
<div class="container">
          <div class="page-inner">
            <div class="page-header">
              <h3 class="fw-bold mb-3">گۆڕین</h3>
              <ul class="breadcrumbs mb-3">
                <li class="nav-home">
                  <a href="home.php">
                    <i class="icon-home"></i>
                  </a>
                </li>
                <li class="separator">
                  <i class="icon-arrow-right"></i>
                </li>
                <li class="nav-item">
                  <a href="#"></a>
                </li>
                <li class="separator">
                  <i class="icon-arrow-right"></i>
                </li>
                <li class="nav-item">
                  <a href="#"></a>
                </li>
              </ul>
            </div>
            <div class="row">
              <div class="col-md-12">
                <div class="card">
                  
                  <div class="card-body">
                    <div class="table-responsive">
                      <table
                        id="basic-datatables"
                        class="display table table-striped table-hover"
                      >
<form action="" method="post"><input type="hidden" name="id"       required value="<?php echo $row['user_id'];?>">

<thead >
	<tr>
		<td>ناو:</td><td><input type="text" name="n" required value="<?php echo $row['full_name'];?>"></td>
	</tr>
	<tr bgcolor="lightblue">
		<td>بەکارهێنەر:</td><td><input type="text" name="u" required value="<?php echo $row['user_mobile'];?>"></td>
	</tr>
	<tr>
		<td>پاسوۆرد:</td><td><input type="text" name="p" required value="<?php echo $row['user_password'];?>"></td>
	</tr>
	<tr>
	<?php if($row['user_position']==4){?>
		<td>ناونیشان:</td><td><select name="t" required><option value=4>Cashier</option><option value=3>User</option><option value=2>Admin</option><option value=1>SuperAdmin</option></select></td>
	<?php } 
	elseif($row['user_position']==3){?>
		<td>ناونیشان:</td><td><select name="t" required><option value=3>User</option><option value=4>Cashier</option><option value=2>Admin</option><option value=1>SuperAdmin</option></select></td>
	<?php } 
	elseif($row['user_position']==2){?>
		<td>ناونیشان:</td><td><select name="t" required><option value=2>Admin</option><option value=4>Cashier</option><option value=3>User</option><option value=1>SuperAdmin</option></select></td>
	<?php } 
	elseif($row['user_position']==1){?>
		<td>ناونیشان:</td><td><select name="t" required><option value=1>SuperAdmin</option><option value=4>Cashier</option><option value=3>User</option><option value=2>Admin</option></select></td>
	<?php } 

	?>
	</tr>
	<tr bgcolor="lightblue">
		<td></td><td><input type="submit" name="submit" value="زیاد کردن"></td>
</tr></table>
   
</form> 


</div>
                  </div>
                </div>
              </div>
			  
			  </div>
          </div>
        </div>
<?php require'includes/foot.php';?>