from django import forms
from dbsynce.models import Orders
from dbsynce.models import Client
from dbsynce.models import Company
from dbsynce.models import Service
from dbsynce.models import ServiceCategory
from dbsynce.models import Provider
from tickets.models import Ticket
from django.contrib.auth import get_user_model

from sharix_admin.forms import OrderForm

class OrderLocalForm(OrderForm):
    def __init__(self, *args, **kwargs):
        super(OrderForm, self).__init__(*args, **kwargs)
        # Добавляем класс .form-control для всех полей формы
        for field in iter(self.fields):
            if 'class' not in self.fields[field].widget.attrs:
                self.fields[field].widget.attrs.update({'class': 'form-control'})
                
#    class Meta:
#        model = Orders
#        fields = [
#            'status', 'title', 'note', 'time_placed', 'time_start', 'time_start_real',
#            'time_start_predicted', 'time_finish_real', 'time_finish_predicted',
#            'real_price', 'predicted_price', 'asap', 'ticket', 'service',
#            'service_category', 'client', 'provider', 'receiver', 'company'
#        ]
#        widgets = {
#            'time_placed': forms.DateTimeInput(attrs={'type': 'datetime-local'}),
#            'time_start': forms.DateTimeInput(attrs={'type': 'datetime-local'}),
#            'time_start_real': forms.DateTimeInput(attrs={'type': 'datetime-local'}),
#            'time_start_predicted': forms.DateTimeInput(attrs={'type': 'datetime-local'}),
#            'time_finish_real': forms.DateTimeInput(attrs={'type': 'datetime-local'}),
#            'time_finish_predicted': forms.DateTimeInput(attrs={'type': 'datetime-local'}),
#        }
#
#    def __init__(self, *args, **kwargs):
#        super().__init__(*args, **kwargs)
#        self.fields['receiver'].queryset = get_user_model().objects.all()
#        self.fields['client'].queryset = Client.objects.all()
#        self.fields['company'].queryset = Company.objects.all()
#        self.fields['provider'].queryset = Provider.objects.all()
#        self.fields['service'].queryset = Service.objects.all()
#        self.fields['service_category'].queryset = ServiceCategory.objects.all()
#        self.fields['ticket'].queryset = Ticket.objects.all()
