Django SQL N-tables To List/Report

Job ID: 32133206

Budget: $10 – $30 USD

Django SQL N-tables To List/Report

Hi there!
I am looking a simple operative example similar to:
- A report (xlsx, pdf, csv) from a SQL
- Obtained from a simple form: [ data_start] [date_end] [client]
- Showing a simple list paginated.

[data_start] [date_end] [client]
buttom:list
buttom:report xlsx
buttom:report pdf
buttom:report csv
[____________columns_____________]
[____________data________________]
[<] [>]

If the example can use:
django-tables2
django-tables2-reports

will be ok, other standard packages are welcome too:


[Postgres]
CREATE TABLE public.client (
id serial4 NOT NULL,
client_code varchar(12) NOT NULL,
first_name varchar(100) NOT NULL,
last_name varchar(100) NOT NULL,
phone varchar(40) NOT NULL,
email varchar(100) NOT NULL,
CONSTRAINT client_pkey PRIMARY KEY (id)

CREATE TABLE public.order_header (
id serial4 NOT NULL,
order_date timestamptz NOT NULL,
phone varchar(40) NOT NULL,
email varchar(40) NOT NULL,
status_id int4 NOT NULL,
cliend_id_id int4 NOT NULL,
CONSTRAINT order_header_pkey PRIMARY KEY (id)
ALTER TABLE public.order_header ADD CONSTRAINT order_header_cliend_id_id_deafe7c7_fk_client_id FOREIGN KEY (cliend_id_id) REFERENCES public.client(id);

CREATE TABLE public.order_detail (
id serial4 NOT NULL,
quantity int4 NOT NULL,
net_price int4 NOT NULL,
discount_amount int4 NOT NULL,
dispatch_value int4 NOT NULL,
item_id_id int4 NOT NULL,
order_no_id int4 NOT NULL,
CONSTRAINT order_detail_pkey PRIMARY KEY (id)
ALTER TABLE public.order_detail ADD CONSTRAINT order_detail_item_id_id_d74dc24a_fk_item_id FOREIGN KEY (item_id_id) REFERENCES public.item(id);
ALTER TABLE public.order_detail ADD CONSTRAINT order_detail_order_no_id_b26d7218_fk_order_header_id FOREIGN KEY (order_no_id) REFERENCES public.order_header(id);

[SQL]
SELECT o1.id, date(o1.order_date) as date_order, SUM(o2.quantity*o2.net_price) as total, SUM(o2.discount_amount) as total_amount , SUM(o2.dispatch_value) as total_dispatch,
c1.first_name, c1.last_name
FROM order_header o1, order_detail o2, client c1
WHERE o1.id = o2.order_no_id AND o1.cliend_id_id = c1.id
and date(now()) - 30 <= o1.order_date and o1.order_date <= date(now())
GROUP BY o1.id, c1.id;


Greetings,
coursesxxi
g mail