-- FCQC - Seed Dummy Data for Advanced CAPA System
-- Run AFTER migration_capa_advanced.sql and seed_qc_inspection.sql


-- ========================================================================
-- 1. CAPA MASTER RECORDS (extended inspection_capa)
-- ========================================================================
INSERT IGNORE INTO `inspection_capa` (`id`, `session_id`, `defect_id`, `capa_number`, `title`, `department`, `severity`, `source`, `root_cause`, `root_cause_category`, `corrective_action`, `preventive_action`, `containment_action`, `containment_responsible`, `containment_deadline`, `containment_completed_at`, `assigned_to`, `deadline`, `status`, `verification_method`, `verification_result`, `re_inspection_session_id`, `effectiveness_rating`, `effectiveness_review_date`, `closure_notes`, `lessons_learned`, `company_id`, `created_by`, `created_at`, `updated_at`) VALUES
(1, 1, 107, 'CAPA-2026-0001', 'Fabric shade variation exceeds acceptable range in PO-2026-001', 'Fabric Store', 'critical', 'inspection',
 'Incoming fabric rolls from supplier had inconsistent dye lots causing visible shade bands across the width.',
 'material',
 'Segregate affected rolls. Return 12 non-compliant rolls to supplier. Issue credit note.',
 'Implement 100% fabric inspection prior to spreading. Update supplier quality agreement with stricter shade tolerance clauses. Install spectrophotometer for digital shade assessment.',
 'Stop all spreading from affected batch. Quarantine 45 rolls. Inform production planning for re-cutting.',
 'Ahmed Hassan', '2026-06-20', '2026-06-19',
 2, '2026-06-30', 'closed', 'Re-inspection', 'All 12 returned rolls verified. Remaining 33 rolls tested with spectrophotometer — within tolerance. Production resumed.',
 NULL, 'effective', '2026-07-10',
 'CAPA closed successfully. Supplier accepted return and issued credit. Spectrophotometer ordered for receiving inspection.',
 'Always verify dye lot numbers before accepting fabric deliveries. Digital shade assessment eliminates human error in pass/fail decisions.',
 1, 1, '2026-06-18 09:30:00', '2026-07-10 14:00:00'),

(2, 1, 108, 'CAPA-2026-0002', 'Open seam defects on Style ST-102 exceeding DHU limit', 'Sewing', 'major', 'inspection',
 'Operators on Line 3 were running machines at excessive speed (4800 RPM vs standard 3800 RPM) causing skipped stitches and open seams. Needle size mismatch for fabric weight.',
 'process',
 'Rework 127 garments with open seams. Reset all machines on Line 3 to standard speed. Replace needles with correct size (DBx1 #14 for denim).',
 'Implement daily machine speed audit. Add needle size chart at each workstation. Mandatory pre-shift machine setup verification by line supervisor. Update SOP for style-specific machine settings.',
 'Stop Line 3 production. Segregate all output from last 2 hours. 100% inspection of 340 pieces.',
 'Fatima Begum', '2026-06-22', '2026-06-21',
 3, '2026-07-05', 'closed', 'Process Audit', 'Speed audit implemented. All 10 machines on Line 3 verified at correct settings. Operator retraining completed. Follow-up DHU check shows 1.2% (down from 8.3%).',
 NULL, 'effective', '2026-07-15',
 'All corrective and preventive actions completed. No recurrence of open seam defects on Line 3 for 10 consecutive production days.',
 'Machine speed control is critical for stitch quality. Needle size must be verified at every style changeover.',
 1, 1, '2026-06-20 11:00:00', '2026-07-15 16:30:00'),

(3, NULL, 150, 'CAPA-2026-0003', 'Customer complaint: Wrong labels attached to 500 pcs of Style ST-105', 'Finishing', 'critical', 'complaint',
 'Label packer on shift B used incorrect care labels (from previous style ST-102) due to poor label segregation at the trimming station. No verification step between label attachment and carton packing.',
 'process',
 'Contact customer, arrange for courier collection of 500 mislabeled pieces. Re-label all pieces with correct labels. Provide 15% discount on next order as goodwill.',
 'Implement two-person verification at label attachment station. Install barcode scanner to verify label vs style before attachment. Segregate label bundles per style in color-coded bins. Add label check step to end-of-line QA checklist.',
 'Quarantine all finished goods of style ST-105. 100% inspection of 1,200 cartons. Separate correctly labeled vs incorrectly labeled.',
 'Rafiq Uddin', '2026-06-25', '2026-06-24',
 4, '2026-07-10', 'closed', 'Physical Verification', 'All 1,200 cartons inspected. 500 pieces re-labeled. Customer accepted return arrangement. Barcode system ordered.',
 NULL, 'effective', '2026-07-20',
 'Customer complaint resolved. Discount provided. Barcode verification system installed and operational. No further label complaints in 3 weeks.',
 'Label verification needs a physical check step — barcode scanning prevents human error. Color-coded bins eliminate mix-ups during style changes.',
 1, 2, '2026-06-22 08:45:00', '2026-07-20 11:00:00'),

(4, NULL, 141, 'CAPA-2026-0004', 'Broken needle found in finished garment during final inspection', 'Sewing', 'critical', 'needle_breakage',
 'Needle broke during sewing of heavy seam intersection (style ST-108, pocket attachment). Operator did not notice breakage and continued sewing. Needle fragment embedded in garment seam.',
 'machine',
 '100% metal detection of all pieces from this style (2,400 pcs). Isolate and quarantine any additional finds. Document incident for insurance.',
 'Implement mandatory needle count procedure at shift start/end for all operators. Install needle detector machines at end of each sewing line. Replace all needles after 8 hours of use (needle replacement policy). Update training on needle breakage protocol.',
 'Stop all sewing for style ST-108. Initiate full metal detection sweep of Line 5 output for last 4 hours. Inform quality manager and production head immediately.',
 'Kamal Hossain', '2026-06-23', '2026-06-23',
 2, '2026-07-01', 'in_progress', NULL, NULL,
 NULL, NULL, NULL,
 'Immediate containment completed. Needle found and removed. Needle detector machines ordered — installation expected next week.',
 'Broken needle incidents require zero tolerance. Needle count policy and detector machines are essential for safety compliance.',
 1, 1, '2026-06-22 14:30:00', '2026-06-28 09:00:00'),

(5, NULL, NULL, 'CAPA-2026-0005', 'Supplier delivery delay causing production line stoppage', 'Production', 'major', 'supplier',
 'Supplier XYZ Trims failed to deliver zippers for style ST-112 on agreed date. No safety stock maintained. Alternative supplier not qualified.',
 'method',
 'Expedite delivery from XYZ with air freight at supplier cost. Source 5,000 zippers from local market as interim measure.',
 'Maintain 2 weeks safety stock for all critical trims. Qualify alternative supplier (ABC Trims) as backup. Implement weekly supplier delivery tracker with automatic escalation at 3 days before deadline.',
 'Stop trimming station for style ST-112. Reallocate operators to alternate styles. Place urgent order with XYZ and local market.',
 'Shamim Reza', '2026-06-26', '2026-06-25',
 NULL, '2026-07-15', 'open', NULL, NULL,
 NULL, NULL, NULL,
 NULL,
 NULL,
 1, 2, '2026-06-24 10:00:00', '2026-06-24 10:00:00'),

(6, 2, 102, 'CAPA-2026-0006', 'AQL rejection on End-Line inspection - Major defects exceed acceptance limit', 'QA', 'major', 'inspection',
 'Lot size 3,200 pcs, sample size 200 pcs. Found 21 major defects (Accept = 14, Reject = 21). Root cause traced to untrained operators on 2 new sewing machines added for capacity increase.',
 'training',
 '100% inspection of entire lot. Rework all defective garments. Segregate and quarantine.',
 'Implement mandatory operator training program before assigning to new machines. Extend training period from 2 days to 5 days. Add skill certification test before allowing independent work.',
 'Hold entire lot for inspection. Do not ship until rework completed and verified.',
 'Quality Manager', '2026-06-28', '2026-06-27',
 3, '2026-07-20', 'open', NULL, NULL,
 NULL, NULL, NULL,
 NULL,
 NULL,
 1, 1, '2026-06-26 16:00:00', '2026-06-26 16:00:00'),

(7, NULL, 113, 'CAPA-2026-0007', 'Print misregistration on 800 pcs - Style ST-115', 'Printing', 'major', 'inspection',
 'Screen tension on Frame #3 dropped below specification. Operator did not check tension before starting production run. First 800 pieces had 3mm misregistration on left chest print.',
 'machine',
 'Strip and reprint all 800 pieces. Replace screen on Frame #3. Retension all screens (daily check).',
 'Implement screen tension check as mandatory pre-production step. Add tension gauge at each screen printing station. Create screen tension log sheet with sign-off.',
 'Stop all printing on Frame #3. Quarantine all pieces from current run. Inspect all printed stock from last 4 hours.',
 'Shahidul Islam', '2026-06-29', '2026-06-28',
 5, '2026-07-12', 'in_progress', NULL, NULL,
 NULL, NULL, NULL,
 NULL, NULL,
 1, 1, '2026-06-27 09:15:00', '2026-06-28 11:00:00'),

(8, NULL, NULL, 'CAPA-2026-0008', 'Safety incident: Chemical splash during garment washing', 'Washing', 'critical', 'safety_incident',
 'Operator was not wearing proper PPE while handling caustic soda. Splash guard on dosing pump was damaged. No emergency shower accessible within 10 meters of chemical station.',
 'environment',
 'Immediate first aid for affected operator. Repair splash guard. Install emergency shower at chemical station. Provide full PPE kit to all washing operators.',
 'Monthly PPE compliance audit. Install chemical handling SOP poster at each station. Conduct quarterly safety training for all washing department staff. Implement chemical handling permit system.',
 'Stop all chemical handling operations until safety review completed. Restricted access to chemical storage area.',
 'Safety Officer', '2026-06-28', '2026-06-29',
 4, '2026-07-15', 'in_progress', NULL, NULL,
 NULL, NULL, NULL,
 NULL, NULL,
 1, 2, '2026-06-27 11:30:00', '2026-06-29 08:00:00'),

(9, NULL, 148, 'CAPA-2026-0009', 'Incorrect quantity packed in cartons - Customer claims shortage', 'Packing', 'critical', 'return',
 'Packing operators were not counting pieces before carton sealing. Verified quantity per carton should be 12 pcs but found cartons with 10, 11, and 13 pcs. No barcode scan verification at carton level.',
 'method',
 'Open and recount all 400 cartons from this order. Adjust packing documents. Send corrected packing list to customer.',
 'Implement barcode scanning at carton sealing station. Each carton must scan all 12 pieces before sealing. Add random weight check every 10th carton.',
 'Stop further shipments of this style. Recount all packed cartons in warehouse.',
 'Nurul Islam', '2026-06-30', '2026-06-29',
 NULL, '2026-07-20', 'open', NULL, NULL,
 NULL, NULL, NULL,
 NULL, NULL,
 1, 1, '2026-06-28 15:00:00', '2026-06-28 15:00:00'),

(10, NULL, 107, 'CAPA-2026-0010', 'Fabric pilling after 3 washes - Buyer complaint on Style ST-120', 'Fabric Store', 'minor', 'complaint',
 'Fabric supplier changed fiber composition without informing. Polyester content was 45% instead of specified 50%, causing reduced abrasion resistance.',
 'material',
 'Provide test reports to buyer showing current fabric composition. Offer discounted price for affected lot. Source replacement fabric from alternative supplier.',
 'Update supplier approval process to require composition testing certificate with every batch. Implement random fiber composition testing on incoming fabric (1 per 10 rolls). Blacklist supplier for 6 months.',
 'Quarantine all remaining fabric rolls of this lot. Separate finished goods for buyer review.',
 'Fabric Manager', '2026-07-05', '2026-07-03',
 NULL, '2026-08-15', 'open', NULL, NULL,
 NULL, NULL, NULL,
 NULL, NULL,
 1, 2, '2026-07-01 09:00:00', '2026-07-03 12:00:00');

-- ========================================================================
-- 2. CAPA ROOT CAUSES (multiple RCA analyses per CAPA)
-- ========================================================================
INSERT IGNORE INTO `capa_root_causes` (`id`, `capa_id`, `method`, `root_cause`, `category`, `why_1`, `why_2`, `why_3`, `why_4`, `why_5`, `ai_confidence`) VALUES
(1, 1, '5whys', 'No incoming fabric shade inspection process', 'method',
 'Shade variation found during spreading',
 'Receiving inspection only checks width and length, not shade',
 'No spectrophotometer available at receiving',
 'Equipment not budgeted for current fiscal year',
 'Management unaware of severity of past shade issues',
 78.50),
(2, 2, '5whys', 'No standard machine speed settings for different fabric types', 'method',
 'Open seams appearing on heavy fabric',
 'Operator increased machine speed to meet target',
 'No speed limit set for different fabric weights',
 'Machine settings not documented in SOP',
 'No process ownership for machine parameter standardization',
 82.30),
(3, 2, 'fishbone', 'Multiple factors contributing to open seam defects', 'method', NULL, NULL, NULL, NULL, NULL, 65.00),
(4, 3, '5whys', 'No label verification step between attachment and packing', 'process',
 'Wrong labels attached to garments',
 'Label packer grabbed wrong bundle',
 'Labels from previous style not cleared from station',
 'No standard procedure for style changeover label clearance',
 'Label verification not included in end-of-line checklist',
 91.20),
(5, 4, '5whys', 'No mandatory needle count procedure', 'machine',
 'Needle broke and operator did not notice',
 'Operator could not detect breakage during sewing',
 'No needle count check at start/end of shift',
 'Needle control policy not established',
 'Management focus on production speed over safety',
 95.00),
(6, 6, '5whys', 'Inadequate operator training period for new machines', 'training',
 'New operators on new machines producing high defect rate',
 'Operators assigned to machines after only 2 days training',
 'Training period reduced to meet production deadlines',
 'Production pressure overriding quality requirements',
 'No formal training curriculum for new machine operators',
 87.60);

-- ========================================================================
-- 3. CAPA ACTIONS (corrective and preventive action items)
-- ========================================================================
INSERT IGNORE INTO `capa_actions` (`id`, `capa_id`, `action_type`, `description`, `department`, `owner`, `start_date`, `deadline`, `priority`, `status`, `completion_date`, `notes`) VALUES
(1, 1, 'corrective', 'Segregate and grade all affected fabric rolls by shade band', 'Fabric Store', 'Store Keeper', '2026-06-19', '2026-06-21', 'high', 'completed', '2026-06-20', '12 rolls graded as reject, 33 rolls graded as acceptable with shade grouping'),
(2, 1, 'corrective', 'Return 12 non-compliant rolls to supplier with debit note', 'Purchase', 'Purchase Manager', '2026-06-21', '2026-06-28', 'high', 'completed', '2026-06-26', 'Supplier accepted return and issued credit note CR-2026-089'),
(3, 1, 'preventive', 'Implement spectrophotometer-based incoming fabric shade inspection', 'Fabric Store', 'QA Manager', '2026-07-01', '2026-08-15', 'high', 'in_progress', NULL, 'Spectrophotometer ordered (PO-2026-045). Expected delivery second week of August.'),
(4, 1, 'preventive', 'Update supplier quality agreement with stricter shade tolerance clause', 'Purchase', 'Purchase Manager', '2026-06-28', '2026-07-10', 'medium', 'completed', '2026-07-08', 'New shade tolerance clause added to all fabric supplier agreements'),
(5, 2, 'corrective', 'Rework all 127 garments with open seams', 'Sewing', 'Line Supervisor', '2026-06-21', '2026-06-23', 'high', 'completed', '2026-06-22', 'All 127 pieces reworked and inspected. Zero defects on re-inspection.'),
(6, 2, 'corrective', 'Reset and calibrate all machines on Line 3 to standard speed', 'Maintenance', 'Maintenance Tech', '2026-06-21', '2026-06-21', 'high', 'completed', '2026-06-21', 'All 10 machines calibrated. Speed governors installed.'),
(7, 2, 'preventive', 'Implement daily machine speed audit checklist', 'Sewing', 'Quality Inspector', '2026-06-22', NULL, 'medium', 'completed', '2026-06-22', 'Daily audit form created and posted at Line 3. Audits started.'),
(8, 2, 'preventive', 'Create machine parameter reference chart per style', 'Industrial Eng', 'IE Manager', '2026-06-22', '2026-07-01', 'high', 'completed', '2026-06-29', 'Reference charts created for top 20 styles. Laminated and posted at each workstation.'),
(9, 3, 'corrective', 'Contact customer and arrange return of 500 mislabeled pieces', 'Sales', 'Sales Manager', '2026-06-23', '2026-06-25', 'high', 'completed', '2026-06-24', 'Customer agreed to return via courier. Discount of 15% offered and accepted.'),
(10, 3, 'corrective', 'Re-label all 500 pieces with correct care labels', 'Finishing', 'Finishing Supervisor', '2026-06-25', '2026-06-28', 'high', 'completed', '2026-06-27', 'All 500 pieces re-labeled and packed. 100% verified.'),
(11, 3, 'preventive', 'Install barcode verification system at label attachment station', 'IT', 'IT Manager', '2026-07-01', '2026-07-15', 'high', 'completed', '2026-07-12', 'Barcode scanners installed. Integration with label printer completed.'),
(12, 3, 'preventive', 'Implement two-person verification at label attachment', 'Finishing', 'QA Manager', '2026-06-28', '2026-07-05', 'medium', 'completed', '2026-07-03', 'Standard procedure updated. Staff trained on new process.'),
(13, 4, 'corrective', '100% metal detection of all 2,400 pieces from affected lot', 'QA', 'QA Inspector', '2026-06-23', '2026-06-24', 'high', 'completed', '2026-06-24', 'All pieces scanned. No additional needles found.'),
(14, 4, 'preventive', 'Implement needle count policy at shift start and end', 'Sewing', 'Production Manager', '2026-06-24', '2026-06-28', 'high', 'completed', '2026-06-27', 'Needle count register created. Policy implemented across all sewing lines.'),
(15, 4, 'preventive', 'Install needle detector machines on all sewing lines', 'Maintenance', 'Engineering Head', '2026-07-01', '2026-08-01', 'high', 'in_progress', NULL, '3 machines ordered. Installation of first machine scheduled for next week.'),
(16, 6, 'corrective', '100% inspection of entire lot (3,200 pcs)', 'QA', 'QA Team Lead', '2026-06-27', '2026-07-02', 'high', 'completed', '2026-07-01', 'Lot fully inspected. 87 pieces reworked. Lot released.'),
(17, 6, 'preventive', 'Develop operator training curriculum for new machines', 'HR', 'Training Manager', '2026-07-01', '2026-07-15', 'high', 'completed', '2026-07-14', '5-day training program developed. Includes theory, practical, and certification test.'),
(18, 8, 'corrective', 'Repair chemical splash guard on dosing pump', 'Maintenance', 'Maintenance Team', '2026-06-28', '2026-06-29', 'high', 'completed', '2026-06-29', 'Splash guard repaired and reinforced.'),
(19, 8, 'corrective', 'Install emergency shower near chemical station', 'Engineering', 'Engineering Head', '2026-06-28', '2026-07-05', 'high', 'completed', '2026-07-04', 'Emergency shower installed and tested. Meets safety distance requirement.'),
(20, 8, 'preventive', 'Conduct monthly PPE compliance audit', 'Safety', 'Safety Officer', '2026-07-01', NULL, 'medium', 'in_progress', NULL, 'First audit scheduled for July 15.');

-- ========================================================================
-- 4. CAPA TASKS
-- ========================================================================
INSERT IGNORE INTO `capa_tasks` (`id`, `capa_id`, `title`, `description`, `assigned_to`, `department`, `start_date`, `deadline`, `priority`, `status`, `completion_date`, `notes`) VALUES
(1, 1, 'Grade fabric rolls by shade', 'Visually grade all 45 fabric rolls into shade groups A, B, C', 5, 'Fabric Store', '2026-06-19', '2026-06-20', 'high', 'completed', '2026-06-19', 'Completed. 12 rolls in group C (reject).'),
(2, 1, 'Prepare debit note for supplier', 'Create debit note for 12 rejected fabric rolls', 6, 'Purchase', '2026-06-21', '2026-06-22', 'high', 'completed', '2026-06-21', 'Debit note DN-2026-034 sent to supplier.'),
(3, 1, 'Order spectrophotometer', 'Research and place purchase order for spectrophotometer', 7, 'QA', '2026-07-01', '2026-07-10', 'high', 'completed', '2026-07-08', 'Spectrophotometer ordered. Model: X-Rite CE-7000A. Delivery: Aug 15.'),
(4, 2, 'Rework open seam garments', 'Re-stitch all 127 garments with open seams', 8, 'Sewing', '2026-06-21', '2026-06-23', 'high', 'completed', '2026-06-22', 'All rework completed.'),
(5, 2, 'Calibrate machine speeds', 'Reset all 10 machines on Line 3 to standard 3800 RPM', 9, 'Maintenance', '2026-06-21', '2026-06-21', 'high', 'completed', '2026-06-21', 'All machines calibrated and speed governors installed.'),
(6, 2, 'Create style parameter charts', 'Document correct machine settings for top 20 styles', 10, 'IE', '2026-06-22', '2026-06-29', 'medium', 'completed', '2026-06-28', 'Charts created and laminated.'),
(7, 3, 'Arrange customer return', 'Contact customer and arrange courier for 500 pieces', 11, 'Sales', '2026-06-23', '2026-06-24', 'high', 'completed', '2026-06-23', 'Customer return arranged.'),
(8, 3, 'Re-label 500 garments', 'Remove incorrect labels and attach correct care labels', 8, 'Finishing', '2026-06-25', '2026-06-27', 'high', 'completed', '2026-06-26', 'All re-labeled and verified.'),
(9, 3, 'Install barcode scanners at label stations', 'Set up barcode verification system for label attachment verification', 12, 'IT', '2026-07-01', '2026-07-12', 'high', 'completed', '2026-07-10', 'System installed and tested.'),
(10, 4, 'Scan all 2,400 pieces with metal detector', 'Run all pieces from affected lot through needle detector machine', 13, 'QA', '2026-06-23', '2026-06-24', 'high', 'completed', '2026-06-24', 'All pieces scanned. No additional needles.'),
(11, 4, 'Create needle count register', 'Design and print needle count log sheets for all sewing lines', 14, 'Production', '2026-06-24', '2026-06-26', 'high', 'completed', '2026-06-25', 'Register created. Distributed to all lines.'),
(12, 6, 'Inspect entire lot 100%', 'Full inspection of 3,200 pieces from rejected lot', 13, 'QA', '2026-06-27', '2026-07-01', 'high', 'completed', '2026-06-30', '87 pieces sent for rework. Lot released after re-inspection.'),
(13, 6, 'Develop training program', 'Create 5-day training curriculum for new machine operators', 15, 'HR', '2026-07-01', '2026-07-14', 'high', 'completed', '2026-07-12', 'Curriculum developed and approved.');

-- ========================================================================
-- 5. CAPA VERIFICATIONS
-- ========================================================================
INSERT IGNORE INTO `capa_verifications` (`id`, `capa_id`, `verification_type`, `verified_by`, `verification_date`, `method`, `criteria`, `result`, `effectiveness_score`, `defects_eliminated`, `rework_completed`, `sop_implemented`, `training_completed`, `before_value`, `after_value`, `improvement_pct`, `remarks`) VALUES
(1, 1, 'physical', 'QA Manager', '2026-07-08', 'Re-inspection of 33 accepted rolls using spectrophotometer', 'All rolls must be within Delta E < 1.0 of standard', 'All 33 rolls measured. Max Delta E = 0.82. Average Delta E = 0.45.', 95, 1, 1, 1, 1, 'Shade rejection rate: 12/45 (26.7%)', 'Shade rejection rate with new process: 0/33 (0%)', 100.0, 'Spectrophotometer verification confirms complete elimination of shade variation issue.'),
(2, 2, 'statistical', 'Quality Inspector', '2026-07-10', 'DHU tracking on Line 3 for 10 production days post-CAPA', 'DHU must be below 3% (target 2%)', 'DHU averaged 1.2% over 10 days. Range: 0.8% - 1.8%.', 90, 1, 1, 1, 1, 'DHU before: 8.3%', 'DHU after: 1.2%', 85.5, 'Open seam defects virtually eliminated. Machine speed audit operating effectively.'),
(3, 3, 'physical', 'QA Team Lead', '2026-07-15', 'Random audit of 100 cartons from 5 production days', 'Zero label defects found in audit sample', '100 cartons checked. All labels correct. Barcode system functioning.', 98, 1, 1, 1, 1, 'Label defect rate: 500/1200 (41.7%)', 'Label defect rate: 0/100 (0%)', 100.0, 'Barcode system and two-person verification working effectively.'),
(4, 4, 'statistical', 'Safety Officer', '2026-06-28', 'Needle count compliance check on all sewing lines', '100% compliance on needle count procedure', '8 out of 8 sewing lines compliant. Needle registers properly maintained.', 85, 1, 1, 0, 1, 'Needle incidents: 1 per month avg', 'Needle incidents since CAPA: 0', 100.0, 'Needle count procedure fully implemented. Detector machines pending installation.');

-- ========================================================================
-- 6. CAPA ATTACHMENTS
-- ========================================================================
INSERT IGNORE INTO `capa_attachments` (`id`, `capa_id`, `file_name`, `file_type`, `file_path`, `file_url`, `file_size`, `mime_type`, `notes`) VALUES
(1, 1, 'shade_variation_report.pdf', 'document', '/uploads/capa/CAPA-1-shade-report.pdf', '/uploads/capa/CAPA-1-shade-report.pdf', 245760, 'application/pdf', 'Spectrophotometer reading report for all 45 rolls'),
(2, 1, 'supplier_credit_note.pdf', 'document', '/uploads/capa/CAPA-1-credit-note.pdf', '/uploads/capa/CAPA-1-credit-note.pdf', 102400, 'application/pdf', 'Credit note CR-2026-089 from supplier'),
(3, 2, 'open_seam_defect_photo.jpg', 'photo', '/uploads/capa/CAPA-2-defect-photo.jpg', '/uploads/capa/CAPA-2-defect-photo.jpg', 512000, 'image/jpeg', 'Typical open seam defect found on Line 3'),
(4, 2, 'machine_speed_audit_form.pdf', 'document', '/uploads/capa/CAPA-2-speed-audit.pdf', '/uploads/capa/CAPA-2-speed-audit.pdf', 81920, 'application/pdf', 'Daily machine speed audit checklist template'),
(5, 3, 'customer_complaint_email.pdf', 'document', '/uploads/capa/CAPA-3-complaint-email.pdf', '/uploads/capa/CAPA-3-complaint-email.pdf', 65536, 'application/pdf', 'Original customer complaint email'),
(6, 3, 'correct_label_photo.jpg', 'photo', '/uploads/capa/CAPA-3-correct-label.jpg', '/uploads/capa/CAPA-3-correct-label.jpg', 384000, 'image/jpeg', 'Correct label placement verification'),
(7, 4, 'incident_report.pdf', 'document', '/uploads/capa/CAPA-4-incident-report.pdf', '/uploads/capa/CAPA-4-incident-report.pdf', 163840, 'application/pdf', 'Needle breakage incident report form'),
(8, 8, 'emergency_shower_installation.jpg', 'photo', '/uploads/capa/CAPA-8-emergency-shower.jpg', '/uploads/capa/CAPA-8-emergency-shower.jpg', 720896, 'image/jpeg', 'Emergency shower installed near chemical station'),
(9, 8, 'ppe_compliance_checklist.pdf', 'document', '/uploads/capa/CAPA-8-PPE-checklist.pdf', '/uploads/capa/CAPA-8-PPE-checklist.pdf', 45056, 'application/pdf', 'Monthly PPE compliance audit checklist template');

