from django.forms import ModelForm, Select
from django import forms
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Submit, Row, Column, Field
from .models import Item, PriceLevel

class ItemForm(ModelForm):
    class Meta:
        model = Item
        fields = "__all__"
        widgets = {
            'SalesDesc':forms.Textarea(attrs={'rows':4}),
            'PurchaseDesc':forms.Textarea(attrs={'rows':4}),

        }

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout(
            # Column('ItemType', css_class='form-group col-md-6 mb-0'),
            Row(
                Column('Name', css_class='form-group col-md-4 mb-0'),
                Column('Parent', css_class='form-group col-md-4 mb-0'),
                Column('ManufacturerPartNumber', css_class='form-group col-md-4 mb-0'),
                css_class='form-row'
            ),
            Field('UnitOfMeasureSetRefFullName', css_class='form-input col-md-4 mb-0'),
            # 'address_2',
            Row(
                # Card
                Column('SalesDesc', css_class='form-group col-md-6 mb-0'),
                Column('state', css_class='form-group col-md-4 mb-0'),
                Column('zip_code', css_class='form-group col-md-2 mb-0'),
                css_class='form-row'
            ),
            'check_me_out',
            Submit('submit', 'Sign in')
        )

class PriceLevelForm(ModelForm):
    class Meta:
        model = PriceLevel
        fields = "__all__"