dmencu 0.3.25 → 0.3.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,19 +16,22 @@ begin
16
16
  where operativo = new.operativo and enc = new.enc;
17
17
  select estado_al_asignar into v_estado_al_asignar from estados where operativo = new.operativo and estado = new.estado;
18
18
  if new.asignado is null then
19
- update tareas_tem
19
+ /*update tareas_tem
20
20
  set estado = '0D'
21
21
  where operativo = new.operativo and enc = new.enc and tarea = new.tarea;
22
+ */
22
23
  update tem
23
24
  set tarea_proxima = new.tarea, tarea_actual = new.tarea_anterior
24
25
  where operativo = new.operativo and enc = new.enc;
25
26
  else
26
27
  if v_tarea_actual is distinct from new.tarea then
27
- if v_estado_al_asignar is not null then
28
+ /*if v_estado_al_asignar is not null then
28
29
  update tareas_tem
29
30
  set estado = v_estado_al_asignar, tarea_anterior = v_tarea_actual
30
31
  where operativo = new.operativo and enc = new.enc and tarea = new.tarea;
32
+
31
33
  end if;
34
+ */
32
35
  update tem
33
36
  set tarea_actual = tarea_proxima, tarea_proxima = null
34
37
  where operativo = new.operativo and enc = new.enc;
@@ -0,0 +1,49 @@
1
+ --set role dmencu_owner;
2
+ --set search_path=base;
3
+ DROP FUNCTION if exists determinar_tarea_proxima_trg();
4
+ CREATE OR REPLACE FUNCTION determinar_tarea_proxima_trg()
5
+ RETURNS trigger
6
+ LANGUAGE 'plpgsql'
7
+ AS $BODY$
8
+ declare
9
+ v_tarea_actual text;
10
+ v_rea integer;
11
+ v_norea integer;
12
+ v_grupo0 text;
13
+ v_proxtarea text;
14
+ begin
15
+ select rea, norea, tarea_actual, grupo0 into v_rea, v_norea, v_tarea_actual, v_grupo0
16
+ from tem t
17
+ left join no_rea nr on nr.no_rea= norea::text
18
+ where operativo = new.operativo and enc = new.enc;
19
+ if new.verificado='1' then
20
+ if v_tarea_actual='encu' then
21
+ case when v_grupo0 in ('ausentes', 'rechazos') then
22
+ v_proxtarea='recu';
23
+ when v_grupo0 in ('no encuestable') then
24
+ v_proxtarea='supe';
25
+ else
26
+ v_proxtarea=null;
27
+ end case;
28
+ --analizar condiciones de supervision para encu por ahora ponemos algo provisiorio, falta cuando la encuesta es rea considerar si la mandan a supervision
29
+ update tem
30
+ set tarea_proxima = v_proxtarea
31
+ where operativo = new.operativo and enc = new.enc;
32
+ end if;
33
+ elsif new.verificado is null then --podria llegar a haber otros valores de verificado
34
+ update tem
35
+ set tarea_proxima = null
36
+ where operativo = new.operativo and enc = new.enc;
37
+ else
38
+ raise exception 'Falta considerar en la encuesta % un caso más de verificado para próxima tarea % ', new.enc, new.verificado;
39
+ end if;
40
+ return new;
41
+ end;
42
+ $BODY$;
43
+
44
+ DROP TRIGGER IF EXISTS determinar_tarea_proxima_trg ON tareas_tem;
45
+ CREATE TRIGGER determinar_tarea_proxima_trg
46
+ AFTER UPDATE OF verificado
47
+ ON tareas_tem
48
+ FOR EACH ROW
49
+ EXECUTE PROCEDURE determinar_tarea_proxima_trg();
@@ -11,11 +11,12 @@ declare
11
11
  v_tarea_actual text;
12
12
  v_tarea_proxima text;
13
13
  v_permite_asignar boolean;
14
+ v_estado_al_asignar text;
14
15
  begin
15
16
  select tarea_actual, habilitada, tarea_proxima into v_tarea_actual, v_habilitada, v_tarea_proxima
16
17
  from tem
17
18
  where operativo = new.operativo and enc = new.enc;
18
- select permite_asignar into v_permite_asignar
19
+ select permite_asignar, estado_al_asignar into v_permite_asignar, v_estado_al_asignar
19
20
  from estados
20
21
  where operativo = new.operativo and estado = new.estado;
21
22
  if v_habilitada then
@@ -26,6 +27,18 @@ begin
26
27
  old.asignado is distinct from new.asignado and new.tarea = v_tarea_proxima) then
27
28
  raise exception 'Error: no es posible modificar la encuesta % del operativo % ya que la tarea actual definida en TEM no coincide con la tarea %', new.enc, new.operativo, new.tarea;
28
29
  end if;
30
+ if old.asignado is distinct from new.asignado then
31
+ if new.asignado is null then
32
+ new.estado = '0D';
33
+ else
34
+ if v_tarea_actual is distinct from new.tarea then
35
+ if v_estado_al_asignar is not null then
36
+ new.estado = v_estado_al_asignar;
37
+ new.tarea_anterior = v_tarea_actual;
38
+ end if;
39
+ end if;
40
+ end if;
41
+ end if;
29
42
  else
30
43
  raise exception 'Error: la encuesta % del operativo % se encuentra deshabilitada', new.enc, new.operativo;
31
44
  end if;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dmencu",
3
3
  "description": "DM Encu - Encuestas en dispositivo móvil",
4
- "version": "0.3.25",
4
+ "version": "0.3.26",
5
5
  "author": "Codenautas <codenautas@googlegroups.com>",
6
6
  "license": "MIT",
7
7
  "main": "dist/server/server/app-dmencu.js",