-- 22-05-2025
CREATE TABLE agents (
                        id INT PRIMARY KEY AUTO_INCREMENT,
                        first_name VARCHAR(50) NOT NULL,
                        last_name VARCHAR(50) NOT NULL,
                        email VARCHAR(100)  NOT NULL,
                        phone_number VARCHAR(20),
                        agency_name VARCHAR(100),
                        hire_date DATE,
                        address VARCHAR(255) NULL DEFAULT NULL,
                        country_name VARCHAR(20),
                        status TINYINT(4) DEFAULT '1' COMMENT 'active=1, inactive=0',
                        created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
                        updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- -----------------
INSERT INTO `sub_modules` (`id`, `module_id`, `name`, `controller_name`, `icon`, `sequence`, `created_on`, `modified_on`) VALUES ('3346', '1004', 'Manage Agents', 'Agent', '<i class=\"fa fa-user\" aria-hidden=\"true\"></i>', '1', '2024-08-28 11:46:17', '2024-08-28 11:46:17') ;
INSERT INTO `pages` (`id`, `module_id`, `sub_module_id`, `name`, `method_name`, `available_to_company`, `created_on`, `modified_on`)
                          VALUES ('10166', '1004', '3346', 'index', 'index', '1', '2024-08-28 11:46:17', '2024-08-28 11:46:17'),
                                 ('10167', '1004', '3346', 'add', 'add', '1', '2024-08-28 11:46:17', '2024-08-28 11:46:17'),
                                 ('10168', '1004', '3346', 'edit', 'edit', '1', '2024-08-28 11:46:17', '2024-08-28 11:46:17'),
                                 ('10169', '1004', '3346', 'view', 'view', '1', '2024-08-28 11:46:17', '2024-08-28 11:46:17'),
                                 ('10170', '1004', '3346', 'delete', 'delete', '1', '2024-08-28 11:46:17', '2024-08-28 11:46:17');

-- deployed

-- new table 6/27/2025

CREATE TABLE course_categories (
                                   id INT AUTO_INCREMENT PRIMARY KEY ,
                                   name VARCHAR(150) NOT NULL,
                                   description VARCHAR(255) NULL DEFAULT NULL ,
                                   status TINYINT(4) DEFAULT 1 COMMENT '1 = Active, 0 = Inactive',
                                   created_by INT ,
                                   updated_by INT ,
                                   created_at DATETIME DEFAULT CURRENT_TIMESTAMP ,
                                   updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
);


CREATE TABLE qualification_types (
                                     id INT AUTO_INCREMENT PRIMARY KEY ,
                                     name VARCHAR(150) NOT NULL,
                                     description VARCHAR(255) NULL DEFAULT NULL ,
                                     status TINYINT(4) DEFAULT 1 COMMENT '1 = Active, 0 = Inactive',
                                     created_by INT ,
                                     updated_by INT ,
                                     created_at DATETIME DEFAULT CURRENT_TIMESTAMP ,
                                     updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
);


CREATE TABLE semesters (
                           id INT AUTO_INCREMENT PRIMARY KEY ,
                           name VARCHAR(50) NOT NULL,
                           description VARCHAR(255) NULL DEFAULT NULL ,
                           status TINYINT(4) DEFAULT 1 COMMENT '1 = Active, 0 = Inactive',
                           created_by INT ,
                           updated_by INT ,
                           created_at DATETIME DEFAULT CURRENT_TIMESTAMP ,
                           updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
);


ALTER TABLE courses
add column course_category_id int COMMENT 'comes from course_categories table' AFTER name,
add column qualification_type_id int COMMENT 'comes from qualification_types table' AFTER course_category_id,
add column level TINYINT(4) COMMENT '1 to 8' AFTER qualification_type_id,
add column total_credit DECIMAL(5,2) COMMENT 'credit 120.5'  AFTER level,
add column code VARCHAR(50) COMMENT 'like as 603/4373/4' AFTER total_credit,
add column progression_routes VARCHAR(255) COMMENT 'QUALIFI Level 4 qualification, or directly into employment in an associated profession.' AFTER code,
add column availability_type TINYINT(4) COMMENT 'UK and international' AFTER progression_routes,
add column delivery_mode TINYINT(4) COMMENT ' 1 = Online, 2 = Blended, 3 = Both (takes from constant)' AFTER availability_type,
add column duration TINYINT(4) COMMENT 'Duration in months' AFTER delivery_mode,
add column assessment VARCHAR(255) COMMENT 'Assignment Based' AFTER duration;


CREATE TABLE course_semesters (
                                  id INT AUTO_INCREMENT PRIMARY KEY,
                                  course_id INT NOT NULL,
                                  semester_id INT NOT NULL,
                                  created_by INT ,
                                  updated_by INT ,
                                  created_at DATETIME DEFAULT CURRENT_TIMESTAMP ,
                                  updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
);




CREATE TABLE course_semester_subjects (
                                          id INT AUTO_INCREMENT PRIMARY KEY,
                                          course_id INT NOT NULL,
                                          course_semester_id INT NOT NULL,
                                          title VARCHAR(255) NOT NULL,
                                          level TINYINT(4) NOT NULL COMMENT '1 to 8',
                                          credit DECIMAL(5,2) NOT NULL COMMENT 'credits = 20.5 or 5 ',
                                          is_mandatory TINYINT(4) DEFAULT 1 COMMENT '1 = mandatory, 2 = Optional',
                                          status TINYINT(4) DEFAULT 1 COMMENT '1 = Active, 0 = Inactive',
                                          created_by INT ,
                                          updated_by INT ,
                                          created_at DATETIME DEFAULT CURRENT_TIMESTAMP ,
                                          updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
);


CREATE TABLE course_semester_fees (
                                      id INT AUTO_INCREMENT PRIMARY KEY ,
                                      course_id INT NOT NULL,
                                      online_fee DECIMAL(10,2) DEFAULT 0.00 NOT NULL,
                                      discount DECIMAL(10,2) DEFAULT 0.00,
                                      monthly_installment_amount DECIMAL(10,2) DEFAULT 0.00 ,
                                      upfront_deposit DECIMAL(10,2) DEFAULT 0.00 ,
                                      blended_fee DECIMAL(10,2) DEFAULT 0.00,
                                      certificate_fee DECIMAL(10,2) DEFAULT 0.00 COMMENT '100.00 for printed certificate',
                                      status TINYINT(4) DEFAULT 1 COMMENT ' 1 = Active, 0 = Inactive',
                                      created_by INT,
                                      updated_by INT ,
                                      created_at DATETIME DEFAULT CURRENT_TIMESTAMP ,
                                      updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
);

-- -----------------
INSERT INTO `sub_modules` (`id`, `module_id`, `name`, `controller_name`, `icon`, `sequence`, `created_on`, `modified_on`) VALUES ('3347', '1004', 'Course Category', 'CourseCategories', '<i class="fa fa-angle-double-right"></i>', '1', '2024-08-28 11:46:17', '2024-08-28 11:46:17'),
                                                                                                                                 ('3348', '1004', 'Qualification Type', 'QualificationTypes', '<i class="fa fa-angle-double-right"></i>', '1', '2024-08-28 11:46:17', '2024-08-28 11:46:17');
INSERT INTO `pages` (`id`, `module_id`, `sub_module_id`, `name`, `method_name`, `available_to_company`, `created_on`, `modified_on`)
VALUES ('10171', '1004', '3347', 'index', 'index', '1', '2024-08-28 11:46:17', '2024-08-28 11:46:17'),
       ('10172', '1004', '3347', 'add', 'add', '1', '2024-08-28 11:46:17', '2024-08-28 11:46:17'),
       ('10173', '1004', '3347', 'edit', 'edit', '1', '2024-08-28 11:46:17', '2024-08-28 11:46:17'),
       ('10174', '1004', '3347', 'view', 'view', '1', '2024-08-28 11:46:17', '2024-08-28 11:46:17'),
       ('10175', '1004', '3347', 'delete', 'delete', '1', '2024-08-28 11:46:17', '2024-08-28 11:46:17'),

       ('10177', '1004', '3348', 'index', 'index', '1', '2024-08-28 11:46:17', '2024-08-28 11:46:17'),
       ('10178', '1004', '3348', 'add', 'add', '1', '2024-08-28 11:46:17', '2024-08-28 11:46:17'),
       ('10179', '1004', '3348', 'edit', 'edit', '1', '2024-08-28 11:46:17', '2024-08-28 11:46:17'),
       ('10180', '1004', '3348', 'view', 'view', '1', '2024-08-28 11:46:17', '2024-08-28 11:46:17'),
       ('10181', '1004', '3348', 'delete', 'delete', '1', '2024-08-28 11:46:17', '2024-08-28 11:46:17');

-- deployed

ALTER TABLE `courses` ADD `qualification_time` SMALLINT NULL DEFAULT '0' AFTER `progression_routes`, ADD `centre_specification_link` VARCHAR(200) NULL DEFAULT NULL AFTER `qualification_time`;
ALTER TABLE `courses` ADD `image_path` VARCHAR(150) NULL DEFAULT NULL AFTER `description`;
ALTER TABLE `courses` ADD `accreditation_status` TINYINT(4) NOT NULL DEFAULT '1' AFTER `code`;

-- deployed