Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
Asistencia
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Billy Larru
Asistencia
Commits
9a0af8e0
Commit
9a0af8e0
authored
Aug 27, 2018
by
Billy Larru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
proyectado de asistencia con array de promesas
parent
76bac4fb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
189 additions
and
195 deletions
+189
-195
general.js
src/main/webapp/js/general.js
+2
-1
proyectar_asistencia_policias.js
src/main/webapp/js/pages/proyectar_asistencia_policias.js
+187
-194
No files found.
src/main/webapp/js/general.js
View file @
9a0af8e0
...
@@ -27,6 +27,7 @@ const URI_POLICIAS_ASISTENCIA = "asistenciaPolicias";
...
@@ -27,6 +27,7 @@ const URI_POLICIAS_ASISTENCIA = "asistenciaPolicias";
const
URI_POLICIA_MONTOS_AMANECIDAS
=
"montoAmanecidas"
;
const
URI_POLICIA_MONTOS_AMANECIDAS
=
"montoAmanecidas"
;
const
URI_POLICIA_CONCEPTOSEDES
=
"conceptoSedes"
;
const
URI_POLICIA_CONCEPTOSEDES
=
"conceptoSedes"
;
const
URI_POLICIA_REPORTE_MONTOS
=
"reporteMontosPolicias"
;
const
URI_POLICIA_REPORTE_MONTOS
=
"reporteMontosPolicias"
;
const
URI_POLICIA_PROYECCION
=
"proyeccion"
;
//</editor-fold>
//</editor-fold>
...
@@ -302,7 +303,7 @@ data: [],
...
@@ -302,7 +303,7 @@ data: [],
classNameForDatatable
:
``
,
classNameForDatatable
:
``
,
footerFilter
:
false
,
footerFilter
:
false
,
highlighting
:
true
highlighting
:
true
})
=>
{
})
=>
{
let
data
=
jsonForDatatable
.
data
;
let
data
=
jsonForDatatable
.
data
;
let
columns
=
jsonForDatatable
.
columns
;
let
columns
=
jsonForDatatable
.
columns
;
let
columnDefs
=
jsonForDatatable
.
columns
;
let
columnDefs
=
jsonForDatatable
.
columns
;
...
...
src/main/webapp/js/pages/proyectar_asistencia_policias.js
View file @
9a0af8e0
...
@@ -5,250 +5,242 @@ let handsonTable;
...
@@ -5,250 +5,242 @@ let handsonTable;
const
TA_EDITOR_HORA
=
Handsontable
.
editors
.
TextEditor
.
prototype
.
extend
();
const
TA_EDITOR_HORA
=
Handsontable
.
editors
.
TextEditor
.
prototype
.
extend
();
TA_EDITOR_HORA
.
prototype
.
createElements
=
function
()
{
TA_EDITOR_HORA
.
prototype
.
createElements
=
function
()
{
Handsontable
.
editors
.
TextEditor
.
prototype
.
createElements
.
apply
(
this
,
arguments
);
Handsontable
.
editors
.
TextEditor
.
prototype
.
createElements
.
apply
(
this
,
arguments
);
// You need to require/import the "inputmask" library
// You need to require/import the "inputmask" library
var
im
=
new
Inputmask
(
'99:99'
);
var
im
=
new
Inputmask
(
'99:99'
);
// Create password input and update relevant properties
// Create password input and update relevant properties
this
.
TEXTAREA
=
document
.
createElement
(
'input'
);
this
.
TEXTAREA
=
document
.
createElement
(
'input'
);
this
.
TEXTAREA
.
setAttribute
(
'type'
,
'text'
);
this
.
TEXTAREA
.
setAttribute
(
'type'
,
'text'
);
this
.
TEXTAREA
.
className
=
'text'
;
this
.
TEXTAREA
.
className
=
'text'
;
im
.
mask
(
this
.
TEXTAREA
);
im
.
mask
(
this
.
TEXTAREA
);
this
.
textareaStyle
=
this
.
TEXTAREA
.
style
;
this
.
textareaStyle
=
this
.
TEXTAREA
.
style
;
this
.
textareaStyle
.
width
=
0
;
this
.
textareaStyle
.
width
=
0
;
this
.
textareaStyle
.
height
=
0
;
this
.
textareaStyle
.
height
=
0
;
// Replace textarea with password input
// Replace textarea with password input
Handsontable
.
dom
.
empty
(
this
.
TEXTAREA_PARENT
);
Handsontable
.
dom
.
empty
(
this
.
TEXTAREA_PARENT
);
this
.
TEXTAREA_PARENT
.
appendChild
(
this
.
TEXTAREA
);
this
.
TEXTAREA_PARENT
.
appendChild
(
this
.
TEXTAREA
);
};
};
function
listarSedes
(
selectorName
)
{
function
listarSedes
(
selectorName
)
{
ajaxWebService
.
get
(
URI_SEDES
).
then
((
result
)
=>
{
ajaxWebService
.
get
(
URI_SEDES
).
then
((
result
)
=>
{
let
sedes
=
result
.
data
;
let
sedes
=
result
.
data
;
sedes
=
_
.
orderBy
(
sedes
,
s
=>
s
.
descripcion
);
sedes
=
_
.
orderBy
(
sedes
,
s
=>
s
.
descripcion
);
listaSedes
=
_
.
map
(
sedes
,
s
=>
s
.
descripcion
);
listaSedes
=
_
.
map
(
sedes
,
s
=>
s
.
descripcion
);
let
html
=
`<option value="">[TODOS]</option>`
;
let
html
=
`<option value="">[TODOS]</option>`
;
sedes
.
forEach
(
sede
=>
html
+=
`<option value="
${
sede
.
codigo
}
">
${
sede
.
descripcion
}
</option>`
);
sedes
.
forEach
(
sede
=>
html
+=
`<option value="
${
sede
.
codigo
}
">
${
sede
.
descripcion
}
</option>`
);
$
(
`
${
selectorName
}
`
).
html
(
html
);
$
(
`
${
selectorName
}
`
).
html
(
html
);
$
(
'.select-search'
).
select2
();
$
(
'.select-search'
).
select2
();
});
});
}
}
function
listarPolicias
(
selectorName
)
{
function
listarPolicias
(
selectorName
)
{
ajaxWebService
.
get
(
URI_POLICIAS
).
then
((
result
)
=>
{
ajaxWebService
.
get
(
URI_POLICIAS
).
then
((
result
)
=>
{
let
policias
=
result
.
data
;
let
policias
=
result
.
data
;
policias
=
_
.
orderBy
(
policias
,
p
=>
p
.
nombres
);
policias
=
_
.
orderBy
(
policias
,
p
=>
p
.
nombres
);
let
html
=
`<option value="">[TODOS]</option>`
;
let
html
=
`<option value="">[TODOS]</option>`
;
policias
.
forEach
(
p
=>
html
+=
`<option documento_identidad="
${
p
.
dni
}
" value="
${
p
.
id
}
">
${
p
.
nombres
}
</option>`
);
policias
.
forEach
(
p
=>
html
+=
`<option documento_identidad="
${
p
.
dni
}
" value="
${
p
.
id
}
">
${
p
.
nombres
}
</option>`
);
$
(
`
${
selectorName
}
`
).
html
(
html
);
$
(
`
${
selectorName
}
`
).
html
(
html
);
$
(
'.select-search'
).
select2
();
$
(
'.select-search'
).
select2
();
});
});
}
}
function
defaultConfigHandsonTable
()
{
function
defaultConfigHandsonTable
()
{
let
container
=
document
.
getElementById
(
"tblProyectado"
);
let
container
=
document
.
getElementById
(
"tblProyectado"
);
handsonTable
=
new
Handsontable
(
container
,
{
handsonTable
=
new
Handsontable
(
container
,
{
data
:
[],
data
:
[],
stretchH
:
'all'
,
stretchH
:
'all'
,
rowHeaders
:
true
,
rowHeaders
:
true
,
colHeaders
:
[
'DNI'
,
'Apellidos y Nombres'
,
'Sede'
,
'Horario'
,
'Rol'
,
'Fecha Entrada'
,
'Hora entrada'
,
'Hora Salida'
,
'Fecha Salida'
],
colHeaders
:
[
'DNI'
,
'Apellidos y Nombres'
,
'Sede'
,
'Horario'
,
'Rol'
,
'Fecha Entrada'
,
'Hora entrada'
,
'Hora Salida'
,
'Fecha Salida'
],
columns
:
[{},
{},
{},
{},
{},
{},
{},
{},
{}]
columns
:
[{},
{},
{},
{},
{},
{},
{},
{},
{}]
});
});
}
}
function
mostrarVistaPrevia
()
{
function
mostrarVistaPrevia
()
{
ajaxWebService
.
get
(
URI_ROL_POLICIA
).
then
((
response
)
=>
{
ajaxWebService
.
get
(
URI_POLICIA_PROYECCION
).
then
((
response
)
=>
{
debugger
debugger
if
(
response
.
status
)
{
if
(
response
.
status
)
{
handsonTable
.
destroy
();
handsonTable
.
destroy
();
let
container
=
document
.
getElementById
(
"tblProyectado"
);
let
container
=
document
.
getElementById
(
"tblProyectado"
);
let
data
=
[];
handsonTable
=
new
Handsontable
(
container
,
{
response
.
data
.
forEach
(
rol
=>
{
data
:
response
.
data
,
rol
.
detalles_rol
stretchH
:
'all'
,
.
map
(
dr
=>
{
rowHeaders
:
true
,
dr
.
horario
=
`
${
dr
.
fecha_entrada
.
split
(
" "
)[
1
]}
-
${
dr
.
fecha_salida
.
split
(
" "
)[
1
]}
`
;
colHeaders
:
[
'DNI'
,
'Apellidos y Nombres'
,
'Sede'
,
'Horario'
,
'Rol'
,
'Fecha Entrada'
,
'Hora entrada'
,
'Hora Salida'
,
'Fecha Salida'
],
dr
.
fecha_entrada
=
dr
.
fecha_entrada
.
split
(
" "
)[
0
];
columns
:
[
dr
.
fecha_salida
=
dr
.
fecha_salida
.
split
(
" "
)[
0
];
{
dr
.
asistencia_entrada
=
dr
.
asistencia_entrada
===
null
?
""
:
dr
.
asistencia_entrada
.
split
(
" "
)[
1
];
data
:
"policia_dni"
,
dr
.
asistencia_salida
=
dr
.
asistencia_salida
===
null
?
""
:
dr
.
asistencia_salida
.
split
(
" "
)[
1
];
className
:
'text-center'
,
return
dr
;
readOnly
:
true
})
},
.
forEach
(
dr
=>
{
{
let
obj
=
{
"data"
:
"policia_nombres"
,
rol_id
:
rol
.
id
,
readOnly
:
true
detallerol_id
:
dr
.
id
,
},
policia_dni
:
rol
.
policia_dni
,
{
policia_nombres
:
rol
.
policia_nombres
,
"data"
:
"sede_descripcion"
,
fecha_entrada
:
dr
.
fecha_entrada
,
"className"
:
"text-center"
,
fecha_salida
:
dr
.
fecha_salida
,
sede_id
:
rol
.
sede_id
,
sede_descripcion
:
rol
.
sede_descripcion
,
horario
:
dr
.
horario
,
tiporol_descripcion
:
rol
.
tiporol_descripcion
,
marcacion_entrada
:
dr
.
asistencia_entrada
,
marcacion_salida
:
dr
.
asistencia_salida
};
data
.
push
(
obj
);
});
});
handsonTable
=
new
Handsontable
(
container
,
{
data
:
data
,
stretchH
:
'all'
,
rowHeaders
:
true
,
colHeaders
:
[
'DNI'
,
'Apellidos y Nombres'
,
'Sede'
,
'Horario'
,
'Rol'
,
'Fecha Entrada'
,
'Hora entrada'
,
'Hora Salida'
,
'Fecha Salida'
],
columns
:
[
{
data
:
"policia_dni"
,
className
:
'text-center'
,
readOnly
:
true
},
{
"data"
:
"policia_nombres"
,
readOnly
:
true
},
{
"data"
:
"sede_descripcion"
,
"className"
:
"text-center"
,
// editor: 'select',
// editor: 'select',
// selectOptions: sedes,
// selectOptions: sedes,
source
:
listaSedes
,
source
:
listaSedes
,
strict
:
true
,
strict
:
true
,
type
:
'autocomplete'
,
type
:
'autocomplete'
,
allowInvalid
:
false
allowInvalid
:
false
},
},
{
{
"data"
:
"horario"
,
"data"
:
"horario"
,
"className"
:
"text-center"
,
"className"
:
"text-center"
,
readOnly
:
true
readOnly
:
true
},
},
{
{
"data"
:
"tiporol_descripcion"
,
"data"
:
"tiporol_descripcion"
,
"className"
:
"text-center"
,
"className"
:
"text-center"
,
readOnly
:
true
readOnly
:
true
},
},
{
{
"data"
:
"fecha_entrada"
,
"data"
:
"fecha_entrada"
,
"className"
:
'text-center'
,
"className"
:
'text-center'
,
type
:
'date'
,
type
:
'date'
,
dateFormat
:
'DD/MM/YYYY'
,
dateFormat
:
'DD/MM/YYYY'
,
readOnly
:
true
readOnly
:
true
},
},
{
{
data
:
"marcacion
_entrada"
,
data
:
"asistencia
_entrada"
,
className
:
'text-center'
,
className
:
'text-center'
,
editor
:
TA_EDITOR_HORA
,
editor
:
TA_EDITOR_HORA
,
type
:
'time'
,
type
:
'time'
,
timeFormat
:
'HH:mm'
,
timeFormat
:
'HH:mm'
,
correctFormat
:
true
,
correctFormat
:
true
,
allowInvalid
:
false
allowInvalid
:
false
},
},
{
{
data
:
"marcacion
_salida"
,
data
:
"asistencia
_salida"
,
className
:
'text-center'
,
className
:
'text-center'
,
timeFormat
:
'HH:mm'
,
timeFormat
:
'HH:mm'
,
editor
:
TA_EDITOR_HORA
,
editor
:
TA_EDITOR_HORA
,
type
:
'time'
,
type
:
'time'
,
correctFormat
:
true
,
correctFormat
:
true
,
allowInvalid
:
false
,
allowInvalid
:
false
,
},
},
{
{
data
:
"fecha_salida"
,
data
:
"fecha_salida"
,
className
:
'text-center'
,
className
:
'text-center'
,
type
:
'date'
,
type
:
'date'
,
dateFormat
:
'DD/MM/YYYY'
,
dateFormat
:
'DD/MM/YYYY'
,
readOnly
:
true
readOnly
:
true
}
}
],
],
// afterChange: (change, source) => {
// afterChange: (change, source) => {
// console.log(`change= ${change}, source=${source}`);
// console.log(`change= ${change}, source=${source}`);
// }
// }
});
});
registrarEventoTab
();
registrarEventoTab
();
}
}
});
});
}
}
function
registrarEventoTab
()
{
function
registrarEventoTab
()
{
Handsontable
.
Dom
.
addEvent
(
document
.
body
,
'keydown'
,
function
(
e
)
{
Handsontable
.
Dom
.
addEvent
(
document
.
body
,
'keydown'
,
function
(
e
)
{
if
(
e
.
keyCode
===
9
&&
handsonTable
)
{
if
(
e
.
keyCode
===
9
&&
handsonTable
)
{
e
.
stopPropagation
();
e
.
stopPropagation
();
var
selection
=
handsonTable
.
getSelected
();
var
selection
=
handsonTable
.
getSelected
();
var
rowIndex
=
selection
[
0
];
var
rowIndex
=
selection
[
0
];
var
colIndex
=
selection
[
1
];
var
colIndex
=
selection
[
1
];
// console.log(`row=${rowIndex}, col=${colIndex}`)
// console.log(`row=${rowIndex}, col=${colIndex}`)
//rowIndex++;
//rowIndex++;
colIndex
++
;
colIndex
++
;
if
(
colIndex
>
7
)
{
if
(
colIndex
>
7
)
{
rowIndex
++
;
rowIndex
++
;
colIndex
=
6
;
colIndex
=
6
;
}
else
if
(
colIndex
<
6
)
{
}
else
if
(
colIndex
<
6
)
{
colIndex
=
6
;
colIndex
=
6
;
}
}
handsonTable
.
selectCell
(
rowIndex
,
colIndex
);
handsonTable
.
selectCell
(
rowIndex
,
colIndex
);
}
}
});
});
}
}
function
guardarCambios
()
{
function
guardarCambios
()
{
let
data
=
handsonTable
.
getSourceData
();
let
data
=
handsonTable
.
getSourceData
();
let
dataRequest
=
data
.
map
(
d
=>
{
return
{
id
:
d
.
id
,
sede_descripcion
:
d
.
sede_descripcion
,
asistencia_entrada
:
d
.
asistencia_entrada
,
asistencia_salida
:
d
.
asistencia_salida
}
});
let
promises
=
[]
dataRequest
.
forEach
(
d
=>
{
promises
.
push
(
ajaxWebService
.
patch
(
`
${
URI_POLICIA_PROYECCION
}
/
${
d
.
id
}
`
,
d
))
});
axios
.
all
(
promises
)
.
then
(
axios
.
spread
(
function
(
acct
,
perms
)
{
debugger
}));
// ajaxWebService.patch(URI_POLICIA_PROYECCION, dataRequest).then((response) => {
//
// });
}
}
$
().
ready
(
function
()
{
$
().
ready
(
function
()
{
listarPolicias
(
"#cboPoliciasFiltro"
);
listarPolicias
(
"#cboPoliciasFiltro"
);
listarSedes
(
"#cboSedesFiltro"
);
listarSedes
(
"#cboSedesFiltro"
);
$
(
"#dpFechaInicio"
).
datepicker
({
$
(
"#dpFechaInicio"
).
datepicker
({
minDate
:
new
Date
(
2000
,
1
-
1
,
1
),
maxDate
:
new
Date
(),
minDate
:
new
Date
(
2000
,
1
-
1
,
1
),
maxDate
:
new
Date
(),
dateFormat
:
'dd/mm/yy'
,
dateFormat
:
'dd/mm/yy'
,
defaultDate
:
new
Date
(),
defaultDate
:
new
Date
(),
changeMonth
:
true
,
changeMonth
:
true
,
changeYear
:
true
,
changeYear
:
true
,
yearRange
:
'-18:+0'
,
yearRange
:
'-18:+0'
,
onSelect
:
function
()
{
onSelect
:
function
()
{
// $(this).valid();
// $(this).valid();
}
}
});
});
$
(
"#dpFechaInicio"
).
datepicker
(
'setDate'
,
'now'
);
$
(
"#dpFechaInicio"
).
datepicker
(
'setDate'
,
'now'
);
$
(
"#dpFechaFin"
).
datepicker
({
$
(
"#dpFechaFin"
).
datepicker
({
minDate
:
new
Date
(
2000
,
1
-
1
,
1
),
maxDate
:
new
Date
(),
minDate
:
new
Date
(
2000
,
1
-
1
,
1
),
maxDate
:
new
Date
(),
dateFormat
:
'dd/mm/yy'
,
dateFormat
:
'dd/mm/yy'
,
defaultDate
:
new
Date
(),
defaultDate
:
new
Date
(),
changeMonth
:
true
,
changeMonth
:
true
,
changeYear
:
true
,
changeYear
:
true
,
yearRange
:
'-18:+0'
,
yearRange
:
'-18:+0'
,
onSelect
:
function
()
{
onSelect
:
function
()
{
// $(this).valid();
// $(this).valid();
}
}
});
});
$
(
"#dpFechaFin"
).
datepicker
(
'setDate'
,
'now'
);
$
(
"#dpFechaFin"
).
datepicker
(
'setDate'
,
'now'
);
// defaultConfigDataTable();
// defaultConfigDataTable();
defaultConfigHandsonTable
();
defaultConfigHandsonTable
();
$
(
"#btnVistaPrevia"
).
click
(
mostrarVistaPrevia
);
$
(
"#btnVistaPrevia"
).
click
(
mostrarVistaPrevia
);
$
(
"#btnGuardarCambios"
).
click
(
guardarCambios
);
$
(
"#btnGuardarCambios"
).
click
(
guardarCambios
);
});
});
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment