first push
This commit is contained in:
0
panel/ReportingPanel/__init__.py
Normal file
0
panel/ReportingPanel/__init__.py
Normal file
174
panel/ReportingPanel/excel_output.py
Normal file
174
panel/ReportingPanel/excel_output.py
Normal file
@@ -0,0 +1,174 @@
|
||||
# if 'excel_export' in request.GET:
|
||||
# options = [
|
||||
# 'مرغدار',
|
||||
# 'شهر',
|
||||
# 'استان',
|
||||
# 'کد پستی',
|
||||
# 'موبایل',
|
||||
# 'تاریخ تولد',
|
||||
# 'کد ملی',
|
||||
# 'کد اکونومی',
|
||||
# 'کد سیستمی',
|
||||
# 'کد اپیدمیلوژیک',
|
||||
# 'کد یکتا',
|
||||
# 'ظرفیت کل',
|
||||
# 'شماره مجوز',
|
||||
# 'شماره گواهی بهداشتی',
|
||||
# 'تعداد درخواست ها',
|
||||
# 'تاریخ جوجه ریزی',
|
||||
# 'تعداد جوجه ریزی',
|
||||
# 'تعاونی',
|
||||
# 'سفارشات',
|
||||
# 'تعداد درخواست مرغدار',
|
||||
# 'تاریخ درخواست',
|
||||
# 'نوع مرغ',
|
||||
# 'وزن جفت مرغ',
|
||||
# 'تاییدیه شهرستان',
|
||||
# 'اپراتور شهرستان',
|
||||
# 'تاییدیه استان',
|
||||
# 'اپراتور استان',
|
||||
# 'موبایل اپراتور شهرستان',
|
||||
# 'موبایل اپراتور استان',
|
||||
# 'تاریخ تاییدیه شهرستان',
|
||||
# 'تاریخ تاییدیه استان',
|
||||
# 'کد سفارش',
|
||||
# 'سن جوجه ها',
|
||||
# 'وزن کل',
|
||||
# 'قیمت کل',
|
||||
# 'کارمزد',
|
||||
# 'بارکد فاکتور',
|
||||
# 'تاریخ فاکتور',
|
||||
# 'نام مقصد پرداختی',
|
||||
# 'شماره کارت مقصد پرداختی',
|
||||
# 'شماره شبا مقصد پرداختی',
|
||||
# ]
|
||||
# excel_options = request.GET['excel_export'].split(',')
|
||||
# if request.GET['excel_export'] == "":
|
||||
# excel_options = options
|
||||
# data_list = []
|
||||
# orders = []
|
||||
# for x in range(len(serializer.data)):
|
||||
# nested_data_list = {}
|
||||
# nested_data_list['مرغدار'] = serializer.data[x]['user']['fullname']
|
||||
# nested_data_list['مرغدار2'] = serializer.data[x]['id']
|
||||
# nested_data_list['شهر'] = serializer.data[x]['user']['address']['city']
|
||||
# nested_data_list['استان'] = serializer.data[x]['user']['address']['province']
|
||||
# nested_data_list['کد پستی'] = serializer.data[x]['user']['address']['postal_code']
|
||||
# nested_data_list['موبایل'] = serializer.data[x]['user']['mobile']
|
||||
# nested_data_list['تاریخ تولد'] = serializer.data[x]['user']['birthday']
|
||||
# nested_data_list['کد ملی'] = serializer.data[x]['user']['natinal_id']
|
||||
# nested_data_list['کد اکونومی'] = serializer.data[x]['user']['economic_code']
|
||||
# nested_data_list['کد سیستمی'] = serializer.data[x]['user']['system_code']
|
||||
# nested_data_list['کد اپیدمیلوژیک'] = serializer.data[x]['user']['epidemiological_code']
|
||||
# nested_data_list['کد یکتا'] = serializer.data[x]['user']['breeding_unique_id']
|
||||
# nested_data_list['ظرفیت کل'] = serializer.data[x]['user']['total_capacity']
|
||||
# nested_data_list['شماره مجوز'] = serializer.data[x]['user']['licence_number']
|
||||
# nested_data_list['شماره گواهی بهداشتی'] = serializer.data[x]['user'][
|
||||
# 'health_certificate_number']
|
||||
# nested_data_list['تعداد درخواست ها'] = serializer.data[x]['user']['number_of_requests']
|
||||
# nested_data_list['تاریخ جوجه ریزی'] = serializer.data[x]['user']['incubation_date']
|
||||
# nested_data_list['تعداد جوجه ریزی'] = serializer.data[x]['user']['number_of_incubators']
|
||||
# nested_data_list['تعاونی'] = serializer.data[x]['user']['cooperative']
|
||||
# if 'kill_house_assinment' in serializer.data[x].keys():
|
||||
# if len(serializer.data[x]['kill_house_assinment']['bars']) != 0:
|
||||
# for i in serializer.data[x]['kill_house_assinment']['bars']:
|
||||
# if 'poultry_net_weight' in i.keys():
|
||||
# poultry_net_weight = i['poultry_net_weight']
|
||||
# else:
|
||||
# poultry_net_weight = ""
|
||||
# if 'poultry_state' in i.keys():
|
||||
# state = i['poultry_state']
|
||||
# else:
|
||||
# state = ""
|
||||
# barcode = i['barcode']
|
||||
# kill_house_name = i['kill_house_name']
|
||||
# quantity = i['quantity']
|
||||
# date = i['date']
|
||||
# time = i['time']
|
||||
# name = i['car_info']['name']
|
||||
# car_quantity = i['car_info']['quantity']
|
||||
# pelak = i['car_info']['pelak']
|
||||
# driver_name = i['car_info']['driver_name']
|
||||
# order_string = "بارکد سفارش : {0}\n نام کشتارگاه : {1} \n تعداد : {2} \n تاریخ " \
|
||||
# ": {3} \n زمان : {4} \n مدل ماشین : {5} \n ظرفیت ماشین : {6} \n " \
|
||||
# "پلاک : {7} \n نام راننده : {8} \n وزن خالص : {9} \n وضعیت : {9} \n".format(
|
||||
# barcode,
|
||||
# kill_house_name,
|
||||
# quantity,
|
||||
# date,
|
||||
# time,
|
||||
# name,
|
||||
# car_quantity,
|
||||
# pelak,
|
||||
# driver_name,
|
||||
# poultry_net_weight,
|
||||
# state,
|
||||
# )
|
||||
# orders.append(order_string)
|
||||
# nested_data_list['سفارشات'] = "".join(orders)
|
||||
# nested_data_list['تعداد درخواست مرغدار'] = serializer.data[x]['quantity']
|
||||
# nested_data_list['تاریخ درخواست'] = serializer.data[x]['send_date']
|
||||
# nested_data_list['نوع مرغ'] = serializer.data[x]['chicken_breed']
|
||||
# nested_data_list['وزن جفت مرغ'] = serializer.data[x]['Index_weight']
|
||||
# nested_data_list['تاییدیه شهرستان'] = serializer.data[x]['state']['city_state']
|
||||
# nested_data_list['اپراتور شهرستان'] = serializer.data[x]['state']['city_operator']
|
||||
# nested_data_list['تاییدیه استان'] = serializer.data[x]['state']['province_state']
|
||||
# nested_data_list['اپراتور استان'] = serializer.data[x]['state']['province_operator']
|
||||
# nested_data_list['موبایل اپراتور شهرستان'] = serializer.data[x]['state']['city_operator_mobile']
|
||||
# if 'province_operator_mobile' in serializer.data[x]['state'].keys():
|
||||
# nested_data_list['موبایل اپراتور استان'] = serializer.data[x]['state'][
|
||||
# 'province_operator_mobile']
|
||||
# if 'city_operator_date_time_accepted' in serializer.data[x]['state'].keys():
|
||||
# nested_data_list['تاریخ تاییدیه شهرستان'] = serializer.data[x]['state'][
|
||||
# 'city_operator_date_time_accepted']
|
||||
# if 'province_operator_date_time_accepted' in serializer.data[x]['state'].keys():
|
||||
# nested_data_list['تاریخ تاییدیه استان'] = serializer.data[x]['state'][
|
||||
# 'province_operator_date_time_accepted']
|
||||
# nested_data_list['کد سفارش'] = serializer.data[x]['order_code']
|
||||
# nested_data_list['سن جوجه ها'] = serializer.data[x]['chicken_age']
|
||||
# if 'province_to_killhouse_factor' in serializer.data[x].keys():
|
||||
# nested_data_list['وزن کل'] = serializer.data[x]['province_to_killhouse_factor'][
|
||||
# 'total_weight']
|
||||
# nested_data_list['قیمت کل'] = serializer.data[x]['province_to_killhouse_factor'][
|
||||
# 'total_price']
|
||||
# nested_data_list['کارمزد'] = serializer.data[x]['province_to_killhouse_factor'][
|
||||
# 'factor_fee']
|
||||
# nested_data_list['بارکد فاکتور'] = serializer.data[x]['province_to_killhouse_factor'][
|
||||
# 'factor_bar_code']
|
||||
# nested_data_list['تاریخ فاکتور'] = serializer.data[x]['province_to_killhouse_factor'][
|
||||
# 'factor_date']
|
||||
# nested_data_list['نام مقصد پرداختی'] = \
|
||||
# serializer.data[x]['province_to_killhouse_factor']['bank']['bank_info']
|
||||
# nested_data_list['شماره کارت مقصد پرداختی'] = \
|
||||
# serializer.data[x]['province_to_killhouse_factor']['bank']['bank_card']
|
||||
# nested_data_list['شماره شبا مقصد پرداختی'] = \
|
||||
# serializer.data[x]['province_to_killhouse_factor']['bank']['bank_shaba']
|
||||
# data_list.append(
|
||||
# nested_data_list,
|
||||
# )
|
||||
# output = BytesIO()
|
||||
# workbook = xlsxwriter.Workbook(output)
|
||||
# worksheet = workbook.add_worksheet()
|
||||
# for count in range(len(excel_options)):
|
||||
# worksheet.write(0, count, excel_options[count])
|
||||
#
|
||||
# for item in range(len(data_list)):
|
||||
# for x in range(len(excel_options)):
|
||||
# if excel_options[x] in data_list[item].keys():
|
||||
# worksheet.write(item + 1, x, data_list[item][excel_options[x]])
|
||||
# else:
|
||||
# worksheet.write(item + 1, x, " ")
|
||||
# workbook.close()
|
||||
# output.seek(0)
|
||||
#
|
||||
# # create a response
|
||||
# response = HttpResponse(content_type='application/vnd.ms-excel')
|
||||
#
|
||||
# # tell the browser what the file is named
|
||||
# response['Content-Disposition'] = 'attachment;filename="Reporting.xlsx"'
|
||||
#
|
||||
# # put the spreadsheet data into the response
|
||||
# response.write(output.getvalue())
|
||||
#
|
||||
# # return the response
|
||||
# return response
|
||||
61
panel/ReportingPanel/filterset.py
Normal file
61
panel/ReportingPanel/filterset.py
Normal file
@@ -0,0 +1,61 @@
|
||||
from url_filter.filtersets import ModelFilterSet
|
||||
|
||||
from authentication.models import SystemUserProfile
|
||||
from panel.models import (
|
||||
PoultryRequest,
|
||||
KillHouseRequest,
|
||||
CityOperatorCheckRequest,
|
||||
ProvinceCheckOperatorRequest,
|
||||
VetCheckRequest,
|
||||
VetFarm,
|
||||
KillHouseVet,
|
||||
PoultryHatching, Poultry
|
||||
)
|
||||
|
||||
|
||||
class UserProfileFilterSet(ModelFilterSet):
|
||||
class Meta(object):
|
||||
model = SystemUserProfile
|
||||
|
||||
|
||||
class PoultryFilterSet(ModelFilterSet):
|
||||
class Meta(object):
|
||||
model = Poultry
|
||||
|
||||
|
||||
class PoultryRequestFilterSet(ModelFilterSet):
|
||||
class Meta(object):
|
||||
model = PoultryRequest
|
||||
|
||||
|
||||
class KillHouseRequestFilterSet(ModelFilterSet):
|
||||
class Meta(object):
|
||||
model = KillHouseRequest
|
||||
|
||||
|
||||
class CityOperatorCheckFilterSet(ModelFilterSet):
|
||||
class Meta(object):
|
||||
model = CityOperatorCheckRequest
|
||||
|
||||
|
||||
class ProvinceOperatorCheckFilterSet(ModelFilterSet):
|
||||
class Meta(object):
|
||||
model = ProvinceCheckOperatorRequest
|
||||
|
||||
|
||||
class VetOperatorCheckFilterSet(ModelFilterSet):
|
||||
class Meta(object):
|
||||
model = VetCheckRequest
|
||||
|
||||
|
||||
class PoultryHatchingFilterSet(ModelFilterSet):
|
||||
class Meta(object):
|
||||
model = PoultryHatching
|
||||
|
||||
class ProfileFilterSet(ModelFilterSet):
|
||||
class Meta(object):
|
||||
model = SystemUserProfile
|
||||
|
||||
class ManagementVetFarmFilterSet(ModelFilterSet):
|
||||
class Meta(object):
|
||||
model = VetFarm
|
||||
179
panel/ReportingPanel/helper.py
Normal file
179
panel/ReportingPanel/helper.py
Normal file
@@ -0,0 +1,179 @@
|
||||
poultry_request_fields = [
|
||||
'poultry__user__mobile',
|
||||
'poultry__user__fullname',
|
||||
'poultry__user__first_name',
|
||||
'poultry__user__last_name',
|
||||
'poultry__user__national_id',
|
||||
'poultry__user__national_code',
|
||||
'poultry__address__province__name',
|
||||
'poultry__address__city__name',
|
||||
'poultry__natinal_id',
|
||||
'poultry__unit_name',
|
||||
'poultry__gis_code',
|
||||
'poultry__operating_licence_capacity',
|
||||
'poultry__number_of_halls',
|
||||
'poultry__person_type',
|
||||
'poultry__economic_code',
|
||||
'poultry__system_code',
|
||||
'poultry__epidemiological_code',
|
||||
'poultry__total_capacity',
|
||||
'poultry__licence_number',
|
||||
'poultry__health_certificate_number',
|
||||
'poultry__number_of_requests',
|
||||
'poultry__hatching_date',
|
||||
'hatching__quantity',
|
||||
'hatching__chicken_breed',
|
||||
'poultry__last_party_date',
|
||||
'poultry__number_of_incubators',
|
||||
'poultry__herd_age_by_day',
|
||||
'poultry__herd_age_by_week',
|
||||
'poultry__number_of_party',
|
||||
'poultry__communication_type',
|
||||
'poultry__cooperative',
|
||||
'poultry__date_of_register',
|
||||
'poultry__unit_status',
|
||||
'poultry__samasat_user_code',
|
||||
'poultry__incubation_date',
|
||||
'poultry__address__breeding_unique_id',
|
||||
'order_code',
|
||||
'quantity',
|
||||
'chicken_breed',
|
||||
'Index_weight',
|
||||
'user__address__postal_code',
|
||||
'user__company'
|
||||
|
||||
# 'bar_code',
|
||||
]
|
||||
|
||||
user_fields = [
|
||||
'mobile',
|
||||
'fullname',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'province__name',
|
||||
'city__name',
|
||||
'national_code',
|
||||
'national_id',
|
||||
]
|
||||
|
||||
city_operator_fields = [
|
||||
'city_operator_system__user__mobile',
|
||||
'city_operator_system__user__fullname',
|
||||
'city_operator_system__user__first_name',
|
||||
'city_operator_system__user__last_name',
|
||||
'city_operator_system__user__national_code',
|
||||
'city_operator_system__user__national_id',
|
||||
]
|
||||
|
||||
province_operator_fields = [
|
||||
'province_operator_system__user__mobile',
|
||||
'province_operator_system__user__fullname',
|
||||
'province_operator_system__user__first_name',
|
||||
'province_operator_system__user__last_name',
|
||||
'province_operator_system__user__national_code',
|
||||
'province_operator_system__user__national_id',
|
||||
]
|
||||
|
||||
kill_house_operator_fields = [
|
||||
'killhouse_user__userprofile__mobile',
|
||||
'killhouse_user__userprofile__fullname',
|
||||
'killhouse_user__userprofile__first_name',
|
||||
'killhouse_user__userprofile__last_name',
|
||||
'killhouse_user__userprofile__national_code',
|
||||
'killhouse_user__userprofile__national_id',
|
||||
'killhouse_user__name',
|
||||
'killhouse_user__phone',
|
||||
'killhouse_user__capacity',
|
||||
'capacity',
|
||||
'quantity',
|
||||
'bar_code',
|
||||
]
|
||||
|
||||
vet_operator_fields = [
|
||||
'vet__user__mobile',
|
||||
'vet__user__fullname',
|
||||
'vet__user__first_name',
|
||||
'vet__user__last_name',
|
||||
'vet__user__national_code',
|
||||
'vet__user__national_id',
|
||||
]
|
||||
|
||||
poultry_hatching_fields = [
|
||||
'quantity',
|
||||
'losses',
|
||||
'left_over',
|
||||
'hall',
|
||||
'chicken_breed',
|
||||
'period',
|
||||
'state'
|
||||
]
|
||||
|
||||
|
||||
#new
|
||||
|
||||
poultry_filterset_fields = [
|
||||
'user__mobile',
|
||||
'user__first_name',
|
||||
'user__last_name',
|
||||
'user__city__name',
|
||||
'user__province_name',
|
||||
'unit_name',
|
||||
'gis_code',
|
||||
'operating_licence_capacity',
|
||||
'number_of_halls',
|
||||
'economic_code',
|
||||
'system_code',
|
||||
'epidemiological_code',
|
||||
'total_capacity',
|
||||
'licence_number',
|
||||
'health_certificate_number',
|
||||
]
|
||||
|
||||
poultry_hatching_filterset_fields = [
|
||||
'quantity',
|
||||
'losses',
|
||||
'left_over',
|
||||
'hall',
|
||||
'chicken_breed',
|
||||
'period',
|
||||
'state'
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
poultry_request_new_fields = [
|
||||
'poultry__user__mobile',
|
||||
'poultry__user__fullname',
|
||||
'poultry__user__first_name',
|
||||
'poultry__user__last_name',
|
||||
'poultry__user__national_id',
|
||||
'poultry__user__national_code',
|
||||
'poultry__address__province__name',
|
||||
'poultry__address__city__name',
|
||||
'poultry__unit_name',
|
||||
'order_code',
|
||||
'quantity',
|
||||
'chicken_breed',
|
||||
'Index_weight',
|
||||
|
||||
# 'bar_code',
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
kill_house_request_filterset_fields = [
|
||||
'killhouse_user__kill_house_operator__user__fullname',
|
||||
'killhouse_user__kill_house_operator__user__mobile',
|
||||
'killhouse_user__kill_house_operator__user__city__name',
|
||||
'province_request__poultry_request__poultry__user__fullname',
|
||||
'province_request__poultry_request__poultry__user__mobile',
|
||||
'province_request__poultry_request__order_code',
|
||||
'province_request__poultry_request__order_code',
|
||||
'bar_code',
|
||||
|
||||
]
|
||||
10
panel/ReportingPanel/models.py
Normal file
10
panel/ReportingPanel/models.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from authentication.models import BaseModel
|
||||
from django.db import models
|
||||
|
||||
|
||||
class SearchFields(BaseModel):
|
||||
type = models.CharField(max_length=100, null=True)
|
||||
field_name = models.CharField(max_length=200, null=True)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
super(SearchFields, self).save(*args, **kwargs)
|
||||
1873
panel/ReportingPanel/serializer.py
Normal file
1873
panel/ReportingPanel/serializer.py
Normal file
File diff suppressed because it is too large
Load Diff
9339
panel/ReportingPanel/views.py
Normal file
9339
panel/ReportingPanel/views.py
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user