# -*- coding: utf-8 -*-
# from django import forms
from django.forms import ModelForm
from .models import *
from django import forms



class RecipientsBatchForm(ModelForm):
    class Meta:
        model = RecipientsBatch
        fields = '__all__'
        widgets = {
            'company': forms.HiddenInput(),
            'ancestor_id': forms.HiddenInput(),
            'user': forms.HiddenInput(),
            'receiver': forms.HiddenInput(),
        }

    def __init__(self, *args, **kwargs):
        super(RecipientsBatchForm, self).__init__(*args, **kwargs)
        self.fields['code'].widget.attrs['class'] = "form-control"
        self.fields['reason'].widget.attrs['class'] = "form-control"


class RecipientsDetailsForm(ModelForm):
    class Meta:
        model = RecipientDetails
        fields = '__all__'
        widgets = {
            'company': forms.HiddenInput(),
            'ancestor_id': forms.HiddenInput(),
            'product': forms.HiddenInput(),
            'receiver': forms.HiddenInput(),
            'label_code': forms.HiddenInput(),
            'label_pkg': forms.HiddenInput(),
            'label_id': forms.HiddenInput(),
            'label_pk_id': forms.HiddenInput(),
        }
RecipientsDetailsFormset=forms.models.inlineformset_factory(RecipientsBatch,RecipientDetails,RecipientsDetailsForm,extra=0,can_delete=True)



#2021-02-22
class TicketForm(ModelForm):
     class Meta:
        model = Tickets
        fields = '__all__'
        widgets = {            
            'ancestor_id': forms.HiddenInput(),
            'user_id': forms.HiddenInput(),  
            'package_id': forms.HiddenInput(), 
            'company': forms.HiddenInput(),
            'agent': forms.HiddenInput(), 
            'store': forms.HiddenInput(), 
            'product': forms.HiddenInput(), 
            
        }


class InboundTicketsForm(ModelForm):
    class Meta:
        model = InboundTickets
        fields = '__all__'
        widgets = {
            'ancestor_id': forms.HiddenInput(),
            'company': forms.HiddenInput(),
            'product': forms.HiddenInput(),
        }

    def __init__(self, *args, **kwargs):
        super(InboundTicketsForm, self).__init__(*args, **kwargs)
        self.fields['chandi'].widget.attrs['placeholder'] = '该属性为非必填属性'
        self.fields['shengchanaddress'].widget.attrs['placeholder'] = '该属性为非必填属性'
        self.fields['shengchanfactory'].widget.attrs['placeholder'] = '该属性为非必填属性'
        self.fields['scxkzbh'].widget.attrs['placeholder'] = '该属性为非必填属性'
        self.fields['ckwszcbh'].widget.attrs['placeholder'] = '该属性为非必填属性'
        self.fields['check_tm'].widget.attrs['placeholder'] = '该属性为非必填属性'

        self.fields['code'].widget.attrs['placeholder'] = '必填,唯一'
