import django_filters
from .models import VMasterView, MgMasterView, BelMasterView, EMasterView, AllProductDimensionForInsProcess,\
        RotateBrokenTest

class VMasterViewFilter(django_filters.FilterSet):
    """
    Filter class for VMasterView model.
    """
    # Define filters for fields
    pro1 = django_filters.CharFilter(
        field_name='PRO1', lookup_expr='icontains', label="Code"
    )
    pro2 = django_filters.CharFilter(
        field_name='PRO2', lookup_expr='icontains', label="Lot No"
    )
    pro1c = django_filters.CharFilter(
        field_name='PRO1C', lookup_expr='icontains', label="Customer"
    )

    class Meta:
        model = VMasterView
        fields = ['pro1', 'pro2']  # Add other fields to filter as needed

class MgMasterViewFilter(django_filters.FilterSet):
    """
    Filter class for VMasterView model.
    """
    # Define filters for fields
    pro1 = django_filters.CharFilter(
        field_name='PRO1', lookup_expr='icontains', label="Code"
    )
    pro2 = django_filters.CharFilter(
        field_name='PRO2', lookup_expr='icontains', label="Lot No"
    )
    pro1c = django_filters.CharFilter(
        field_name='PRO1C', lookup_expr='icontains', label="Customer"
    )

    class Meta:
        model = MgMasterView
        fields = ['pro1', 'pro2']  # Add other fields to filter as needed

class BelMasterViewFilter(django_filters.FilterSet):
    """
    Filter class for VMasterView model.
    """
    # Define filters for fields
    pro1 = django_filters.CharFilter(
        field_name='PRO1', lookup_expr='icontains', label="Code"
    )
    pro2 = django_filters.CharFilter(
        field_name='PRO2', lookup_expr='icontains', label="Lot No"
    )

    pro1c = django_filters.CharFilter(
        field_name='PRO1C', lookup_expr='icontains', label="Customer"
    )

    class Meta:
        model = BelMasterView
        fields = ['pro1', 'pro2']  # Add other fields to filter as needed

class EMasterViewFilter(django_filters.FilterSet):
    """
    Filter class for VMasterView model.
    """
    # Define filters for fields
    pro1 = django_filters.CharFilter(
        field_name='PRO1', lookup_expr='icontains', label="Code"
    )
    pro2 = django_filters.CharFilter(
        field_name='PRO2', lookup_expr='icontains', label="Lot No"
    )
    pro1c = django_filters.CharFilter(
        field_name='PRO1C', lookup_expr='icontains', label="Customer"
    )

    class Meta:
        model = EMasterView
        fields = ['pro1', 'pro2']  # Add other fields to filter as needed


class AllProductDimensionForInsProcessFilter(django_filters.FilterSet):
    ProductCode = django_filters.CharFilter(field_name='ProductCode', lookup_expr='icontains')

    class Meta:
        model = AllProductDimensionForInsProcess
        fields = ["ProductCode"]

class RotateBrokenTestFilter(django_filters.FilterSet):
    lot_no = django_filters.CharFilter(field_name='lot_no', lookup_expr='icontains')
    code = django_filters.CharFilter(field_name='code', lookup_expr='icontains')

    class Meta:
        model = RotateBrokenTest
        fields = ["lot_no", "code",]
