WorkReport kész 90%
This commit is contained in:
parent
0beb80773a
commit
85aa906d6e
9
app.js
9
app.js
|
|
@ -24,8 +24,8 @@ var PdfPrinter=require('pdfmake');
|
||||||
//const util = require('util');
|
//const util = require('util');
|
||||||
//var currentWorkNumber=0;
|
//var currentWorkNumber=0;
|
||||||
const { XMLParser, XMLBuilder, XMLValidator} = require("fast-xml-parser/src/fxp");
|
const { XMLParser, XMLBuilder, XMLValidator} = require("fast-xml-parser/src/fxp");
|
||||||
const { apiSaveReport, apiGetReport, apiGetReportList, apiGetUsers } = require('./js/workReport.js');
|
const { apiSaveReport, apiGetReport, apiGetReportList, apiGetUsers, apiGetReportDates, apiUpdateReport } = require('./js/workReport.js');
|
||||||
|
moment.locale('HU');
|
||||||
const fss = require('fs');
|
const fss = require('fs');
|
||||||
global.currentWorkNumber=0;
|
global.currentWorkNumber=0;
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
|
|
@ -1871,10 +1871,11 @@ app.get('/media/:file', function(req, res) {
|
||||||
|
|
||||||
});
|
});
|
||||||
app.route('/workreport').post(apiSaveReport);
|
app.route('/workreport').post(apiSaveReport);
|
||||||
|
app.route('/workreportUpdate').post(apiUpdateReport);
|
||||||
app.route('/workreportUserList').get(apiGetUsers);
|
app.route('/workreportUserList').get(apiGetUsers);
|
||||||
app.route('/workreport/:id').get(apiGetReport);
|
app.route('/workreport/:id').get(apiGetReport);
|
||||||
app.route('/workreportList/:id').get(apiGetReportList);
|
app.route('/workreportList/:id').get(apiGetReportList);
|
||||||
|
app.route('/workreportDates/:id').get(apiGetReportDates);
|
||||||
// Route Files
|
// Route Files
|
||||||
app.locals.moment = require('moment');
|
app.locals.moment = require('moment');
|
||||||
//app.use('/articles', articles);
|
//app.use('/articles', articles);
|
||||||
|
|
@ -1898,6 +1899,7 @@ let components_base=require('./routes/components_base');
|
||||||
let bid=require('./routes/bid');
|
let bid=require('./routes/bid');
|
||||||
let vehicles=require('./routes/vehicles');
|
let vehicles=require('./routes/vehicles');
|
||||||
let quotes=require('./routes/quotes');
|
let quotes=require('./routes/quotes');
|
||||||
|
let workReport=require('./routes/workReport');
|
||||||
|
|
||||||
const { date } = require('jszip/lib/defaults');
|
const { date } = require('jszip/lib/defaults');
|
||||||
const { apiGetWorkList, apiGetEmployeeList, apiGetDailyReport, apiEmployee, apiGetAllReport, apiCheckDevice, apiRegisterDevice,apiRequestAPIkey, apiGetQRCode,apiGetWorkState } = require('./js/androidApi');
|
const { apiGetWorkList, apiGetEmployeeList, apiGetDailyReport, apiEmployee, apiGetAllReport, apiCheckDevice, apiRegisterDevice,apiRequestAPIkey, apiGetQRCode,apiGetWorkState } = require('./js/androidApi');
|
||||||
|
|
@ -1924,6 +1926,7 @@ app.use('/certificates_mc',certificates_mc);
|
||||||
app.use('/components',components);
|
app.use('/components',components);
|
||||||
app.use('/components_base',components_base);
|
app.use('/components_base',components_base);
|
||||||
app.use('/quotes',quotes);
|
app.use('/quotes',quotes);
|
||||||
|
app.use('/workReport',workReport);
|
||||||
// Kábel mérési jegyzőkönyv
|
// Kábel mérési jegyzőkönyv
|
||||||
|
|
||||||
//apkUpdater.enable(app, '/anyUpdateServerRoute');
|
//apkUpdater.enable(app, '/anyUpdateServerRoute');
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ let Employee = require('../models/employee');
|
||||||
const asyncHandler = require('express-async-handler');
|
const asyncHandler = require('express-async-handler');
|
||||||
var mongoose = require('mongoose');
|
var mongoose = require('mongoose');
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
|
/*
|
||||||
exports.apiSaveReport=asyncHandler(async (req,res)=>{
|
exports.apiSaveReport=asyncHandler(async (req,res)=>{
|
||||||
const {workId,foremanId,date, workTitle,employeeList }=req.body;
|
const {workId,foremanId,date, workTitle,employeeList }=req.body;
|
||||||
const workReport = new WorkReport({
|
const workReport = new WorkReport({
|
||||||
|
|
@ -24,7 +24,59 @@ exports.apiSaveReport=asyncHandler(async (req,res)=>{
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.apiSaveReport=asyncHandler(async (req,res)=>{
|
||||||
|
const {workId,foremanId,date, workTitle,workFlow }=req.body;
|
||||||
|
const workReport = new WorkReport({
|
||||||
|
workId: mongoose.Types.ObjectId(workId),
|
||||||
|
date:new Date(date),
|
||||||
|
foremanId: mongoose.Types.ObjectId(foremanId),
|
||||||
|
workTitle: workTitle,
|
||||||
|
workFlow: workFlow
|
||||||
|
|
||||||
|
})
|
||||||
|
res.setHeader('Content-Type', 'application/json');
|
||||||
|
try{
|
||||||
|
await workReport.save();
|
||||||
|
res.send({'response':'ok','message':'Sikeresen létrehozva!'});
|
||||||
|
}catch(err){
|
||||||
|
|
||||||
|
res.status(500).json({'response':'fail','message':'Hiba a mentésnél !\n'+err.message});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
exports.apiUpdateReport=asyncHandler(async (req,res)=>{
|
||||||
|
const {workReport }=req.body;
|
||||||
|
|
||||||
|
|
||||||
|
res.setHeader('Content-Type', 'application/json');
|
||||||
|
try{
|
||||||
|
await WorkReport.replaceOne(
|
||||||
|
{_id: mongoose.Types.ObjectId(workReport._id)},
|
||||||
|
workReport
|
||||||
|
)
|
||||||
|
res.send({'response':'ok','message':'Sikeresen mentve!'});
|
||||||
|
}catch(err){
|
||||||
|
|
||||||
|
res.status(500).json({'response':'fail','message':'Hiba a mentésnél !\n'+err.message});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
/*exports.apiGetReport=asyncHandler(async (req,res)=>{
|
||||||
|
//const {workId,foremanId, workTitle,employeeList }=req.body;
|
||||||
|
|
||||||
|
res.setHeader('Content-Type', 'application/json');
|
||||||
|
try{
|
||||||
|
const reports=await WorkReport.find({workId: mongoose.Types.ObjectId(req.params.id)})
|
||||||
|
res.send({'response':'ok','reports':reports});
|
||||||
|
}catch(err){
|
||||||
|
|
||||||
|
res.status(500).json({'response':'fail','message':'Hiba a mentésnél !\n'+err.message});
|
||||||
|
}
|
||||||
|
|
||||||
|
});*/
|
||||||
exports.apiGetReport=asyncHandler(async (req,res)=>{
|
exports.apiGetReport=asyncHandler(async (req,res)=>{
|
||||||
//const {workId,foremanId, workTitle,employeeList }=req.body;
|
//const {workId,foremanId, workTitle,employeeList }=req.body;
|
||||||
|
|
||||||
|
|
@ -38,6 +90,26 @@ exports.apiGetReport=asyncHandler(async (req,res)=>{
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Használt dátumok
|
||||||
|
exports.apiGetReportDates=asyncHandler(async (req,res)=>{
|
||||||
|
//const {workId,foremanId, workTitle,employeeList }=req.body;
|
||||||
|
|
||||||
|
res.setHeader('Content-Type', 'application/json');
|
||||||
|
try{
|
||||||
|
const reports=await WorkReport.find({workId: mongoose.Types.ObjectId(req.params.id)})
|
||||||
|
var dates=[];
|
||||||
|
reports.forEach((elem,idx)=>{
|
||||||
|
dates.push(elem.date)
|
||||||
|
})
|
||||||
|
res.send({'response':'ok','dates':dates});
|
||||||
|
}catch(err){
|
||||||
|
|
||||||
|
res.status(500).json({'response':'fail','message':'Hiba a mentésnél !\n'+err.message});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
// Felhasználói adatok
|
// Felhasználói adatok
|
||||||
exports.apiGetUsers=asyncHandler(async (req,res)=>{
|
exports.apiGetUsers=asyncHandler(async (req,res)=>{
|
||||||
//const {workId,foremanId, workTitle,employeeList }=req.body;
|
//const {workId,foremanId, workTitle,employeeList }=req.body;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
let mongoose = require('mongoose');
|
let mongoose = require('mongoose');
|
||||||
|
/*
|
||||||
let workReportSchema = mongoose.Schema({
|
let workReportSchema = mongoose.Schema({
|
||||||
// Napi jelentés
|
// Napi jelentés
|
||||||
workId:{type: mongoose.Schema.Types.ObjectId},
|
workId:{type: mongoose.Schema.Types.ObjectId},
|
||||||
|
|
@ -12,5 +12,21 @@ let workReportSchema = mongoose.Schema({
|
||||||
}]
|
}]
|
||||||
|
|
||||||
})
|
})
|
||||||
|
*/
|
||||||
|
|
||||||
|
let workReportSchema = mongoose.Schema({
|
||||||
|
// Napi jelentés
|
||||||
|
workId:{type: mongoose.Schema.Types.ObjectId},
|
||||||
|
date: {type: Date},
|
||||||
|
foremanId: {type: String},
|
||||||
|
workTitle: {type: String},
|
||||||
|
workFlow: [{
|
||||||
|
Title: {type: String},
|
||||||
|
employeeList:[{
|
||||||
|
employeeId:{type: mongoose.Schema.Types.ObjectId},
|
||||||
|
name: {type: String},
|
||||||
|
}]
|
||||||
|
}],
|
||||||
|
})
|
||||||
|
|
||||||
let WorkReport = module.exports = mongoose.model('WorkReport', workReportSchema);
|
let WorkReport = module.exports = mongoose.model('WorkReport', workReportSchema);
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
const express = require('express');
|
||||||
|
const router = express.Router();
|
||||||
|
var utils = require('../js/utils');
|
||||||
|
var mongoose = require('mongoose');
|
||||||
|
const moment = require('moment');
|
||||||
|
let Work=require('../models/works');
|
||||||
|
let WorkReport = require('../models/workReportModel');
|
||||||
|
// Add Route
|
||||||
|
router.get('/new/:wid', utils.ensureAuthenticated, async function (req,res) {
|
||||||
|
var devId =new Date().getFullYear() ;
|
||||||
|
// Find last id
|
||||||
|
const currentWork=await Work.findById(req.params.wid);
|
||||||
|
const reports=await WorkReport.find({workId: mongoose.Types.ObjectId(req.params.wid)})
|
||||||
|
var dates=[];
|
||||||
|
reports.forEach((elem,idx)=>{
|
||||||
|
dates.push(moment(elem.date).format("YYYY.MM.DD"))
|
||||||
|
})
|
||||||
|
res.render('workReportNew', {
|
||||||
|
title: 'Műhely munkavégzés Felvétele',
|
||||||
|
workId: req.params.wid,
|
||||||
|
dates: JSON.stringify(dates),
|
||||||
|
workTitle: currentWork.title
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
router.get('/edit/:wid/:reportId', utils.ensureAuthenticated, async function (req,res) {
|
||||||
|
var devId =new Date().getFullYear() ;
|
||||||
|
// Find last id
|
||||||
|
const reports=await WorkReport.findOne({_id: mongoose.Types.ObjectId(req.params.reportId), workId:mongoose.Types.ObjectId(req.params.wid),})
|
||||||
|
|
||||||
|
|
||||||
|
res.render('workReportEdit', {
|
||||||
|
title: 'Műhely munkavégzés Módosítás',
|
||||||
|
workId: req.params.wid,
|
||||||
|
report: JSON.stringify(reports),
|
||||||
|
workTitle: reports.workTitle
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
|
|
@ -22,6 +22,15 @@
|
||||||
.row
|
.row
|
||||||
.col-sm-12
|
.col-sm-12
|
||||||
input(id='datepicker',style='display:none', type=text)
|
input(id='datepicker',style='display:none', type=text)
|
||||||
|
.row
|
||||||
|
.table-responsive
|
||||||
|
table#workReportEdit.table.table-striped
|
||||||
|
col(width='15%')
|
||||||
|
col(width='auto')
|
||||||
|
thead
|
||||||
|
th(style='text-align:left') Résztvevők
|
||||||
|
th(style='text-align:left') Munkavégzés leírása
|
||||||
|
tbody
|
||||||
hr
|
hr
|
||||||
.row
|
.row
|
||||||
.col-sm-12
|
.col-sm-12
|
||||||
|
|
@ -47,21 +56,37 @@
|
||||||
script.
|
script.
|
||||||
|
|
||||||
var workers=[]
|
var workers=[]
|
||||||
|
function tableUpdate()
|
||||||
|
{
|
||||||
|
const workFlow = document.getElementById('workFlow').value;
|
||||||
|
// $.each(data.reports,function(i,item){
|
||||||
|
var newRow="<tr><td>"
|
||||||
|
//newRow+='<td>'
|
||||||
|
$.each(workers,function(i,employee){
|
||||||
|
newRow+=employee.name+'<br>'
|
||||||
|
});
|
||||||
|
newRow+='</td>'
|
||||||
|
newRow+="<td>"+workFlow+"</td>"
|
||||||
|
newRow+='</tr>';
|
||||||
|
$('#workReportEdit > tbody:last-child').append (newRow);
|
||||||
|
// })
|
||||||
|
}
|
||||||
const form = document.getElementById('kabelform');
|
const form = document.getElementById('kabelform');
|
||||||
function handleClick(identifier) {
|
function handleClick(identifier) {
|
||||||
const state=$(identifier).hasClass('active');
|
const state=$(identifier).hasClass('active');
|
||||||
//const d=JSON.parse(decodeURIComponent($(identifier).data('item')))
|
//const d=JSON.parse(decodeURIComponent($(identifier).data('item')))
|
||||||
const d=$(identifier).data('id')
|
const d=$(identifier).data('id')
|
||||||
|
const name=$(identifier).data('name')
|
||||||
if (!state)
|
if (!state)
|
||||||
{
|
{
|
||||||
workers.push({employeeId:d,workFlow:""});
|
workers.push({employeeId:d, name:name,workFlow:""});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
workers=workers.filter(obj=>obj._id!==d._id);
|
workers=workers.filter(obj=>obj._id!==d._id);
|
||||||
}
|
}
|
||||||
// alert("data-id:"+JSON.stringify(workers) );
|
// alert("data-id:"+JSON.stringify(workers) );
|
||||||
|
tableUpdate()
|
||||||
$('#arc').text(JSON.stringify(workers))
|
$('#arc').text(JSON.stringify(workers))
|
||||||
}
|
}
|
||||||
function textChanged(){
|
function textChanged(){
|
||||||
|
|
@ -222,7 +247,7 @@ script.
|
||||||
console.log(data)
|
console.log(data)
|
||||||
$.each(data.users,function(i,item){
|
$.each(data.users,function(i,item){
|
||||||
var data_str = encodeURIComponent(JSON.stringify(item));
|
var data_str = encodeURIComponent(JSON.stringify(item));
|
||||||
$('<button class="btn btn-primary aaa" disabled onclick="handleClick(this)" data-item="'+data_str+'" data-id="'+item._id+'" style="width:150px;margin: 3px" data-toggle="button" type="button">'+item.name+'</button>').appendTo('#buttons');
|
$('<button class="btn btn-primary aaa" disabled onclick="handleClick(this)" data-item="'+data_str+'" data-name="'+item.name+'" data-id="'+item._id+'" style="width:150px;margin: 3px" data-toggle="button" type="button">'+item.name+'</button>').appendTo('#buttons');
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(error => console.error('Error:', error));
|
.catch(error => console.error('Error:', error));
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,190 @@
|
||||||
|
#workReportEditModal.modal(tabindex='-1', role='dialog', aria-labelledby='workReportEditModalLabel')
|
||||||
|
//-form(method='GET',id='holidayForm' action='/employee/holidays_byperson/')
|
||||||
|
style(type="text/css").
|
||||||
|
.aaa:active,
|
||||||
|
.aaa.active {
|
||||||
|
background: red !important;
|
||||||
|
box-shadow: none !important;
|
||||||
|
}
|
||||||
|
.modal-dialog(role='document', style='width:1000px;')
|
||||||
|
.modal-content
|
||||||
|
.modal-header#workReportEditHeader.bg-primary(style="background: Primary")
|
||||||
|
h4 #{workTitle}
|
||||||
|
.modal-body(style='background-color:#5f6b79')
|
||||||
|
|
||||||
|
form#kabelform2
|
||||||
|
#form-group
|
||||||
|
input#wn1(name='wn1',style='display:none')
|
||||||
|
input#userid(name='userid',style='display:none', value=user._id)
|
||||||
|
input#id(name='id',style='display:none')
|
||||||
|
input#modify(name='modify',style='display:none')
|
||||||
|
|
||||||
|
.row
|
||||||
|
.col-sm-12
|
||||||
|
label(for="workFlow",style='color: white') Munka leírása:
|
||||||
|
input.form-control(id='workFlow', name='workFlow', required, minlength="6",type=text, autofocus, readonly=false,style='')
|
||||||
|
br
|
||||||
|
.row
|
||||||
|
.col-sm-12
|
||||||
|
#buttons2(style="margin: 10px;")
|
||||||
|
|
||||||
|
h4#arc
|
||||||
|
br
|
||||||
|
//button#submit.btn.btn-primary(type='submit' ) Rendben
|
||||||
|
|
||||||
|
.modal-footer(style="background-color: #2C3446")
|
||||||
|
|
||||||
|
|
||||||
|
button#sendData.btn.btn-primary(type='button',data-dismiss='modal') Mentés
|
||||||
|
button#fmodalClose.btn.btn-primary(type='button', data-dismiss='modal') Mégsem
|
||||||
|
|
||||||
|
script(src='/bower_components/jquery/dist/jquery.min.js')
|
||||||
|
//-script(src='/bower_components/bootstrap-validator/dist/validator.min.js')
|
||||||
|
script.
|
||||||
|
|
||||||
|
var workers=[]
|
||||||
|
var usedWorkers=[]
|
||||||
|
const form = document.getElementById('kabelform2');
|
||||||
|
function handleClick(identifier) {
|
||||||
|
const state=$(identifier).hasClass('active');
|
||||||
|
//const d=JSON.parse(decodeURIComponent($(identifier).data('item')))
|
||||||
|
const d=$(identifier).data('id')
|
||||||
|
const name=$(identifier).data('name')
|
||||||
|
if (!state)
|
||||||
|
{
|
||||||
|
workers.push({employeeId:d, name:name});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
workers=workers.filter(obj=>obj.employeeId!==d);
|
||||||
|
}
|
||||||
|
if (workers.length)
|
||||||
|
{
|
||||||
|
document.getElementById("sendData").disabled=false
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
document.getElementById("sendData").disabled=true
|
||||||
|
}
|
||||||
|
$('#arc').text(JSON.stringify(workers))
|
||||||
|
}
|
||||||
|
function textChanged(){
|
||||||
|
var length=document.getElementById("workFlow").value.length
|
||||||
|
if (length>3)
|
||||||
|
{
|
||||||
|
let divElement = document.getElementById("buttons2");
|
||||||
|
$.each(divElement.children,function(i,item){
|
||||||
|
if (workers.some(item3 => item3.employeeId === item.id)){
|
||||||
|
item.classList.add("active")
|
||||||
|
}
|
||||||
|
if (usedWorkers.some(item2 => item2.employeeId === item.id)===false){
|
||||||
|
item.disabled=false
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
if (workers.length)
|
||||||
|
{
|
||||||
|
document.getElementById("sendData").disabled=false
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
let divElement = document.getElementById("buttons2");
|
||||||
|
$.each(divElement.children,function(i,item){
|
||||||
|
|
||||||
|
item.disabled=true
|
||||||
|
item.classList.remove("active")
|
||||||
|
})
|
||||||
|
workers=[]
|
||||||
|
document.getElementById("sendData").disabled=true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$(document).ready(function () {
|
||||||
|
var wid = document.getElementById ('wn').textContent;
|
||||||
|
var uid = document.getElementById ('uid').textContent;
|
||||||
|
var workFlowId=""
|
||||||
|
|
||||||
|
|
||||||
|
const title=document.getElementById ('wn').textContent;
|
||||||
|
document.getElementById("workFlow").onkeydown = function() {
|
||||||
|
textChanged();
|
||||||
|
};
|
||||||
|
$('#workFlow').change(function(event) {
|
||||||
|
//do stuff with the "event" object as the object that called the method
|
||||||
|
textChanged();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
document.getElementById('sendData').addEventListener('click', function(a) {
|
||||||
|
const workFlowTitle = document.getElementById('workFlow').value;
|
||||||
|
var dummy=document.getElementById('dummy').textContent
|
||||||
|
var t=JSON.parse(dummy);
|
||||||
|
//let result = t.workFlow.find(obj => obj._id === workFlowId);
|
||||||
|
var foundIndex = t.workFlow.findIndex(x => x._id == workFlowId);
|
||||||
|
const workFlowItem=
|
||||||
|
{
|
||||||
|
Title : workFlowTitle,
|
||||||
|
employeeList: workers
|
||||||
|
}
|
||||||
|
t.workFlow[foundIndex].Title=workFlowTitle;
|
||||||
|
t.workFlow[foundIndex].employeeList=workers;
|
||||||
|
document.getElementById('dummy').textContent=JSON.stringify(t)
|
||||||
|
updateEditTable()
|
||||||
|
})
|
||||||
|
// Modal megjelenítése esemény
|
||||||
|
$(document).on('show.bs.modal','#workReportEditModal', function (event) {
|
||||||
|
form.reset();
|
||||||
|
document.getElementById("sendData").disabled=true
|
||||||
|
var dummy=document.getElementById('dummy').textContent
|
||||||
|
|
||||||
|
var button = $(event.relatedTarget); // button the triggered modal
|
||||||
|
workFlowId = button.data("rid"); //data-id of button which is equal to id (primary key) of person
|
||||||
|
|
||||||
|
|
||||||
|
var t=JSON.parse(dummy);
|
||||||
|
let result = t.workFlow.find(obj => obj._id === workFlowId);
|
||||||
|
document.getElementById("workFlow").value=result.Title
|
||||||
|
|
||||||
|
workers=[]
|
||||||
|
usedWorkers=[];
|
||||||
|
|
||||||
|
workers=result.employeeList;
|
||||||
|
|
||||||
|
|
||||||
|
$.each(t.workFlow,function(i,item){
|
||||||
|
if(item._id!=result._id)
|
||||||
|
{
|
||||||
|
var arr=usedWorkers
|
||||||
|
usedWorkers=[...arr,...item.employeeList]//.push(item.employeeList)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
let divElement = document.getElementById("buttons2");
|
||||||
|
while (divElement.firstChild) {
|
||||||
|
divElement.removeChild(divElement.firstChild);
|
||||||
|
}
|
||||||
|
// const title=document.getElementById ('headertitle').textContent;
|
||||||
|
|
||||||
|
//var foo = document.getElementById("buttons");
|
||||||
|
//Append the element in page (in span).
|
||||||
|
|
||||||
|
//Fetch workReport
|
||||||
|
|
||||||
|
fetch('/workreportUserList', {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
console.log(data)
|
||||||
|
$.each(data.users,function(i,item){
|
||||||
|
var data_str = encodeURIComponent(JSON.stringify(item));
|
||||||
|
$('<button class="btn btn-primary aaa" disabled onclick="handleClick(this)" id="'+item._id+'" data-item="'+data_str+'" data-name="'+item.name+'" data-id="'+item._id+'" style="width:150px;margin: 3px" data-toggle="button" type="button">'+item.name+'</button>').appendTo('#buttons2');
|
||||||
|
})
|
||||||
|
textChanged()
|
||||||
|
})
|
||||||
|
.catch(error => console.error('Error:', error));
|
||||||
|
})
|
||||||
|
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,238 @@
|
||||||
|
#workReportNewModal.modal(tabindex='-1', role='dialog', aria-labelledby='workReportNewModalLabel')
|
||||||
|
//-form(method='GET',id='holidayForm' action='/employee/holidays_byperson/')
|
||||||
|
style(type="text/css").
|
||||||
|
.aaa:active,
|
||||||
|
.aaa.active {
|
||||||
|
background: red !important;
|
||||||
|
box-shadow: none !important;
|
||||||
|
}
|
||||||
|
.modal-dialog(role='document', style='width:1000px;')
|
||||||
|
.modal-content
|
||||||
|
.modal-header#workReportNewHeader.bg-primary(style="background: Primary")
|
||||||
|
h4 #{workTitle}
|
||||||
|
.modal-body(style='background-color:#5f6b79')
|
||||||
|
|
||||||
|
form#kabelform2
|
||||||
|
#form-group
|
||||||
|
input#wn1(name='wn1',style='display:none')
|
||||||
|
input#userid(name='userid',style='display:none', value=user._id)
|
||||||
|
input#id(name='id',style='display:none')
|
||||||
|
input#modify(name='modify',style='display:none')
|
||||||
|
|
||||||
|
.row
|
||||||
|
.col-sm-12
|
||||||
|
label(for="workFlow",style='color: white') Munka leírása:
|
||||||
|
input.form-control(id='workFlow', name='workFlow', required, placeholder="Nevezze meg a munka folyamatot", minlength="6",type=text, autofocus, readonly=false,style='')
|
||||||
|
br
|
||||||
|
.row
|
||||||
|
.col-sm-12
|
||||||
|
#buttons(style="margin: 10px;")
|
||||||
|
|
||||||
|
h4#arc(style="display:none")
|
||||||
|
br
|
||||||
|
//button#submit.btn.btn-primary(type='submit' ) Rendben
|
||||||
|
|
||||||
|
.modal-footer(style="background-color: #2C3446")
|
||||||
|
|
||||||
|
|
||||||
|
button#sendData.btn.btn-primary(type='button',data-dismiss='modal') Mentés
|
||||||
|
button#fmodalClose.btn.btn-primary(type='button', data-dismiss='modal') Mégsem
|
||||||
|
|
||||||
|
script(src='/bower_components/jquery/dist/jquery.min.js')
|
||||||
|
//-script(src='/bower_components/bootstrap-validator/dist/validator.min.js')
|
||||||
|
script.
|
||||||
|
|
||||||
|
var workers=[]
|
||||||
|
var usedWorkers=[]
|
||||||
|
const form = document.getElementById('kabelform2');
|
||||||
|
function handleClick(identifier) {
|
||||||
|
const state=$(identifier).hasClass('active');
|
||||||
|
//const d=JSON.parse(decodeURIComponent($(identifier).data('item')))
|
||||||
|
const d=$(identifier).data('id')
|
||||||
|
const name=$(identifier).data('name')
|
||||||
|
if (!state)
|
||||||
|
{
|
||||||
|
workers.push({employeeId:d, name:name});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
workers=workers.filter(obj=>obj.employeeId!==d);
|
||||||
|
}
|
||||||
|
if (workers.length)
|
||||||
|
{
|
||||||
|
document.getElementById("sendData").disabled=false
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
document.getElementById("sendData").disabled=true
|
||||||
|
}
|
||||||
|
$('#arc').text(JSON.stringify(workers))
|
||||||
|
}
|
||||||
|
function textChanged(){
|
||||||
|
var length=document.getElementById("workFlow").value.length
|
||||||
|
if (length>3)
|
||||||
|
{
|
||||||
|
let divElement = document.getElementById("buttons");
|
||||||
|
$.each(divElement.children,function(i,item){
|
||||||
|
|
||||||
|
if (usedWorkers.some(item2 => item2.employeeId === item.id)===false){
|
||||||
|
item.disabled=false
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
if (workers.length)
|
||||||
|
{
|
||||||
|
document.getElementById("sendData").disabled=false
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
let divElement = document.getElementById("buttons");
|
||||||
|
$.each(divElement.children,function(i,item){
|
||||||
|
|
||||||
|
item.disabled=true
|
||||||
|
item.classList.remove("active")
|
||||||
|
})
|
||||||
|
workers=[]
|
||||||
|
document.getElementById("sendData").disabled=true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$(document).ready(function () {
|
||||||
|
var wid = document.getElementById ('wn').textContent;
|
||||||
|
var uid = document.getElementById ('uid').textContent;
|
||||||
|
var selectedDate="";
|
||||||
|
const title=document.getElementById ('wn').textContent;
|
||||||
|
document.getElementById("workFlow").onkeydown = function() {
|
||||||
|
textChanged();
|
||||||
|
};
|
||||||
|
$('#workFlow').change(function(event) {
|
||||||
|
//do stuff with the "event" object as the object that called the method
|
||||||
|
textChanged();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
document.getElementById('sendData').addEventListener('click', function(a) {
|
||||||
|
const workFlowTitle = document.getElementById('workFlow').value;
|
||||||
|
var dummy=document.getElementById('dummy').textContent
|
||||||
|
var t=JSON.parse(dummy);
|
||||||
|
const workFlowItem=
|
||||||
|
{
|
||||||
|
Title : workFlowTitle,
|
||||||
|
employeeList: workers
|
||||||
|
}
|
||||||
|
t.workFlow.push(workFlowItem)
|
||||||
|
document.getElementById('dummy').textContent=JSON.stringify(t)
|
||||||
|
/* {
|
||||||
|
// Napi jelentés
|
||||||
|
workId:1,
|
||||||
|
date: {type: Date},
|
||||||
|
foremanId: {type: String},
|
||||||
|
workTitle: {type: String},
|
||||||
|
workFlow: [{
|
||||||
|
Title: {type: String},
|
||||||
|
employeeList:[{
|
||||||
|
id:{type: mongoose.Schema.Types.ObjectId},
|
||||||
|
name: {type: String},
|
||||||
|
}]
|
||||||
|
}],
|
||||||
|
}*/
|
||||||
|
/* if(selectedDate.length)
|
||||||
|
{
|
||||||
|
Swal.fire('Error', '', 'error')
|
||||||
|
}
|
||||||
|
$.each(workers,function(i,w){
|
||||||
|
w.workFlow=workFlow
|
||||||
|
})
|
||||||
|
var dataa={
|
||||||
|
date: selectedDate,
|
||||||
|
workId:wid,
|
||||||
|
foremanId:uid,
|
||||||
|
workTitle:title,
|
||||||
|
employeeList:workers
|
||||||
|
}
|
||||||
|
const response = fetch('/workreport', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(dataa)
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
//console.log(data)
|
||||||
|
if (!data.response.ok)
|
||||||
|
{
|
||||||
|
Swal.fire('Error', '', 'error')
|
||||||
|
}
|
||||||
|
if (data.response="ok")
|
||||||
|
{
|
||||||
|
Swal.fire({
|
||||||
|
position: "top-end",
|
||||||
|
icon: "success",
|
||||||
|
title: data.message,
|
||||||
|
showConfirmButton: false,
|
||||||
|
timer: 1500,
|
||||||
|
backdrop: false
|
||||||
|
});
|
||||||
|
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
Swal.fire({
|
||||||
|
position: "top-end",
|
||||||
|
icon: "error",
|
||||||
|
title: data.message,
|
||||||
|
showConfirmButton: false,
|
||||||
|
timer: 1500,
|
||||||
|
backdrop: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$('#workReportNewModal').modal('hide');//.modal('toggle');
|
||||||
|
$('.modal').removeClass('in');
|
||||||
|
$('.modal').attr("aria-hidden","true");
|
||||||
|
$('.modal').css("display", "none");
|
||||||
|
$('.modal-backdrop').remove();
|
||||||
|
$('body').removeClass('modal-open');
|
||||||
|
$('.modal-backdrop').remove()
|
||||||
|
})
|
||||||
|
.catch(error => console.error('Error:', error)); */
|
||||||
|
})
|
||||||
|
|
||||||
|
// Modal megjelenítése esemény
|
||||||
|
$(document).on('show.bs.modal','#workReportNewModal', function () {
|
||||||
|
document.getElementById("sendData").disabled=true
|
||||||
|
var dummy=document.getElementById('dummy').textContent
|
||||||
|
var t=JSON.parse(dummy);
|
||||||
|
$.each(t.workFlow,function(i,item){
|
||||||
|
var arr=usedWorkers
|
||||||
|
usedWorkers=[...arr,...item.employeeList]//.push(item.employeeList)
|
||||||
|
})
|
||||||
|
form.reset();
|
||||||
|
let divElement = document.getElementById("buttons");
|
||||||
|
while (divElement.firstChild) {
|
||||||
|
divElement.removeChild(divElement.firstChild);
|
||||||
|
}
|
||||||
|
// const title=document.getElementById ('headertitle').textContent;
|
||||||
|
|
||||||
|
//var foo = document.getElementById("buttons");
|
||||||
|
//Append the element in page (in span).
|
||||||
|
|
||||||
|
//Fetch workReport
|
||||||
|
|
||||||
|
fetch('/workreportUserList', {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
console.log(data)
|
||||||
|
$.each(data.users,function(i,item){
|
||||||
|
var data_str = encodeURIComponent(JSON.stringify(item));
|
||||||
|
$('<button class="btn btn-primary aaa" disabled onclick="handleClick(this)" id="'+item._id+'"data-item="'+data_str+'" data-name="'+item.name+'" data-id="'+item._id+'" style="width:150px;margin: 3px" data-toggle="button" type="button">'+item.name+'</button>').appendTo('#buttons');
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch(error => console.error('Error:', error));
|
||||||
|
})
|
||||||
|
|
||||||
|
});
|
||||||
|
|
@ -98,6 +98,7 @@ block content
|
||||||
a.btn.btn-success.col-sm-1(href='/')
|
a.btn.btn-success.col-sm-1(href='/')
|
||||||
i.fa.fa-home.fa-lg.fa-fw
|
i.fa.fa-home.fa-lg.fa-fw
|
||||||
| Vissza
|
| Vissza
|
||||||
|
|
||||||
br
|
br
|
||||||
//-a(href='http://localhost/work/generateXML/634fdcc026d48a5c353a3e8d/63bd6a7d38a2c0150522567e')
|
//-a(href='http://localhost/work/generateXML/634fdcc026d48a5c353a3e8d/63bd6a7d38a2c0150522567e')
|
||||||
span.glyphicon.glyphicon-download
|
span.glyphicon.glyphicon-download
|
||||||
|
|
@ -166,7 +167,7 @@ block content
|
||||||
//-button.btn.btn-primary(id=report._id,form="myForm",type='submit',formaction='/work/generateXML/'+work._id+'/'+report._id, value='enaplo',tabindex='56')
|
//-button.btn.btn-primary(id=report._id,form="myForm",type='submit',formaction='/work/generateXML/'+work._id+'/'+report._id, value='enaplo',tabindex='56')
|
||||||
//-button.btn.btn-secondary.button-spacer(id=report._id,form="myForm", data-wid=work._id,data-rid=report._id, type='submit')
|
//-button.btn.btn-secondary.button-spacer(id=report._id,form="myForm", data-wid=work._id,data-rid=report._id, type='submit')
|
||||||
br
|
br
|
||||||
.panel.panel-primary( data-toggle="collapse")
|
.panel.panel-warning
|
||||||
.panel-heading
|
.panel-heading
|
||||||
.row
|
.row
|
||||||
.col-md-9
|
.col-md-9
|
||||||
|
|
@ -177,31 +178,33 @@ block content
|
||||||
span.pull-right.clickable
|
span.pull-right.clickable
|
||||||
i.glyphicon.glyphicon-chevron-up
|
i.glyphicon.glyphicon-chevron-up
|
||||||
|
|
||||||
#collapsePanel.panel-body
|
.panel-body
|
||||||
form#form-1
|
|
||||||
.row
|
.row
|
||||||
.table-responsive
|
.table-responsive
|
||||||
table#workReportTable.table.table-striped
|
table#workReportTable2.table.table-striped
|
||||||
col(width='5%')
|
-//col(width='5%')
|
||||||
col(width='10%')
|
col(width='10%')
|
||||||
col(width='15%')
|
|
||||||
col(width='auto')
|
col(width='auto')
|
||||||
if (work.enaploTemplate)
|
col(width='15%')
|
||||||
col(width='5%')
|
|
||||||
thead
|
thead
|
||||||
tr
|
tr
|
||||||
th #
|
-//th #
|
||||||
th(style='text-align:left') Dátum
|
th(style='text-align:left') Dátum
|
||||||
th(style='text-align:left') Résztvevők
|
|
||||||
th(style='text-align:left') Munkavégzés leírása
|
th(style='text-align:left') Munkavégzés leírása
|
||||||
|
th(style='text-align:left') Résztvevők
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
tbody
|
tbody
|
||||||
|
|
||||||
.panel-footer
|
.panel-footer
|
||||||
.btn-toolbar
|
.btn-toolbar
|
||||||
if(user.canAdd.device)
|
if(user.canAdd.device)
|
||||||
button.btn.btn-primary(data-toggle='modal', data-wn=work._id,data-title=work.title, data-target='#workReportModal',data-headertitle='Műhely munkavégzés',type='button')
|
button.btn.btn-default(data-toggle='modal', disabled data-wn=work._id,data-title=work.title, data-target='#workReportModal',data-headertitle='Műhely munkavégzés',type='button')
|
||||||
|
i.fa.fa-plus.fa-lg.fa-fw
|
||||||
|
| Bejegyzés hozzáadása
|
||||||
|
a.btn.btn-primary(href='/workReport/new/'+work._id)
|
||||||
i.fa.fa-plus.fa-lg.fa-fw
|
i.fa.fa-plus.fa-lg.fa-fw
|
||||||
| Bejegyzés hozzáadása
|
| Bejegyzés hozzáadása
|
||||||
|
|
||||||
|
|
@ -243,19 +246,82 @@ block content
|
||||||
a.btn.btn-success.col-sm-2(href='/')
|
a.btn.btn-success.col-sm-2(href='/')
|
||||||
i.fa.fa-home.fa-lg.fa-fw
|
i.fa.fa-home.fa-lg.fa-fw
|
||||||
| Vissza
|
| Vissza
|
||||||
|
|
||||||
script(src='/bower_components/jquery/dist/jquery.js')
|
script(src='/bower_components/jquery/dist/jquery.js')
|
||||||
script(src='/js/work_utils.js')
|
script(src='/js/work_utils.js')
|
||||||
script(type='text/javascript', src='/bower_components/moment/min/moment.min.js')
|
script(type='text/javascript', src='/bower_components/moment/min/moment.min.js')
|
||||||
|
script(src='/bower_components/moment/min/moment-with-locales.js')
|
||||||
script(type='text/javascript',src='/build/pdfmake.js')
|
script(type='text/javascript',src='/build/pdfmake.js')
|
||||||
script(type='text/javascript',src='/build/vfs_fonts.js')
|
script(type='text/javascript',src='/build/vfs_fonts.js')
|
||||||
script(src='https://unpkg.com/lightpick@latest/lightpick.js')
|
script(src='https://unpkg.com/lightpick@latest/lightpick.js')
|
||||||
script(src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/11.14.2/sweetalert2.min.js" integrity="sha512-nD7/PXl2UD6bAYMJVKTLhr7qwnWVvoyqk8/WMzedDKMiQbaNXT3EUPzLYbLUHCLWqAZoXO37aVCtCKmAxZfqGw==" crossorigin="anonymous" referrerpolicy="no-referrer")
|
script(src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/11.14.2/sweetalert2.min.js" integrity="sha512-nD7/PXl2UD6bAYMJVKTLhr7qwnWVvoyqk8/WMzedDKMiQbaNXT3EUPzLYbLUHCLWqAZoXO37aVCtCKmAxZfqGw==" crossorigin="anonymous" referrerpolicy="no-referrer")
|
||||||
script.
|
script.
|
||||||
$(document).ready(function () {
|
|
||||||
|
|
||||||
|
function getEmployeeList(wf)
|
||||||
|
{
|
||||||
|
var elist=""
|
||||||
|
$.each(wf.employeeList,function(i,el){
|
||||||
|
elist+=el.name+'<br>'
|
||||||
|
});
|
||||||
|
return elist;
|
||||||
|
}
|
||||||
|
function editReport(b){
|
||||||
|
var wid = document.getElementById ('wn').textContent;
|
||||||
|
location.href = '/workReport/edit/'+wid+'/'+b.getAttribute('data-id');
|
||||||
|
console.log(b.getAttribute('data-id'))
|
||||||
|
}
|
||||||
|
$(document).ready(function () {
|
||||||
|
moment.locale('HU')
|
||||||
//Fetch workReport
|
//Fetch workReport
|
||||||
var wid = document.getElementById ('wn').textContent;
|
var wid = document.getElementById ('wn').textContent;
|
||||||
fetch('/workreportList/'+wid, {
|
fetch('/workreport/'+wid, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
console.log(data)
|
||||||
|
//var t=data.reports[0];
|
||||||
|
var newRow= ""
|
||||||
|
|
||||||
|
$.each(data.reports,function(ix,t){
|
||||||
|
newRow= `<tr><td rowspan=${t.workFlow.length}>
|
||||||
|
<div class="row" style="margin-left: 3px">
|
||||||
|
${moment(t.date).format("YYYY.MM.DD")}
|
||||||
|
</div>
|
||||||
|
<div class="row" style="margin-left: 3px">
|
||||||
|
${moment(t.date).format("dddd")}
|
||||||
|
</div>
|
||||||
|
<div class="row justify-content-center" style="margin-left: 3px">
|
||||||
|
<button type="button" class="btn btn-primary btn-sm" style="margin-left: 4px" data-id=${t._id} onclick="editReport(this);">
|
||||||
|
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</td>`
|
||||||
|
$.each(t.workFlow,function(i,item){
|
||||||
|
|
||||||
|
//newRow+= `<tr>` +
|
||||||
|
|
||||||
|
newRow+= `<td>${item.Title}</td><td>`
|
||||||
|
|
||||||
|
$.each(item.employeeList,function(idx,employee){
|
||||||
|
newRow+=employee.name+'<br>'
|
||||||
|
})
|
||||||
|
newRow+= `</td>`
|
||||||
|
newRow+= `</tr>`
|
||||||
|
})
|
||||||
|
//newRow+= `<td rowspan=${t.workFlow.length}>12</td></tr>`
|
||||||
|
$('#workReportTable2 > tbody:last-child').append (newRow);
|
||||||
|
})
|
||||||
|
//$('#workReportTable > tbody:last-child').append (newRow);
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
.catch(error => console.error('Error:', error));
|
||||||
|
/*fetch('/workreportList/'+wid, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|
@ -286,7 +352,7 @@ block content
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(error => console.error('Error:', error));
|
.catch(error => console.error('Error:', error));
|
||||||
|
*/
|
||||||
|
|
||||||
document.getElementById('enaploImp').addEventListener('change', readFile, false);
|
document.getElementById('enaploImp').addEventListener('change', readFile, false);
|
||||||
/* var entemplate = document.getElementById ('entemp').textContent;
|
/* var entemplate = document.getElementById ('entemp').textContent;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,179 @@
|
||||||
|
extends layout
|
||||||
|
|
||||||
|
block content
|
||||||
|
.container
|
||||||
|
link(rel='stylesheet' href='/bower_components/bootstrap/dist/css/bootstrap.css')
|
||||||
|
link(href='//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css', rel='stylesheet')
|
||||||
|
link(rel='stylesheet', type='text/css', href='https://unpkg.com/lightpick@latest/css/lightpick.css')
|
||||||
|
link(rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/11.14.2/sweetalert2.css" integrity="sha512-TG239kA30BXeGpy+HpJei+qfJcKo8V9HKpe8UWuVdpk49NGUe86EDhmdXkCxMqD5gSlkLLi6YQ9SbNp+yRa9xQ==" crossorigin="anonymous" referrerpolicy="no-referrer")
|
||||||
|
include Modals/modal_workReportEdit
|
||||||
|
style(type="text/css").
|
||||||
|
|
||||||
|
|
||||||
|
.clickable{
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.vcenter {
|
||||||
|
text-align: center;
|
||||||
|
align-content: center;
|
||||||
|
}
|
||||||
|
h4#dummy(style="display:none") #{report}
|
||||||
|
#form-group
|
||||||
|
-//form(id="myForm",name="myForm")
|
||||||
|
.panel.panel-warning
|
||||||
|
.panel-heading
|
||||||
|
.row
|
||||||
|
.col-md-9
|
||||||
|
h4 #{title}
|
||||||
|
h5#wn #{workTitle}
|
||||||
|
h6#wid(style="display:none") #{workId}
|
||||||
|
h6#uid(style="display:none") #{user._id}
|
||||||
|
|
||||||
|
.panel-body
|
||||||
|
form#form-1
|
||||||
|
.row
|
||||||
|
.table-responsive
|
||||||
|
table#workReportTableEdit.table.table-striped
|
||||||
|
|
||||||
|
col(width='5%')
|
||||||
|
col(width='auto')
|
||||||
|
col(width='15%')
|
||||||
|
col(width='15%')
|
||||||
|
thead
|
||||||
|
tr
|
||||||
|
|
||||||
|
th(style='text-align:left') #
|
||||||
|
th(style='text-align:left') Munkavégzés leírása
|
||||||
|
th(style='text-align:left') Résztvevők
|
||||||
|
th(style='text-align:center') Művelet
|
||||||
|
|
||||||
|
|
||||||
|
tbody
|
||||||
|
.panel-footer
|
||||||
|
.col-sm-3
|
||||||
|
.input-group
|
||||||
|
span#basic-addon1.input-group-addon
|
||||||
|
i.fa.fa-calendar.fa-lg.fa-fw
|
||||||
|
input.form-control( readonly, placeholder="Válasszon dátumot!", id='dpEditWorkReport', type=text)
|
||||||
|
|
||||||
|
|
||||||
|
.btn-toolbar
|
||||||
|
|
||||||
|
//button.btn.btn-primary(data-toggle='modal', data-wn=workId,data-title=workTitle, data-target='#workReportNewModal',data-headertitle='Műhely munkavégzés',type='button')
|
||||||
|
i.fa.fa-plus.fa-lg.fa-fw
|
||||||
|
| Bejegyzés hozzáadása
|
||||||
|
button#btnSave2.btn.btn-primary(data-toggle='modal', disabled, type='button')
|
||||||
|
i.fa.fa-save.fa-lg.fa-fw
|
||||||
|
| Mentés
|
||||||
|
a.btn.btn-success(href='/work/'+workId)
|
||||||
|
i.fa.fa-home.fa-lg.fa-fw
|
||||||
|
| Vissza
|
||||||
|
br
|
||||||
|
|
||||||
|
script(src='/bower_components/jquery/dist/jquery.js')
|
||||||
|
script(src='/js/work_utils.js')
|
||||||
|
script(type='text/javascript', src='/bower_components/moment/min/moment.min.js')
|
||||||
|
script(type='text/javascript',src='/build/pdfmake.js')
|
||||||
|
script(type='text/javascript',src='/build/vfs_fonts.js')
|
||||||
|
script(src='https://unpkg.com/lightpick@latest/lightpick.js')
|
||||||
|
script(src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/11.14.2/sweetalert2.min.js" integrity="sha512-nD7/PXl2UD6bAYMJVKTLhr7qwnWVvoyqk8/WMzedDKMiQbaNXT3EUPzLYbLUHCLWqAZoXO37aVCtCKmAxZfqGw==" crossorigin="anonymous" referrerpolicy="no-referrer")
|
||||||
|
script.
|
||||||
|
function updateEditTable()
|
||||||
|
{
|
||||||
|
var wn = document.getElementById ('wn').textContent;
|
||||||
|
var wid = document.getElementById ('wid').textContent;
|
||||||
|
var uid = document.getElementById ('uid').textContent;
|
||||||
|
|
||||||
|
$('#workReportTableEdit > tbody:last-child').empty();
|
||||||
|
var dummy=document.getElementById('dummy').textContent
|
||||||
|
|
||||||
|
var t=JSON.parse(dummy);
|
||||||
|
document.getElementById ('dpEditWorkReport').value=moment(t.date).format("YYYY.MM.DD");
|
||||||
|
$.each(t.workFlow,function(i,item){
|
||||||
|
var newRow= ""
|
||||||
|
const rows=item.employeeList.length
|
||||||
|
newRow= `<tr>` +
|
||||||
|
`<td rowspan="${rows}">${i}</td>`+
|
||||||
|
`<td rowspan="${rows}" >${item.Title}</td>`
|
||||||
|
$.each(item.employeeList,function(idx,employee){
|
||||||
|
|
||||||
|
|
||||||
|
if (idx==0){
|
||||||
|
newRow+=`<td>${employee.name}</td>`+
|
||||||
|
`<td rowspan="${rows}" class="vcenter"><button class="btn btn-success" data-rid='${item._id}' data-toggle='modal' type='button' data-target='#workReportEditModal'>Szerkeszt</button></td>`
|
||||||
|
newRow+= `</tr>`
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
newRow+=`<tr><td>${employee.name}</td></tr>`//+
|
||||||
|
//`<td><button>Edit</button></td></tr>`
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
$('#workReportTableEdit > tbody:last-child').append (newRow);
|
||||||
|
})
|
||||||
|
if (document.getElementById('dummy').textContent.length && document.getElementById('dpEditWorkReport').value.length)
|
||||||
|
{
|
||||||
|
document.getElementById('btnSave2').disabled=false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$(document).ready(function () {
|
||||||
|
//var dummy=document.getElementById('dummy').textContent
|
||||||
|
|
||||||
|
updateEditTable()
|
||||||
|
document.getElementById('btnSave2').addEventListener('click', function(a) {
|
||||||
|
const da=JSON.parse(document.getElementById('dummy').textContent)
|
||||||
|
|
||||||
|
if (!da.workFlow.length)
|
||||||
|
{
|
||||||
|
alert("Adjon hozzá valamit!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
console.log(da)
|
||||||
|
|
||||||
|
// Adatok mentése szerverre
|
||||||
|
const response = fetch('/workreportUpdate', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({workReport:da})
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
//console.log(data)
|
||||||
|
if (!data.response.ok)
|
||||||
|
{
|
||||||
|
Swal.fire('Error', '', 'error')
|
||||||
|
}
|
||||||
|
if (data.response="ok")
|
||||||
|
{
|
||||||
|
Swal.fire({
|
||||||
|
position: "top-end",
|
||||||
|
icon: "success",
|
||||||
|
title: data.message,
|
||||||
|
showConfirmButton: false,
|
||||||
|
timer: 1500,
|
||||||
|
backdrop: false
|
||||||
|
});
|
||||||
|
window.location.href = "/work/"+da.workId;
|
||||||
|
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
Swal.fire({
|
||||||
|
position: "top-end",
|
||||||
|
icon: "error",
|
||||||
|
title: data.message,
|
||||||
|
showConfirmButton: false,
|
||||||
|
timer: 1500,
|
||||||
|
backdrop: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
.catch(error => console.error('Error:', error));
|
||||||
|
});
|
||||||
|
|
||||||
|
})
|
||||||
|
|
@ -0,0 +1,203 @@
|
||||||
|
extends layout
|
||||||
|
|
||||||
|
block content
|
||||||
|
.container
|
||||||
|
link(rel='stylesheet' href='/bower_components/bootstrap/dist/css/bootstrap.css')
|
||||||
|
link(href='//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css', rel='stylesheet')
|
||||||
|
link(rel='stylesheet', type='text/css', href='https://unpkg.com/lightpick@latest/css/lightpick.css')
|
||||||
|
link(rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/11.14.2/sweetalert2.css" integrity="sha512-TG239kA30BXeGpy+HpJei+qfJcKo8V9HKpe8UWuVdpk49NGUe86EDhmdXkCxMqD5gSlkLLi6YQ9SbNp+yRa9xQ==" crossorigin="anonymous" referrerpolicy="no-referrer")
|
||||||
|
include Modals/modal_workReportNew
|
||||||
|
style(type="text/css").
|
||||||
|
|
||||||
|
|
||||||
|
.clickable{
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
h4#dummy(style="display:none")
|
||||||
|
#form-group
|
||||||
|
form(id="myForm",name="myForm",method='get', action='/work/generateXML/')
|
||||||
|
.panel.panel-warning
|
||||||
|
.panel-heading
|
||||||
|
.row
|
||||||
|
.col-md-9
|
||||||
|
h4 #{title}
|
||||||
|
h5#wn #{workTitle}
|
||||||
|
h6#wid(style="display:none") #{workId}
|
||||||
|
h6#uid(style="display:none") #{user._id}
|
||||||
|
h4#ddates(style="display:none") #{dates}
|
||||||
|
.panel-body
|
||||||
|
form#form-1
|
||||||
|
.row
|
||||||
|
.table-responsive
|
||||||
|
table#workReportTable.table.table-striped
|
||||||
|
|
||||||
|
col(width='5%')
|
||||||
|
col(width='auto')
|
||||||
|
col(width='15%')
|
||||||
|
col(width='15%')
|
||||||
|
thead
|
||||||
|
tr
|
||||||
|
|
||||||
|
th(style='text-align:left') #
|
||||||
|
th(style='text-align:left') Munkavégzés leírása
|
||||||
|
th(style='text-align:left') Résztvevők
|
||||||
|
th(style='text-align:left') Művelet
|
||||||
|
|
||||||
|
|
||||||
|
tbody
|
||||||
|
.panel-footer
|
||||||
|
.col-sm-3
|
||||||
|
.input-group
|
||||||
|
span#basic-addon1.input-group-addon
|
||||||
|
i.fa.fa-calendar.fa-lg.fa-fw
|
||||||
|
input.form-control( readonly, placeholder="Válasszon dátumot!", id='dpNewWorkReport', type=text)
|
||||||
|
|
||||||
|
|
||||||
|
.btn-toolbar
|
||||||
|
|
||||||
|
button.btn.btn-primary(data-toggle='modal', data-wn=workId,data-title=workTitle, data-target='#workReportNewModal',data-headertitle='Műhely munkavégzés',type='button')
|
||||||
|
i.fa.fa-plus.fa-lg.fa-fw
|
||||||
|
| Bejegyzés hozzáadása
|
||||||
|
button#btnSave.btn.btn-primary(data-toggle='modal', disabled, type='button')
|
||||||
|
i.fa.fa-save.fa-lg.fa-fw
|
||||||
|
| Mentés
|
||||||
|
a.btn.btn-success(href='/work/'+workId)
|
||||||
|
i.fa.fa-home.fa-lg.fa-fw
|
||||||
|
| Vissza
|
||||||
|
br
|
||||||
|
|
||||||
|
script(src='/bower_components/jquery/dist/jquery.js')
|
||||||
|
script(src='/js/work_utils.js')
|
||||||
|
script(type='text/javascript', src='/bower_components/moment/min/moment.min.js')
|
||||||
|
script(type='text/javascript',src='/build/pdfmake.js')
|
||||||
|
script(type='text/javascript',src='/build/vfs_fonts.js')
|
||||||
|
script(src='https://unpkg.com/lightpick@latest/lightpick.js')
|
||||||
|
script(src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/11.14.2/sweetalert2.min.js" integrity="sha512-nD7/PXl2UD6bAYMJVKTLhr7qwnWVvoyqk8/WMzedDKMiQbaNXT3EUPzLYbLUHCLWqAZoXO37aVCtCKmAxZfqGw==" crossorigin="anonymous" referrerpolicy="no-referrer")
|
||||||
|
script.
|
||||||
|
$(document).ready(function () {
|
||||||
|
//var dummy=document.getElementById('dummy').textContent
|
||||||
|
var wn = document.getElementById ('wn').textContent;
|
||||||
|
var wid = document.getElementById ('wid').textContent;
|
||||||
|
var uid = document.getElementById ('uid').textContent;
|
||||||
|
dummy= {
|
||||||
|
// Napi jelentés
|
||||||
|
workId:wid,
|
||||||
|
date: new Date(),
|
||||||
|
foremanId: uid,
|
||||||
|
workTitle: wn,
|
||||||
|
workFlow: [],
|
||||||
|
}
|
||||||
|
document.getElementById('dummy').textContent=JSON.stringify(dummy)
|
||||||
|
|
||||||
|
document.getElementById('sendData').addEventListener('click', function(a) {
|
||||||
|
console.log("Jacica")
|
||||||
|
var dummy=document.getElementById('dummy').textContent
|
||||||
|
var t=JSON.parse(dummy);
|
||||||
|
var newRow= ""
|
||||||
|
$.each(t.workFlow,function(i,item){
|
||||||
|
const rows=item.employeeList.length
|
||||||
|
newRow= `<tr>` +
|
||||||
|
`<td rowspan="${rows}">${i}</td>`+
|
||||||
|
`<td rowspan="${rows}" >${item.Title}</td>`
|
||||||
|
$.each(item.employeeList,function(idx,employee){
|
||||||
|
|
||||||
|
|
||||||
|
if (idx==0){
|
||||||
|
newRow+=`<td>${employee.name}</td>`+
|
||||||
|
`<td><button>Edit</button></td>`
|
||||||
|
newRow+= `</tr>`
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
newRow+=`<tr><td>${employee.name}</td>`+
|
||||||
|
`<td><button>Edit</button></td></tr>`
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
$('#workReportTable > tbody:last-child').append (newRow);
|
||||||
|
if (document.getElementById('dummy').textContent.length && document.getElementById('dpNewWorkReport').value.length)
|
||||||
|
{
|
||||||
|
document.getElementById('btnSave').disabled=false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
document.getElementById('btnSave').addEventListener('click', function(a) {
|
||||||
|
const da=JSON.parse(document.getElementById('dummy').textContent)
|
||||||
|
const dt=document.getElementById('dpNewWorkReport').value
|
||||||
|
if (!da.workFlow.length)
|
||||||
|
{
|
||||||
|
alert("Adjon hozzá valamit!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!dt.length)
|
||||||
|
{
|
||||||
|
alert("Válasszon Dátumot!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
da.date=dt
|
||||||
|
console.log(da)
|
||||||
|
|
||||||
|
// Adatok mentése szerverre
|
||||||
|
const response = fetch('/workreport', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(da)
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
//console.log(data)
|
||||||
|
if (!data.response.ok)
|
||||||
|
{
|
||||||
|
Swal.fire('Error', '', 'error')
|
||||||
|
}
|
||||||
|
if (data.response="ok")
|
||||||
|
{
|
||||||
|
Swal.fire({
|
||||||
|
position: "top-end",
|
||||||
|
icon: "success",
|
||||||
|
title: data.message,
|
||||||
|
showConfirmButton: false,
|
||||||
|
timer: 1500,
|
||||||
|
backdrop: false
|
||||||
|
});
|
||||||
|
window.location.href = "/work/"+da.workId;
|
||||||
|
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
Swal.fire({
|
||||||
|
position: "top-end",
|
||||||
|
icon: "error",
|
||||||
|
title: data.message,
|
||||||
|
showConfirmButton: false,
|
||||||
|
timer: 1500,
|
||||||
|
backdrop: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
.catch(error => console.error('Error:', error));
|
||||||
|
});
|
||||||
|
})
|
||||||
|
const dd=JSON.parse(document.getElementById('ddates').textContent)
|
||||||
|
var picker = new Lightpick({ field: document.getElementById('dpNewWorkReport'),
|
||||||
|
singleDate: true,
|
||||||
|
inline: false,
|
||||||
|
//numberOfColumns: 2,
|
||||||
|
//numberOfMonths: 2,
|
||||||
|
disableDates: dd,
|
||||||
|
format: 'YYYY.MM.DD',
|
||||||
|
disableWeekends: false,
|
||||||
|
maxDate: moment(),
|
||||||
|
onSelect: function(date){
|
||||||
|
selectedDate=date
|
||||||
|
const da=JSON.parse(document.getElementById('dummy').textContent).workFlow.length
|
||||||
|
|
||||||
|
if (da )
|
||||||
|
{
|
||||||
|
document.getElementById('btnSave').disabled=false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue