From 341c41489c6a548f6f0e2746bf97df14ac04ca6a Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Thu, 24 Oct 2024 23:30:57 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=BF=D1=80=D0=BE=D1=81=20?= =?UTF-8?q?=E2=84=963?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Requests/requests.py | 24 ++++++++++++++++--- App/Requests/sql/zapros3.sql | 9 +++++++ ...{zagotovki_ship.html => sellers_ship.html} | 4 ++-- .../{sklad_zapros.html => zagotovki.html} | 6 ++--- App/Requests/zapros_menu.json | 5 ++-- 5 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 App/Requests/sql/zapros3.sql rename App/Requests/templates/{zagotovki_ship.html => sellers_ship.html} (88%) rename App/Requests/templates/{sklad_zapros.html => zagotovki.html} (81%) diff --git a/App/Requests/requests.py b/App/Requests/requests.py index 0accc82..17a982c 100644 --- a/App/Requests/requests.py +++ b/App/Requests/requests.py @@ -24,7 +24,7 @@ def sklad_zapros(): if request.method == 'GET': zagotovki = route(session['db_config'], {}, sql_provider, 'zagotovki.sql') if zagotovki.status: - return render_template('sklad_zapros.html', materials=zagotovki.result) + return render_template('zagotovki.html', materials=zagotovki.result, header='Количество заготовок на складе') else: return render_template('error.html', error_message=zagotovki.error_message) else: @@ -38,13 +38,13 @@ def sklad_zapros(): @requests_bp.route('/req2', methods=['GET', 'POST']) @check_auth -def zagotovki_ship(): +def sellers_ship(): if request.method == 'GET': zagotovki = route(session['db_config'], {}, sql_provider, 'sellers.sql') if zagotovki.status: min_year = '2000' max_year = str(date.today().year) - return render_template('zagotovki_ship.html', sellers=zagotovki.result, year_from=min_year, year_to=max_year) + return render_template('sellers_ship.html', sellers=zagotovki.result, year_from=min_year, year_to=max_year) else: return render_template('error.html', error_message=zagotovki.error_message) else: @@ -53,5 +53,23 @@ def zagotovki_ship(): if zagotovki.status: header = f'Заготовки, поставленные поставщиком \'{seller['seller']}\'' return render_template('output.html', items=zagotovki.result, object=header) + else: + return render_template('error.html', error_message=zagotovki.error_message) + +@requests_bp.route('/req3', methods=['GET', 'POST']) +@check_auth +def zagotovki_ship(): + if request.method == 'GET': + zagotovki = route(session['db_config'], {}, sql_provider, 'zagotovki.sql') + if zagotovki.status: + return render_template('zagotovki.html', materials=zagotovki.result, header='Поставки заготовок') + else: + return render_template('error.html', error_message=zagotovki.error_message) + else: + material = dict(request.form) + zagotovki = route(session['db_config'], material, sql_provider, 'zapros3.sql') + if zagotovki.status: + header = f'Поставки заготовок из материала \'{material['material']}\'' + return render_template('output.html', items=zagotovki.result, object=header) else: return render_template('error.html', error_message=zagotovki.error_message) \ No newline at end of file diff --git a/App/Requests/sql/zapros3.sql b/App/Requests/sql/zapros3.sql new file mode 100644 index 0000000..21d1431 --- /dev/null +++ b/App/Requests/sql/zapros3.sql @@ -0,0 +1,9 @@ +SELECT w.date_of_delivery AS 'Дата поставки', + name AS 'Поставщик', + wl.count AS 'Количество', + wl.price * wl.count AS 'Общая сумма' +FROM waybill w +JOIN waybill_lines wl USING(waybill_id) +JOIN workpiece wp USING(work_id) +JOIN sellers USING(sel_id) +WHERE material = '${material}'; \ No newline at end of file diff --git a/App/Requests/templates/zagotovki_ship.html b/App/Requests/templates/sellers_ship.html similarity index 88% rename from App/Requests/templates/zagotovki_ship.html rename to App/Requests/templates/sellers_ship.html index def07c4..ae25ec4 100644 --- a/App/Requests/templates/zagotovki_ship.html +++ b/App/Requests/templates/sellers_ship.html @@ -2,7 +2,7 @@ - Поставки за год + Поставки поставщиком за год @@ -10,7 +10,7 @@ -

Поставки за год

+

Поставки поставщиком за год

Выберите поставщика

diff --git a/App/Requests/templates/sklad_zapros.html b/App/Requests/templates/zagotovki.html similarity index 81% rename from App/Requests/templates/sklad_zapros.html rename to App/Requests/templates/zagotovki.html index 88e7c92..c511f67 100644 --- a/App/Requests/templates/sklad_zapros.html +++ b/App/Requests/templates/zagotovki.html @@ -2,7 +2,7 @@ - Материалы заготовок + {{ header }} @@ -10,13 +10,13 @@
-

Материалы заготовок

+

{{ header }}

Выберите материал

diff --git a/App/Requests/zapros_menu.json b/App/Requests/zapros_menu.json index 8ffbbec..865ba67 100644 --- a/App/Requests/zapros_menu.json +++ b/App/Requests/zapros_menu.json @@ -1,4 +1,5 @@ [ - {"name": "Материалы заготовок", "url": "requests_bp.sklad_zapros", "roles" : "admin, user"}, - {"name": "Поставки заготовок за год", "url": "requests_bp.zagotovki_ship", "roles" : "admin, user"} + {"name": "Количество заготовок на складе", "url": "requests_bp.sklad_zapros", "roles" : "admin, user"}, + {"name": "Поставки заготовок", "url": "requests_bp.zagotovki_ship", "roles" : "admin, user"}, + {"name": "Поставки поставщиком за год", "url": "requests_bp.sellers_ship", "roles" : "admin, user"} ] \ No newline at end of file