Files
MBS/PROYECTOS/otrodir/prd00000.4gl
T

321 lines
8.1 KiB
Plaintext

{
--------------------------------------------------------------------------
PROGRAMA : PRD00000
OBJETIVO : Este programa da mantenimiento a los periodos contables;
Agrega, Modifica periodos de un ano especifico.
REALIZADO POR : Ing. Juan Fco. Soto.
FECHA : Noviembre 3, 1992.
MODIFICADO POR: Tadeo A. Ferreras
FECHA : Noviembre 25, 1993.
OBJETIVO : Incluir dias de gracias para cada periodo mensual.
--------------------------------------------------------------------------
}
DATABASE marmotech
GLOBALS
DEFINE control CHAR(2)
DEFINE fecha date
DEFINE hore CHAR(5)
DEFINE p_mes,p_act,s_act,numero_msg,bandera ,idx smallint
DEFINE descripcion CHAR(60)
DEFINE mes1 ARRAY[12] OF CHAR(10)
DEFINE peri ARRAY[12] OF RECORD
descrip_mes CHAR(10),
fecha_inicio DATE,
fecha_corte DATE,
dias_habiles SMALLINT,
dias_gracia SMALLINT
END RECORD
DEFINE usuarios RECORD
us_crea LIKE prdtable.us_crea,
fech_crea LIKE prdtable.fech_crea,
us_mod LIKE prdtable.us_mod,
fech_mod LIKE prdtable.fech_mod
END RECORD
DEFINE p_ano LIKE prdtable.ano
END GLOBALS
MAIN
DEFER INTERRUPT
OPTIONS
FORM LINE 8,
ERROR LINE 24,
COMMENT LINE 22
CALL pantalla()
OPEN FORM prdfm FROM "prdfm"
DISPLAY FORM prdfm
MENU "OPCION"
COMMAND "Agregar"
"<Esc> Adiciona Registro <Supr> Cancela Operacion"
CALL prdadd()
COMMAND "Consulta-modifica"
"<Esc> Busca Registro <Supr> Cancela Operacion"
CLEAR FORM
CALL prdmod()
COMMAND "Salir"
EXIT MENU
END MENU
END MAIN
FUNCTION prdadd()
#WHENEVER ERROR CONTINUE
SELECT count(*) FROM prdtable
IF bandera = 1 THEN
LET bandera = 0
RETURN
END IF
LABEL vuelve:
LET p_ano = year(today)
INPUT BY NAME p_ano WITHOUT DEFAULTS
AFTER FIELD p_ano
IF p_ano is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD p_ano
END IF
SELECT UNIQUE ano FROM prdtable WHERE ano = p_ano
IF status != notfound THEN
LET numero_msg = 12
CALL msg(numero_msg)
NEXT FIELD p_ano
END IF
AFTER INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
CLEAR FORM
LET int_flag = false
RETURN
END IF
EXIT INPUT
END INPUT
FOR idx = 1 to 12
CALL meses()
LET peri[idx].descrip_mes = mes1[idx]
LET peri[idx].fecha_corte = null
END FOR
CALL set_count(idx-1)
INPUT ARRAY peri WITHOUT DEFAULTS FROM s_peri.*
BEFORE ROW
LET p_act = arr_curr()
LET s_act = scr_line()
AFTER FIELD fecha_inicio
IF peri[p_act].fecha_inicio is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD fecha_inicio
END IF
AFTER INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = false
RETURN
END IF
EXIT INPUT
END INPUT
FOR idx = 1 to 12
INSERT INTO prdtable VALUES (p_ano,idx,peri[idx].fecha_inicio,
peri[idx].fecha_corte,peri[idx].dias_habiles,
peri[idx].dias_gracia,user,current,null,null)
CALL integridad()
IF bandera = 1 THEN
LET bandera = 0
RETURN
END IF
END FOR
LET numero_msg = 1
CALL msg(numero_msg)
CLEAR FORM
GOTO vuelve
END FUNCTION
FUNCTION prdmod()
#WHENEVER ERROR CONTINUE
SELECT count(*) FROM prdtable
IF bandera = 1 THEN
LET bandera = 0
RETURN
END IF
LABEL vuelve:
LET p_ano = year(today)
INPUT BY NAME p_ano WITHOUT DEFAULTS
AFTER FIELD p_ano
IF p_ano is null THEN
LET numero_msg = 16
CALL msg(numero_msg)
NEXT FIELD p_ano
END IF
SELECT UNIQUE ano FROM prdtable WHERE ano = p_ano
IF status = notfound THEN
LET numero_msg = 3
CALL msg(numero_msg)
NEXT FIELD p_ano
END IF
AFTER INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
LET int_flag = false
RETURN
END IF
EXIT INPUT
END INPUT
{DECLARE datos CURSOR FOR
SELECT mes,fecha_inicio,fecha_corte,dias_habiles,dias_gracia,us_crea,
fech_crea,us_mod,fech_mod
FROM prdtable where ano = p_ano
ORDER BY 2
LET idx = 1
FOREACH datos INTO p_mes,peri[idx].fecha_inicio,peri[idx].fecha_corte,
peri[idx].dias_habiles,peri[idx].dias_gracia,usuarios.*
CALL meses()
LET peri[idx].descrip_mes = mes1[idx]
LET idx = idx + 1
END FOREACH}
FOR idx = 1 to 12
CALL meses()
LET peri[idx].descrip_mes = mes1[idx]
SELECT UNIQUE a.fecha_inicio,a.fecha_corte,a.dias_habiles,a.dias_gracia,
a.us_crea,a.fech_crea,a.us_mod,a.fech_mod
INTO peri[idx].fecha_inicio,peri[idx].fecha_corte,
peri[idx].dias_habiles,peri[idx].dias_gracia,usuarios.*
FROM prdtable a
WHERE a.ano = p_ano AND a.mes = idx
#LET peri[idx].fecha_corte = null
END FOR
SELECT UNIQUE a.us_crea,a.fech_crea,a.us_mod,a.fech_mod
INTO usuarios.*
FROM prdtable a
WHERE a.ano = p_ano AND a.us_crea IS NOT NULL
DISPLAY BY NAME usuarios.*
CALL set_count(idx)
INPUT ARRAY peri WITHOUT DEFAULTS FROM s_peri.*
BEFORE ROW
LET p_act = arr_curr()
LET s_act = scr_line()
{AFTER FIELD fecha_corte
LET control = month(peri[p_act].fecha_corte)
IF p_act != control THEN
LET numero_msg = 56
CALL msg(numero_msg)
NEXT FIELD fecha_corte
END IF}
AFTER INPUT
IF int_flag THEN
LET numero_msg = 2
CALL msg(numero_msg)
CLEAR FORM
LET int_flag = false
RETURN
END IF
EXIT INPUT
END INPUT
DELETE FROM prdtable WHERE @ano = p_ano
FOR idx = 1 to 12
IF peri[idx].fecha_inicio IS NOT NULL THEN
INSERT INTO prdtable VALUES (p_ano,idx,peri[idx].fecha_inicio,
peri[idx].fecha_corte,peri[idx].dias_habiles,
peri[idx].dias_gracia,user,current,user,current)
END IF
END FOR
LET numero_msg = 13
CALL msg(numero_msg)
END FUNCTION
FUNCTION integridad()
IF sqlca.sqlcode < 0 THEN
LET numero_msg = sqlca.sqlcode
CALL msg(numero_msg)
DISPLAY numero_msg AT 23,70
LET bandera = 1
SLEEP 2
RETURN
END IF
END FUNCTION
FUNCTION msg(numero_msg)
DEFINE numero_msg SMALLINT
DEFINE descripcion CHAR (60)
SELECT desc_msg INTO descripcion FROM msgtable
WHERE cod_msg = numero_msg
IF status = NOTFOUND THEN
LET numero_msg = 22
SELECT desc_msg INTO descripcion FROM msgtable
WHERE cod_msg = numero_msg
ERROR descripcion
ELSE
ERROR descripcion
LET numero_msg = 0
END IF
END FUNCTION
FUNCTION meses()
LET mes1[1] = "Enero"
LET mes1[2] = "Febrero"
LET mes1[3] = "Marzo"
LET mes1[4] = "Abril"
LET mes1[5] = "Mayo"
LET mes1[6] = "Junio"
LET mes1[7] = "Julio"
LET mes1[8] = "Agosto"
LET mes1[9] = "Septiembre"
LET mes1[10] = "Octubre"
LET mes1[11] = "Noviembre"
LET mes1[12] = "Diciembre"
END FUNCTION
FUNCTION pantalla()
DEFINE fecha CHAR(8),
hora char(5) ,
p_compania RECORD LIKE companias.*,
l SMALLINT
SELECT * INTO p_compania.*
FROM companias
LET l = (80 - LENGTH(p_compania.nombre))/2
LET fecha = today USING "dd/mm/yy"
LET hora = time
DISPLAY p_compania.nombre CLIPPED AT 4,l
ATTRIBUTE (REVERSE,YELLOW)
DISPLAY "prd00000" AT 4,3 ATTRIBUTE (BOLD)
DISPLAY fecha AT 4,70 ATTRIBUTE (YELLOW)
LET l = (80 - LENGTH("Mantenimento Fechas de corte Mensuales"))/2
DISPLAY "Mantinimento Fechas de corte Mensuales" AT 5,l
DISPLAY hora AT 6,73 ATTRIBUTE(YELLOW)
CALL fgl_drawbox(5,79,3,1)
CALL fgl_drawbox(1,79,22,1)
END FUNCTION