- Added search functionality to the Project List page, allowing users to filter projects by name, WP, plot, or investment number. - Created a new Project Tasks page to manage tasks across all projects, including filtering by status and priority. - Implemented task status updates and deletion functionality. - Added a new Task Template Edit page for modifying existing task templates. - Enhanced Task Template Form to include a description field and loading state during submission. - Updated UI components for better user experience, including badges for task status and priority. - Introduced new database queries for managing contracts and projects, including fetching tasks related to projects. - Added migrations to the database for new columns and improved data handling.
58 lines
893 B
JavaScript
58 lines
893 B
JavaScript
import db from "../db";
|
|
|
|
export function getAllContracts() {
|
|
return db
|
|
.prepare(
|
|
`
|
|
SELECT
|
|
contract_id,
|
|
contract_number,
|
|
contract_name,
|
|
customer,
|
|
investor,
|
|
date_signed,
|
|
finish_date
|
|
FROM contracts
|
|
ORDER BY contract_number
|
|
`
|
|
)
|
|
.all();
|
|
}
|
|
|
|
export function getContractById(id) {
|
|
return db
|
|
.prepare(
|
|
`
|
|
SELECT * FROM contracts
|
|
WHERE contract_id = ?
|
|
`
|
|
)
|
|
.get(id);
|
|
}
|
|
|
|
export function deleteContract(id) {
|
|
db.prepare("DELETE FROM contracts WHERE contract_id = ?").run(id);
|
|
}
|
|
|
|
export function getContractWithProjects(id) {
|
|
const contract = getContractById(id);
|
|
if (!contract) return null;
|
|
|
|
const projects = db
|
|
.prepare(
|
|
`
|
|
SELECT
|
|
project_id,
|
|
project_name,
|
|
project_number,
|
|
finish_date
|
|
FROM projects
|
|
WHERE contract_id = ?
|
|
ORDER BY project_name
|
|
`
|
|
)
|
|
.all(id);
|
|
|
|
return { ...contract, projects };
|
|
}
|