From 42720af4e26521a55b2e6b13f7835a33698de2a2 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Thu, 24 Oct 2024 22:48:26 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B0=D0=BD=D0=BD=D1=8B=D0=B9=20=D0=B2=D1=82=D0=BE=D1=80=D0=BE?= =?UTF-8?q?=D0=B9=20=D0=B7=D0=B0=D0=BF=D1=80=D0=BE=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Requests/requests.py | 14 ++++----- App/Requests/sql/sellers.sql | 3 ++ App/Requests/sql/zapros2.sql | 16 +++++------ App/Requests/templates/zagotovki_ship.html | 33 +++++++++++----------- App/Requests/zapros_menu.json | 2 +- 5 files changed, 35 insertions(+), 33 deletions(-) create mode 100644 App/Requests/sql/sellers.sql diff --git a/App/Requests/requests.py b/App/Requests/requests.py index 3c050ba..0accc82 100644 --- a/App/Requests/requests.py +++ b/App/Requests/requests.py @@ -40,18 +40,18 @@ def sklad_zapros(): @check_auth def zagotovki_ship(): if request.method == 'GET': - zagotovki = route(session['db_config'], {}, sql_provider, 'zagotovki.sql') + zagotovki = route(session['db_config'], {}, sql_provider, 'sellers.sql') if zagotovki.status: - date_from = '2000-01-01' - date_to = date.today().strftime('%Y-%m-%d') - return render_template('zagotovki_ship.html', materials=zagotovki.result, date_from=date_from, date_to=date_to) + 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) else: return render_template('error.html', error_message=zagotovki.error_message) else: - material = dict(request.form) - zagotovki = route(session['db_config'], material, sql_provider, 'zapros2.sql') + seller = dict(request.form) + zagotovki = route(session['db_config'], seller, sql_provider, 'zapros2.sql') if zagotovki.status: - header = f'Поставленные заготовки из материала \'{material["material"]}\'' + 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) \ No newline at end of file diff --git a/App/Requests/sql/sellers.sql b/App/Requests/sql/sellers.sql new file mode 100644 index 0000000..9303472 --- /dev/null +++ b/App/Requests/sql/sellers.sql @@ -0,0 +1,3 @@ +SELECT name FROM sellers +ORDER BY name +LIMIT 100; \ No newline at end of file diff --git a/App/Requests/sql/zapros2.sql b/App/Requests/sql/zapros2.sql index bac1519..7336117 100644 --- a/App/Requests/sql/zapros2.sql +++ b/App/Requests/sql/zapros2.sql @@ -1,11 +1,9 @@ -SELECT sellers.name AS 'Поставщик', - w.date_of_delivery AS 'Дата поставки', - SUM(wl.count) AS 'Общее количество заготовок', - SUM(wl.price) AS 'Общая стоимость поставленных заготовок' +SELECT w.date_of_delivery AS 'Дата поставки', + SUM(w.sum) AS 'Общая сумма', + SUM(wl.cnt) as 'Количество' FROM waybill w -JOIN waybill_lines wl USING(waybill_id) -JOIN workpiece USING(work_id) +JOIN (SELECT waybill_id, SUM(count) AS cnt FROM waybill_lines wl GROUP BY waybill_id)wl USING (waybill_id) JOIN sellers USING(sel_id) -WHERE workpiece.material = '${material}' -AND (w.date_of_delivery BETWEEN '${date_from}' AND '${date_to}') -GROUP BY sellers.name, w.date_of_delivery; +WHERE sellers.name = '${seller}' +AND YEAR(date_of_delivery) = '${date}' +GROUP BY date_of_delivery \ No newline at end of file diff --git a/App/Requests/templates/zagotovki_ship.html b/App/Requests/templates/zagotovki_ship.html index 5e48411..def07c4 100644 --- a/App/Requests/templates/zagotovki_ship.html +++ b/App/Requests/templates/zagotovki_ship.html @@ -2,7 +2,7 @@ - Поставки заготовок + Поставки за год @@ -10,21 +10,22 @@ -

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

-

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

-
- -

Выберите даты:

-

с

-

по

- -
-
- +

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

+
+

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

+
+ +

Выберите год:

+

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