<?php include 'sets.php';?>
<?php
$superuser="1";
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Webadmin <?php echo $domain ?></title>
<?php include 'codes.php';?>
</head>
<body>

<?php include 'navbar.php';?>
    
<div class="container">
<div class="frame">
<div class="frametitles flist">
<?php
if  (isset($_POST['submit'.$_REQUEST['id']])) {
$name = $mysqli->real_escape_string(stripslashes($_REQUEST['name']));
$active = $mysqli->real_escape_string(stripslashes($_REQUEST['active']));
$mysqli->query("UPDATE paymethods SET name='$name', active='$active' WHERE id='{$_REQUEST['id']}'"); 
}?> 
<?php
$result = $mysqli->query("SELECT * FROM paymethods");
$nrrows = mysqli_num_rows($result);
?>
<a href="list-paymethods.php">Payment methods</a> (<?php echo $nrrows ?>)
<div class="floatright"><a href="add-paymethod.php"><img src="img/add.png" alt="<?php echo $adminadditem ?>" title="<?php echo $adminadditem ?>"></a></div>
</div>
<div class="framein">

<?php
$result = $mysqli->query("SELECT * FROM paymethods ORDER BY id");
while($row = $result->fetch_array()) {
$id=$row['id'];
$name=$row['name'];
$active=$row['active'];
?>
<div class="framerow<?php if ($active==0) { echo " notpublished"; }?>">
    <table>
        <tr>
          <td class="tabletd1"><?php echo $id ?></td>
          <td width="180">
            <span class="titles"><?php echo $name ?> *</span>
          </td>
          <td width="180">
            <?php if ($active==0) { ?>
       <span class="icon icstyle1 fa-eye-slash" title="<?php echo $adminpublish ?> &raquo; <?php echo $adminno ?>"></span>  
       <?php } ?>
          </td>
          <td>
            
            <form name="forma" method="post">
              <input type="hidden" name="id" value="<?php echo $id ?>">
              
              <input type="text" name="name" size="15" value="<?php echo $name ?>" class="inputauto" required>     
              <?php if ($active==0) { ?>
              <input type="hidden" name="active" value="0"> <input type="checkbox" name="active" value="1">  
              <?php }else{?>
              <input type="hidden" name="active" value="0"> <input type="checkbox" name="active" value="1" checked>  
              <?php } ?>
              
              <button type="submit" name="submit<?php echo $id ?>" class="button buttonsmall"><span class="icon fa-check"></span></button>
              </form>
            
          </td>
          <td class="divoption">
<?php
if  (isset($_POST['deleterow'])) {
$mysqli->query("DELETE FROM paymethods WHERE id='{$_REQUEST['id']}'");
$mysqli->query("ALTER TABLE paymethods AUTO_INCREMENT = 1");
?>
<meta http-equiv="refresh" content="0;URL=list-paymethods.php">
<?php } ?>
              <form name="formdelete" method="post">
              <input type="hidden" name="id" value="<?php echo $id ?>">
              <button type="submit" name="deleterow" class="linkoption linkdelete" title="<?php echo $admindelete ?>"><span class="icon fa-trash-o"></span> <?php echo $admindelete ?></button>
            </form>
            </td>
          </tr>
      </table>
     </div> 
    <?php } ?>      
      
</div>
</div>
</div>

<?php include 'menudown.php';?>

</body>
</html>