dsad
This commit is contained in:
@@ -3,6 +3,17 @@ CREATE TABLE sampling_templates (
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
template_name VARCHAR(100),
|
||||
description TEXT,
|
||||
is_active BOOLEAN DEFAULT true,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- Tabel Template Analisis
|
||||
CREATE TABLE analysis_templates (
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
template_name VARCHAR(100),
|
||||
description TEXT,
|
||||
is_lab_analysis BOOLEAN DEFAULT true,
|
||||
is_active BOOLEAN DEFAULT true,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
@@ -11,35 +22,61 @@ CREATE TABLE analysis_parameters (
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
parameter_code VARCHAR(20),
|
||||
parameter_name VARCHAR(100),
|
||||
testing_method VARCHAR(100),
|
||||
unit VARCHAR(20),
|
||||
standard_method_number VARCHAR(50),
|
||||
price DECIMAL(10,2),
|
||||
method VARCHAR(100),
|
||||
is_active BOOLEAN DEFAULT true,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- Tabel Template Parameter
|
||||
CREATE TABLE template_parameters (
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
template_id INT,
|
||||
parameter_id INT,
|
||||
is_required BOOLEAN DEFAULT false,
|
||||
FOREIGN KEY (template_id) REFERENCES analysis_templates(id),
|
||||
FOREIGN KEY (parameter_id) REFERENCES analysis_parameters(id)
|
||||
);
|
||||
|
||||
-- Tabel Permintaan Layanan
|
||||
CREATE TABLE service_requests (
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
request_code VARCHAR(20) UNIQUE,
|
||||
customer_id INT,
|
||||
request_type ENUM('sampling_analysis', 'analysis_only'),
|
||||
template_id INT,
|
||||
sampling_date DATE,
|
||||
sampling_location TEXT,
|
||||
gps_coordinates VARCHAR(50),
|
||||
status ENUM('draft', 'submitted', 'approved', 'rejected', 'in_progress', 'completed'),
|
||||
sampling_officer_id INT,
|
||||
testing_officer_id INT,
|
||||
total_amount DECIMAL(10,2),
|
||||
dp_amount DECIMAL(10,2),
|
||||
dp_status ENUM('unpaid', 'paid') DEFAULT 'unpaid',
|
||||
notes TEXT,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (customer_id) REFERENCES customers(id)
|
||||
updated_at DATETIME ON UPDATE CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (customer_id) REFERENCES customers(id),
|
||||
FOREIGN KEY (template_id) REFERENCES analysis_templates(id),
|
||||
FOREIGN KEY (sampling_officer_id) REFERENCES users(id),
|
||||
FOREIGN KEY (testing_officer_id) REFERENCES users(id)
|
||||
);
|
||||
|
||||
-- Tabel Detail Parameter yang Diminta
|
||||
-- Tabel Detail Parameter Permintaan
|
||||
CREATE TABLE request_parameters (
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
request_id INT,
|
||||
parameter_id INT,
|
||||
price DECIMAL(10,2),
|
||||
status ENUM('pending', 'in_progress', 'completed', 'rejected'),
|
||||
result_value VARCHAR(50),
|
||||
result_unit VARCHAR(20),
|
||||
is_compliant BOOLEAN,
|
||||
notes TEXT,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (request_id) REFERENCES service_requests(id),
|
||||
FOREIGN KEY (parameter_id) REFERENCES analysis_parameters(id)
|
||||
);
|
||||
@@ -52,12 +89,41 @@ CREATE TABLE quotations (
|
||||
issue_date DATE,
|
||||
valid_until DATE,
|
||||
status ENUM('draft', 'sent', 'approved', 'rejected'),
|
||||
subtotal DECIMAL(10,2),
|
||||
tax_percentage DECIMAL(5,2),
|
||||
tax_amount DECIMAL(10,2),
|
||||
total_amount DECIMAL(10,2),
|
||||
terms_and_conditions TEXT,
|
||||
notes TEXT,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME ON UPDATE CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (request_id) REFERENCES service_requests(id)
|
||||
);
|
||||
|
||||
-- Tabel Peralatan Sampling
|
||||
CREATE TABLE sampling_equipment (
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
equipment_name VARCHAR(100),
|
||||
equipment_code VARCHAR(50),
|
||||
is_available BOOLEAN DEFAULT true,
|
||||
last_calibration_date DATE,
|
||||
next_calibration_date DATE,
|
||||
notes TEXT,
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- Tabel Peralatan yang Digunakan dalam Sampling
|
||||
CREATE TABLE request_equipment (
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
request_id INT,
|
||||
equipment_id INT,
|
||||
usage_date DATE,
|
||||
return_date DATE,
|
||||
notes TEXT,
|
||||
FOREIGN KEY (request_id) REFERENCES service_requests(id),
|
||||
FOREIGN KEY (equipment_id) REFERENCES sampling_equipment(id)
|
||||
);
|
||||
|
||||
-- Contoh data template sampling
|
||||
INSERT INTO sampling_templates (template_name, description) VALUES
|
||||
('Air Limbah Industri', 'Template untuk sampling air limbah industri'),
|
||||
|
||||
Reference in New Issue
Block a user