# coding=utf-8

from django.db import models

from apps.foundation.models import Option
from apps.vehicle.models import Series
from apps.customer.models import Customer, CustomerVehicle
from apps.store.models import Shop



class MaintOrderReserve(models.Model):
    RESERVEING = 1
    FINISHED = 2
    REVOKE = 3
    STATUS_CHOICES = (
        (RESERVEING, u'预约中'),
        (FINISHED, u'已完成'),
        (REVOKE, u'已取消'),
    )
    type = models.ForeignKey(Option, verbose_name=u'服务类型', on_delete=models.PROTECT)
    vehicle = models.ForeignKey(CustomerVehicle, verbose_name=u'车辆', on_delete=models.PROTECT)
    shop = models.ForeignKey(Shop, verbose_name=u'门店', on_delete=models.PROTECT)
    create_time = models.DateTimeField(verbose_name=u"添加时间", auto_now_add=True, editable=False)
    status = models.PositiveSmallIntegerField(choices=STATUS_CHOICES, verbose_name=u'状态', default=RESERVEING)
    customer = models.ForeignKey(Customer, verbose_name=u'客户', on_delete=models.PROTECT, editable=False)
    name = models.CharField(max_length=100, verbose_name=u'名称', null=True)
    tel = models.CharField(max_length=20, verbose_name=u'电话', null=True)
    date = models.DateField(verbose_name=u'预约日期', null=True)
    notes = models.CharField(max_length=500, verbose_name=u'备注', null=True)
    delete = models.BooleanField(verbose_name=u'删除', default=False, editable=False)

    class Meta:
        db_table = 'maint_order_reserve'
        verbose_name = u'保养预约'
        ordering = ("-id",)
        default_permissions = ()
