import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, ManyToMany, OneToMany } from "typeorm";
import { ClassDetail } from "./ClassDetail";
import { CourseCategory } from "./CourseCategory";
import { TypeStudent } from "./TypeStudent";

@Entity()
export class Course {

    @PrimaryGeneratedColumn()
    id!: number;

    @Column()
    title!: string;

    @Column({ type: 'text', nullable: true, default: null })
    description!: string;
    
    @Column({ type: 'decimal', precision: 10, scale: 2 })
    cost!: number;

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

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

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

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

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

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

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

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

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

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

    @Column({ nullable: true, default: null })
    authorisedCEUs!: number;

    @ManyToMany(type => ClassDetail, ClassDetail => ClassDetail.Course)
    ClassesDetail!: ClassDetail[];

    @ManyToOne(type => CourseCategory, CourseCategory => CourseCategory.Courses)
    CourseCategory!: CourseCategory;

    @ManyToOne(type => TypeStudent, TypeStudent => TypeStudent.Courses)
    TypeStudent!: TypeStudent;


}