/home2/kerimkazan/dvf/magaza/inc/user.php
<?php if(!defined('ADMIN_INCLUDED')) { exit; } ?>
<?php
if(!m_authority(m_admin('authoritys'),'users'))
{
		m_redirect(ADMIN_URL);
}
?>
<?php
	$informations = $db->table('users')->where('id','=',m_a_g('id'))->get();
	if($informations['total_count']=='0')
	{
		m_redirect(ADMIN_URL);
	}
	$info = $informations['data'][0];
?>
<div class="card mt-2 mb-3">
		<div class="card-header fw-bold">Yönetici Düzenle</div>
		<div class="card-body">
		
		<?php
		if($_POST)
		{
			$authoritys = '';
			foreach ($_POST['authoritys'] as $key => $value)
			{
				$authoritys.='<'.$key.'>'.$value.'</'.$key.'>';
			}
			
			if(m_u_p('password')=='')
			{
				$password = $info['password'];
			}
			else
			{
				$password = m_password(m_u_p('password'));
			}
			
			
			$data = [
			'authoritys' => $authoritys,
			'name' => m_u_p('name'),
			'email' => m_u_p('email'),
			'password' => $password,
			'status' => m_u_p('status')
			];
			
			$query = $db->table('users')->where('id','=',$info['id'])->update($data);
			
			if($query)
			{
				echo m_alert('Başarılı','İşleminiz başarıyla gerçekleştirildi.');
			}
			else
			{
				echo m_alert('Hata','İşlem gerçekleştirilirken bir hata oluştu.');
			}
							
		}
		
		$informations = $db->table('users')->where('id','=',m_a_g('id'))->get();
		$info = $informations['data'][0];
		
		
		?>
		<form action="" method="post" enctype="multipart/form-data">
		<div class="mb-2">
		<label class="form-label fw-bold">Durum</label>
		<div>
		<div class="form-check form-check-inline">
			<label class="form-check-label">
				<input type="radio" class="form-check-input" name="status" value="1" <?php if($info['status']==1) { echo 'checked'; } ?>>
				Aktif
			</label>
		</div>
		<div class="form-check form-check-inline">
			<label class="form-check-label">
				<input type="radio" class="form-check-input" name="status" value="0" <?php if($info['status']==0) { echo 'checked'; } ?>>
				Pasif
			</label>
		</div>
		</div>
		</div>
		<div class="mb-2">
		  <label class="form-label fw-bold">İsim</label>
		  <input type="text" class="form-control" name="name" value="<?php echo $info['name']; ?>" required>
		</div>
		<div class="mb-2">
		  <label class="form-label fw-bold">Email</label>
		  <input type="text" class="form-control" name="email" value="<?php echo $info['email']; ?>" required>
		</div>
		<div class="mb-2">
		  <label class="form-label fw-bold">Şifre</label>
		  <input type="password" class="form-control" name="password">
		</div>
		<?php
$authoritys = array();
$authoritys['settings'] = 'Genel Ayarlar';
$authoritys['reports'] = 'Raporlar';
$authoritys['products'] = 'Ürün Yönetimi';
$authoritys['users'] = 'Yöneticiler';
$authoritys['delete'] = 'Silme';
$authoritys['hakedisler'] = 'Hakedişler';  // Yeni yetki eklendi
foreach($authoritys as $key => $value)
{
?>
<div class="mb-2">
    <label class="form-label fw-bold">YETKİ - <?php echo $value; ?></label>
    <div>
    <div class="form-check form-check-inline">
        <label class="form-check-label">
            <input type="radio" class="form-check-input" name="authoritys[<?php echo $key; ?>]" value="1" <?php if(m_authority($info['authoritys'],$key)) { echo 'checked'; } ?>>
            Aktif
        </label>
    </div>
    <div class="form-check form-check-inline">
        <label class="form-check-label">
            <input type="radio" class="form-check-input" name="authoritys[<?php echo $key; ?>]" value="0" <?php if(!m_authority($info['authoritys'],$key)) { echo 'checked'; } ?>>
            Pasif
        </label>
    </div>
    </div>
</div>
<?php
}
?>

		
		
		<button class="btn btn-primary w-100" type="submit"><i class="fa fa-save"></i> Kaydet</button>
		
		</form>
		
		</div>
</div>