diff --git a/docker/database/start-scripts/0-init.sql b/docker/database/start-scripts/0-init.sql index 54f27126..732e2d3f 100644 --- a/docker/database/start-scripts/0-init.sql +++ b/docker/database/start-scripts/0-init.sql @@ -70,6 +70,20 @@ create table workers ( foreign key (role_id) references roles(id) ); + +CREATE TABLE contracts ( + id int auto_increment primary key, + name varchar(255), + start_date DATE, + end_date DATE, + invoice_proposed float, + invoice_agreed float, + invoice_paid float, + created_at timestamp default current_timestamp, + deleted_at timestamp, + updated_at timestamp +); + create table work_orders ( id int auto_increment primary key, name varchar(255), diff --git a/docker/database/start-scripts/1-seed.sql b/docker/database/start-scripts/1-seed.sql index 12c4e424..478e036e 100644 --- a/docker/database/start-scripts/1-seed.sql +++ b/docker/database/start-scripts/1-seed.sql @@ -16,3 +16,8 @@ INSERT INTO tree_types (family, genus, species) VALUES ('Pinaceae', 'Pinus', 'Pinus sylvestris'), ('Sapindaceae', 'Acer', 'Acer campestre'); +-- Insert sample contracts +INSERT INTO contracts (name, start_date, end_date, invoice_proposed, invoice_agreed, invoice_paid) VALUES +('Ayuntamiento de Valencia', '2021-01-01', '2021-12-31', 1000.00, 900.00, 900.00), +('Administración General del Estado', '2021-01-01', '2021-12-31', 2000.00, 1800.00, 1800.00), +('Ayuntamiento de Carlet', '2021-01-01', '2021-12-31', 3000.00, 2700.00, 2700.00); \ No newline at end of file diff --git a/src/app/Controllers/ContractController.php b/src/app/Controllers/ContractController.php new file mode 100644 index 00000000..cd4388b0 --- /dev/null +++ b/src/app/Controllers/ContractController.php @@ -0,0 +1,25 @@ + "Contracts", + "title" => "Contracts", + "layout" => "MainLayout", + "data" => ["contracts" => $contracts] + ]); + } + + public function post() {} + public function put() {} + public function delete() {} +} \ No newline at end of file diff --git a/src/app/Models/Contract.php b/src/app/Models/Contract.php new file mode 100644 index 00000000..6d63d922 --- /dev/null +++ b/src/app/Models/Contract.php @@ -0,0 +1,34 @@ +id = $data['id']; + $contract->name = $data['name']; + $contract->start_date = $data['start_date']; + $contract->end_date = $data['end_date']; + $contract->invoice_proposed = $data['invoice_proposed']; + $contract->invoice_agreed = $data['invoice_agreed']; + $contract->invoice_paid = $data['invoice_paid']; + $contract->created_at = $data['created_at']; + return $contract; + } +} diff --git a/src/app/Models/TreeType.php b/src/app/Models/TreeType.php index e59f8f1f..359a9d20 100644 --- a/src/app/Models/TreeType.php +++ b/src/app/Models/TreeType.php @@ -10,7 +10,7 @@ class TreeType extends BaseModel public string $genus; public string $species; - protected static function getTableName(): string + protected static function getTableName() { return 'tree_types'; } diff --git a/src/app/Views/Contracts.php b/src/app/Views/Contracts.php new file mode 100644 index 00000000..021129a3 --- /dev/null +++ b/src/app/Views/Contracts.php @@ -0,0 +1,30 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
IDNameStart DateEnd DateInvoice proposedInvoice agreedInvoice paidCreated at
getId(); ?>name; ?>start_date; ?>end_date; ?>invoice_proposed; ?>invoice_agreed; ?>invoice_paid; ?>created_at; ?>
+