def process_export_GroupAdminReportData(db, request, user_id):
    if request.csv:
        converter = ConvertJsonToCSV(
            db, request, user_id, "GroupAdminRegistrationEMail"
        )
        if converter.FILE_DOWNLOAD_PATH is None:
            return technoreports.ExportToCSVEmpty()
        else:
            return technoreports.ExportToCSVSuccess(
                link=converter.FILE_DOWNLOAD_PATH
            )
def process_export_ReassignUserReportData(db, request, user_id):
    if request.csv:
        converter = ConvertJsonToCSV(
            db, request, user_id, "ReassignUserReport"
        )
        if converter.FILE_DOWNLOAD_PATH is None:
            return technoreports.ExportToCSVEmpty()
        else:
            return technoreports.ExportToCSVSuccess(
                link=converter.FILE_DOWNLOAD_PATH
            )
def process_export_user_mapping_details_reports_data(db, request, session_user):
    if request.csv:
        converter = ConvertJsonToCSV(
            db, request, session_user, "UserMappingReport"
        )
        if converter.FILE_DOWNLOAD_PATH is None:
            return technoreports.ExportToCSVEmpty()
        else:
            return technoreports.ExportToCSVSuccess(
                link=converter.FILE_DOWNLOAD_PATH
            )
def process_get_assigned_statutory_report_data(db, request_frame, user_id):
    if request_frame.csv:
        converter = ConvertJsonToCSV(
            db, request_frame, user_id, "StatutorySettingsReport"
        )
        if converter.FILE_DOWNLOAD_PATH is None:
            return technoreports.ExportToCSVEmpty()
        else:
            return technoreports.ExportToCSVSuccess(
                link=converter.FILE_DOWNLOAD_PATH
            )
    else:
        result = get_assigned_statutories_report_data(db, request_frame, user_id)
        unit_groups = result[0]
        act_groups = result[1]
        compliance_statutories_list = result[2]
        return technoreports.GetAssignedStatutoryReportSuccess(unit_groups, act_groups, compliance_statutories_list, total_count=result[3])
def process_get_domainwise_agreement_report_data(db, request, session_user):
    if request.csv:
        converter = ConvertJsonToCSV(
            db, request, session_user, "DomainwiseAgreementReport"
        )
        return technoreports.ExportToCSVSuccess(
            link=converter.FILE_DOWNLOAD_PATH
        )
    else:
        client_agreement_list = get_domainwise_agreement_report(
            db, request.country_id, request.client_id, request.business_group_id, request.legal_entity_id,
            request.domain_id, request.contract_from, request.contract_to,
            request.from_count, request.page_count, session_user
        )
        total_count = get_domainwise_agreement_report_count(
            db, request.country_id, request.client_id, request.business_group_id, request.legal_entity_id,
            request.domain_id, request.contract_from, request.contract_to, session_user
        )
        return technoreports.GetDomainwiseAgreementReportDataSuccess(
            domainwise_agreement_list=client_agreement_list, total_count=total_count
        )
def process_get_user_mapping_details_reports_data(db, request_frame, session_user):
    if request_frame.csv:
        converter = ConvertJsonToCSV(
            db, request_frame, session_user, "UserMappingReport"
        )
        if converter.FILE_DOWNLOAD_PATH is None:
            return technoreports.ExportToCSVEmpty()
        else:
            return technoreports.ExportToCSVSuccess(
                link=converter.FILE_DOWNLOAD_PATH
            )
    else:
        country_id = request_frame.country_id
        client_id = request_frame.client_id
        legal_entity_id = request_frame.legal_entity_id
        user_mapping_none_values = request_frame.u_m_none
        from_count = request_frame.from_count
        page_count = request_frame.page_count
        bgrp_id = division_id = catagory_id = unit_id = 0
        if user_mapping_none_values.find(",") > 0:
            bgrp_id = user_mapping_none_values.split(",")[0]
            division_id = user_mapping_none_values.split(",")[1]
            catagory_id = user_mapping_none_values.split(",")[2]
            unit_id = user_mapping_none_values.split(",")[3]
        usermapping_report_dataset = []
        usermapping_report_dataset = get_usermapping_report_dataset(
            db, int(session_user), client_id, legal_entity_id,
            country_id, int(bgrp_id), int(division_id), int(catagory_id),
            int(unit_id), from_count, page_count
        )

        techno_details = []
        unit_domains = []
        domains = []
        print usermapping_report_dataset
        if(len(usermapping_report_dataset) > 0):

            for techno in usermapping_report_dataset[0]:

                techno_details.append(core.UserMappingReportTechno(
                    techno["unit_id"], techno["techno_manager"], techno["techno_user"],
                    unit_code_with_name=techno["unit_name"]
                ))

            for assign_domain in usermapping_report_dataset[1]:
                unit_domains.append(core.UserMappingReportDomain(
                    assign_domain["unit_id"], assign_domain["employee_name"], assign_domain["user_category_name"], assign_domain["domain_id"]
                ))
            for domain in usermapping_report_dataset[2]:
                domains.append(technoreports.UserMappingDomain(
                    domain["domain_id"], domain["domain_name"], bool(domain["is_active"])
                ))
            '''if(len(usermapping_report_dataset[0]) > 0):
                techno_details = usermapping_report_dataset[0]
            else:
                techno_details = None,

            if(len(usermapping_report_dataset[1]) > 0):
                unit_domains = usermapping_report_dataset[1]
            else:
                unit_domains = None,

            if(len(usermapping_report_dataset[2]) > 0):
                domains = usermapping_report_dataset[2]
            else:
                domains = None'''

            return technoreports.GetUserMappingReportDataSuccess(
                techno_details=techno_details,
                unit_domains=unit_domains,
                usermapping_domain=domains,
                total_count=usermapping_report_dataset[3]
            )