add good received popup window
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import flet as ft
|
||||
from dbActions.products import Products
|
||||
from dbActions.categories import Categories
|
||||
|
||||
class GoodsReception:
|
||||
def __init__(self, page: ft.Page, dashboard, inventory):
|
||||
@@ -6,9 +8,191 @@ class GoodsReception:
|
||||
self.dashboard = dashboard
|
||||
self.inventory = inventory
|
||||
|
||||
def on_add_btn_click(self, e):
|
||||
self.product_id = None
|
||||
self.products_manager = Products()
|
||||
self.category_manager = Categories()
|
||||
self.all_products = self.products_manager.get_all()
|
||||
self.categories = self.category_manager.get_categories()
|
||||
self.list_products = ft.ListView(
|
||||
controls=self.create_list(self.all_products, self.on_products_btn_click),
|
||||
expand=True,
|
||||
spacing=10,
|
||||
width=350,
|
||||
height=450
|
||||
)
|
||||
self.name = ft.TextField(label="Denumire")
|
||||
self.category = ft.Dropdown(
|
||||
label="Categorie",
|
||||
options=self.get_categories(),
|
||||
expand=True
|
||||
)
|
||||
self.quantity = ft.TextField(label="grame/buc")
|
||||
self.init_stock = ft.TextField(label = "Stoc initial")
|
||||
self.masure = ft.Dropdown(
|
||||
label="Unitate de masura",
|
||||
options=self.get_masure_unit(),
|
||||
expand=True
|
||||
)
|
||||
self.new_stock = ft.TextField(label="Stoc nou")
|
||||
self.total_units = ft.TextField(label="Cantitate totala", read_only=True)
|
||||
self.enter_price = ft.TextField(label="Pret intrare")
|
||||
self.exit_price = ft.TextField(label = "Pret vanzare")
|
||||
self.stock_min = ft.TextField(label = "Stoc minim")
|
||||
self.stock_max = ft.TextField(label = "Stoc maxim")
|
||||
|
||||
self.search_bar = ft.TextField(label="Cauta", on_submit=self.on_search_btn_click)
|
||||
self.search_btn = ft.IconButton(
|
||||
icon=ft.Icons.SEARCH,
|
||||
on_click=self.on_search_btn_click,
|
||||
bgcolor=ft.Colors.BROWN,
|
||||
icon_color=ft.Colors.WHITE
|
||||
)
|
||||
|
||||
self.add_new_item_dialog = ft.AlertDialog(
|
||||
title=ft.Text("Adauga intrare noua"),
|
||||
content=ft.Column(
|
||||
[
|
||||
ft.Row(
|
||||
[
|
||||
ft.Column(
|
||||
[
|
||||
ft.Row(
|
||||
[
|
||||
self.search_bar,
|
||||
self.search_btn
|
||||
],
|
||||
),
|
||||
self.list_products,
|
||||
ft.Button(
|
||||
"Adauga produs",
|
||||
on_click=self.on_add_produt_btn_click,
|
||||
icon=ft.Icons.ADD,
|
||||
width=350
|
||||
),
|
||||
|
||||
],
|
||||
width=350
|
||||
),
|
||||
ft.VerticalDivider(width=2) ,
|
||||
ft.Column(
|
||||
[
|
||||
self.name,
|
||||
self.category,
|
||||
self.quantity,
|
||||
self.init_stock,
|
||||
self.new_stock,
|
||||
self.masure,
|
||||
self.total_units,
|
||||
self.enter_price,
|
||||
self.exit_price,
|
||||
self.stock_min,
|
||||
self.stock_max
|
||||
],
|
||||
width=320,
|
||||
height=550,
|
||||
scroll=ft.ScrollMode.AUTO
|
||||
)
|
||||
],
|
||||
vertical_alignment=ft.CrossAxisAlignment.START,
|
||||
spacing=10
|
||||
)
|
||||
],
|
||||
width=700,
|
||||
height=650,
|
||||
alignment=ft.MainAxisAlignment.START
|
||||
),
|
||||
actions=[
|
||||
ft.FilledButton("Salveaza", on_click=self.on_save_btn_click),
|
||||
ft.Button("Anuleaza", on_click=self.on_cancel_btn_click)
|
||||
]
|
||||
)
|
||||
|
||||
def on_add_produt_btn_click(self, e):
|
||||
pass
|
||||
|
||||
def on_save_btn_click(self, e):
|
||||
pass
|
||||
|
||||
def on_cancel_btn_click(self, e):
|
||||
pass
|
||||
|
||||
def on_search_btn_click(self, e):
|
||||
pass
|
||||
|
||||
def get_categories(self):
|
||||
return [
|
||||
ft.dropdown.Option(key=cat['id'], text=cat['name'])
|
||||
for cat in self.categories
|
||||
]
|
||||
|
||||
def get_masure_unit(self):
|
||||
return [
|
||||
ft.dropdown.Option(key='buc', text='BUC'),
|
||||
ft.dropdown.Option(key='kg', text='KG')
|
||||
]
|
||||
|
||||
def on_products_btn_click(self, item):
|
||||
self.name.value = item['name']
|
||||
self.name.update()
|
||||
self.category.value = item['category_id']
|
||||
self.category.update()
|
||||
self.quantity.value = item['quantity']
|
||||
self.quantity.update()
|
||||
# self.init_stock.value = ''
|
||||
# self.new_stock.value = ''
|
||||
# self.masure.value = ''
|
||||
# self.total_units.value = ''
|
||||
# self.enter_price.value = ''
|
||||
# self.exit_price.value = ''
|
||||
# self.stock_min.value = ''
|
||||
# self.stock_max.value = ''
|
||||
|
||||
|
||||
def get_category_name(self, id):
|
||||
for category in self.categories:
|
||||
if int(category['id']) == int(id):
|
||||
return category['name']
|
||||
|
||||
def create_list(self, items, on_click_handler):
|
||||
"""Helper to create list items for a column."""
|
||||
return [
|
||||
ft.Container(
|
||||
content=ft.Row(
|
||||
[
|
||||
ft.Row(
|
||||
[
|
||||
ft.Image(
|
||||
src=item['image'],
|
||||
width=50,
|
||||
height=50,
|
||||
fit=ft.ImageFit.COVER,
|
||||
border_radius=5
|
||||
),
|
||||
ft.Column(
|
||||
[
|
||||
ft.Text(value=item['name'], weight=ft.FontWeight.BOLD, size=15),
|
||||
ft.Text(value=f"Categorie: {self.get_category_name(item['category_id'])}", size=12)
|
||||
]
|
||||
),
|
||||
]
|
||||
)
|
||||
],
|
||||
alignment=ft.MainAxisAlignment.SPACE_BETWEEN,
|
||||
),
|
||||
width=300,
|
||||
bgcolor=ft.Colors.BROWN_50,
|
||||
padding=10,
|
||||
border_radius=8,
|
||||
border = ft.border.all(1, ft.Colors.GREY),
|
||||
ink=True,
|
||||
on_click=lambda e, id=item: on_click_handler(id)
|
||||
)
|
||||
for item in items
|
||||
]
|
||||
|
||||
def on_add_btn_click(self, e):
|
||||
self.page.open(self.add_new_item_dialog)
|
||||
|
||||
def build(self):
|
||||
return ft.Container(
|
||||
ft.Column(
|
||||
|
||||
Reference in New Issue
Block a user