from django.db import models
from accounts.models import User
from vehicles.models import VehicleModels, VehicleTypes, TransmissionTypes
# Create your models here.

class Trips(models.Model):
    id : models.AutoField(primary_key=True)
    user = models.ForeignKey(User, blank=True, null=True, default="", on_delete=models.SET_NULL, related_name='user_trips')
    vehicle_model = models.ForeignKey(VehicleModels, default="", blank=True, null=True, on_delete=models.SET_NULL)
    vehicle_type = models.ForeignKey(VehicleTypes, default="", blank=True, null=True, on_delete=models.SET_NULL)
    transmission_type = models.ForeignKey(TransmissionTypes, default="", blank=True, null=True, on_delete=models.SET_NULL)
    vehicle_model_name = models.CharField(blank=True,  null=True, max_length=255, default="")
    vehicle_type_name = models.CharField(blank=True,  null=True, max_length=255, default="")
    transmission_type_name = models.CharField(blank=True,  null=True, max_length=255, default="")    
    trip_types = ((0, 'One way'), (1, 'Round'))
    trip_type = models.IntegerField(default=0, choices=trip_types)
    uniform_types = ((0, 'No Uniform'), (1, 'Uniform'))
    uniform_type = models.IntegerField(default=0, choices=uniform_types, blank=False, null=False)
    pickup_address = models.CharField(max_length=255, blank=False, null=False)
    pickup_latitude = models.CharField(blank=True,  null=True, max_length=255, default="")
    pickup_longitude = models.CharField(blank=True,  null=True, max_length=255, default="")
    destination_address = models.CharField(max_length=255, blank=True, null=True, default="")
    destination_latitude = models.CharField(blank=True, max_length=255, null=True, default="")
    destination_longitude = models.CharField(blank=True, max_length=255, null=True, default="")
    start_date = models.DateField(blank=False, null=False)
    start_time = models.CharField(max_length=255, blank=False, null=False)
    end_date = models.DateField(blank=False, null=False)
    end_time = models.CharField(max_length=255, blank=False, null=False)
    station_types = ((0, 'In Station'), (1, 'Out Station'))
    station_type = models.IntegerField(default=0, choices=station_types)
    instructions = models.TextField(blank=True, null=True)  
    status_types = ((0, 'Pending'), (1, 'Ongoing'), (2, 'Complete'), (4, 'Rejected'), (5, 'Canceled'))
    status = models.IntegerField(default=0, choices=station_types)  
    driver = models.ForeignKey(User, blank=True, null=True, default="", on_delete=models.SET_NULL, related_name='trip_driver')
    trip_start_date = models.DateField(blank=True, null=True)
    trip_start_time = models.CharField(max_length=255, blank=True, null=True)
    trip_end_date = models.DateField(blank=True, null=True)
    trip_end_time = models.CharField(max_length=255, blank=True, null=True)
    edit_start_date = models.DateField(blank=True, null=True)
    edit_start_time = models.CharField(max_length=255, blank=True, null=True)
    edit_end_date = models.DateField(blank=True, null=True)
    edit_end_time = models.CharField(max_length=255, blank=True, null=True)
    reference_id = models.CharField(max_length=255, blank=True, null=True)
    payment_status_types = ((0, 'Pending'), (1, 'Out Station'))
    payment_status = models.IntegerField(default=0, choices=payment_status_types)
    amount = models.IntegerField(default=0, blank=False, null=False)
    net_amount = models.IntegerField(default=0, blank=False, null=False)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now_add=True)
