# coding=utf-8

from django.db import models
from django.conf import settings

from apps.foundation.models import Option
from apps.vehicle.models import Model
from apps.customer.models import Customer
from apps.store.models import Shop
from apps.images.models import Images


class VhicleDriveReserve(models.Model):
    WAIT_DRIVE = 1
    FINISHED = 2
    REVOKE = 3
    STATUS_CHOICES = (
        (WAIT_DRIVE, u'待试驾'),
        (FINISHED, u'已试驾'),
        (REVOKE, u'已取消'),
    )
    model = models.ForeignKey(Model, 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=WAIT_DRIVE)
    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)
    img1 = models.ForeignKey(Images, verbose_name=u'驾驶证正面', on_delete=models.PROTECT,
                                  related_name=u'vehicle_drive_reserve_front', null=True)
    img2 = models.ForeignKey(Images, verbose_name=u'驾驶证反面', on_delete=models.PROTECT,
                                  related_name=u'vehicle_drive_reserve_back', 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 = 'vehicle_drive_reserve'
        verbose_name = u'试驾预约'
        default_permissions = ()


class VhicleInquiry(models.Model):
    WAIT_DRIVE = 1
    FINISHED = 2
    STATUS_CHOICES = (
        (WAIT_DRIVE, u'待回访'),
        (FINISHED, u'已回访'),
    )
    model = models.ForeignKey(Model, 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=WAIT_DRIVE)
    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)
    area = models.CharField(max_length=100, verbose_name=u'城市', null=True)
    displace = models.BooleanField(verbose_name=u'置换', default=False, editable=False)
    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 = 'vehicle_inquiry'
        verbose_name = u'新车询价'
        default_permissions = ()