-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhoras_24x7.sh
More file actions
executable file
·74 lines (67 loc) · 1.84 KB
/
horas_24x7.sh
File metadata and controls
executable file
·74 lines (67 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
MES="$(date +%m)"
ANO="$(date +%Y)"
TIEMPOS_REALES=0
ODOO_STRING=""
USUARIO="acarreno"
last_inci=""
last_tiempo=0
# usage() { echo "Usage: $0 -m MONTH" }
# while getopts ":m" opt; do
# case $opt in
# m)
# if [ -z $opt ]; then
# usage
# exit 1
# else
# if [[ $opt =~ ^[0-9]+$ ]]; then
# MES=$opt
# else
# usage
# exit 1
# fi
# fi
# ;;
# \?)
# echo "Error"
# usage
# exit 1
# ;;
# esac
# done
if [ -z $1 ]; then
echo "Mes no recibido. Calculamos con el mes actual: $(date +%B)"
else
echo "Mes $1 recibido. Calculamos con el mes de $(date -d 2019-$1-01 +%B)"
MES=$1
fi
if [ -z $2 ]; then
echo "Año no recibido. Usamos el actual $(date +%Y)"
else
echo "Mes $2 recibido."
ANO=$2
fi
# Ultimo dia del mes
ULTIMO_DIA="$(cal $MES 2019 | awk 'NF {DAYS = $NF}; END {print DAYS}')"
for inci in $(mquery -C -B -p 24x7 -fu $USUARIO 01/$MES/$ANO $ULTIMO_DIA/$MES/$ANO); do
TAM="$(echo -n $ODOO_STRING | wc -c)"
if [ $TAM -eq 0 ]; then
ODOO_STRING=$inci
else
ODOO_STRING="$ODOO_STRING, $inci"
fi
for tiempo in $(mquery -C -v $inci | grep Nota | grep $USUARIO | awk '{print $12}'); do
# Solo mostramos si el tiempo es mayor que 0
if [ $(echo "$tiempo == 0" | bc -l) -ne 1 ]; then
TIEMPOS_REALES=$(echo -n $TIEMPOS_REALES+$tiempo)
echo $inci: $tiempo
fi
done
done
TIEMPOS_REALES=$(echo "$TIEMPOS_REALES" | bc)
TIEMPOS_MULTIPLO=$(echo "$TIEMPOS_REALES * 1.5" | bc)
echo "Tiempos reales: $TIEMPOS_REALES"
echo "Tiempos múltiplo: $TIEMPOS_MULTIPLO"
DIAS_TOTALES=$(echo "scale=2; $TIEMPOS_MULTIPLO / 8" | bc)
echo "Dias totales: $DIAS_TOTALES"
echo "Para Odoo: $ODOO_STRING"