-- SQL Script to create print_header table
-- Run this in phpMyAdmin SQL tab

CREATE TABLE IF NOT EXISTS `print_header` (
  `id` INT(11) NOT NULL AUTO_INCREMENT,
  `company_id` INT(11) NOT NULL COMMENT 'Company this print header belongs to',
  `header_code` VARCHAR(50) NOT NULL COMMENT 'Unique code for the print header',
  `header_name` VARCHAR(200) NOT NULL COMMENT 'Name/description of the print header',
  `logo_path` VARCHAR(500) DEFAULT NULL COMMENT 'Path to company logo file',
  `logo_file_name` VARCHAR(255) DEFAULT NULL COMMENT 'Original filename of the logo',
  `company_name` VARCHAR(200) DEFAULT NULL COMMENT 'Company name to display on print header',
  `former_name` VARCHAR(200) DEFAULT NULL COMMENT 'Former name of the company (e.g., Formerly Known as...)',
  `address` TEXT DEFAULT NULL COMMENT 'Complete address for print header',
  `phone` VARCHAR(50) DEFAULT NULL COMMENT 'Phone number(s)',
  `fax` VARCHAR(50) DEFAULT NULL COMMENT 'Fax number',
  `email` VARCHAR(100) DEFAULT NULL COMMENT 'Email address',
  `website` VARCHAR(200) DEFAULT NULL COMMENT 'Website URL',
  `quality_certification_logo_path` VARCHAR(500) DEFAULT NULL COMMENT 'Path to quality certification logo file',
  `quality_certification_logo_file_name` VARCHAR(255) DEFAULT NULL COMMENT 'Original filename of the certification logo',
  `quality_certification_text` VARCHAR(200) DEFAULT NULL COMMENT 'Quality certification text (e.g., ISO 9001, DNV)',
  `quality_certification_body` VARCHAR(100) DEFAULT NULL COMMENT 'Certification body (e.g., DNV)',
  `status` ENUM('ACTIVE', 'INACTIVE') NOT NULL DEFAULT 'ACTIVE',
  `created_by` INT(11) DEFAULT NULL,
  `updated_by` INT(11) DEFAULT NULL,
  `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `header_code` (`header_code`),
  KEY `company_id` (`company_id`),
  KEY `status` (`status`),
  CONSTRAINT `fk_print_header_company` FOREIGN KEY (`company_id`) REFERENCES `company` (`id`) ON UPDATE CASCADE ON DELETE RESTRICT,
  CONSTRAINT `fk_print_header_created_by` FOREIGN KEY (`created_by`) REFERENCES `user` (`id`) ON UPDATE CASCADE ON DELETE SET NULL,
  CONSTRAINT `fk_print_header_updated_by` FOREIGN KEY (`updated_by`) REFERENCES `user` (`id`) ON UPDATE CASCADE ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Print header master table for document headers';

