Dashboard

Genel bakış, istatistikler ve son aktiviteler.

Bildirimler

Admin User

Toplam Satış

₺180,694.00

+12.5% geçen aya göre

Toplam Gider

₺73,160.00

-5.3% geçen aya göre

Aktif Üretimler

0

Devam ediyor

Bekleyen Ödemeler

₺78,190.00

3 sipariş

Satış Performansı

Son Aktiviteler

Tümünü Gör

Yeni Üretim Emri #ÜR-202508-953

asdfasd

19 Aug 2025, 12:46

₺20,620.00

Yeni Satış Siparişi #asdfasdfa

Büyük Market Zinciri A.?.

15 Jul 2025, 22:00

₺1,438.56

Yeni Üretim Emri #ÜR-202507-156

Ömer Üretim

15 Jul 2025, 21:26

₺120,905.00

Yeni Satın Alma #Sip002

Ambalaj Plastik Ltd. ?ti.

15 Jul 2025, 21:22

₺134.46

Yeni Üretim Emri #ÜR-202507-311

Sıvı Dolum

15 Jul 2025, 08:41

₺14,213.20

Devam Eden Üretim Emirleri

Tümünü Gör
Emir No Ürün Miktar Kalan Gün Durum
#ÜE-2025-001 Sinek ?lac? 30ml Üretimi 1,000 -275 gün Planlandı
#ÜE-2025-002 Sinek ?lac? 100ml Üretimi 800 -274 gün Planlandı
#ÜE-2025-003 Sinek ?lac? 250ml Üretimi 500 -273 gün Planlandı
#ÜE-2025-004 Sinek ?lac? 500ml Üretimi 300 -272 gün Planlandı
#ÜE-2025-005 Sinek ?lac? 1L Üretimi 200 -271 gün Planlandı

Kritik Stok Durumu

0 Uyarı

Sinek İlaç Sıvısı (Ham)

2600/1000
Normal

Pizza Kutusu

505/150
Normal

Sinek ilaç 5 Litre

200/50
Normal

Koli Etiketleri

4800/1000
Normal

PET Bidon 5L (Ham)

1000/200
Normal

PET şişe 1L (Ham)

3000/600
Normal

PET şişe 500ml (Ham)

4000/800
Normal

Plastik Çatal

40000/8000
Normal

PET Şişe 30ml (Ham)

10000/2000
Normal

DIŞ Kaplama Etiketleri

15000/3000
Normal

Kategori Bazlı Satışlar

En İyi Müşteriler

User

Sohbet

Çevrimiçi

.render(); // Global Arama Fonksiyonu let searchTimeout; const $searchInput = $('#globalSearch'); const $searchResults = $('#searchResults'); $searchInput.on('input', function() { const query = $(this).val().trim(); clearTimeout(searchTimeout); if (query.length < 2) { $searchResults.html(`

Arama yapmak için en az 2 karakter girin

`).addClass('hidden'); return; } $searchResults.html(`

Aranıyor...

`).removeClass('hidden'); searchTimeout = setTimeout(() => { $.ajax({ url: 'search_api.php', method: 'GET', data: { q: query }, dataType: 'json', success: function(response) { if (response.success && response.results.length > 0) { let html = ''; response.results.forEach(item => { const typeColors = { 'product': 'bg-blue-100 text-blue-800', 'production': 'bg-purple-100 text-purple-800', 'customer': 'bg-green-100 text-green-800', 'supplier': 'bg-orange-100 text-orange-800', 'invoice': 'bg-yellow-100 text-yellow-800' }; const typeLabels = { 'product': 'Ürün', 'production': 'Üretim', 'customer': 'Müşteri', 'supplier': 'Tedarikçi', 'invoice': 'Fatura' }; html += `
${item.image ? `${item.title}` : `
` }

${item.title}

${typeLabels[item.type] || item.type}

${item.subtitle}

${item.meta ? `

${item.meta}

` : ''}
`; }); if (response.count > 6) { html += `

Ve ${response.count - 6} sonuç daha...

`; } $searchResults.html(html); } else { $searchResults.html(`

Sonuç bulunamadı

"${query}" için arama sonucu yok

`); } }, error: function() { $searchResults.html(`

Arama sırasında bir hata oluştu

`); } }); }, 300); }); // Arama kutusuna focus olunduğunda sonuçları göster $searchInput.on('focus', function() { if ($(this).val().length >= 2) { $searchResults.removeClass('hidden'); } }); // Sayfa herhangi bir yerine tıklandığında arama sonuçlarını gizle $(document).on('click', function(e) { if (!$(e.target).closest('#globalSearch, #searchResults').length) { $searchResults.addClass('hidden'); } }); // ESC tuşu ile arama sonuçlarını kapat $(document).on('keydown', function(e) { if (e.key === 'Escape') { $searchResults.addClass('hidden'); $searchInput.blur(); } }); // Chat ve Notification Fonksiyonları let currentChatUser = null; let chatUpdateInterval = null; let notificationUpdateInterval = null; // Chat Toggle window.toggleChat = function() { const $container = $('#chatContainer'); const $floatingBtn = $('#chatFloatingButton'); if ($container.is(':visible')) { $container.fadeOut(300); $floatingBtn.fadeIn(300); clearInterval(chatUpdateInterval); } else { $container.fadeIn(300); $floatingBtn.fadeOut(300); loadChatConversations(); chatUpdateInterval = setInterval(updateCurrentChat, 3000); } }; // Chat List Toggle window.toggleChatList = function() { const $chatList = $('#chatList'); const $chatMessages = $('#chatMessages'); if ($chatList.is(':visible')) { $chatList.hide(); $chatMessages.show(); } else { $chatList.show(); $chatMessages.hide(); loadOnlineUsers(); } }; // Load Chat Conversations function loadChatConversations() { $.ajax({ url: 'chat_api.php?action=get_conversations', method: 'GET', success: function(response) { if (response.success) { let unreadTotal = 0; response.conversations.forEach(conv => { unreadTotal += conv.unread_count; }); updateChatBadge(unreadTotal); if (response.conversations.length > 0 && !currentChatUser) { openChat(response.conversations[0].user_id); } } } }); } // Load Online Users function loadOnlineUsers() { $.ajax({ url: 'chat_api.php?action=get_online_users', method: 'GET', success: function(response) { if (response.success) { let html = ''; response.users.forEach(user => { html += `
${user.name} ${user.is_online ? '
' : ''}

${user.name} ${user.surname}

${user.is_online ? 'Çevrimiçi' : 'Çevrimdışı'}

`; }); $('#chatUserList').html(html); } } }); } // Open Chat with User window.openChat = function(userId) { currentChatUser = userId; // UI güncelle $('.chat-list-item').removeClass('active'); $(`.chat-list-item[data-user-id="${userId}"]`).addClass('active'); // Chat list'i kapat $('#chatList').hide(); $('#chatMessages').show(); // Mesajları yükle loadChatMessages(userId); // Kullanıcı bilgilerini güncelle $.ajax({ url: 'chat_api.php?action=get_online_users', method: 'GET', success: function(response) { if (response.success) { const user = response.users.find(u => u.id == userId); if (user) { $('#chatUserName').text(user.name + ' ' + user.surname); $('#chatUserAvatar').attr('src', user.avatar_url || 'https://i.pravatar.cc/150?u=' + user.id); $('#chatUserStatusText').text(user.is_online ? 'Çevrimiçi' : 'Çevrimdışı'); $('#chatUserStatus').toggle(user.is_online); } } } }); }; // Load Chat Messages function loadChatMessages(userId) { $.ajax({ url: 'chat_api.php?action=get_messages&user_id=' + userId, method: 'GET', success: function(response) { if (response.success) { let html = ''; response.messages.forEach(msg => { const isSent = msg.sender_id == 1; // Current user ID html += `
${msg.message}
${formatTime(msg.created_at)}
`; }); $('#chatMessages').html(html); // Scroll to bottom $('#chatMessages').scrollTop($('#chatMessages')[0].scrollHeight); } } }); } // Send Message window.sendMessage = function() { const message = $('#chatInput').val().trim(); if (!message || !currentChatUser) return; $.ajax({ url: 'chat_api.php?action=send_message', method: 'POST', contentType: 'application/json', data: JSON.stringify({ receiver_id: currentChatUser, message: message }), success: function(response) { if (response.success) { $('#chatInput').val(''); loadChatMessages(currentChatUser); } } }); }; // Enter key to send message $('#chatInput').on('keypress', function(e) { if (e.which == 13) { sendMessage(); } }); // Update current chat function updateCurrentChat() { if (currentChatUser) { loadChatMessages(currentChatUser); } } // Update chat badge function updateChatBadge(count) { const $badges = $('#chatBadge, #chatFloatingBadge'); if (count > 0) { $badges.text(count).show(); } else { $badges.hide(); } } // Notification Functions $('#notificationToggle').on('click', function(e) { e.stopPropagation(); const $dropdown = $('#notificationDropdown'); if ($dropdown.is(':visible')) { $dropdown.fadeOut(200); } else { $dropdown.fadeIn(200); loadNotifications(); } }); // Load Notifications function loadNotifications() { $.ajax({ url: 'notification_api.php?action=get_notifications', method: 'GET', success: function(response) { if (response.success) { updateNotificationBadge(response.unread_count); let html = ''; if (response.notifications.length > 0) { response.notifications.forEach(notif => { const iconColors = { 'info': 'bg-blue-100 text-blue-600', 'success': 'bg-green-100 text-green-600', 'warning': 'bg-yellow-100 text-yellow-600', 'error': 'bg-red-100 text-red-600', 'chat': 'bg-purple-100 text-purple-600', 'production': 'bg-indigo-100 text-indigo-600', 'order': 'bg-blue-100 text-blue-600', 'payment': 'bg-green-100 text-green-600', 'stock': 'bg-red-100 text-red-600' }; html += `

${notif.title}

${notif.message}

${notif.time_ago}

`; }); } else { html = `

Bildiriminiz bulunmuyor

`; } $('#notificationList').html(html); } } }); } // Handle notification click window.handleNotificationClick = function(id, link) { $.ajax({ url: 'notification_api.php?action=mark_read&id=' + id, method: 'GET', success: function() { if (link && link !== '#') { window.location.href = link; } } }); }; // Mark all notifications as read window.markAllNotificationsRead = function() { $.ajax({ url: 'notification_api.php?action=mark_read&id=all', method: 'GET', success: function() { loadNotifications(); } }); }; // Update notification badge function updateNotificationBadge(count) { const $badge = $('#notificationBadge'); if (count > 0) { $badge.text(count).show(); } else { $badge.hide(); } } // Format time function formatTime(datetime) { const date = new Date(datetime); const now = new Date(); const diffMs = now - date; const diffMins = Math.floor(diffMs / 60000); if (diffMins < 1) return 'Az önce'; if (diffMins < 60) return diffMins + ' dakika önce'; if (diffMins < 1440) return Math.floor(diffMins / 60) + ' saat önce'; return date.toLocaleDateString('tr-TR'); } // Click outside to close dropdowns $(document).on('click', function(e) { if (!$(e.target).closest('#notificationToggle, #notificationDropdown').length) { $('#notificationDropdown').fadeOut(200); } }); // Update online status periodically setInterval(function() { $.ajax({ url: 'chat_api.php?action=update_online_status', method: 'GET' }); }, 60000); // Her dakika // Initial load loadNotifications(); loadChatConversations(); // Periodic updates notificationUpdateInterval = setInterval(function() { loadNotifications(); loadChatConversations(); }, 30000); // Her 30 saniye // Animasyonlar için intersection observer const observerOptions = { threshold: 0.1, rootMargin: '0px 0px -100px 0px' }; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.style.opacity = '1'; entry.target.style.transform = 'translateY(0)'; } }); }, observerOptions); document.querySelectorAll('.animate-fadeIn').forEach(el => { el.style.opacity = '0'; el.style.transform = 'translateY(20px)'; el.style.transition = 'all 0.6s ease-out'; observer.observe(el); }); }); .render(); // Global Arama Fonksiyonu let searchTimeout; const $searchInput = $('#globalSearch'); const $searchResults = $('#searchResults'); $searchInput.on('input', function() { const query = $(this).val().trim(); clearTimeout(searchTimeout); if (query.length < 2) { $searchResults.html(`

Arama yapmak için en az 2 karakter girin

`).addClass('hidden'); return; } $searchResults.html(`

Aranıyor...

`).removeClass('hidden'); searchTimeout = setTimeout(() => { $.ajax({ url: 'search_api.php', method: 'GET', data: { q: query }, dataType: 'json', success: function(response) { if (response.success && response.results.length > 0) { let html = ''; response.results.forEach(item => { const typeColors = { 'product': 'bg-blue-100 text-blue-800', 'production': 'bg-purple-100 text-purple-800', 'customer': 'bg-green-100 text-green-800', 'supplier': 'bg-orange-100 text-orange-800', 'invoice': 'bg-yellow-100 text-yellow-800' }; const typeLabels = { 'product': 'Ürün', 'production': 'Üretim', 'customer': 'Müşteri', 'supplier': 'Tedarikçi', 'invoice': 'Fatura' }; html += `
${item.image ? `${item.title}` : `
` }

${item.title}

${typeLabels[item.type] || item.type}

${item.subtitle}

${item.meta ? `

${item.meta}

` : ''}
`; }); if (response.count > 6) { html += `

Ve ${response.count - 6} sonuç daha...

`; } $searchResults.html(html); } else { $searchResults.html(`

Sonuç bulunamadı

"${query}" için arama sonucu yok

`); } }, error: function() { $searchResults.html(`

Arama sırasında bir hata oluştu

`); } }); }, 300); // 300ms debounce }); // Arama kutusuna focus olunduğunda sonuçları göster $searchInput.on('focus', function() { if ($(this).val().length >= 2) { $searchResults.removeClass('hidden'); } }); // Sayfa herhangi bir yerine tıklandığında arama sonuçlarını gizle $(document).on('click', function(e) { if (!$(e.target).closest('#globalSearch, #searchResults').length) { $searchResults.addClass('hidden'); } }); // ESC tuşu ile arama sonuçlarını kapat $(document).on('keydown', function(e) { if (e.key === 'Escape') { $searchResults.addClass('hidden'); $searchInput.blur(); } }); // Animasyonlar için intersection observer const observerOptions = { threshold: 0.1, rootMargin: '0px 0px -100px 0px' }; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.style.opacity = '1'; entry.target.style.transform = 'translateY(0)'; } }); }, observerOptions); document.querySelectorAll('.animate-fadeIn').forEach(el => { el.style.opacity = '0'; el.style.transform = 'translateY(20px)'; el.style.transition = 'all 0.6s ease-out'; observer.observe(el); }); });