perosnel işlemleri change
This commit is contained in:
@@ -28,7 +28,7 @@ export async function POST({ request }) {
|
||||
registration_number,
|
||||
tc_kimlik,
|
||||
phone,
|
||||
email,
|
||||
unit_id,
|
||||
username,
|
||||
password,
|
||||
is_active = true
|
||||
@@ -40,14 +40,14 @@ export async function POST({ request }) {
|
||||
registration_number,
|
||||
tc_kimlik,
|
||||
phone,
|
||||
email,
|
||||
unit_id,
|
||||
username,
|
||||
password,
|
||||
is_active
|
||||
});
|
||||
|
||||
return json({
|
||||
message: 'Mal sorumlusu başarıyla eklendi.',
|
||||
message: 'Personel başarıyla eklendi.',
|
||||
goodsManager: newManager
|
||||
});
|
||||
|
||||
@@ -74,7 +74,7 @@ export async function PUT({ request }) {
|
||||
registration_number,
|
||||
tc_kimlik,
|
||||
phone,
|
||||
email,
|
||||
unit_id,
|
||||
username,
|
||||
password,
|
||||
is_active
|
||||
@@ -86,14 +86,14 @@ export async function PUT({ request }) {
|
||||
registration_number,
|
||||
tc_kimlik,
|
||||
phone,
|
||||
email,
|
||||
unit_id,
|
||||
username,
|
||||
password,
|
||||
is_active
|
||||
});
|
||||
|
||||
return json({
|
||||
message: 'Mal sorumlusu başarıyla güncellendi.',
|
||||
message: 'Personel başarıyla güncellendi.',
|
||||
goodsManager: updatedManager
|
||||
});
|
||||
|
||||
|
||||
@@ -532,7 +532,7 @@
|
||||
<path d="M23 21v-2a4 4 0 0 0-3-3.87"/>
|
||||
<path d="M16 3.13a4 4 0 0 1 0 7.75"/>
|
||||
</svg>
|
||||
Mal Sorumluları
|
||||
Personel İşlemleri
|
||||
</button>
|
||||
</li>
|
||||
{:else if user.role === 'fuel_manager'}
|
||||
@@ -703,7 +703,7 @@
|
||||
{#if user.role === 'admin'}
|
||||
<ul class="info-list">
|
||||
<li>Araç, birlik ve personel yönetimi yapabilirsiniz</li>
|
||||
<li>Mal sorumluları ekleyebilir, düzenleyebilirsiniz</li>
|
||||
<li>Personel işlemlerini yönetebilirsiniz</li>
|
||||
<li>Tüm kullanıcıları yönetebilirsiniz</li>
|
||||
<li>Sistem ayarlarını yapılandırabilirsiniz</li>
|
||||
<li>Raporları görüntüleyebilirsiniz</li>
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
let user = null;
|
||||
let goodsManagers = [];
|
||||
let units = [];
|
||||
let loading = true;
|
||||
let error = '';
|
||||
let showAddModal = false;
|
||||
@@ -25,7 +26,7 @@
|
||||
registration_number: '',
|
||||
tc_kimlik: '',
|
||||
phone: '',
|
||||
email: '',
|
||||
unit_id: '',
|
||||
username: '',
|
||||
password: '',
|
||||
is_active: true
|
||||
@@ -40,6 +41,7 @@
|
||||
|
||||
user = JSON.parse(userData);
|
||||
await loadGoodsManagers();
|
||||
await loadUnits();
|
||||
});
|
||||
|
||||
async function loadGoodsManagers() {
|
||||
@@ -49,7 +51,7 @@
|
||||
const data = await response.json();
|
||||
goodsManagers = data.goodsManagers;
|
||||
} else {
|
||||
error = 'Mal sorumluları yüklenemedi.';
|
||||
error = 'Personel bilgileri yüklenemedi.';
|
||||
}
|
||||
} catch (err) {
|
||||
error = 'Bağlantı hatası.';
|
||||
@@ -59,6 +61,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function loadUnits() {
|
||||
try {
|
||||
const response = await fetch('/api/units');
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
units = data.units || [];
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Load units error:', err);
|
||||
}
|
||||
}
|
||||
|
||||
function resetForm() {
|
||||
formData = {
|
||||
full_name: '',
|
||||
@@ -66,7 +80,7 @@
|
||||
registration_number: '',
|
||||
tc_kimlik: '',
|
||||
phone: '',
|
||||
email: '',
|
||||
unit_id: '',
|
||||
username: '',
|
||||
password: '',
|
||||
is_active: true
|
||||
@@ -102,7 +116,7 @@
|
||||
}
|
||||
|
||||
async function handleAddManager() {
|
||||
if (!formData.full_name || !formData.rank || !formData.registration_number || !formData.tc_kimlik || !formData.phone || !formData.email || !formData.username || !formData.password) {
|
||||
if (!formData.full_name || !formData.rank || !formData.registration_number || !formData.tc_kimlik || !formData.phone || !formData.unit_id || !formData.username || !formData.password) {
|
||||
error = 'Tüm alanlar zorunludur.';
|
||||
return;
|
||||
}
|
||||
@@ -112,12 +126,6 @@
|
||||
return;
|
||||
}
|
||||
|
||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
if (!emailRegex.test(formData.email)) {
|
||||
error = 'Geçersiz e-posta formatı.';
|
||||
return;
|
||||
}
|
||||
|
||||
if (!/^[a-zA-Z0-9]{3,20}$/.test(formData.username)) {
|
||||
error = 'Kullanıcı adı 3-20 karakter arası olmalı ve sadece harf ve rakam içermelidir.';
|
||||
return;
|
||||
@@ -144,7 +152,7 @@
|
||||
closeModal();
|
||||
error = '';
|
||||
} else {
|
||||
error = data.message || 'Mal sorumlusu eklenemedi.';
|
||||
error = data.message || 'Personel eklenemedi.';
|
||||
}
|
||||
} catch (err) {
|
||||
error = 'Bağlantı hatası.';
|
||||
@@ -153,7 +161,7 @@
|
||||
}
|
||||
|
||||
async function handleUpdateManager() {
|
||||
if (!formData.full_name || !formData.rank || !formData.registration_number || !formData.tc_kimlik || !formData.phone || !formData.email || !formData.username) {
|
||||
if (!formData.full_name || !formData.rank || !formData.registration_number || !formData.tc_kimlik || !formData.phone || !formData.unit_id || !formData.username) {
|
||||
error = 'Kullanıcı adı hariç tüm alanlar zorunludur.';
|
||||
return;
|
||||
}
|
||||
@@ -163,12 +171,6 @@
|
||||
return;
|
||||
}
|
||||
|
||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
if (!emailRegex.test(formData.email)) {
|
||||
error = 'Geçersiz e-posta formatı.';
|
||||
return;
|
||||
}
|
||||
|
||||
if (!/^[a-zA-Z0-9]{3,20}$/.test(formData.username)) {
|
||||
error = 'Kullanıcı adı 3-20 karakter arası olmalı ve sadece harf ve rakam içermelidir.';
|
||||
return;
|
||||
@@ -198,7 +200,7 @@
|
||||
closeModal();
|
||||
error = '';
|
||||
} else {
|
||||
error = data.message || 'Mal sorumlusu güncellenemedi.';
|
||||
error = data.message || 'Personel güncellenemedi.';
|
||||
}
|
||||
} catch (err) {
|
||||
error = 'Bağlantı hatası.';
|
||||
@@ -207,7 +209,7 @@
|
||||
}
|
||||
|
||||
async function handleDeleteManager(manager) {
|
||||
if (!confirm(`${manager.rank} ${manager.full_name} mal sorumlusunu silmek istediğinizden emin misiniz?`)) {
|
||||
if (!confirm(`${manager.rank} ${manager.full_name} personelini silmek istediğinizden emin misiniz?`)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -226,7 +228,7 @@
|
||||
await loadGoodsManagers();
|
||||
error = '';
|
||||
} else {
|
||||
error = data.message || 'Mal sorumlusu silinemedi.';
|
||||
error = data.message || 'Personel silinemedi.';
|
||||
}
|
||||
} catch (err) {
|
||||
error = 'Bağlantı hatası.';
|
||||
@@ -254,7 +256,7 @@
|
||||
await loadGoodsManagers();
|
||||
error = '';
|
||||
} else {
|
||||
error = data.message || 'Mal sorumlusu durumu güncellenemedi.';
|
||||
error = data.message || 'Personel durumu güncellenemedi.';
|
||||
}
|
||||
} catch (err) {
|
||||
error = 'Bağlantı hatası.';
|
||||
@@ -277,14 +279,14 @@
|
||||
</svg>
|
||||
Geri
|
||||
</button>
|
||||
<h1 class="page-title">Mal Sorumluları</h1>
|
||||
<h1 class="page-title">Personel İşlemleri</h1>
|
||||
</div>
|
||||
<button class="btn btn-primary" on:click={openAddModal}>
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<line x1="12" y1="5" x2="12" y2="19"/>
|
||||
<line x1="5" y1="12" x2="19" y2="12"/>
|
||||
</svg>
|
||||
Yeni Mal Sorumlusu Ekle
|
||||
Yeni Personel Ekle
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -309,11 +311,8 @@
|
||||
<path d="M16 3.13a4 4 0 0 1 0 7.75"/>
|
||||
</svg>
|
||||
</div>
|
||||
<h3>Henüz Mal Sorumlusu Yok</h3>
|
||||
<p>Sisteme mal sorumlusu eklemek için "Yeni Mal Sorumlusu Ekle" butonuna tıklayın.</p>
|
||||
<button class="btn btn-primary" on:click={openAddModal}>
|
||||
İlk Mal Sorumlusunu Ekle
|
||||
</button>
|
||||
<h3>Henüz Personel Yok</h3>
|
||||
<p>Sisteme personel eklemek için "Yeni Personel Ekle" butonuna tıklayın.</p>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="managers-grid">
|
||||
@@ -340,8 +339,8 @@
|
||||
<span class="detail-value">{manager.tc_kimlik}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<span class="detail-label">📧 E-posta:</span>
|
||||
<span class="detail-value">{manager.email}</span>
|
||||
<span class="detail-label">🏢 Birlik:</span>
|
||||
<span class="detail-value">{manager.unit_name || 'Belirtilmemiş'}</span>
|
||||
</div>
|
||||
<div class="detail-item">
|
||||
<span class="detail-label">📱 İrtibat:</span>
|
||||
@@ -399,7 +398,7 @@
|
||||
<div class="modal-overlay" on:click={closeModal}>
|
||||
<div class="modal" on:click|stopPropagation>
|
||||
<div class="modal-header">
|
||||
<h2>Yeni Mal Sorumlusu Ekle</h2>
|
||||
<h2>Yeni Personel Ekle</h2>
|
||||
<button class="modal-close" on:click={closeModal}>×</button>
|
||||
</div>
|
||||
<form on:submit|preventDefault={handleAddManager} class="modal-form">
|
||||
@@ -460,15 +459,18 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">E-posta</label>
|
||||
<input
|
||||
id="email"
|
||||
type="email"
|
||||
<label for="unit_id">Birlik</label>
|
||||
<select
|
||||
id="unit_id"
|
||||
class="form-input"
|
||||
bind:value={formData.email}
|
||||
placeholder="ali.veli@mil.tr"
|
||||
bind:value={formData.unit_id}
|
||||
required
|
||||
/>
|
||||
>
|
||||
<option value="">Birlik Seçiniz</option>
|
||||
{#each units as unit}
|
||||
<option value={unit.id}>{unit.name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="username">Kullanıcı Adı</label>
|
||||
@@ -504,12 +506,12 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Mal Sorumlusu Düzenle Modal -->
|
||||
<!-- Personel Düzenle Modal -->
|
||||
{#if showEditModal}
|
||||
<div class="modal-overlay" on:click={closeModal}>
|
||||
<div class="modal" on:click|stopPropagation>
|
||||
<div class="modal-header">
|
||||
<h2>Mal Sorumlusu Düzenle</h2>
|
||||
<h2>Personel Düzenle</h2>
|
||||
<button class="modal-close" on:click={closeModal}>×</button>
|
||||
</div>
|
||||
<form on:submit|preventDefault={handleUpdateManager} class="modal-form">
|
||||
@@ -570,15 +572,18 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="edit-email">E-posta</label>
|
||||
<input
|
||||
id="edit-email"
|
||||
type="email"
|
||||
<label for="edit-unit_id">Birlik</label>
|
||||
<select
|
||||
id="edit-unit_id"
|
||||
class="form-input"
|
||||
bind:value={formData.email}
|
||||
placeholder="ali.veli@mil.tr"
|
||||
bind:value={formData.unit_id}
|
||||
required
|
||||
/>
|
||||
>
|
||||
<option value="">Birlik Seçiniz</option>
|
||||
{#each units as unit}
|
||||
<option value={unit.id}>{unit.name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="edit-username">Kullanıcı Adı</label>
|
||||
|
||||
Reference in New Issue
Block a user