80 lines
2.0 KiB
JavaScript
80 lines
2.0 KiB
JavaScript
//import functions from production order todo model
|
|
import {
|
|
insertProductionOrderTodo,
|
|
getProductionOrderTodosById,
|
|
getProductionOrderTodosByAsset,
|
|
updateProductionOrderTodoById,
|
|
deleteProductionOrderTodosChecklistID,
|
|
getProductionOrderTodosByTemplate,
|
|
} from "../models/productionOrdersTodosModel.js";
|
|
|
|
//create new production order todo
|
|
export const createProductionOrderTodos = (req, res) => {
|
|
const data = req.body;
|
|
insertProductionOrderTodo(data, (err, results) => {
|
|
if (err) {
|
|
res.send(err);
|
|
} else {
|
|
res.json(results);
|
|
}
|
|
});
|
|
};
|
|
|
|
//get single production order todos by id
|
|
export const showProductionOrderTodosById = (req, res) => {
|
|
getProductionOrderTodosById(req.params.id, (err, results) => {
|
|
if (err) {
|
|
res.send(err);
|
|
} else {
|
|
res.json(results);
|
|
}
|
|
});
|
|
};
|
|
|
|
//get single production order todos by asset
|
|
export const showProductionOrderTodosByAsset = (req, res) => {
|
|
getProductionOrderTodosByAsset(req.params.id, (err, results) => {
|
|
if (err) {
|
|
res.send(err);
|
|
} else {
|
|
res.json(results);
|
|
}
|
|
});
|
|
};
|
|
|
|
|
|
//get production order todos by template
|
|
export const showProductionOrderTodosByTemplate = (req, res) => {
|
|
getProductionOrderTodosByTemplate(req.params.id, (err, results) => {
|
|
if (err) {
|
|
res.send(err);
|
|
} else {
|
|
res.json(results);
|
|
}
|
|
});
|
|
};
|
|
|
|
// Update production order todo
|
|
export const updateProductionOrderTodo = (req, res) => {
|
|
const data = req.body;
|
|
updateProductionOrderTodoById(data, (err, results) => {
|
|
if (err) {
|
|
res.send(err);
|
|
} else {
|
|
res.json(results);
|
|
}
|
|
});
|
|
};
|
|
|
|
// Delete production order todos
|
|
export const deleteProductionOrderTodos = (req, res) => {
|
|
const id = req.params.id;
|
|
deleteProductionOrderTodosChecklistID(id, (err, results) => {
|
|
if (err) {
|
|
res.send(err);
|
|
} else {
|
|
res.json(results);
|
|
}
|
|
});
|
|
};
|