import {Entity, PrimaryGeneratedColumn, Column,  ManyToOne, OneToMany} from "typeorm";
import {  Student } from "./Student";
import { Classes } from "./Classes";
import { ClientType } from "./ClientType";
import { Address } from "./Address";

@Entity()
export class Client {

    @PrimaryGeneratedColumn()
    id!: number;

    @Column()
    name!: string;

    @Column({ type: 'text', nullable: true, default: null })
    description!: string;

    @Column({ default: null, nullable: true })
    phoneNumber!: string;
    
    @Column({ default: null, nullable: true })
    cellNumber!: string;

    @Column({ default: null, nullable: true })
    fax!: string;

    @Column({ default: null, nullable: true })
    email!: string;

    @Column({ default: null, nullable: true })
    email2!: string;

    @Column({ default: null, nullable: true })
    website!: string;

    @Column({ default: null, nullable: true })
    contactName!: string;
    
    @Column({ default: null, nullable: true })
    contactEmail!: string;

    @Column({ default: null, nullable: true })
    contactPhoneNumber!: string;

    @Column({ default: false })
    newsletter!: boolean;

    @Column({ type: 'decimal', default: 2, precision: 10, scale: 2 })
    defaultTravelMilesAmount!: number;

    @Column({ default: true })
    enable!: boolean;

    @Column({ type: 'text', nullable: true, default: null })
    note!: string;

    @ManyToOne(type => ClientType, ClientType => ClientType.Clients) // note: we will create author property in the Photo class below
    ClientType!: ClientType;

    @OneToMany(type => Student, Student => Student.Client) // note: we will create author property in the Photo class below
    Students!: Student[];

    @OneToMany(type => Classes, Class => Class.client) // note: we will create author property in the Photo class below
    Classes!: Classes[];

    @OneToMany(type => Address, Address => Address.Client) // note: we will create author property in the Photo class below
    Addresses!: Address[];

}
