Example #1
0
class StartView:
    """
    creates start view with scroll, top movies, tv series from last year, and history
    """
    def __init__(self, master):
        self.scroll_frame = ScrollableFrame(master)
        self.scroll_frame.pack(fill='both', expand=True)

        self.master = master

        self.movies_frame = tk.LabelFrame(self.scroll_frame.scrollable_frame,
                                          bg=functions.BG_COLOR)
        self.tv_frame = tk.LabelFrame(self.scroll_frame.scrollable_frame,
                                      bg=functions.BG_COLOR)
        self.last_frame = tk.LabelFrame(self.scroll_frame.scrollable_frame,
                                        bg=functions.BG_COLOR)
        functions.ACTUAL_HISTORY_OBJECT_MASTER = self.last_frame

        self.movies_frame.grid(column=0, row=0, padx=30, pady=30)
        self.tv_frame.grid(column=0, row=1)
        self.last_frame.grid(column=0, row=2, pady=30, sticky='w', padx=30)

        StartViewSection(self.movies_frame, "movie")
        StartViewSection(self.tv_frame, "tv")
        if os.path.exists("history.txt"):
            history = StartViewSection(self.last_frame, "last")
            functions.ACTUAL_HISTORY_OBJECT = history
Example #2
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.resizable(0, 0)
        self.title("Inventario de productos")

        self.frameb = Frame(self)
        self.frameb.pack()
        self.frameb.config(width=750, height=550)
        self.frameb.config(bg="white")

        self.framet = ScrollableFrame(self.frameb, width=100)
        self.framet.place(x=25, y=75)

        self.lab1 = Label(self.frameb,
                          text="Buscar por...",
                          bg="white",
                          font=("Verdana", 12))
        self.lab1.place(x=25, y=25)

        self.comb = ttk.Combobox(self.frameb,
                                 width=25,
                                 height=10,
                                 state="readonly")
        self.comb.place(x=150, y=25)
        self.comb["values"] = ["Nombre", "Código"]
        self.comb.set("Nombre")

        self.lab2 = Label(self.frameb,
                          text="Buscar:",
                          bg="white",
                          font=("Verdana", 12))
        self.lab2.place(x=340, y=25)

        self.text = Entry(self.frameb, width=30)
        self.text.place(x=420, y=25)

        self.bot = Button(self.frameb,
                          width=10,
                          height=1,
                          text="Aceptar",
                          command=self.vali)
        self.bot.place(x=640, y=25)

        self.bot2 = Button(self.frameb,
                           text="Listado de productos",
                           command=self.lprodu)
        self.bot2.place(x=580, y=500)

        self.bot3 = Button(self.frameb, text="Regresar")
        self.bot3.place(x=25, y=500)

        self.bot4 = Button(self.frameb,
                           text="Realizar reporte",
                           command=self.reporti)
        self.bot4.place(x=150, y=500)

        self.rellenar(allitem())

        self.mainloop()
Example #3
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.resizable(0,0)
        self.title("Listado de eventos")
        
        
        self.frameb= Frame(self)
        self.frameb.pack()
        self.frameb.config(width=750,height=550)
        self.frameb.config(bg="white")


        self.framet= ScrollableFrame(self.frameb,width=100)
        self.framet.place(x=25,y=75)

        
        self.lab1= Label(self.frameb, text="Buscar por...",bg="white",font=("Verdana",12))
        self.lab1.place(x=25,y=25)

        self.comb= ttk.Combobox(self.frameb, width=25,height=10,state="readonly")
        self.comb.place(x=150,y=25)
        self.comb["values"] = ["CI Cliente","CI Empleado","N° de Factura","Metodo"]
        self.comb.set("CI Cliente")
        
        
        self.lab2= Label(self.frameb, text="Buscar:",bg="white",font=("Verdana",12))
        self.lab2.place(x=340,y=25)

        self.text= Entry(self.frameb, width=30)
        self.text.place(x=420,y=25)

        
        
        self.bot = Button(self.frameb, width=10,height=1,text= "Aceptar", command=self.valv)
        self.bot.place(x=640,y=25)

        self.bot2 = Button(self.frameb,text="Movimiento de items",command=self.lmov)
        self.bot2.place(x=580,y=500)

        self.bot3 = Button(self.frameb,text="Operaciones de inventario",command=self.lope)
        self.bot3.place(x=400,y=500)

        self.bot4 = Button(self.frameb,text="Ventas realizadas",command=self.lventa,state="disabled")
        self.bot4.place(x=265,y=500)

        self.bot6 = Button(self.frameb,text="Realizar reporte", command=self.reportv)
        self.bot6.place(x=150,y=500)

        self.bot5 = Button(self.frameb,text="Regresar")
        self.bot5.place(x=25,y=500)

        self.rellenar(allventa())


        self.mainloop()
Example #4
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.resizable(0, 0)
        self.title("Consulta de usuarios")

        self.frameb = Frame(self)
        self.frameb.pack()
        self.frameb.config(width=750, height=550)
        self.frameb.config(bg="white")

        self.framet = ScrollableFrame(self.frameb, width=100)
        self.framet.place(x=25, y=75)

        self.lab1 = Label(self.frameb,
                          text="Buscar por...",
                          bg="white",
                          font=("Verdana", 12))
        self.lab1.place(x=25, y=25)

        self.comb = ttk.Combobox(self.frameb,
                                 width=25,
                                 height=10,
                                 state="readonly")
        self.comb.place(x=150, y=25)
        self.comb["values"] = ["Cedula", "Nombre", "ID"]
        self.comb.set("Cedula")

        self.lab2 = Label(self.frameb,
                          text="Buscar:",
                          bg="white",
                          font=("Verdana", 12))
        self.lab2.place(x=340, y=25)

        self.text = Entry(self.frameb, width=30)
        self.text.place(x=420, y=25)

        self.rellenar(alluser())

        self.bot = Button(self.frameb,
                          width=10,
                          height=1,
                          text="Aceptar",
                          command=self.val)
        self.bot.place(x=640, y=25)

        self.bot3 = Button(self.frameb,
                           text="Realizar reporte",
                           command=self.reporte)
        self.bot3.place(x=150, y=500)

        self.mainloop()
Example #5
0
    def __init__(self, master, what, id, photo):

        self.scroll_frame = ScrollableFrame(master)
        self.scroll_frame.pack(fill='both', expand=True)

        self.details_frame = tk.LabelFrame(self.scroll_frame.scrollable_frame, bg=functions.BG_COLOR)
        self.details_frame.grid(column=0, row=0, padx=30, pady=50)

        self.info = functions.get_info_about(what, id, True)

        functions.write_history(what, id)

        self.place_poster(photo)
        self.place_info(self.info, what)
Example #6
0
class buser(Tk):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.resizable(0, 0)
        self.title("Consulta de usuarios")

        self.frameb = Frame(self)
        self.frameb.pack()
        self.frameb.config(width=750, height=550)
        self.frameb.config(bg="white")

        self.framet = ScrollableFrame(self.frameb, width=100)
        self.framet.place(x=25, y=75)

        self.lab1 = Label(self.frameb,
                          text="Buscar por...",
                          bg="white",
                          font=("Verdana", 12))
        self.lab1.place(x=25, y=25)

        self.comb = ttk.Combobox(self.frameb,
                                 width=25,
                                 height=10,
                                 state="readonly")
        self.comb.place(x=150, y=25)
        self.comb["values"] = ["Cedula", "Nombre", "ID"]
        self.comb.set("Cedula")

        self.lab2 = Label(self.frameb,
                          text="Buscar:",
                          bg="white",
                          font=("Verdana", 12))
        self.lab2.place(x=340, y=25)

        self.text = Entry(self.frameb, width=30)
        self.text.place(x=420, y=25)

        self.rellenar(alluser())

        self.bot = Button(self.frameb,
                          width=10,
                          height=1,
                          text="Aceptar",
                          command=self.val)
        self.bot.place(x=640, y=25)

        self.bot3 = Button(self.frameb,
                           text="Realizar reporte",
                           command=self.reporte)
        self.bot3.place(x=150, y=500)

        self.mainloop()

    def rellenar(self, lista):
        self.marco = []
        self.reportdata = lista
        i = 0
        for per in lista:
            self.marco.append(
                framemod(self.framet.scrollable_frame,
                         per[0],
                         width=750,
                         height=60,
                         bg="#DB7093"))
            self.marco[i].pack()
            self.marco[i].bind("<Button-1>", self.allinfo)
            self.id = Label(self.marco[i], text=per[0], fg="white")
            self.id.place(x=20, y=5)
            self.nom = Label(self.marco[i], text=per[2], fg="white")
            self.nom.place(x=50, y=5)
            self.ci = Label(self.marco[i],
                            text="Cedula: " + str(per[1]),
                            fg="white")
            self.ci.place(x=50, y=30)
            self.priv = Label(self.marco[i], text=per[3], fg="white")
            self.priv.place(x=570, y=5)
            self.id.config(bg="#DB7093")
            self.nom.config(bg="#DB7093")
            self.ci.config(bg="#DB7093")
            self.priv.config(bg="#DB7093")
            if i % 2 == 0:
                self.marco[i].config(bg="#C40233")
                self.id.config(bg="#C40233")
                self.nom.config(bg="#C40233")
                self.ci.config(bg="#C40233")
                self.priv.config(bg="#C40233")
            i += 1

    def val(self):
        if self.text.get() == "":
            messagebox.showerror("Error",
                                 "Ingrese un valor para realizar la busqueda")
            self.text.delete(0, END)
        else:
            self.buscar()

    def buscar(self):
        quer = suser(self.comb.get(), self.text.get())
        self.text.delete(0, END)
        for i in self.marco:
            i.pack_forget()
            i.destroy()
        if len(quer) < 1:
            messagebox.showerror(
                "Error", "No se han encontrado relaciones, intente otra vez")
        else:
            messagebox.showinfo(
                "Busqueda exitosa",
                "Se ha encontrado " + str(len(quer)) + " registros")
            self.rellenar(quer)

    def allinfo(self, event):
        caller = event.widget
        pos = caller.id
        nwin = userindi(self, pos)

    def refresh(self):
        for i in self.marco:
            i.pack_forget()
            i.destroy()
        self.rellenar(alluser())

    def reporte(self):
        res = messagebox.askquestion(
            "Confirmación",
            "¿Estas seguro que deseas guardar un reporte de los elementos seleccionados?"
        )
        if res == "yes":
            self.empreport = [[
                "ID", "CI Empleado", "Nombre", "Privilegios", "N° de ventas",
                "F. de registro"
            ]]
            for e in self.reportdata:
                self.empreport.append(e)
            now = datetime.now()
            titulo = "Reporte de empleados " + str(date.today()) + "  " + str(
                now.hour) + "-" + str(now.minute) + "-" + str(
                    now.second) + ".pdf"
            export_to_pdf(4, titulo, "Clientes", self.empreport)
            messagebox.showinfo("Operación Exitosa",
                                "El reporte se ha generado exitosamente")
Example #7
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.resizable(0, 0)
        self.title("Procesar venta")

        self.frameb = Frame(self)
        self.frameb.pack()
        self.frameb.config(width=950, height=550)
        self.frameb.config(bg="white")

        self.framet = ScrollableFrame(self.frameb)
        self.framet.canvas.config(height=180)
        self.framet.place(x=25, y=330)

        self.frmcl = Frame(self.frameb,
                           width=270,
                           height=120,
                           relief="sunken",
                           bd=5,
                           bg="white")
        self.frmcl.place(x=660, y=20)

        self.titu = Label(self.frameb,
                          text="Agregar item a \n la compra",
                          font=("Verdana", 15),
                          bg="white")
        self.titu.place(x=100, y=30)

        self.lab1 = Label(self.frameb,
                          text="Código:",
                          font=("Verdana", 12),
                          bg="white")
        self.lab1.place(x=70, y=130)

        self.lab2 = Label(self.frameb,
                          text="Cantidad:",
                          font=("Verdana", 12),
                          bg="white")
        self.lab2.place(x=50, y=205)

        self.cod = Entry(self.frameb, width=30)
        self.cod.place(x=150, y=130)

        self.spin = Spinbox(self.frameb, from_=0, to=10000, width=7)
        self.spin.place(x=150, y=205)

        self.agre = Button(self.frameb, text="Agregar", command=self.val)
        self.agre.place(x=150, y=255)

        self.regr = Button(self.frameb,
                           text="Regresar al\n menu anterior",
                           width=25,
                           height=3,
                           command=self.regre)
        self.regr.place(x=730, y=332)
        self.rein = Button(self.frameb,
                           text="Reiniciar \nCompra",
                           width=25,
                           height=3,
                           command=self.reiniciar)
        self.rein.place(x=730, y=402)
        self.fin = Button(self.frameb,
                          text="Proseguir \nCompra",
                          width=25,
                          height=3,
                          command=self.sig)
        self.fin.place(x=730, y=472)

        self.lab3 = Label(self.frameb,
                          text="TOTAL",
                          font=("Verdana", 20),
                          bg="white")
        self.lab3.place(x=500, y=30)

        self.total = Label(self.frameb,
                           text="0.00",
                           font=("Verdana", 40),
                           bg="white")
        self.sum = 0.00
        self.total.place(x=480, y=150)

        nwin = bcliente(self)

        self.item = []
        self.i = 0
        self.tota = []
        self.cantidad = []
        self.facturao = []

        self.mainloop()
Example #8
0
class venta(Tk):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.resizable(0, 0)
        self.title("Procesar venta")

        self.frameb = Frame(self)
        self.frameb.pack()
        self.frameb.config(width=950, height=550)
        self.frameb.config(bg="white")

        self.framet = ScrollableFrame(self.frameb)
        self.framet.canvas.config(height=180)
        self.framet.place(x=25, y=330)

        self.frmcl = Frame(self.frameb,
                           width=270,
                           height=120,
                           relief="sunken",
                           bd=5,
                           bg="white")
        self.frmcl.place(x=660, y=20)

        self.titu = Label(self.frameb,
                          text="Agregar item a \n la compra",
                          font=("Verdana", 15),
                          bg="white")
        self.titu.place(x=100, y=30)

        self.lab1 = Label(self.frameb,
                          text="Código:",
                          font=("Verdana", 12),
                          bg="white")
        self.lab1.place(x=70, y=130)

        self.lab2 = Label(self.frameb,
                          text="Cantidad:",
                          font=("Verdana", 12),
                          bg="white")
        self.lab2.place(x=50, y=205)

        self.cod = Entry(self.frameb, width=30)
        self.cod.place(x=150, y=130)

        self.spin = Spinbox(self.frameb, from_=0, to=10000, width=7)
        self.spin.place(x=150, y=205)

        self.agre = Button(self.frameb, text="Agregar", command=self.val)
        self.agre.place(x=150, y=255)

        self.regr = Button(self.frameb,
                           text="Regresar al\n menu anterior",
                           width=25,
                           height=3,
                           command=self.regre)
        self.regr.place(x=730, y=332)
        self.rein = Button(self.frameb,
                           text="Reiniciar \nCompra",
                           width=25,
                           height=3,
                           command=self.reiniciar)
        self.rein.place(x=730, y=402)
        self.fin = Button(self.frameb,
                          text="Proseguir \nCompra",
                          width=25,
                          height=3,
                          command=self.sig)
        self.fin.place(x=730, y=472)

        self.lab3 = Label(self.frameb,
                          text="TOTAL",
                          font=("Verdana", 20),
                          bg="white")
        self.lab3.place(x=500, y=30)

        self.total = Label(self.frameb,
                           text="0.00",
                           font=("Verdana", 40),
                           bg="white")
        self.sum = 0.00
        self.total.place(x=480, y=150)

        nwin = bcliente(self)

        self.item = []
        self.i = 0
        self.tota = []
        self.cantidad = []
        self.facturao = []

        self.mainloop()

    def val(self):
        if self.cod.get() == "":
            messagebox.showerror("Error", "Ingrese un código de barras")
            self.cod.delete(0, END)
            self.spin.delete(0, END)
        elif len(self.cod.get()) < 7:
            messagebox.showerror(
                "Error", "El codigo debe tener un total de 13 dígitos")
            self.cod.delete(0, END)
            self.spin.delete(0, END)
        elif not self.cod.get().isdigit():
            messagebox.showerror("Error", "El codigo solo puede tener números")
            self.cod.delete(0, END)
            self.spin.delete(0, END)
        elif not self.spin.get().isdigit():
            messagebox.showerror("Error",
                                 "Ingrese una cantidad valida de elementos")
            self.cod.delete(0, END)
            self.spin.delete(0, END)
        elif not checkprodu(self.cod.get()):
            messagebox.showerror("Error", "El item no se ha encontrado")
            self.cod.delete(0, END)
            self.spin.delete(0, END)
        elif checkcant(self.cod.get()) < int(self.spin.get()):
            messagebox.showerror("Error",
                                 "El item no posee suficientes elementos")
            self.cod.delete(0, END)
            self.spin.delete(0, END)
        else:
            self.fill()

    def fill(self):
        self.item.append(
            framemod(self.framet.scrollable_frame,
                     self.cod.get(),
                     width=750,
                     height=80,
                     bg="white"))
        self.item[self.i].pack()
        info = produforventa(self.cod.get())
        self.facturao.append([
            info[1],
            self.spin.get(), info[0], (float(self.spin.get()) * info[1])
        ])
        self.nompro = Label(self.item[self.i], text=info[0], bg="white")
        self.nompro.place(x=20, y=5)
        self.costi = Label(self.item[self.i],
                           text=str(self.spin.get()) + " x Bs.S " +
                           str(info[1]),
                           bg="white")
        self.costi.place(x=20, y=25)
        self.toti = Label(self.item[self.i],
                          text=str(float(self.spin.get()) * info[1]),
                          font=("Verdana", 17),
                          bg="white")
        self.toti.place(x=250, y=5)
        self.tota.append(float(self.spin.get()) * info[1])
        self.cantidad.append(self.spin.get())
        self.canc = Button(self.item[self.i],
                           text="Cancelar",
                           bg="white",
                           command=partial(self.eli, self.item[self.i],
                                           self.tota[self.i],
                                           self.cantidad[self.i]))
        self.canc.place(x=600, y=15)
        self.sum = self.sum + (float(self.spin.get()) * info[1])
        self.total.config(text=self.sum)
        self.cod.delete("0", "end")
        self.spin.delete("0", "end")
        self.i += 1

    def eli(self, fram, tota, cant):
        rest = float(tota)
        self.sum -= rest
        self.total.config(text=self.sum)
        fram.pack_forget()
        fram.destroy()
        self.item.remove(fram)
        self.tota.remove(tota)
        self.cantidad.remove(cant)
        self.i -= 1

    def infoclient(self, ci, nom):
        self.titu2 = Label(self.frmcl,
                           text="Inf. cliente",
                           font=("Verdana", 15),
                           bg="white")
        self.titu2.place(x=40, y=5)
        self.nom = Label(self.frmcl,
                         text="Nombre: " + str(nom),
                         font=("Verdana", 12),
                         bg="white")
        self.nom.place(x=5, y=45)
        self.cic = Label(self.frmcl,
                         text="CI: " + str(ci),
                         font=("Verdana", 12),
                         bg="white")
        self.cic.place(x=5, y=85)
        self.ciclient = ci

    def regre(self):
        ans = messagebox.askquestion(
            "Confirmación", "¿Estas seguro que deseas abandonar la ventana?")
        if ans == "yes":
            self.destroy()

    def reiniciar(self):
        ans = messagebox.askquestion(
            "Confirmación", "¿Estas seguro que deseas reiniciar el proceso?")
        if ans == "yes":
            self.ini()

    def ini(self):
        for i in self.item:
            i.pack_forget()
            i.destroy()
        self.total.config(text=0)
        self.sum = 0.00
        self.i = 0
        self.item = []
        self.tota = []
        self.cantidad = []
        self.facturao = []
        nwin = bcliente(self)

    def sig(self):
        nwind = metodop(self)

    def final(self, met):
        # NOTA: CAMBIAR EL ID DEL EMPLEADO CUANDO ESTE COMPLETO LOS MENUS
        idemp = 4
        idclient = getidcliet(self.ciclient)
        factura = proceventa(idemp, idclient, met, self.sum)
        j = 0
        for i in self.item:
            movventa(i.id, factura, self.cantidad[j])
            retiitem(i.id, self.cantidad[j])
            j += 1

        messagebox.showinfo("Compra exitosa",
                            "La compra se ha procesado correctamente")
        gen_factura(self.facturao, self.sum, factura, idclient)
        self.ini()
Example #9
0
class leventos(Tk):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.resizable(0,0)
        self.title("Listado de eventos")
        
        
        self.frameb= Frame(self)
        self.frameb.pack()
        self.frameb.config(width=750,height=550)
        self.frameb.config(bg="white")


        self.framet= ScrollableFrame(self.frameb,width=100)
        self.framet.place(x=25,y=75)

        
        self.lab1= Label(self.frameb, text="Buscar por...",bg="white",font=("Verdana",12))
        self.lab1.place(x=25,y=25)

        self.comb= ttk.Combobox(self.frameb, width=25,height=10,state="readonly")
        self.comb.place(x=150,y=25)
        self.comb["values"] = ["CI Cliente","CI Empleado","N° de Factura","Metodo"]
        self.comb.set("CI Cliente")
        
        
        self.lab2= Label(self.frameb, text="Buscar:",bg="white",font=("Verdana",12))
        self.lab2.place(x=340,y=25)

        self.text= Entry(self.frameb, width=30)
        self.text.place(x=420,y=25)

        
        
        self.bot = Button(self.frameb, width=10,height=1,text= "Aceptar", command=self.valv)
        self.bot.place(x=640,y=25)

        self.bot2 = Button(self.frameb,text="Movimiento de items",command=self.lmov)
        self.bot2.place(x=580,y=500)

        self.bot3 = Button(self.frameb,text="Operaciones de inventario",command=self.lope)
        self.bot3.place(x=400,y=500)

        self.bot4 = Button(self.frameb,text="Ventas realizadas",command=self.lventa,state="disabled")
        self.bot4.place(x=265,y=500)

        self.bot6 = Button(self.frameb,text="Realizar reporte", command=self.reportv)
        self.bot6.place(x=150,y=500)

        self.bot5 = Button(self.frameb,text="Regresar")
        self.bot5.place(x=25,y=500)

        self.rellenar(allventa())


        self.mainloop()

    def rellenar(self,lista):
        self.reportdata=lista
        self.marco=[]
        i=0
        for vent in lista:
            self.marco.append(framemod(self.framet.scrollable_frame, vent[0],width=750, height=60, bg="#DB7093"))
            self.marco[i].pack()
            self.id = Label(self.marco[i], text="N° Factura: "+str(vent[0]), fg="white", bg="#DB7093")
            self.id.place(x=20,y=5)
            self.cie = Label(self.marco[i], text="CI empleado: "+str(vent[1]), fg="white", bg="#DB7093")
            self.cie.place(x=20,y=25)
            self.cic = Label(self.marco[i], text="CI cliente: "+str(vent[2]), fg="white", bg="#DB7093")
            self.cic.place(x=250,y=25)
            self.met = Label(self.marco[i], text="Pago en: "+str(vent[3]), fg="white", bg="#DB7093")
            self.met.place(x=250,y=5)
            self.mon = Label(self.marco[i], text="Monto: Bs.S"+str(vent[4]), fg="white", bg="#DB7093")
            self.mon.place(x=500,y=5)
            if i % 2 == 0:
                self.marco[i].config(bg="#C40233")
                self.id.config(bg="#C40233")
                self.cie.config(bg="#C40233")
                self.cic.config(bg="#C40233")
                self.met.config(bg="#C40233")
                self.mon.config(bg="#C40233")
            i+=1

    def rellenarm(self,lista):
        self.reportdata=lista
        self.marco=[]
        i=0
        for mov in lista:
            self.marco.append(framemod(self.framet.scrollable_frame, mov[0],width=750, height=60, bg="#DB7093"))
            self.marco[i].pack()
            self.id =Label(self.marco[i], text="ID: " + str(mov[0]), fg="white", bg="#DB7093")
            self.id.place(x=20,y=5)
            self.prod =Label(self.marco[i], text="Producto: "+ str(mov[1]), fg="white", bg="#DB7093")
            self.prod.place(x=20,y=25)
            if mov[2]==0:
                self.iden= Label(self.marco[i], text="ID operación: "+str(mov[3]), fg="white", bg="#DB7093")
            else:
                self.iden= Label(self.marco[i], text="N° factura: "+str(mov[2]), fg="white", bg="#DB7093")  
            self.iden.place(x=250,y=5)
            self.acc =Label(self.marco[i], text="Acción: "+ str(mov[4]), fg="white", bg="#DB7093")
            self.acc.place(x=250,y=25)
            self.cant = Label(self.marco[i], text="Cantidad: "+str(mov[5]), fg="white", bg="#DB7093")
            self.cant.place(x=500,y=5)
            if i % 2 == 0:
                self.marco[i].config(bg="#C40233")
                self.id.config(bg="#C40233")
                self.prod.config(bg="#C40233")
                self.iden.config(bg="#C40233")
                self.acc.config(bg="#C40233")
                self.cant.config(bg="#C40233")
            i+=1

    def rellenaro(self,lista):
        self.reportdata=lista
        self.marco=[]
        i=0
        for ope in lista:
            self.marco.append(framemod(self.framet.scrollable_frame, ope[0],width=750, height=60, bg="#DB7093"))
            self.marco[i].pack()
            self.id = Label(self.marco[i], text="ID Operación: "+str(ope[0]), fg="white", bg="#DB7093")
            self.id.place(x=20,y=5)
            self.cie = Label(self.marco[i], text="CI empleado: "+str(ope[1]), fg="white", bg="#DB7093")
            self.cie.place(x=20,y=25)
            self.des = Label(self.marco[i], text="Acción: "+str(ope[2]), fg="white", bg="#DB7093")
            self.des.place(x=250,y=25)
            self.hora = Label(self.marco[i], text="Fecha: "+str(ope[3]), fg="white", bg="#DB7093")
            self.hora.place(x=250,y=5)
            if i % 2 == 0:
                self.marco[i].config(bg="#C40233")
                self.id.config(bg="#C40233")
                self.cie.config(bg="#C40233")
                self.des.config(bg="#C40233")
                self.hora.config(bg="#C40233")
            i+=1

    def valv(self):
        if self.text.get() == "":
            messagebox.showerror("Error","Ingrese un valor para realizar la busqueda")
            self.text.delete(0,END)
        else: 
            self.buscarv()

    def valm(self):
        if self.text.get() == "":
            messagebox.showerror("Error","Ingrese un valor para realizar la busqueda")
            self.text.delete(0,END)
        else: 
            self.buscarm()

    def valo(self):
        if self.text.get() == "":
            messagebox.showerror("Error","Ingrese un valor para realizar la busqueda")
            self.text.delete(0,END)
        else: 
            self.buscaro()


    def buscarv(self):
        quer=sventa(self.comb.get(),self.text.get())
        self.text.delete(0,END)
        for i in self.marco:
                i.pack_forget()
                i.destroy()
        if len(quer)<1:
            messagebox.showerror("Error","No se han encontrado relaciones, intente otra vez") 
        else:
            messagebox.showinfo("Busqueda exitosa","Se ha encontrado " +str(len(quer))+" registros")
            self.rellenar(quer)
    
    def buscarm(self):
        quer=smov(self.comb.get(),self.text.get())
        self.text.delete(0,END)
        for i in self.marco:
                i.pack_forget()
                i.destroy()
        if len(quer)<1:
            messagebox.showerror("Error","No se han encontrado relaciones, intente otra vez") 
        else:
            messagebox.showinfo("Busqueda exitosa","Se ha encontrado " +str(len(quer))+" registros")
            self.rellenarm(quer)

    def buscaro(self):
        quer=sope(self.comb.get(),self.text.get())
        self.text.delete(0,END)
        for i in self.marco:
                i.pack_forget()
                i.destroy()
        if len(quer)<1:
            messagebox.showerror("Error","No se han encontrado relaciones, intente otra vez") 
        else:
            messagebox.showinfo("Busqueda exitosa","Se ha encontrado " +str(len(quer))+" registros")
            self.rellenaro(quer)

    def lmov(self):
        for i in self.marco:
            i.pack_forget()
            i.destroy()
        self.rellenarm(allmov())
        self.comb["values"] = ["ID","Nombre de producto","Acción"]
        self.comb.set("ID")
        self.bot2.config(state="disabled")
        self.bot3.config(state="normal")
        self.bot4.config(state="normal")
        self.bot6.config(command=self.reportm)
        self.bot.config(command=self.valm)

    def lventa(self):
        for i in self.marco:
            i.pack_forget()
            i.destroy()
        self.rellenar(allventa())
        self.comb["values"] = ["CI Cliente","CI Empleado","N° de Factura","Metodo"]
        self.comb.set("CI Cliente")
        self.bot4.config(state="disabled")
        self.bot2.config(state="normal")
        self.bot3.config(state="normal")
        self.bot6.config(command=self.reportv)
        
        self.bot.config(command=self.valv)

    def lope(self):
        for i in self.marco:
            i.pack_forget()
            i.destroy()
        self.rellenaro(allope())
        self.comb["values"] = ["ID","CI Empleado","Descripción"]
        self.comb.set("ID")
        self.bot4.config(state="normal")
        self.bot2.config(state="normal")
        self.bot3.config(state="disabled")
        self.bot6.config(command=self.reporto)
        self.bot.config(command=self.valo)

    def reportv(self):
        res=messagebox.askquestion("Confirmación","¿Estas seguro que deseas guardar un reporte de los elementos seleccionados?")
        if res == "yes":
            self.ventreport=[["N° de factura","CI Empleado","CI Cliente","Tipo de pago","Monto(Bs.S)"]]
            for v in self.reportdata:
                self.ventreport.append(v)
            now=datetime.now()
            titulo="Reporte de ventas "+str(date.today()) +"  "+ str(now.hour) + "-" + str(now.minute) + "-" + str(now.second) + ".pdf"
            export_to_pdf(4,titulo,"Clientes",self.ventreport)
            messagebox.showinfo("Operación Exitosa","El reporte se ha generado exitosamente")
    
    def reportm(self):
        res=messagebox.askquestion("Confirmación","¿Estas seguro que deseas guardar un reporte de los elementos seleccionados?")
        if res == "yes":
            self.movreport=[["ID","Producto","N° de factura","ID operación","Acción","Cantidad"]]
            for m in self.reportdata:
                if m[2]==0:
                    m[2]="No posee"
                else:
                    m[3]="No posee" 
                self.movreport.append(m)
            now=datetime.now()
            titulo="Reporte de movimientos "+str(date.today()) +"  "+ str(now.hour) + "-" + str(now.minute) + "-" + str(now.second) + ".pdf"
            export_to_pdf(4,titulo,"Clientes",self.movreport)
            messagebox.showinfo("Operación Exitosa","El reporte se ha generado exitosamente")
            
    def reporto(self):
        res=messagebox.askquestion("Confirmación","¿Estas seguro que deseas guardar un reporte de los elementos seleccionados?")
        if res == "yes":
            self.opereport=[["ID","CI Empleado","Descripción","Fecha/Hora"]]
            for o in self.reportdata:
                self.opereport.append(o)
            now=datetime.now()
            titulo="Reporte de operaciones "+str(date.today()) +"  "+ str(now.hour) + "-" + str(now.minute) + "-" + str(now.second) + ".pdf"
            export_to_pdf(4,titulo,"Clientes",self.opereport)
            messagebox.showinfo("Operación Exitosa","El reporte se ha generado exitosamente")
Example #10
0
class SearchView:
    """
    creates search view with scroll, filter menu and place for results
    """
    def __init__(self, master):

        self.scroll_frame = ScrollableFrame(master)
        self.scroll_frame.pack(side=tk.LEFT, fill='both', expand=True)

        self.oldest_movie = int(functions.get_oldest_release_year("movie"))
        self.oldest_tv = int(functions.get_oldest_release_year("tv"))

        self.search_frame = tk.Frame(self.scroll_frame.scrollable_frame,
                                     bg="#FFFFFF")
        self.search_frame.pack(side=tk.LEFT, anchor='n', fill='y')

        self.go_up_button = tk.Button(self.search_frame,
                                      text="GO UP",
                                      font=(functions.FONT, 12, "bold"),
                                      command=self.go_up,
                                      width=15,
                                      bg=functions.THIRD_COLOR,
                                      fg="#FFFFFF",
                                      pady=5)
        self.go_up_button.pack(side=tk.BOTTOM)

        self.var_what = tk.IntVar()
        self.checkbuttons_input = []
        self.checkbuttons_states = []

        self.title_input = ""
        self.sorting_input = ""
        self.release_date_from_input = tk.StringVar()
        self.release_date_to_input = tk.StringVar()
        self.vote_average_from_input = tk.StringVar()
        self.vote_average_to_input = tk.StringVar()

        self.sorting_options = [
            "", "A-Z", "Z-A", "release date - asc", "release date - desc",
            "popularity - asc", "popularity - desc", "vote average - asc",
            "vote average - desc"
        ]

        self.comboboxes = []
        self.create_options()

        self.results_frame = tk.Frame(self.scroll_frame.scrollable_frame,
                                      bg=functions.BG_COLOR)
        self.results_frame.pack(side=tk.RIGHT,
                                fill='x',
                                expand=True,
                                anchor='n')
        self.results_frame.columnconfigure(1, minsize=1000)

        self.results_grid_frame = tk.Frame(self.results_frame,
                                           bg=functions.BG_COLOR)
        self.results_grid_frame.pack(fill='x', expand=True)
        self.results_table = []

        self.pages_frame = tk.Frame(self.results_frame, bg=functions.BG_COLOR)
        self.pages_frame.pack()
        self.pages_table = []
        self.pages_amount = 0
        self.actual_page = -1

        self.default_fg = ""
        self.default_bg = ""

    """
    scrolls to the top of the page
    """

    def go_up(self):
        self.scroll_frame.canvas.yview_moveto('0.0')

    """
    chooses correct year for type of production
    """

    def oldest(self, what):
        if what == 1:
            return self.oldest_movie
        elif what == 2:
            return self.oldest_tv

    """
    creates filter options
    """

    def create_options(self):

        button_frame = tk.Frame(self.search_frame, padx=5, pady=5)
        button_frame.pack(fill='x')

        what_frame = tk.LabelFrame(self.search_frame,
                                   text="CATEGORY",
                                   font=(functions.FONT, 10),
                                   fg=functions.FONT_COLOR)
        what_frame.pack(fill='x')
        """
        changes content of widgets when required
        """
        def change_widgets():
            change_checkbuttons()
            change_comboboxes()

        """
        changes content of checkbuttons (genres) when required
        """

        def change_checkbuttons():

            for button in self.checkbuttons_input:
                button.destroy()
            self.checkbuttons_states.clear()
            self.checkbuttons_input.clear()

            for i in range(len(functions.get_genres(self.var_what.get())[0])):
                self.checkbuttons_states.append(tk.BooleanVar())
                checkbutton = tk.Checkbutton(
                    genres_frame,
                    variable=self.checkbuttons_states[-1],
                    text=functions.get_genres(self.var_what.get())[0][i],
                    font=(functions.FONT, 10),
                    fg=functions.FONT_COLOR)
                checkbutton.grid(row=i, sticky='w')
                self.checkbuttons_input.append(checkbutton)

        # RADIOBUTTONS
        radio1 = tk.Radiobutton(what_frame,
                                text="Movies",
                                variable=self.var_what,
                                command=change_widgets,
                                value=1,
                                font=(functions.FONT, 10),
                                fg=functions.FONT_COLOR)
        radio1.grid(row=0, column=0)
        radio2 = tk.Radiobutton(what_frame,
                                text="TV series",
                                variable=self.var_what,
                                command=change_widgets,
                                value=2,
                                font=(functions.FONT, 10),
                                fg=functions.FONT_COLOR)
        radio2.grid(row=0, column=1)
        self.var_what.set('1')

        # TITLE
        title_frame = tk.LabelFrame(self.search_frame,
                                    text='TITLE',
                                    font=(functions.FONT, 10),
                                    fg=functions.FONT_COLOR)
        title_frame.pack(fill='x')
        enter_title = tk.Entry(title_frame)
        enter_title.pack()

        # SORT
        sort_frame = tk.LabelFrame(self.search_frame,
                                   text='SORTING',
                                   font=(functions.FONT, 10),
                                   fg=functions.FONT_COLOR)
        sort_frame.pack(fill='x')
        sort_combo = ttk.Combobox(sort_frame,
                                  values=self.sorting_options,
                                  state="readonly")
        sort_combo.pack()

        # GENRES
        genres_frame = tk.LabelFrame(self.search_frame,
                                     text="GENRES",
                                     font=(functions.FONT, 10),
                                     fg=functions.FONT_COLOR)
        genres_frame.pack(fill='x')

        change_checkbuttons()

        # RELEASE DATE
        when_frame = tk.LabelFrame(self.search_frame,
                                   text="RELEASE DATE",
                                   font=(functions.FONT, 10),
                                   fg=functions.FONT_COLOR)
        when_frame.pack(fill='x')
        year_from = tk.Label(when_frame,
                             text="From",
                             font=(functions.FONT, 10),
                             fg=functions.FONT_COLOR)
        year_from.grid(row=0, sticky='w')
        year_to = tk.Label(when_frame,
                           text="To",
                           font=(functions.FONT, 10),
                           fg=functions.FONT_COLOR)
        year_to.grid(row=2, sticky='w')
        now = datetime.datetime.now()

        self.wrong_query_date = tk.Message(
            when_frame,
            text="Date 'from' can't be bigger than 'to'.",
            font=(functions.FONT, 9),
            width=120,
            fg="#8B0000")
        """
        changes content of comboboxes (years) when required
        """

        def change_comboboxes():
            for combo in self.comboboxes:
                combo.destroy()
                self.comboboxes.clear()

            combo_from = ttk.Combobox(
                when_frame,
                values=list(
                    range(self.oldest(self.var_what.get()), now.year + 1)),
                textvariable=self.release_date_from_input,
                state="readonly")
            combo_from.grid(row=1, sticky='w')
            self.comboboxes.append(combo_from)
            combo_to = ttk.Combobox(when_frame,
                                    values=list(
                                        range(self.oldest(self.var_what.get()),
                                              now.year + 1)),
                                    textvariable=self.release_date_to_input,
                                    state="readonly")
            combo_to.grid(row=3, sticky='w')
            self.comboboxes.append(combo_to)

        change_comboboxes()

        #VOTES AVERAGE
        vote_frame = tk.LabelFrame(self.search_frame,
                                   text="VOTE AVERAGE",
                                   font=(functions.FONT, 10),
                                   fg=functions.FONT_COLOR)
        vote_frame.pack(fill='x')
        avg_from = tk.Label(vote_frame,
                            text="From",
                            font=(functions.FONT, 10),
                            fg=functions.FONT_COLOR)
        avg_from.grid(row=0, sticky='w')
        avg_to = tk.Label(vote_frame,
                          text="To",
                          font=(functions.FONT, 10),
                          fg=functions.FONT_COLOR)
        avg_to.grid(row=2, sticky='w')
        combo_avg_from = ttk.Combobox(
            vote_frame,
            values=list(x / 10 for x in range(0, 101)),
            textvariable=self.vote_average_from_input,
            state="readonly")
        combo_avg_from.grid(row=1, sticky='w')
        combo_avg_to = ttk.Combobox(vote_frame,
                                    values=list(x / 10 for x in range(0, 101)),
                                    textvariable=self.vote_average_to_input,
                                    state="readonly")
        combo_avg_to.grid(row=3, sticky='w')

        self.wrong_query_vote = tk.Message(
            vote_frame,
            text="Vote 'from' can't be bigger than 'to'.",
            font=(functions.FONT, 9),
            width=120,
            fg="#8B0000")
        """
        gets selected filters and sorting and shows results
        """

        def get_input():
            # GENRES
            genres = []
            for i in range(len(self.checkbuttons_states)):
                if self.checkbuttons_states[i].get():
                    genres.append(self.checkbuttons_input[i].cget("text"))

            self.title_input = enter_title.get()
            self.sorting_input = sort_combo.get()

            # TYPE OF PRODUCTION
            what_get = self.var_what.get()

            if what_get == 1:
                what = "movie"
            elif what_get == 2:
                what = "tv"

            # GET REST OF INFO
            title = self.title_input
            sorting = self.sorting_input
            date_from = self.release_date_from_input.get()
            date_to = self.release_date_to_input.get()
            vote_from = self.vote_average_from_input.get()
            vote_to = self.vote_average_to_input.get()

            self.actual_page = -1

            self.results_table.clear()
            self.pages_table.clear()

            # FILTER, SORT PRODUCTIONS AND GET MOST IMPORTANT INFO
            result = functions.search_filter_sort(what, title, genres,
                                                  date_from, date_to,
                                                  vote_from, vote_to, sorting)
            result = functions.filter_info(what, result)

            for item in self.results_table:
                item.grid_forget()

            for widget in self.results_grid_frame.winfo_children():
                widget.destroy()

            for widget in self.pages_frame.winfo_children():
                widget.destroy()
            """
            devides list into lists of n elements
            """
            def chunks(lst, n):
                for i in range(0, len(lst), n):
                    yield lst[i:i + n]

            # INCONSISTENT FILTERS (DATE, VOTE)
            if len(self.release_date_from_input.get()) > 0 and len(
                    self.release_date_to_input.get()) > 0 and len(
                        self.vote_average_from_input.get()) > 0 and len(
                            self.vote_average_to_input.get()) > 0:
                if int(self.release_date_from_input.get()) > int(
                        self.release_date_to_input.get()) and float(
                            self.vote_average_from_input.get()) > float(
                                self.vote_average_to_input.get()):
                    self.wrong_query_date.grid(row=4, sticky='w')
                    self.wrong_query_vote.grid(row=4, sticky='w')
                    return

            if len(self.release_date_from_input.get()) > 0 and len(
                    self.release_date_to_input.get()) > 0:
                if int(self.release_date_from_input.get()) > int(
                        self.release_date_to_input.get()):
                    self.wrong_query_vote.grid_forget()
                    self.wrong_query_date.grid(row=4, sticky='w')
                    return

            if len(self.vote_average_from_input.get()) > 0 and len(
                    self.vote_average_to_input.get()) > 0:
                if float(self.vote_average_from_input.get()) > float(
                        self.vote_average_to_input.get()):
                    self.wrong_query_date.grid_forget()
                    self.wrong_query_vote.grid(row=4, sticky='w')
                    return
            """
            shows n-th page of results
            """

            def show_page(page):
                if self.actual_page != -1:
                    for child in self.results_table[self.actual_page]:
                        child.grid_forget()

                # CHANGE COLOR OF ACTUAL PAGE
                if self.actual_page != page:
                    self.pages_table[self.actual_page].configure(
                        bg=self.default_bg, fg=self.default_fg)
                    self.pages_table[page].configure(bg=functions.SECOND_COLOR,
                                                     fg="#FFFFFF")

                self.actual_page = page
                rows = math.ceil(len(self.results_table[page]) / 5)
                columns_last_row = len(self.results_table[page]) % 5

                # DEVIDE INTO COLUMNS AND ROWS
                for row in range(rows):
                    if row == rows - 1 and columns_last_row != 0:
                        columns = columns_last_row
                    else:
                        columns = 5
                    for column in range(columns):
                        self.results_table[page][row * 5 + column].grid(
                            column=column, row=row, padx=10, sticky='n')

                for page_button in self.pages_table:
                    page_button.pack_forget()

                # SHOW PROPER NUMBER OF PAGES
                if self.pages_amount < 11:
                    for page_button in self.pages_table:
                        page_button.pack(side=tk.LEFT)
                else:
                    if page <= 5:
                        for i in range(10):
                            self.pages_table[i].pack(side=tk.LEFT)
                    elif page >= self.pages_amount - 5:
                        for i in range(self.pages_amount - 10,
                                       self.pages_amount):
                            self.pages_table[i].pack(side=tk.LEFT)
                    else:
                        for i in range(page - 5, page + 5):
                            self.pages_table[i].pack(side=tk.LEFT)

                self.scroll_frame.canvas.yview_moveto('0.0')

            self.wrong_query_date.grid_forget()
            self.wrong_query_vote.grid_forget()

            # NO RESULTS
            if len(result) == 0:
                no_results = tk.Label(
                    self.results_grid_frame,
                    text="Sorry, there are no results for your query:(",
                    font=(functions.FONT, 30),
                    bg=functions.BG_COLOR,
                    fg=functions.FONT_COLOR,
                    pady=100)
                no_results.pack(fill='x', expand=True, anchor='center')

            # RESULTS
            else:
                for i in range(len(result)):
                    SingleProdView(self.results_grid_frame, self.results_table,
                                   i, result, False)

                self.results_table = list(chunks(self.results_table, 20))
                self.pages_amount = len(self.results_table)

                # PAGES
                for i in range(len(self.results_table)):
                    button = tk.Button(self.pages_frame,
                                       text=(i + 1),
                                       command=lambda page=i: show_page(page),
                                       fg=functions.FONT_COLOR)
                    self.pages_table.append(button)

                self.default_bg = self.pages_table[0].cget("background")
                self.default_fg = self.pages_table[0].cget("foreground")

                show_page(0)

        # SEARCH
        search_button = tk.Button(button_frame,
                                  text="SEARCH",
                                  font=(functions.FONT, 12, "bold"),
                                  pady=5,
                                  padx=25,
                                  command=lambda: get_input(),
                                  bg=functions.THIRD_COLOR,
                                  fg="#FFFFFF")
        search_button.pack(fill='x', expand=True)
Example #11
0
    def __init__(self, master):

        self.scroll_frame = ScrollableFrame(master)
        self.scroll_frame.pack(side=tk.LEFT, fill='both', expand=True)

        self.oldest_movie = int(functions.get_oldest_release_year("movie"))
        self.oldest_tv = int(functions.get_oldest_release_year("tv"))

        self.search_frame = tk.Frame(self.scroll_frame.scrollable_frame,
                                     bg="#FFFFFF")
        self.search_frame.pack(side=tk.LEFT, anchor='n', fill='y')

        self.go_up_button = tk.Button(self.search_frame,
                                      text="GO UP",
                                      font=(functions.FONT, 12, "bold"),
                                      command=self.go_up,
                                      width=15,
                                      bg=functions.THIRD_COLOR,
                                      fg="#FFFFFF",
                                      pady=5)
        self.go_up_button.pack(side=tk.BOTTOM)

        self.var_what = tk.IntVar()
        self.checkbuttons_input = []
        self.checkbuttons_states = []

        self.title_input = ""
        self.sorting_input = ""
        self.release_date_from_input = tk.StringVar()
        self.release_date_to_input = tk.StringVar()
        self.vote_average_from_input = tk.StringVar()
        self.vote_average_to_input = tk.StringVar()

        self.sorting_options = [
            "", "A-Z", "Z-A", "release date - asc", "release date - desc",
            "popularity - asc", "popularity - desc", "vote average - asc",
            "vote average - desc"
        ]

        self.comboboxes = []
        self.create_options()

        self.results_frame = tk.Frame(self.scroll_frame.scrollable_frame,
                                      bg=functions.BG_COLOR)
        self.results_frame.pack(side=tk.RIGHT,
                                fill='x',
                                expand=True,
                                anchor='n')
        self.results_frame.columnconfigure(1, minsize=1000)

        self.results_grid_frame = tk.Frame(self.results_frame,
                                           bg=functions.BG_COLOR)
        self.results_grid_frame.pack(fill='x', expand=True)
        self.results_table = []

        self.pages_frame = tk.Frame(self.results_frame, bg=functions.BG_COLOR)
        self.pages_frame.pack()
        self.pages_table = []
        self.pages_amount = 0
        self.actual_page = -1

        self.default_fg = ""
        self.default_bg = ""
Example #12
0
class DetailsView:

    """
    creates details view with info about specific production
    """

    def __init__(self, master, what, id, photo):

        self.scroll_frame = ScrollableFrame(master)
        self.scroll_frame.pack(fill='both', expand=True)

        self.details_frame = tk.LabelFrame(self.scroll_frame.scrollable_frame, bg=functions.BG_COLOR)
        self.details_frame.grid(column=0, row=0, padx=30, pady=50)

        self.info = functions.get_info_about(what, id, True)

        functions.write_history(what, id)

        self.place_poster(photo)
        self.place_info(self.info, what)

    """
    send request to get poster of production and places it
    """

    def place_poster(self, photo):
        if photo is not None:
            img_url = "https://image.tmdb.org/t/p/w300" + photo
            img_data = reqs.get(img_url).content
            img = ImageTk.PhotoImage(Image.open(BytesIO(img_data)).resize((300, 450), Image.ANTIALIAS))
        else:
            img_path = functions.ICONS_PATH + "300x450.png"
            img = tk.PhotoImage(file=img_path)

        photo_label = tk.Label(self.details_frame, image=img, bg="#FFFFFF")
        photo_label.image = img
        photo_label.grid(row=0, column=0, rowspan=5, sticky='nw')

    """
    places info about production
    """

    def place_info(self, info, what):

        title = tk.Message(self.details_frame, text=info[0], padx=10, font=(functions.FONT, 36), bg=functions.BG_COLOR,
                           fg=functions.FONT_COLOR, width=700)
        title.grid(row=0, column=1, sticky='w')

        if what == "movie":
            date = info[1]
            details_text = info[4]
            genres = info[2]
        elif what == "tv":
            if info[6] == "Ended":
                if info[1] == info[2]:
                    date = info[1]
                else:
                    date = str(info[1]) + " - " + str(info[2])
            else:
                date = str(info[1]) + " - now"

            details_text = info[5]
            genres = info[3]

        genres = ", ".join(genres)
        genres.replace("{", "").replace("}", "")

        genres_label = tk.Message(self.details_frame, text=genres, padx=10, font=(functions.FONT, 24), bg=functions.BG_COLOR, fg=functions.FONT_COLOR, width=700)
        genres_label.grid(row=1, column=1, sticky='nw')

        year = tk.Label(self.details_frame, text=date, padx=10, font=(functions.FONT, 24), bg=functions.BG_COLOR, fg=functions.FONT_COLOR)
        year.grid(row=2, column=1, sticky='nw')

        rating = tk.Label(self.details_frame, text=str(info[-1]) + "/10", padx=10, bg=functions.BG_COLOR, fg=functions.FONT_COLOR,
                          font=(functions.FONT, 18))
        rating.grid(row=3, column=1, sticky='w')

        details = tk.Message(self.details_frame, text=details_text, padx=10, font=(functions.FONT, 16), bg=functions.BG_COLOR,
                             fg=functions.FONT_COLOR, width=700)
        details.grid(row=4, column=1, sticky='w')

        self.details_frame.rowconfigure(0, weight=1)
        self.details_frame.rowconfigure(1, weight=1)
        self.details_frame.rowconfigure(2, weight=1)
        self.details_frame.rowconfigure(3, weight=1)
        self.details_frame.rowconfigure(4, weight=5)
Example #13
0
class inventario(Tk):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.resizable(0, 0)
        self.title("Inventario de productos")

        self.frameb = Frame(self)
        self.frameb.pack()
        self.frameb.config(width=750, height=550)
        self.frameb.config(bg="white")

        self.framet = ScrollableFrame(self.frameb, width=100)
        self.framet.place(x=25, y=75)

        self.lab1 = Label(self.frameb,
                          text="Buscar por...",
                          bg="white",
                          font=("Verdana", 12))
        self.lab1.place(x=25, y=25)

        self.comb = ttk.Combobox(self.frameb,
                                 width=25,
                                 height=10,
                                 state="readonly")
        self.comb.place(x=150, y=25)
        self.comb["values"] = ["Nombre", "Código"]
        self.comb.set("Nombre")

        self.lab2 = Label(self.frameb,
                          text="Buscar:",
                          bg="white",
                          font=("Verdana", 12))
        self.lab2.place(x=340, y=25)

        self.text = Entry(self.frameb, width=30)
        self.text.place(x=420, y=25)

        self.bot = Button(self.frameb,
                          width=10,
                          height=1,
                          text="Aceptar",
                          command=self.vali)
        self.bot.place(x=640, y=25)

        self.bot2 = Button(self.frameb,
                           text="Listado de productos",
                           command=self.lprodu)
        self.bot2.place(x=580, y=500)

        self.bot3 = Button(self.frameb, text="Regresar")
        self.bot3.place(x=25, y=500)

        self.bot4 = Button(self.frameb,
                           text="Realizar reporte",
                           command=self.reporti)
        self.bot4.place(x=150, y=500)

        self.rellenar(allitem())

        self.mainloop()

    def rellenar(self, lista):
        self.reportdata = lista
        self.marco = []
        i = 0
        for item in lista:
            self.marco.append(
                framemod(self.framet.scrollable_frame,
                         item[0],
                         width=750,
                         height=60,
                         bg="#DB7093"))
            self.marco[i].pack()
            self.marco[i].bind("<Button-1>", self.iteminfo)
            self.id = Label(self.marco[i],
                            text="Codigo de barras: " + str(item[0]),
                            fg="white",
                            bg="#DB7093")
            self.id.place(x=20, y=5)
            self.nom = Label(self.marco[i],
                             text=item[1],
                             fg="white",
                             bg="#DB7093")
            self.nom.place(x=20, y=25)
            self.cant = Label(self.marco[i],
                              text="Cantidad ingresada: " + str(item[2]),
                              fg="white",
                              bg="#DB7093")
            self.cant.place(x=250, y=5)
            self.est = Label(self.marco[i],
                             text="Estado: " + str(item[3]),
                             fg="white",
                             bg="#DB7093")
            self.est.place(x=500, y=5)
            if i % 2 == 0:
                self.marco[i].config(bg="#C40233")
                self.id.config(bg="#C40233")
                self.nom.config(bg="#C40233")
                self.cant.config(bg="#C40233")
                self.est.config(bg="#C40233")
            i += 1

    def rellenarp(self, lista):
        self.marco = []
        self.reportdata = lista
        i = 0
        for item in lista:
            self.marco.append(
                framemod(self.framet.scrollable_frame,
                         item[0],
                         width=750,
                         height=60,
                         bg="#DB7093"))
            self.marco[i].pack()
            self.marco[i].bind("<Button-1>", self.prodinfo)
            self.id = Label(self.marco[i],
                            text=str(item[0]),
                            fg="white",
                            bg="#DB7093")
            self.id.place(x=20, y=5)
            self.nom = Label(self.marco[i],
                             text=item[1],
                             fg="white",
                             bg="#DB7093")
            self.nom.place(x=50, y=5)
            self.clas = Label(self.marco[i],
                              text=item[3],
                              fg="white",
                              bg="#DB7093")
            self.clas.place(x=50, y=30)
            self.cant = Label(self.marco[i],
                              text=item[2],
                              fg="white",
                              bg="#DB7093")
            self.cant.place(x=570, y=5)
            if i % 2 == 0:
                self.marco[i].config(bg="#C40233")
                self.id.config(bg="#C40233")
                self.nom.config(bg="#C40233")
                self.cant.config(bg="#C40233")
                self.clas.config(bg="#C40233")
            i += 1

    def vali(self):
        if self.text.get() == "":
            messagebox.showerror("Error",
                                 "Ingrese un valor para realizar la busqueda")
            self.text.delete(0, END)
        else:
            self.buscari()

    def valp(self):
        if self.text.get() == "":
            messagebox.showerror("Error",
                                 "Ingrese un valor para realizar la busqueda")
            self.text.delete(0, END)
        else:
            self.buscarp()

    def buscari(self):
        quer = sitem(self.comb.get(), self.text.get())
        self.text.delete(0, END)
        for i in self.marco:
            i.pack_forget()
            i.destroy()
        if len(quer) < 1:
            messagebox.showerror(
                "Error", "No se han encontrado relaciones, intente otra vez")
        else:
            messagebox.showinfo(
                "Busqueda exitosa",
                "Se ha encontrado " + str(len(quer)) + " registros")
            self.rellenar(quer)

    def buscarp(self):
        quer = sprodu(self.comb.get(), self.text.get())
        self.text.delete(0, END)
        for i in self.marco:
            i.pack_forget()
            i.destroy()
        if len(quer) < 1:
            messagebox.showerror(
                "Error", "No se han encontrado relaciones, intente otra vez")
        else:
            messagebox.showinfo(
                "Busqueda exitosa",
                "Se ha encontrado " + str(len(quer)) + " registros")
            self.rellenarp(quer)

    def lprodu(self):
        for i in self.marco:
            i.pack_forget()
            i.destroy()
        self.rellenarp(allprodu())
        self.comb["values"] = ["Nombre", "ID", "Clasificación"]
        self.comb.set("Nombre")
        self.bot2.config(command=self.litem, text="Listado de items")
        self.bot.config(command=self.valp)
        self.bot4.config(command=self.reportp)

    def litem(self):
        for i in self.marco:
            i.pack_forget()
            i.destroy()
        self.rellenar(allitem())
        self.comb["values"] = ["Nombre", "Código"]
        self.comb.set("Nombre")
        self.bot2.config(command=self.lprodu, text="Listado de productos")
        self.bot.config(command=self.vali)
        self.bot4.config(command=self.reporti)

    def iteminfo(self, event):
        caller = event.widget
        pos = caller.id
        nwin = itemindi(self, pos)

    def prodinfo(self, event):
        caller = event.widget
        pos = caller.id
        nwin = produindi(self, pos)

    def refreshi(self):
        for i in self.marco:
            i.pack_forget()
            i.destroy()
        self.rellenar(allitem())

    def refreshp(self):
        for i in self.marco:
            i.pack_forget()
            i.destroy()
        self.rellenarp(allprodu())

    def reportp(self):
        res = messagebox.askquestion(
            "Confirmación",
            "¿Estas seguro que deseas guardar un reporte de los elementos seleccionados?"
        )
        if res == "yes":
            self.prodreport = [[
                "ID", "Nombre", "disponibilidad", "Clasificación",
                "Precio(Bs.S)"
            ]]
            for p in self.reportdata:
                self.prodreport.append(p)
            now = datetime.now()
            titulo = "Reporte de productos " + str(date.today()) + "  " + str(
                now.hour) + "-" + str(now.minute) + "-" + str(
                    now.second) + ".pdf"
            export_to_pdf(4, titulo, "Clientes", self.prodreport)
            messagebox.showinfo("Operación Exitosa",
                                "El reporte se ha generado exitosamente")

    def reporti(self):
        res = messagebox.askquestion(
            "Confirmación",
            "¿Estas seguro que deseas guardar un reporte de los elementos seleccionados?"
        )
        if res == "yes":
            self.itreport = [[
                "Código", "Producto", "Cant registrada", "Estado",
                "F. registro", "F. expedición"
            ]]
            for p in self.reportdata:
                self.itreport.append(p)
            now = datetime.now()
            titulo = "Reporte de clientes " + str(date.today()) + "  " + str(
                now.hour) + "-" + str(now.minute) + "-" + str(
                    now.second) + ".pdf"
            export_to_pdf(4, titulo, "Clientes", self.itreport)
            messagebox.showinfo("Operación Exitosa",
                                "El reporte se ha generado exitosamente")