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KO}ӽmSşذqsOy?\[,d@'73'j%kOe`1.g2"e =YIzS2|zŐƄa\U,dP;jhhhaxǶ?КZ՚.q SE+XrbOu%\GتX(H,N^~]JyEZQKceTQ]VGYqnah;y$cQahT&QPZ*iZ8UQQM.qo/T\7X"u?Mttl2Xq(IoW{R^ ux*SYJ! 4S.Jy~ BROS[V|žKNɛP(L6V^|cR7i7nZW1Fd@ Ara{詑|(T*dN]Ko?s=@ |_EvF]׍kR)eBJc" MUUbY6`~V޴dJKß&~'d3i WWWWWW
Current Directory: /home/u588966950/domains/vtsinfotech.online/public_html/swanayurbed/test
Viewing File: /home/u588966950/domains/vtsinfotech.online/public_html/swanayurbed/test/setup_db(v2).php
<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); include 'includes/db.php'; $forceSeed = isset($_GET['force_seed']) && $_GET['force_seed'] === '1'; echo "<head><title>GDR - Database Setup</title><style>body { font-family: Arial, sans-serif; margin: 20px; } .success { color: #28a745; } .error { color: #dc3545; } .info { color: #0066cc; margin-top: 20px; } .step { margin: 8px 0; }</style></head>"; echo "<h2>GDR Contractor Management System - Database Setup</h2>"; echo "<p class='info'>This script is idempotent. You can safely run it multiple times.</p>"; if ($forceSeed) { echo "<p class='info'><b>Force Seed Mode:</b> Existing table data will be cleared and replaced with fresh dummy data.</p>"; } // Read the SQL schema file $sqlFile = 'init.sql'; if (!file_exists($sqlFile)) { die("<p class='error'><b>Error:</b> init.sql file not found.</p>"); } function columnExists($pdo, $table, $column) { $stmt = $pdo->prepare("SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ? AND COLUMN_NAME = ?"); $stmt->execute([$table, $column]); return (int)$stmt->fetchColumn() > 0; } function getForeignKeyName($pdo, $table, $column) { $stmt = $pdo->prepare("SELECT CONSTRAINT_NAME FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ? AND COLUMN_NAME = ? AND REFERENCED_TABLE_NAME IS NOT NULL LIMIT 1"); $stmt->execute([$table, $column]); $name = $stmt->fetchColumn(); return $name ? $name : null; } function hasProjectForeignKey($pdo, $table) { $stmt = $pdo->prepare("SELECT COUNT(*) FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ? AND COLUMN_NAME = 'project_id' AND REFERENCED_TABLE_NAME = 'test_gdr_projects'"); $stmt->execute([$table]); return (int)$stmt->fetchColumn() > 0; } function tableIsEmpty($pdo, $table) { $stmt = $pdo->query("SELECT COUNT(*) FROM " . $table); return ((int)$stmt->fetchColumn()) === 0; } function indexExists($pdo, $table, $indexName) { $stmt = $pdo->prepare("SELECT COUNT(*) FROM information_schema.STATISTICS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ? AND INDEX_NAME = ?"); $stmt->execute([$table, $indexName]); return (int)$stmt->fetchColumn() > 0; } try { if ($forceSeed) { echo "<p class='step'><b>Pre-Step:</b> Clearing existing data for reseed</p>"; $pdo->exec("SET FOREIGN_KEY_CHECKS = 0"); $tables = [ 'test_gdr_rars', 'test_gdr_ca_item_details', 'test_gdr_ca_items', 'test_gdr_bbs_items', 'test_gdr_bbs', 'test_gdr_escalation_items', 'test_gdr_escalations', 'test_gdr_material_items', 'test_gdr_materials', 'test_gdr_em_emb_items', 'test_gdr_em_emb', 'test_gdr_emb_items', 'test_gdr_emb', 'test_gdr_abstract_items', 'test_gdr_abstracts', 'test_gdr_yard_sticks', 'test_gdr_projects', 'test_gdr_users' ]; foreach ($tables as $table) { $pdo->exec("TRUNCATE TABLE " . $table); } $pdo->exec("SET FOREIGN_KEY_CHECKS = 1"); echo "<p class='success step'>✓ Existing data cleared</p>"; } echo "<p class='step'><b>Step 1:</b> Loading base schema from init.sql</p>"; $sql = file_get_contents($sqlFile); // Execute the schema $pdo->exec($sql); echo "<p class='success step'>✓ Base schema applied</p>"; echo "<p class='step'><b>Step 2:</b> Ensuring CA Items tables exist</p>"; $pdo->exec("CREATE TABLE IF NOT EXISTS test_gdr_ca_items ( id INT AUTO_INCREMENT PRIMARY KEY, project_id INT NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (project_id) REFERENCES test_gdr_projects(id) ON DELETE CASCADE )"); $pdo->exec("CREATE TABLE IF NOT EXISTS test_gdr_ca_item_details ( id INT AUTO_INCREMENT PRIMARY KEY, ca_item_id INT NOT NULL, sr_no VARCHAR(50), description TEXT, no_val DECIMAL(10, 2) DEFAULT 0.00, l_in_m DECIMAL(10, 2) DEFAULT 0.00, b_in_m DECIMAL(10, 2) DEFAULT 0.00, h_in_m DECIMAL(10, 2) DEFAULT 0.00, qty DECIMAL(15, 4) DEFAULT 0.00, total_qty DECIMAL(15, 4) DEFAULT 0.00, measured_qty DECIMAL(15, 4) DEFAULT 0.00, unit VARCHAR(50), created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (ca_item_id) REFERENCES test_gdr_ca_items(id) ON DELETE CASCADE )"); echo "<p class='success step'>✓ CA Items tables are ready</p>"; echo "<p class='step'><b>Step 2.1:</b> Ensuring Work Done Summary tables exist</p>"; $pdo->exec("CREATE TABLE IF NOT EXISTS test_gdr_work_done_summary ( id INT AUTO_INCREMENT PRIMARY KEY, project_id INT NOT NULL, summary_date DATE NOT NULL, work_amount_total DECIMAL(18, 2) DEFAULT 0.00, br_total DECIMAL(18, 2) DEFAULT 0.00, em_total DECIMAL(18, 2) DEFAULT 0.00, grand_total DECIMAL(18, 2) DEFAULT 0.00, created_by INT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (project_id) REFERENCES test_gdr_projects(id) ON DELETE CASCADE )"); $pdo->exec("CREATE TABLE IF NOT EXISTS test_gdr_work_done_summary_items ( id INT AUTO_INCREMENT PRIMARY KEY, summary_id INT NOT NULL, subproject_id INT NULL, subproject_name VARCHAR(255) NOT NULL, rate_as_per_ca DECIMAL(18, 2) DEFAULT 0.00, rate_quoted_by_contractor DECIMAL(18, 2) DEFAULT 0.00, progress_percent DECIMAL(8, 2) DEFAULT 0.00, amount DECIMAL(18, 2) DEFAULT 0.00, remarks VARCHAR(255) NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (summary_id) REFERENCES test_gdr_work_done_summary(id) ON DELETE CASCADE )"); echo "<p class='success step'>✓ Work Done Summary tables are ready</p>"; echo "<p class='step'><b>Step 3:</b> Ensuring RAR payload column exists</p>"; if (!columnExists($pdo, 'test_gdr_rars', 'rar_payload')) { $pdo->exec("ALTER TABLE test_gdr_rars ADD COLUMN rar_payload LONGTEXT NULL AFTER total_rar_amt"); echo "<p class='success step'>✓ Added column test_gdr_rars.rar_payload</p>"; } else { echo "<p class='success step'>✓ Column test_gdr_rars.rar_payload already exists</p>"; } echo "<p class='step'><b>Step 3.0:</b> Ensuring quotation + stage based RAR columns exist</p>"; if (!columnExists($pdo, 'test_gdr_projects', 'total_quotation')) { $pdo->exec("ALTER TABLE test_gdr_projects ADD COLUMN total_quotation DECIMAL(15, 2) DEFAULT 0.00 AFTER contractor"); echo "<p class='success step'>✓ Added column test_gdr_projects.total_quotation</p>"; } if (!columnExists($pdo, 'test_gdr_rars', 'yard_stick_id')) { $pdo->exec("ALTER TABLE test_gdr_rars ADD COLUMN yard_stick_id INT NULL AFTER project_id"); echo "<p class='success step'>✓ Added column test_gdr_rars.yard_stick_id</p>"; } if (!columnExists($pdo, 'test_gdr_rars', 'percentage_type')) { $pdo->exec("ALTER TABLE test_gdr_rars ADD COLUMN percentage_type VARCHAR(20) NULL AFTER yard_stick_id"); echo "<p class='success step'>✓ Added column test_gdr_rars.percentage_type</p>"; } if (!columnExists($pdo, 'test_gdr_rars', 'calculated_percentage')) { $pdo->exec("ALTER TABLE test_gdr_rars ADD COLUMN calculated_percentage DECIMAL(8, 4) DEFAULT 0.0000 AFTER percentage_type"); echo "<p class='success step'>✓ Added column test_gdr_rars.calculated_percentage</p>"; } if (!columnExists($pdo, 'test_gdr_rars', 'calculated_amount')) { $pdo->exec("ALTER TABLE test_gdr_rars ADD COLUMN calculated_amount DECIMAL(15, 2) DEFAULT 0.00 AFTER calculated_percentage"); echo "<p class='success step'>✓ Added column test_gdr_rars.calculated_amount</p>"; } if (columnExists($pdo, 'test_gdr_rars', 'yard_stick_id') && !getForeignKeyName($pdo, 'test_gdr_rars', 'yard_stick_id')) { $pdo->exec("ALTER TABLE test_gdr_rars ADD CONSTRAINT fk_rars_yard_stick_id FOREIGN KEY (yard_stick_id) REFERENCES test_gdr_yard_sticks(id) ON DELETE CASCADE"); echo "<p class='success step'>✓ Added FK test_gdr_rars.yard_stick_id</p>"; } if (!indexExists($pdo, 'test_gdr_rars', 'uniq_rars_stage_type')) { $pdo->exec("CREATE UNIQUE INDEX uniq_rars_stage_type ON test_gdr_rars (project_id, yard_stick_id, percentage_type)"); echo "<p class='success step'>✓ Added unique index uniq_rars_stage_type</p>"; } echo "<p class='step'><b>Step 3.1:</b> Ensuring Yard Stick stage amount column exists</p>"; if (!columnExists($pdo, 'test_gdr_yard_sticks', 'stage_amount')) { $pdo->exec("ALTER TABLE test_gdr_yard_sticks ADD COLUMN stage_amount DECIMAL(18, 4) DEFAULT 0.0000 AFTER stage_name"); echo "<p class='success step'>✓ Added column test_gdr_yard_sticks.stage_amount</p>"; } else { $pdo->exec("ALTER TABLE test_gdr_yard_sticks MODIFY COLUMN stage_amount DECIMAL(18, 4) DEFAULT 0.0000"); echo "<p class='success step'>✓ Column test_gdr_yard_sticks.stage_amount already exists</p>"; } echo "<p class='step'><b>Step 3.2:</b> Ensuring BBS and Civil EMB are project-linked</p>"; if (!columnExists($pdo, 'test_gdr_emb', 'project_id')) { $pdo->exec("ALTER TABLE test_gdr_emb ADD COLUMN project_id INT NULL AFTER id"); echo "<p class='success step'>✓ Added column test_gdr_emb.project_id</p>"; } if (columnExists($pdo, 'test_gdr_emb', 'yard_stick_id')) { $pdo->exec("UPDATE test_gdr_emb e JOIN test_gdr_yard_sticks ys ON ys.id = e.yard_stick_id SET e.project_id = ys.project_id WHERE e.project_id IS NULL OR e.project_id = 0"); $embFk = getForeignKeyName($pdo, 'test_gdr_emb', 'yard_stick_id'); if ($embFk) { $pdo->exec("ALTER TABLE test_gdr_emb DROP FOREIGN KEY `" . $embFk . "`"); } $pdo->exec("ALTER TABLE test_gdr_emb DROP COLUMN yard_stick_id"); echo "<p class='success step'>✓ Civil EMB migrated to project_id</p>"; } if (!hasProjectForeignKey($pdo, 'test_gdr_emb')) { $pdo->exec("ALTER TABLE test_gdr_emb ADD CONSTRAINT fk_emb_project_id FOREIGN KEY (project_id) REFERENCES test_gdr_projects(id) ON DELETE CASCADE"); } $pdo->exec("ALTER TABLE test_gdr_emb MODIFY COLUMN project_id INT NOT NULL"); if (!columnExists($pdo, 'test_gdr_bbs', 'project_id')) { $pdo->exec("ALTER TABLE test_gdr_bbs ADD COLUMN project_id INT NULL AFTER id"); echo "<p class='success step'>✓ Added column test_gdr_bbs.project_id</p>"; } if (columnExists($pdo, 'test_gdr_bbs', 'yard_stick_id')) { $pdo->exec("UPDATE test_gdr_bbs b JOIN test_gdr_yard_sticks ys ON ys.id = b.yard_stick_id SET b.project_id = ys.project_id WHERE b.project_id IS NULL OR b.project_id = 0"); $bbsFk = getForeignKeyName($pdo, 'test_gdr_bbs', 'yard_stick_id'); if ($bbsFk) { $pdo->exec("ALTER TABLE test_gdr_bbs DROP FOREIGN KEY `" . $bbsFk . "`"); } $pdo->exec("ALTER TABLE test_gdr_bbs DROP COLUMN yard_stick_id"); echo "<p class='success step'>✓ BBS migrated to project_id</p>"; } if (!hasProjectForeignKey($pdo, 'test_gdr_bbs')) { $pdo->exec("ALTER TABLE test_gdr_bbs ADD CONSTRAINT fk_bbs_project_id FOREIGN KEY (project_id) REFERENCES test_gdr_projects(id) ON DELETE CASCADE"); } $pdo->exec("ALTER TABLE test_gdr_bbs MODIFY COLUMN project_id INT NOT NULL"); // CA Items migration to project_id if (columnExists($pdo, 'test_gdr_ca_items', 'yard_stick_id')) { if (!columnExists($pdo, 'test_gdr_ca_items', 'project_id')) { $pdo->exec("ALTER TABLE test_gdr_ca_items ADD COLUMN project_id INT NULL AFTER id"); echo "<p class='success step'>✓ Added column test_gdr_ca_items.project_id</p>"; } $pdo->exec("UPDATE test_gdr_ca_items ca JOIN test_gdr_yard_sticks ys ON ys.id = ca.yard_stick_id SET ca.project_id = ys.project_id WHERE ca.project_id IS NULL OR ca.project_id = 0"); $caFk = getForeignKeyName($pdo, 'test_gdr_ca_items', 'yard_stick_id'); if ($caFk) { $pdo->exec("ALTER TABLE test_gdr_ca_items DROP FOREIGN KEY `" . $caFk . "`"); } $pdo->exec("ALTER TABLE test_gdr_ca_items DROP COLUMN yard_stick_id"); echo "<p class='success step'>✓ CA Items migrated to project_id</p>"; } if (!hasProjectForeignKey($pdo, 'test_gdr_ca_items')) { $pdo->exec("ALTER TABLE test_gdr_ca_items ADD CONSTRAINT fk_ca_items_project_id FOREIGN KEY (project_id) REFERENCES test_gdr_projects(id) ON DELETE CASCADE"); } $pdo->exec("ALTER TABLE test_gdr_ca_items MODIFY COLUMN project_id INT NOT NULL"); echo "<p class='step'><b>Step 4:</b> Seeding dummy data in all tables (only if empty)</p>"; $pdo->beginTransaction(); // Users if (tableIsEmpty($pdo, 'test_gdr_users')) { $stmt = $pdo->prepare("INSERT INTO test_gdr_users (username, password, role) VALUES (?, ?, ?)"); $stmt->execute(['admin', 'admin123', 'government']); $stmt->execute(['contractor1', 'contractor123', 'contractor']); } // Projects (from user-provided production screenshot) if (tableIsEmpty($pdo, 'test_gdr_projects')) { $stmt = $pdo->prepare("INSERT INTO test_gdr_projects (ca_number, project_name, description, contractor) VALUES (?, ?, ?, ?)"); $stmt->execute([ '008', 'PROVN OF STORAGE ACCN (PH-II) AT PANAGARH MIL. STN', 'IGLOO FOR 36 M X 18 M X 8 M (L X B X H)', 'M/S UNITED ROAD CONSTRUCTION PVT. LTD.' ]); $stmt->execute([ 'CEKZ/PAN/15 OF 2022-23', 'PROVN OF STORAGE ACCOMODATION PANAGARH (PH-II) AT PANAGARH', "IGLOO FOR 36M X 18M X 8M (L X B X H) (SL NO. 1 OF SCH 'A' PART-I (BUILDING WORKS))", 'M/S UNITED ROAD CONSTRUCTION PVT. LTD.' ]); $stmt->execute([ 'CEKZ/PAN/15 OF 2022-23-IGLOO', 'IGLOO FOR 36M X 18M X 8M (L X B X H)', 'IGLOO FOR 36M X 18M X 8M (L X B X H)', 'M/S UNITED ROAD CONSTRUCTION PVT. LTD.' ]); } // Fetch first project for linked inserts $projectId = (int)$pdo->query("SELECT id FROM test_gdr_projects WHERE ca_number = '008' LIMIT 1")->fetchColumn(); // Yard sticks (from user-provided production screenshot) if ($projectId > 0 && tableIsEmpty($pdo, 'test_gdr_yard_sticks')) { $projectAId = (int)$pdo->query("SELECT id FROM test_gdr_projects WHERE project_name = 'PROVN OF STORAGE ACCN (PH-II) AT PANAGARH MIL. STN' LIMIT 1")->fetchColumn(); $projectBId = (int)$pdo->query("SELECT id FROM test_gdr_projects WHERE project_name = 'PROVN OF STORAGE ACCOMODATION PANAGARH (PH-II) AT PANAGARH' LIMIT 1")->fetchColumn(); $projectCId = (int)$pdo->query("SELECT id FROM test_gdr_projects WHERE project_name = 'IGLOO FOR 36M X 18M X 8M (L X B X H)' LIMIT 1")->fetchColumn(); $stmt = $pdo->prepare("INSERT INTO test_gdr_yard_sticks (project_id, stage_name, stage_amount, perc_calculated, perc_recommended, description, status, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); $projectAStages = [ ['Stage - 1 Upto Excavation', 1786565.831, 1.15, 2.00, 'Surface Dressing & Excavation'], ['Stage -2 750mm Dia Pile', 16787647.4267, 12.91, 0.00, 'Boring, RCC M-30, including reinforcement of 750mm Dia. Pile'], ['Stage - 3 450mm Dia Pile', 1139331138.942, 6.83, 0.00, 'Boring, RCC M-30, including reinforcement of 450mm Dia. Pile'], ['Stage -4 Raft Foundation', 45859877.93, 29.44, 0.00, 'PCC(1:2:4) in footings, RCC M-30 in 2575 mm, 900 mm and 450 mm Thk raft foundation'], ['Stage -5 Upto FFL', 17404443.30, 11.27, 0.00, 'RCC M-25 in RCC Wall, column, Roof Beam, retaining wall, slab including reinforcement, Form work upto Roof Slab Level complete.'], ['Stage - 6 : FFL To Roof Slab Level', 37414192.54, 24.63, 0.00, 'RCC M-25 in RCC Wall, column, Roof Beam, retaining wall, slab including reinforcement, Form work upto Roof Slab Level complete.'], ['Stage -7 : Earth Traverse', 14079999.89, 9.65, 0.00, 'Earth Traverse Filling Complete'], ['Stage - 8 : Steel work', 1532090.38, 1.32, 0.00, 'Base Plate, Bolt, I-Section, C-Section Etc., Door'], ['Stage - 9 : Plaster work', 865679.63, 0.56, 0.00, 'Plaster to internal surface of walls in CM(1:6), ceiling in CM(1:6) and external surfaces of walls in CM(1:6) etc.'], ['Stage - 10 : Surface finishes', 3904126.19, 1.09, 0.00, 'Fire Resistance Painting work for internal, ceiling newly plastered surfaces'], ['Stage - 11 : Flooring', 1238396.20, 0.79, 0.00, 'PVC Flooring, Sub base to floors, 25mm Thk. PCC, 75mm Thk. PCC for ramp complete'], ['Stage - 12 : Roof Treatment', 450707.90, 0.29, 0.00, 'Roof Treatment Complete'], ['Stage - 13 : Misc Items', 101397.06, 0.07, 0.00, 'Site clearance, Misc Items etc complete'] ]; $projectBStages = [ ['Stage 1 : Upto Excavation', 1650848.55, 1.10, 1.30, 'Surface Dressing & Excavation'], ['Stage 2: 750 mm Dia Pile', 13574695.28, 10.00, 10.00, 'Boring, RCC M-30, including reinforcement of 750mm Dia. Pile'], ['Stage 3: 450mm Dia Pile', 6250060.49, 4.75, 4.75, 'Boring, RCC M-30, including reinforcement of 450mm Dia. Pile'], ['Stage 4: Raft Foundation', 39000768.25, 26.50, 30.50, 'PCC(1:2:4) in footing, RCC m-30 in 2575 mm, 900mm and 450mm Thk raft foundation and reinforcement'], ['Stage 5: Upto FFL', 12306780.57, 6.50, 9.00, 'RCC M-25 including reinforcement, Form work complete Upto FFL.'], ['Stage 6: FFL To Roof Slab Level', 29501548.79, 1.10, 23.00, 'RCC M-25, including reinforcement, formwork, complete from FFL to Roof slab level'], ['Stage 7: Earth Traverse', 14583406.71, 0.00, 11.00, 'Earth Traverse filling complete'], ['Stage :8 steel work', 3185732.70, 0.00, 3.00, 'Base Plate, BOLT, Section-I, Section-C, Etc., Door'], ['Stage: 9 Plaster work', 773542.18, 0.00, 2.00, 'Plater to internal surface of walls, Ceiling Plaster, External Plaster complete'], ['Stage: 10 Surface Finishes', 1569494.58, 0.00, 2.00, 'Fire resisting Painting work for internal, ceiling newly plastered surfaces'], ['Stage: 11 Flooring', 1145295.16, 0.00, 1.50, 'PVC flooring, Sub base floors, 25mm Thk. PCC, 75mm Thk. PCC for ramp complete'], ['Stage: 12 Roof treatment', 379806.06, 0.00, 0.50, 'Roof treatment complete'], ['Stag: 13 Misc items', 65845.68, 0.00, 1.45, 'Site clearance, Misc items etc complete'] ]; $projectCStages = [ ['stage 40', 0.00, 10.00, 100.00, 'dhruv'] ]; if ($projectAId > 0) { foreach ($projectAStages as $st) { $stmt->execute([$projectAId, $st[0], $st[1], $st[2], $st[3], $st[4], 'Approved', '2023-01-31 00:00:00']); } } if ($projectBId > 0) { foreach ($projectBStages as $st) { $stmt->execute([$projectBId, $st[0], $st[1], $st[2], $st[3], $st[4], 'Approved', '2024-05-21 00:00:00']); } } if ($projectCId > 0) { foreach ($projectCStages as $st) { $stmt->execute([$projectCId, $st[0], $st[1], $st[2], $st[3], $st[4], 'Approved', '2026-02-12 00:00:00']); } } } // Initialize quotation from stage totals only when quotation is missing. $pdo->exec("UPDATE test_gdr_projects p LEFT JOIN ( SELECT project_id, SUM(COALESCE(stage_amount, 0)) AS total_stage_amount FROM test_gdr_yard_sticks GROUP BY project_id ) ys ON ys.project_id = p.id SET p.total_quotation = COALESCE(ys.total_stage_amount, p.total_quotation) WHERE p.total_quotation IS NULL OR p.total_quotation = 0"); $yardStickId = (int)$pdo->query("SELECT id FROM test_gdr_yard_sticks ORDER BY id ASC LIMIT 1")->fetchColumn(); // Abstracts + items if ($yardStickId > 0 && tableIsEmpty($pdo, 'test_gdr_abstracts')) { $stmt = $pdo->prepare("INSERT INTO test_gdr_abstracts (yard_stick_id, cost_upto_pl, cost_above_pl, total_cost, plinth_area, plinth_area_rate) VALUES (?, ?, ?, ?, ?, ?)"); $stmt->execute([$yardStickId, 1200000, 800000, 2000000, 250, 8000]); $abstractId = (int)$pdo->lastInsertId(); $stmtItem = $pdo->prepare("INSERT INTO test_gdr_abstract_items (abstract_id, sr_no, description, au, qty, measured_qty, rate, ssr_amount, measured_amount, mes_ssr_year) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); $stmtItem->execute([$abstractId, '1.0', 'Excavation for footing upto 1.50 mt depth', 'Cu M', 1343.34, 1200.00, 258.50, 347253.39, 310200.00, '3004']); $stmtItem->execute([$abstractId, '1.1', 'Excavation for wall footing', 'Cu M', 1056.76, 950.00, 417.20, 440880.27, 396340.00, '3004']); } // Civil EMB seeds (project-level) if ($projectId > 0 && tableIsEmpty($pdo, 'test_gdr_emb')) { $stmt = $pdo->prepare("INSERT INTO test_gdr_emb (project_id, cost_of_block, plinth_area, plinth_area_rate, plinth_area_calc) VALUES (?, ?, ?, ?, ?)"); $stmt->execute([$projectId, 0, 0, 0, 0]); $embId = (int)$pdo->lastInsertId(); if (tableIsEmpty($pdo, 'test_gdr_emb_items')) { $insertItem = $pdo->prepare("INSERT INTO test_gdr_emb_items (emb_id, sr_no, description, no_val, l_in_m, b_in_m, h_in_m, qty, total_qty, measured_qty, unit, is_sub_item) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); $insertItem->execute([$embId, '1', 'Excavation For Footing upto 1.50 mt Depth', 0, 0, 0, 0, 1343.34, 1343.34, 2000, 'Cu M', 0]); $insertItem->execute([$embId, '', '2275 thk Raft Foundation', 1.0, 22.25, 40.25, 1.50, 1343.34, 0, 0, '', 1]); $insertItem->execute([$embId, '2', 'Excavation For Footing from 1.50 mt to 3.0 mt Depth', 0, 0, 0, 0, 1056.76, 1056.76, 0, 'Cu M', 0]); $insertItem->execute([$embId, '', '2275 thk Raft Foundation', 1.0, 22.25, 40.25, 1.18, 1056.76, 0, 0, '', 1]); } } // E&M EMB + items if ($projectId > 0 && tableIsEmpty($pdo, 'test_gdr_em_emb')) { $stmt = $pdo->prepare("INSERT INTO test_gdr_em_emb (project_id, station) VALUES (?, ?)"); $stmt->execute([$projectId, 'Panagarh Station']); $emEmbId = (int)$pdo->lastInsertId(); $stmtItem = $pdo->prepare("INSERT INTO test_gdr_em_emb_items (em_emb_id, sr_no, des_of_work, auth, drg_no, brief_spec, au, qty, rate, amount_ssr, amount_mr, remarks) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); $stmtItem->execute([$emEmbId, '1', 'External Electrification', 'Auth-A', 'DRG-01', 'Cable laying and accessories', 'RM', 952, 259, 246568, 0, '']); $stmtItem->execute([$emEmbId, '2', 'Supply and fixing fixtures', 'Auth-B', 'DRG-02', 'Electrical fixtures', 'Nos', 50, 1200, 60000, 0, '']); } // Materials + items if ($projectId > 0 && tableIsEmpty($pdo, 'test_gdr_materials')) { $stmt = $pdo->prepare("INSERT INTO test_gdr_materials (project_id, material_date, total_amount) VALUES (?, ?, ?)"); $stmt->execute([$projectId, date('Y-m-d'), 2650000]); $materialId = (int)$pdo->lastInsertId(); $stmtItem = $pdo->prepare("INSERT INTO test_gdr_material_items (material_id, sr_no, description, unit, rate, total) VALUES (?, ?, ?, ?, ?, ?)"); $stmtItem->execute([$materialId, '1', 'Steel', 'MT', 65000, 1300000]); $stmtItem->execute([$materialId, '2', 'Cement', 'Bag', 380, 1350000]); } // Escalations + items if ($projectId > 0 && tableIsEmpty($pdo, 'test_gdr_escalations')) { $stmt = $pdo->prepare("INSERT INTO test_gdr_escalations (project_id, voucher_no, escalation_date, total_amount) VALUES (?, ?, ?, ?)"); $stmt->execute([$projectId, 'SDO/V/001', date('Y-m-d'), 180000]); $escId = (int)$pdo->lastInsertId(); $stmtItem = $pdo->prepare("INSERT INTO test_gdr_escalation_items (escalation_id, sr_no, qtr, amt_material, amt_fuel, amt_labour, total_amt) VALUES (?, ?, ?, ?, ?, ?, ?)"); $stmtItem->execute([$escId, '1', 'Q1', 180000, 0, 0, 180000]); } // BBS seeds (project-level) if ($projectId > 0 && tableIsEmpty($pdo, 'test_gdr_bbs')) { $insertBbs = $pdo->prepare("INSERT INTO test_gdr_bbs (project_id) VALUES (?)"); $insertBbs->execute([$projectId]); $bbsId = (int)$pdo->lastInsertId(); $insertBbsItem = $pdo->prepare("INSERT INTO test_gdr_bbs_items (bbs_id, sr_no, description, shape, a_mm, b_mm, c_mm, no_of_lap, d_lap_length_mm, dia_mm, no_of_unit, no_of_bar, length_m, qty_8, qty_10, qty_12, qty_16, qty_20, qty_25, qty_32, qty_40) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); $insertBbsItem->execute([$bbsId, '1', 'Main Steel Reinforcement', 'L', 400, 150, 0, 2, 300, 10, 12, 8, 3200, 0, 120, 0, 0, 0, 0, 0, 0]); $insertBbsItem->execute([$bbsId, '2', 'Distribution Bars', 'Straight', 200, 0, 0, 0, 0, 8, 6, 15, 1800, 80, 0, 0, 0, 0, 0, 0, 0]); } // CA Items + details if ($projectId > 0 && tableIsEmpty($pdo, 'test_gdr_ca_items')) { $stmt = $pdo->prepare("INSERT INTO test_gdr_ca_items (project_id) VALUES (?)"); $stmt->execute([$projectId]); $caItemId = (int)$pdo->lastInsertId(); $stmtItem = $pdo->prepare("INSERT INTO test_gdr_ca_item_details (ca_item_id, sr_no, description, no_val, l_in_m, b_in_m, h_in_m, qty, total_qty, measured_qty, unit) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); $stmtItem->execute([$caItemId, '1', 'Earthwork in excavation', 2, 2, 2, 2, 16, 20, 20, 'Cu M']); } // RAR (depends on material/escalation) if ($projectId > 0 && tableIsEmpty($pdo, 'test_gdr_rars')) { $materialNo = (string)$pdo->query("SELECT id FROM test_gdr_materials ORDER BY id ASC LIMIT 1")->fetchColumn(); $escNo = (string)$pdo->query("SELECT id FROM test_gdr_escalations ORDER BY id ASC LIMIT 1")->fetchColumn(); $rarPayload = json_encode([ 'sdo_voucher_no' => '01/1101/AGE B/R (P)-1 Dated ' . date('d M Y'), 'name_of_work' => 'Storage accommodation work package', 'project_name' => 'Seeded project', 'job_no' => 'E-2013', 'ch_to' => '01/902/33', 'tin' => 'TIN-001', 'contractor_name' => 'ABC Infra Pvt Ltd', 'gross_value' => 2651100, 'total_reserve_minus' => 397600, 'gross_due' => 2253490, 'net_payable' => 2253490 ]); if (columnExists($pdo, 'test_gdr_rars', 'rar_payload')) { $stmt = $pdo->prepare("INSERT INTO test_gdr_rars (project_id, escalation_no, material_no, total_rar_amt, rar_payload) VALUES (?, ?, ?, ?, ?)"); $stmt->execute([$projectId, $escNo, $materialNo, 2253490, $rarPayload]); } else { $stmt = $pdo->prepare("INSERT INTO test_gdr_rars (project_id, escalation_no, material_no, total_rar_amt) VALUES (?, ?, ?, ?)"); $stmt->execute([$projectId, $escNo, $materialNo, 2253490]); } } $pdo->commit(); echo "<p class='success step'>✓ Dummy data seeding completed (where tables were empty)</p>"; echo "<p class='success'><b>✓ Success!</b></p>"; echo "<p class='success'>All required database objects are initialized successfully with prefix <code>test_gdr_*</code></p>"; echo "<p class='info'><b>Note:</b> Database setup and dummy data seeding are complete.</p>"; echo "<p class='info'>If you want to refresh all sample data, run: <code>setup_db.php?force_seed=1</code></p>"; echo "<p class='info'><b>Default Login:</b> <code>admin / admin123</code> or <code>contractor1 / contractor123</code></p>"; echo "<p><a href='login.php'><b style='font-size:16px;'>→ Go to Login Page</b></a></p>"; } catch (PDOException $e) { echo "<p class='error'><b>✗ Error:</b> Database setup failed</p>"; echo "<p class='error'><b>Details:</b> " . htmlspecialchars($e->getMessage()) . "</p>"; echo "<p class='error'>Please ensure all tables have been cleared in phpMyAdmin before running this script.</p>"; } ?>