diff --git a/assets/css/custom.css b/assets/css/custom.css
new file mode 100644
index 0000000..8c1de4a
--- /dev/null
+++ b/assets/css/custom.css
@@ -0,0 +1,75 @@
+/* Custom Styles for Stock Management App */
+
+body {
+ font-family: 'Roboto', sans-serif;
+ background-color: #121212;
+ color: #FFFFFF;
+}
+
+.navbar {
+ background-color: #1E1E1E;
+ border-bottom: 1px solid #FFA500;
+}
+
+.navbar-brand {
+ color: #FFA500 !important;
+ font-weight: bold;
+}
+
+.stat-card {
+ background-color: #1E1E1E;
+ border: 1px solid #333;
+ border-radius: .5rem;
+ padding: 1.5rem;
+ margin-bottom: 1rem;
+ color: #FFFFFF;
+}
+
+.stat-card h5 {
+ color: #A0A0A0;
+ font-size: 1rem;
+ text-transform: uppercase;
+}
+
+.stat-card .stat-value {
+ font-size: 2.5rem;
+ font-weight: bold;
+ color: #FFA500;
+}
+
+.btn-primary {
+ background-color: #FFA500;
+ border-color: #FFA500;
+ color: #121212;
+ font-weight: bold;
+}
+
+.btn-primary:hover {
+ background-color: #FFC107;
+ border-color: #FFC107;
+ color: #121212;
+}
+
+.table {
+ background-color: #1E1E1E;
+ color: #FFFFFF;
+}
+
+thead th {
+ border-bottom: 2px solid #FFA500 !important;
+ color: #FFFFFF;
+}
+
+tbody td {
+ border-color: #333 !important;
+}
+
+.table-hover tbody tr:hover {
+ background-color: #2a2a2a;
+ color: #FFA500;
+}
+
+.badge-warning {
+ background-color: #FFA500;
+ color: #121212;
+}
diff --git a/assets/js/main.js b/assets/js/main.js
new file mode 100644
index 0000000..f4a0ea7
--- /dev/null
+++ b/assets/js/main.js
@@ -0,0 +1,5 @@
+// Custom JS for Stock Management App
+
+document.addEventListener('DOMContentLoaded', function () {
+ // Future interactive scripts will go here
+});
diff --git a/db/config.php b/db/config.php
index cc9229f..204ae6d 100644
--- a/db/config.php
+++ b/db/config.php
@@ -6,12 +6,30 @@ define('DB_USER', 'app_30972');
define('DB_PASS', '9eb17a13-4a89-4e11-8517-0c201096e935');
function db() {
- static $pdo;
- if (!$pdo) {
- $pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
- PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
- ]);
- }
- return $pdo;
+ static $pdo;
+ if ($pdo) {
+ return $pdo;
+ }
+
+ try {
+ // Connect to MySQL server without specifying a database
+ $pdo_temp = new PDO('mysql:host='.DB_HOST, DB_USER, DB_PASS, [
+ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
+ PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
+ ]);
+ // Create the database if it doesn't exist
+ $pdo_temp->exec("CREATE DATABASE IF NOT EXISTS `".DB_NAME."`");
+
+ // Now connect to the specific database
+ $pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [
+ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
+ PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
+ ]);
+
+ } catch (PDOException $e) {
+ // If connection fails, it might be a more serious issue
+ die("Database connection failed: " . $e->getMessage());
+ }
+
+ return $pdo;
}
diff --git a/db/migrate.php b/db/migrate.php
new file mode 100644
index 0000000..9decc66
--- /dev/null
+++ b/db/migrate.php
@@ -0,0 +1,22 @@
+exec($sql);
+ }
+
+ echo "All migrations completed successfully!\n";
+} catch (PDOException $e) {
+ die("Migration failed: " . $e->getMessage() . "\n");
+}
+
+
diff --git a/db/migrations/001_initial_schema.sql b/db/migrations/001_initial_schema.sql
new file mode 100644
index 0000000..f35ab7c
--- /dev/null
+++ b/db/migrations/001_initial_schema.sql
@@ -0,0 +1,31 @@
+-- Initial Schema for Stock Management App
+
+CREATE TABLE IF NOT EXISTS `products` (
+ `id` INT AUTO_INCREMENT PRIMARY KEY,
+ `name` VARCHAR(255) NOT NULL,
+ `type` ENUM('jant', 'lastik', 'akü') NOT NULL,
+ `stock_quantity` INT NOT NULL DEFAULT 0,
+ `purchase_price` DECIMAL(10, 2) NOT NULL,
+ `sale_price` DECIMAL(10, 2) NOT NULL,
+ `low_stock_threshold` INT NOT NULL DEFAULT 5,
+ `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+CREATE TABLE IF NOT EXISTS `sales` (
+ `id` INT AUTO_INCREMENT PRIMARY KEY,
+ `total_amount` DECIMAL(10, 2) NOT NULL,
+ `profit_amount` DECIMAL(10, 2) NOT NULL,
+ `payment_method` VARCHAR(50) DEFAULT 'nakit',
+ `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+CREATE TABLE IF NOT EXISTS `sale_items` (
+ `id` INT AUTO_INCREMENT PRIMARY KEY,
+ `sale_id` INT NOT NULL,
+ `product_id` INT NOT NULL,
+ `quantity` INT NOT NULL,
+ `unit_price` DECIMAL(10, 2) NOT NULL,
+ `total_price` DECIMAL(10, 2) NOT NULL,
+ FOREIGN KEY (`sale_id`) REFERENCES `sales`(`id`) ON DELETE CASCADE,
+ FOREIGN KEY (`product_id`) REFERENCES `products`(`id`) ON DELETE RESTRICT
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
diff --git a/db/migrations/002_add_users_table.sql b/db/migrations/002_add_users_table.sql
new file mode 100644
index 0000000..2186dfe
--- /dev/null
+++ b/db/migrations/002_add_users_table.sql
@@ -0,0 +1,6 @@
+CREATE TABLE IF NOT EXISTS `users` (
+ `id` INT AUTO_INCREMENT PRIMARY KEY,
+ `username` VARCHAR(50) NOT NULL UNIQUE,
+ `password` VARCHAR(255) NOT NULL,
+ `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
diff --git a/edit-product.php b/edit-product.php
new file mode 100644
index 0000000..d7b04c1
--- /dev/null
+++ b/edit-product.php
@@ -0,0 +1,108 @@
+prepare("UPDATE products SET name = ?, type = ?, stock_quantity = ?, purchase_price = ?, sale_price = ?, low_stock_threshold = ? WHERE id = ?");
+ $stmt->execute([$name, $type, $stock_quantity, $purchase_price, $sale_price, $low_stock_threshold, $product_id]);
+ $_SESSION['notification'] = "Ürün başarıyla güncellendi.";
+ header('Location: products.php');
+ exit();
+ } catch (PDOException $e) {
+ $_SESSION['error'] = "Veritabanı hatası: " . $e->getMessage();
+ }
+ } else {
+ $_SESSION['error'] = "Lütfen tüm alanları doğru bir şekilde doldurun.";
+ }
+ // Hata durumunda aynı sayfada kal, form tekrar dolsun
+ header("Location: edit-product.php?id=" . $product_id);
+ exit();
+}
+
+// Sayfa ilk yüklendiğinde (GET request)
+try {
+ $stmt = $pdo->prepare("SELECT * FROM products WHERE id = ?");
+ $stmt->execute([$product_id]);
+ $product = $stmt->fetch(PDO::FETCH_ASSOC);
+
+ if (!$product) {
+ $_SESSION['error'] = "Ürün bulunamadı.";
+ header('Location: products.php');
+ exit();
+ }
+} catch (PDOException $e) {
+ $_SESSION['error'] = "Veritabanı hatası: " . $e->getMessage();
+ header('Location: products.php');
+ exit();
+}
+
+require_once 'partials/header.php';
+?>
+
+
Ürünü Düzenle
+
+
+
+
diff --git a/index.php b/index.php
index 7205f3d..4e4fc7d 100644
--- a/index.php
+++ b/index.php
@@ -1,150 +1,199 @@
0,
+ 'total_profit' => 0,
+ 'product_count' => 0,
+ 'low_stock_count' => 0
+];
+
+try {
+ // Toplam Gelir ve Kâr
+ $stmt = $pdo->query("SELECT SUM(total_amount) as total_revenue, SUM(profit_amount) as total_profit FROM sales");
+ $sales_stats = $stmt->fetch(PDO::FETCH_ASSOC);
+ if ($sales_stats) {
+ $stats['total_revenue'] = $sales_stats['total_revenue'] ?? 0;
+ $stats['total_profit'] = $sales_stats['total_profit'] ?? 0;
+ }
+
+ // Toplam Ürün Sayısı
+ $stats['product_count'] = $pdo->query("SELECT count(*) FROM products")->fetchColumn();
+
+ // Düşük Stoktaki Ürün Sayısı
+ $stats['low_stock_count'] = $pdo->query("SELECT count(*) FROM products WHERE stock_quantity <= low_stock_threshold")->fetchColumn();
+
+ // Son Satışlar (Son 5)
+ $recent_sales_stmt = $pdo->query("
+ SELECT p.name AS product_name, si.quantity, si.total_price, s.created_at
+ FROM sale_items si
+ JOIN sales s ON si.sale_id = s.id
+ JOIN products p ON si.product_id = p.id
+ ORDER BY s.created_at DESC
+ LIMIT 5
+ ");
+ $recent_sales = $recent_sales_stmt->fetchAll(PDO::FETCH_ASSOC);
+
+ // Düşük Stoktaki Ürünler
+ $low_stock_products_stmt = $pdo->query("SELECT id, name, stock_quantity, low_stock_threshold FROM products WHERE stock_quantity <= low_stock_threshold ORDER BY stock_quantity ASC");
+ $low_stock_products = $low_stock_products_stmt->fetchAll(PDO::FETCH_ASSOC);
+
+} catch (PDOException $e) {
+ $_SESSION['error'] = "Dashboard verileri çekilirken bir hata oluştu: " . $e->getMessage();
+}
+
+require_once 'partials/header.php';
?>
-
-
-
-
-
- New Style
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Analyzing your requirements and generating your website…
-
- Loading…
-
-
= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.
-
This page will update automatically as the plan is implemented.
-
Runtime: PHP = htmlspecialchars($phpVersion) ?> — UTC = htmlspecialchars($now) ?>
+
+
Ana Panel
+
+
+
+
-
-
- Page updated: = htmlspecialchars($now) ?> (UTC)
-
-
-
+
+
+
+
+
+
+
+
+
+
+
Düşük Stok Uyarısı
+
Ürün
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Ürün
+ Adet
+ Tutar
+ Tarih
+
+
+
+
+ Henüz satış yok.
+
+
+
+
+
+ TL
+
+
+
+
+
+
+
+
Tüm Satışları Gör →
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Ürün
+ Kalan Stok
+
+
+
+
+ Stoğu azalan ürün yok.
+
+
+
+
+
+
+
+
+ /
+
+
+
+
+
+
+
Ürünleri Yönet →
+
+
+
+
+
+
\ No newline at end of file
diff --git a/partials/footer.php b/partials/footer.php
new file mode 100644
index 0000000..a1b4643
--- /dev/null
+++ b/partials/footer.php
@@ -0,0 +1,6 @@
+
+
+
+
+