Exemple #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])
Exemple #2
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, 
                # pero me curo en salud y capturo todas.
        entry.set_text(utils.str_fecha(utils.mostrar_calendario(padre=padre)))
Exemple #4
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'])))
Exemple #5
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):
                 ausencia = pclases.Ausencia(
                     empleado=self.objeto, fecha=fecha + (mx.DateTime.oneDay * i), motivo=motivo
                 )
             self.actualizar_ventana()
         except ValueError:
             utils.dialogo_info(
                 titulo="VALOR INCORRECTO",
                 texto="Debe teclear un número. Vuelva a intentarlo",
                 padre=self.wids["ventana"],
             )
Exemple #6
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'])))
 def set_fin(self, boton):
     temp = utils.mostrar_calendario(fecha_defecto = self.fin, 
                                     padre = self.wids['ventana'])
     self.fin = temp
     self.fin = datetime.date(day = temp[0], month = temp[1], 
                              year = temp[2])
     self.wids['e_fechafin'].set_text(utils.str_fecha(self.fin))
 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))
 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'])]))
 def set_inicio(self, boton):
     temp = utils.mostrar_calendario(
         fecha_defecto = utils.parse_fecha(
             self.wids['e_fechainicio'].get_text()), 
         padre = self.wids['ventana'])
     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 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 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"]
             )
         )
     )
 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])
 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])
 def nueva_alarma(self, idfras):
     texto = utils.dialogo_entrada(
         titulo="TEXTO ALARMA", texto="Introduzca el texto de la alarma.", padre=self.wids["ventana"]
     )
     if texto:
         fechalarma = utils.mostrar_calendario(
             titulo="FECHA Y HORA",
             padre=self.wids["ventana"],
             fecha_defecto=mx.DateTime.localtime() + mx.DateTime.oneDay,
         )
         try:
             dia, mes, anno = fechalarma
             fechalarma = mx.DateTime.DateTimeFrom(day=dia, month=mes, year=anno)
         except (TypeError, ValueError, AttributeError):
             utils.dialogo_info(
                 titulo="FECHA INCORRECTA",
                 texto="La fecha seleccionada (%s)\n" "no es correcta." % ` fechalarma `,
                 padre=self.wids["ventana"],
             )
             fechalarma = None
         if fechalarma:
             hora = utils.mostrar_hora(
                 titulo="SELECCIONE HORA DE ALARMA",
                 padre=self.wids["ventana"],
                 horas=mx.DateTime.localtime().hour,
                 minutos=mx.DateTime.localtime().minute,
             )
             if not hora:
                 return  # Canceló
             try:
                 horas = int(hora.split(":")[0])
                 minutos = int(hora.split(":")[1])
                 fechalarma = mx.DateTime.DateTimeFrom(
                     day=fechalarma.day, month=fechalarma.month, year=fechalarma.year, hour=horas, minute=minutos
                 )
             except (IndexError, TypeError, ValueError, AttributeError):
                 utils.dialogo_info(
                     titulo="HORA INCORRECTA",
                     texto="La hora %s no es correcta." % (hora),
                     padre=self.wids["ventana"],
                 )
                 fechalarma = None
             if fechalarma:
                 try:
                     estado = pclases.Estado.get(1)  # *Debería* existir.
                 except:
                     estado = None
                 # print idfras
                 for id in idfras:
                     tarea = pclases.Alarma(
                         facturaVentaID=id,
                         texto=texto,
                         fechahora=mx.DateTime.localtime(),
                         estado=estado,
                         fechahoraAlarma=fechalarma,
                         objetoRelacionado=None,
                     )
                 self.buscar_alertas()
Exemple #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))
 def buscar_fecha(self, boton):
     """
     Muestra el diálogo calendario y establece la fecha de la partida.
     """
     partida = self.get_partida()
     if partida != 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))
 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 = mx.DateTime.today()
     w.set_text(utils.str_fecha(utils.mostrar_calendario(
                                             fecha_defecto = fechaentry, 
                                             padre = self.wids['ventana'])))
Exemple #19
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._SO_columnDict:
                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
 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))
Exemple #21
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)
Exemple #22
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)
     self.actualizar_ventana()
 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 = datetime.date(year = int(temp[2]), month = int(temp[1]), day = (temp[0]))
 def set_fin(self, boton):
     temp = utils.mostrar_calendario(padre = self.wids['ventana'], 
                                     fecha_defecto = self.fechafin)
     self.wids['e_fechafin'].set_text(utils.str_fecha(temp))
     self.fechafin = datetime.date(*temp[::-1])
Exemple #25
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))
     self.fin = mx.DateTime.DateTimeFrom(year = int(temp[2]), month = int(temp[1]), day = (temp[0]))
Exemple #27
0
 def set_fecha(self, boton):
     """
     Introduce la fecha seleccionada de un diálogo calendario en el entry.
     """
     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(padre = self.wids['ventana'])
     self.wids['e_fechafin'].set_text(utils.str_fecha(temp))
     self.fin = utils.parse_fecha(self.wids['e_fechafin'].get_text()) 
 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])
    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]))