Example #1
0
 def set_fin(self,boton):
     try:
         temp = utils.mostrar_calendario(utils.parse_fecha(self.wids['e_fechafin'].get_text()), padre = self.wids['ventana'])
     except:
         temp = utils.mostrar_calendario(padre = self.wids['ventana'])
     self.wids['e_fechafin'].set_text(utils.str_fecha(temp))
     self.fin = mx.DateTime.DateTimeFrom(day = temp[0], month = temp[1], year = temp[2])
Example #2
0
 def set_fecha(self, boton):
     try:
         fecha_actual = utils.parse_fecha(self.wids['e_fecha'].get_text())
         temp = utils.mostrar_calendario(fecha_actual, 
                                         padre = self.wids['ventana'])
     except:
         temp = utils.mostrar_calendario(padre = self.wids['ventana'])
     self.wids['e_fecha'].set_text(utils.str_fecha(temp))
     self.wids['e_fecha'].grab_focus()
 def set_fin(self, boton):
     try:
         temp = utils.mostrar_calendario(
                 fecha_defecto = utils.parse_fecha(
                     self.wids["e_fechafin"].get_text()), 
                 padre = self.wids['ventana'])
     except (ValueError, TypeError):
         temp = utils.mostrar_calendario(
                 padre = self.wids['ventana'])
     self.wids['e_fechafin'].set_text(utils.str_fecha(temp))
Example #4
0
 def set_inicio(self,boton):
     try:
         datinw = utils.parse_fecha(self.wids['e_fechainicio'].get_text())
         temp = utils.mostrar_calendario(datinw,
                                         padre = self.wids['ventana'])
     except:
         temp = utils.mostrar_calendario(padre = self.wids['ventana'])
     self.wids['e_fechainicio'].set_text(utils.str_fecha(temp))
     self.inicio = mx.DateTime.DateTimeFrom(day = temp[0],
                                            month = temp[1],
                                            year = temp[2])
def cambiar_fecha(entry, padre = None):
    """
    Cambia el texto del entry por la fecha seleccionada en un diálogo 
    centrado en la ventana "padre".
    """
    try:
        entry.set_text(utils.str_fecha(utils.mostrar_calendario(
            fecha_defecto = utils.parse_fecha(entry.get_text()), 
            padre = padre)))
    except:     # Probablemente fecha mal formada, mx.DateTime.RangeError, 
                # pero me curo en salud y capturo todas.
        entry.set_text(utils.str_fecha(utils.mostrar_calendario(padre=padre)))
Example #6
0
 def set_fecha(self, boton):
     """
     Muestra el diálogo de selección de fecha en calendario.
     """
     if "inicio" in boton.name:
         e = self.wids['e_fecha_inicio']
     elif "fin" in boton.name:
         e = self.wids['e_fecha_fin']
     else:
         return
     try:
         e.set_text(utils.str_fecha(utils.mostrar_calendario(e.get_text(), self.wids['ventana'])))
     except:
         e.set_text(utils.str_fecha(utils.mostrar_calendario(padre = self.wids['ventana'])))
Example #7
0
 def set_fecha_fin(self, b):
     try:
         fecha_defecto = utils.parse_fecha(self.wids['e_fecha_fin'].get_text())
     except: 
         fecha_defecto = mx.DateTime.localtime()
     else:
         self.wids['e_fecha_fin'].set_text(utils.str_fecha(utils.mostrar_calendario(fecha_defecto = fecha_defecto, padre = self.wids['ventana'])))
Example #8
0
 def set_fin(self, boton):
     temp = utils.mostrar_calendario(
         fecha_defecto=utils.parse_fechahora(
             self.wids['e_fechafin'].get_text()),
         padre=self.wids['ventana'])
     temp = mx.DateTime.DateFrom(day=temp[0], month=temp[1], year=temp[2]) + mx.DateTime.TimeDelta(hours = 6)
     self.wids['e_fechafin'].set_text(utils.str_fechahora(temp))
Example #9
0
 def set_fin(self, boton):
     temp = utils.mostrar_calendario(
         fecha_defecto = utils.parse_fecha(
             self.wids["e_fechafin"].get_text()), 
         padre = self.wids['ventana'])
     self.fin = mx.DateTime.DateTimeFrom(*temp[::-1])
     self.wids['e_fechafin'].set_text(utils.str_fecha(self.fin))
Example #10
0
 def set_fecha(self, b):
     try:
         fecha_defecto = utils.parse_fecha(self.wids['e_fecha'].get_text())
     except: 
         fecha_defecto = mx.DateTime.localtime()
     else:
         self.wids['e_fecha'].set_text("/".join(["%02d" % i for i in utils.mostrar_calendario(fecha_defecto = fecha_defecto, padre = self.wids['ventana'])]))
Example #11
0
 def add_baja(self, boton):
     """
     Crea una nueva baja laboral para el empleado actual.
     """
     fecha = utils.str_fecha(utils.mostrar_calendario(
         padre = self.wids['ventana']))
     dia, mes, anno = map(int, fecha.split('/'))
     fecha = mx.DateTime.DateTimeFrom(day = dia, month = mes, year = anno)
     bajas = self.objeto.bajas[:]
     bajas.sort(lambda f1, f2: (f1.fechaInicio < f2.fechaInicio and -1) \
                               or (f1.fechaInicio > f2.fechaInicio and 1) \
                               or 0)
     fechaFin = None
     for b in bajas:
         if b.fechaInicio >= fecha:
             fechaFin = b.fechaInicio
         if b.esta_vigente(fecha):
             utils.dialogo_info(titulo = "BAJA SOLAPADA",
                                texto = "Las bajas médicas no pueden solaparse entre sí, elija otra fecha.",
                                padre = self.wids['ventana'])
             return
     baja = pclases.Baja(empleado = self.objeto,
                         fechaInicio = fecha,
                         fechaFin = fechaFin)
     pclases.Auditoria.nuevo(baja, self.usuario, __file__)
     self.actualizar_ventana(deep_refresh=False)
 def set_inicio(self,boton):
     try:
         fini = map(int, self.inicio.split("/"))[::-1]
     except:
         fini = None
     temp = utils.mostrar_calendario(fecha_defecto = fini, padre = self.wids['ventana'])
     self.wids['e_fechainicio'].set_text(utils.str_fecha(temp))
     self.inicio = str(temp[2])+'/'+str(temp[1])+'/'+str(temp[0])
Example #13
0
 def fecha(self, w):
     self.wids["e_fecha"].set_text(
         utils.str_fecha(
             utils.mostrar_calendario(
                 fecha_defecto=self.objeto and self.objeto.fecha or None, padre=self.wids["ventana"]
             )
         )
     )
Example #14
0
 def set_fecha(self, boton):
     """
     Cambia la fecha a la seleccionada en la ventana calendario.
     """
     self.wids['e_fecha'].set_text(utils.str_fecha(
         utils.mostrar_calendario(
             fecha_defecto = self.wids['e_fecha'].get_text(), 
             padre = self.wids['ventana'])))
 def set_fin(self,boton):
     try:
         ffin = map(int, self.fin.split("/"))[::-1]
     except:
         ffin = None
     temp = utils.mostrar_calendario(fecha_defecto = ffin, 
                                     padre = self.wids['ventana'])
     self.wids['e_fechafin'].set_text(utils.str_fecha(temp))
     self.fin = str(temp[2])+'/'+str(temp[1])+'/'+str(temp[0])
Example #16
0
 def set_validez(self, boton):
     """
     Muestra un diálogo de selecciónde fecha y 
     escribe la fecha elegida en el Entry 
     correspondiente.
     """
     entry = boton.name.replace("b", "e")
     fecha = utils.mostrar_calendario(padre = self.wids['ventana'])
     self.wids[entry].set_text(utils.str_fecha(fecha))
Example #17
0
 def buscar_fecha(self, boton):
     """
     Abre el diálogo del calendario.
     """
     e_fecha = boton.name.replace("b_", "e_")
     try:
         valor_anterior = utils.parse_fecha(self.wids[e_fecha].get_text())
     except:
         valor_anterior = None
     self.wids[e_fecha].set_text(utils.str_fecha(utils.mostrar_calendario(valor_anterior, padre = self.wids['ventana'])))
Example #18
0
 def set_inicio(self, boton):
     try:
         temp = utils.mostrar_calendario(
             fecha_defecto = utils.parse_fecha(
                 self.wids['e_fechainicio'].get_text()), 
             padre = self.wids['ventana'])
     except ValueError:
         temp = datetime.date.today().timetuple()[:3][::-1]
     self.inicio = mx.DateTime.DateTimeFrom(*temp[::-1])
     self.wids['e_fechainicio'].set_text(utils.str_fecha(self.inicio))
 def set_fecha(self, boton):
     """
     Cambia la fecha de los filtros.
     """
     w = self.wids[boton.name.replace("b_", "e_")]
     try:
         fechaentry = utils.parse_fecha(w.get_text())
     except (TypeError, ValueError):
         fechaentry = datetime.date.today()
     w.set_text(utils.str_fecha(utils.mostrar_calendario(
                                             fecha_defecto = fechaentry,
                                             padre = self.wids['ventana'])))
Example #20
0
def build_widget_valor(col):
    """
    Recibe un objeto de la familia SOCol y devuelve el 
    widget adecuado para mostrar su valor.
    Si es un texto, entero o float: entry.
    Si es un boolean: checkbutton.
    Si es una fecha: entry con un botón para mostrar el calendario.
    Si es un ForeignKey, usar un ComboBoxEntry con utils.rellenar... con las
    tuplas de la tabla referenciada.
    """
    box = None  # Posible contenedor externo.
    if isinstance(col, pclases.SOStringCol): 
        w = gtk.Entry()
        w.set_name(col.name)
    elif isinstance(col, pclases.SOIntCol):
        w = gtk.Entry()
        w.set_name(col.name)
    elif isinstance(col, pclases.SOFloatCol):
        w = gtk.Entry()
        w.set_name(col.name)
    elif isinstance(col, pclases.SOBoolCol):
        w = gtk.CheckButton()
        w.set_name(col.name)
    elif isinstance(col, pclases.SODateCol):
        box = gtk.HBox()
        w = gtk.Entry()
        w.set_name(col.name)
        button = gtk.Button(label = "Buscar _fecha")
        button.connect("clicked", lambda boton: w.set_text(utils.str_fecha(utils.mostrar_calendario())))
        button.set_name("b_%s" % (col.name))
        box.add(w)
        box.add(button)
    elif isinstance(col, pclases.SOForeignKey):
        w = gtk.ComboBoxEntry()
        w.set_name(col.name)
        tablajena = col.foreignKey
        clase_tablajena = getattr(pclases, tablajena)
        func_select = getattr(clase_tablajena, "select")
        datos = []
        for reg in func_select():
            campos = []
            for columna in clase_tablajena.sqlmeta.columns:
                valor = getattr(reg, columna)
                campos.append(`valor`)
            info = ", ".join(campos)
            # info = reg.get_info()
            datos.append((reg.id, info))
        utils.rellenar_lista(w, datos)
    else:
        w = gtk.Entry()
        w.set_name(col.name)
    return w, box
Example #21
0
 def add_fecha(self, boton):
     fecha = utils.mostrar_calendario(padre = self.wids['ventana'])
     fecha = mx.DateTime.DateFrom(year = fecha[-1], 
                                  month = fecha[1], 
                                  day = fecha[0])
     fechas_existentes = [item[1] for item 
             in self.wids['cb_fecha'].get_model()]
     if utils.str_fecha(fecha) not in fechas_existentes:
         self.objeto = self.objeto.clone(fecha = fecha)
         self.actualizar_ventana()
     else:
         utils.dialogo_info(titulo = "FECHA INCORRECTA", 
                 texto = "Ya existe la fecha de inicio de validez.", 
                 padre = self.wids['ventana'])
Example #22
0
 def buscar_fecha(self, boton):
     """
     Muestra el diálogo calendario y establece la fecha de la partida.
     """
     partida = self.get_partida()
     if partida is not None:
         fecha = utils.mostrar_calendario(fecha_defecto=partida.fecha,
                                          padre=self.wids['ventana'])
         fecha = utils.parse_fecha(utils.str_fecha(fecha))
         partida.fecha = mx.DateTime.DateTimeFrom(day=fecha.day,
                 month=fecha.month, year=fecha.year,
                 hour=partida.fecha.hour, minute=partida.fecha.minute,
                 second=partida.fecha.second)
         self.wids['e_fecha'].set_text(utils.str_fechahora(partida.fecha))
Example #23
0
 def set_fecha(self, boton):
     """
     Muestra un calendario y pone la fecha seleccionada en el entry 
     que le corresponde al botón pulsado.
     """
     nombreboton = boton.get_name()
     if nombreboton == "b_fechaini":
         entry = self.wids["e_fechaini"]
     elif nombreboton == "b_fechafin":
         entry = self.wids["e_fechafin"]
     else:
         return
     fecha = utils.mostrar_calendario(
         fecha_defecto = utils.parse_fecha(entry.get_text()), 
         padre = self.wids['ventana'])
     entry.set_text(utils.str_fecha(fecha))
Example #24
0
 def set_fecha(self, boton):
     """
     Muestra un calendario y pone la fecha seleccionada en el entry 
     que le corresponde al botón pulsado.
     """
     nombreboton = boton.get_name()
     if nombreboton == "b_fecha_inicio":
         entry = self.wids["e_fechainicio"]
     elif nombreboton == "b_fecha_fin":
         entry = self.wids["e_fechafin"]
     else:
         return
     fecha = utils.mostrar_calendario(fecha_defecto = utils.parse_fecha(
                                                         entry.get_text()),
                                      padre = self.wids['ventana'])
     entry.set_text(utils.str_fecha(fecha))
     dia, mes, anno = fecha
     if nombreboton == "b_fecha_inicio":
         self.inicio = mx.DateTime.DateTimeFrom(day = dia, month = mes, year = anno)
     elif nombreboton == "b_fecha_fin":
         self.fin = mx.DateTime.DateTimeFrom(day = dia, month = mes, year = anno)
Example #25
0
 def add_ausencia(self, b):
     fecha = utils.str_fecha(
             utils.mostrar_calendario(padre = self.wids['ventana']))
     dia, mes, anno = map(int, fecha.split('/'))
     fecha = mx.DateTime.DateTimeFrom(day = dia, month = mes, year = anno)
     opciones = []
     for motivo in pclases.Motivo.select():
         opciones.append((motivo.id, "%s %s" % (
             motivo.descripcion, motivo.descripcionDias)))
     idmotivo = utils.dialogo_combo(titulo = "¿MOTIVO?",
                                    texto = "Seleccione motivo de ausencia",
                                    ops = opciones,
                                    padre = self.wids['ventana'])
     if idmotivo != None:
         motivo = pclases.Motivo.get(idmotivo)
         defecto = "%d" % motivo.excedenciaMaxima
         duracion = utils.dialogo_entrada(titulo = "DURACIÓN",
                 texto = "Introduzca la duración en días de la ausencia.",
                 padre = self.wids['ventana'],
                 valor_por_defecto = defecto)
         try:
             duracion = int(duracion)
             for i in range(duracion):
                 if isinstance(fecha, datetime.date):
                     fechaincrementada = fecha + (datetime.timedelta(i))
                 else:
                     fechaincrementada = fecha + (mx.DateTime.oneDay * i)
                 ausencia = pclases.Ausencia(empleado = self.objeto,
                                             fecha = fechaincrementada,
                                             motivo = motivo)
                 pclases.Auditoria.nuevo(ausencia, self.usuario, __file__)
             self.actualizar_ventana(deep_refresh=False)
         except (ValueError, TypeError):
             utils.dialogo_info(titulo = "VALOR INCORRECTO",
                     texto = "Debe teclear un número. Vuelva a intentarlo",
                     padre = self.wids['ventana'])
Example #26
0
 def set_fin(self,boton):
     temp = utils.mostrar_calendario(padre = self.wids['ventana'])
     self.wids['e_fechafin'].set_text(utils.str_fecha(temp))
     self.fin = utils.parse_fecha(utils.str_fecha(temp))
Example #27
0
 def set_inicio(self,boton):
     temp = utils.mostrar_calendario(padre = self.wids['ventana'])
     self.wids['e_fechainicio'].set_text(utils.str_fecha(temp))
     self.inicio = utils.parse_fecha(utils.str_fecha(temp))
    def set_fin(self,boton):
        temp = utils.mostrar_calendario(padre = self.wids['ventana'])
        self.wids['e_fechafin'].set_text(utils.str_fecha(temp))
#        self.fin = str(temp[2])+'/'+str(temp[1])+'/'+str(temp[0])
        self.fin = mx.DateTime.DateTimeFrom(year = int(temp[2]), month = int(temp[1]), day = (temp[0]))
 def buscar_fecha(self, boton):
     self.wids['e_fecha'].set_text(utils.str_fecha(utils.mostrar_calendario(fecha_defecto = self.objeto and self.objeto.fecha or None, padre = self.wids['ventana'])))
 def set_fin(self, boton):
     temp = utils.mostrar_calendario(
         fecha_defecto=utils.parse_fecha(self.wids["e_fechafin"].get_text()), padre=self.wids["ventana"]
     )
     self.wids["e_fechafin"].set_text(utils.str_fecha(temp))