from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, TextAreaField, IntegerField, BooleanField, RadioField, HiddenField, SelectField, IntegerField, TimeField, \
    EmailField, DateField
from flask_wtf.file import FileField, FileRequired, FileAllowed
from wtforms.validators import InputRequired, Length, NumberRange, Email#
from datetime import time


class RecordForm(FlaskForm):
    hid_record_id = HiddenField(id="hid_record_id", default="0")
    txt_name_1 = StringField(id="txt_name_1", label="First name", validators=[InputRequired(), Length(min=3, max=50)])
    txt_name_2 = StringField(id="txt_name_2", label="Second name (optional)", validators=[Length(min=0, max=50)])
    txt_name_3 = StringField(id="txt_name_3", label="Third name (optional)", validators=[Length(min=0, max=50)])
    txt_surname = StringField(id="txt_surname", label="Surname", validators=[InputRequired(), Length(min=3, max=50)])
    txt_id_number = StringField(id="txt_id_number", label="I.D./Passport number", validators=[InputRequired(), Length(min=3, max=50)])
    sel_gender = SelectField(id="sel_gender", label="Gender", choices=[("m", "male"), ("f", "female"), ("n", "n/a")], default="m")
    txt_years_experience = IntegerField(id="txt_years_experience", label="Years of experience", validators=[InputRequired(), NumberRange(min=0, max=50)])
    sel_sap_k_level = SelectField(id="sel_sap_k_level", label="SAP K Level", choices=[("", "---n/a---"), ("K1", "K1"), ("K2", "K2"), ("K3", "K3"), ("K4", "K4"), ("K5", "K5"), ("K6", "K6"), ("K7", "K7"), ("K8", "K8")], default="")
    txt_contact_number = StringField(id="txt_contact_number", label="Contact number", validators=[InputRequired(), Length(min=3, max=18)])
    txt_email = EmailField(id="txt_email", label="Email", validators=[InputRequired(), Length(min=3, max=128), Email()])
# end of RecordForm class


class QualificationTypeForm(FlaskForm):
    hid_qualification_type_id = HiddenField(id="hid_qualification_type_id", default="0")
    txt_qualification_type = StringField(id="txt_qualification_type", label="Qualification type", validators=[InputRequired(), Length(min=3, max=128)])
# end of QualificationTypeForm class


class QualificationForm(FlaskForm):
    hid_qualification_id = HiddenField(id="hid_qualification_id", default="0")
    sel_qualification_type = SelectField(id="sel_qualification_type", label="Qualification type", choices=[(0, "certificate"), (1, "diploma"), (2, "degree")], default=0)
    txt_qualification_name = StringField(id="txt_qualification_name", label="Qualification Name", validators=[InputRequired(), Length(min=3, max=128)])
    txt_description = TextAreaField(id="txt_description", label="Description", validators=[InputRequired(), Length(min=0, max=255)], render_kw={"wrap": "hard", "rows": "5", "cols": "50"})
# end of QualificationForm class

class QualificationTypeRemovalForm(FlaskForm):
    hid_remove_qualification_type_id = HiddenField(id="hid_remove_qualification_type_id", default="0")
# end of QualificationTypeRemovalForm class

class QualificationRemovalForm(FlaskForm):
    hid_remove_qualification_id = HiddenField(id="hid_remove_qualification_id", default="0")
# end of QualificationRemovalForm class


class RecordQualificationForm(FlaskForm):
    hid_record_qualification_id = HiddenField(id="hid_record_qualification_id", default="0")
    sel_qualification = SelectField(id="sel_qualification", label="Qualification", choices=[])
    d_acquired = DateField(id="d_acquired", label="Date acquired", validators=[InputRequired()], default=None, format="%Y-%m-%d")
# end of RecordQualificationForm class

class RecordQualificationRemovalForm(FlaskForm):
    hid_remove_qualification_id = HiddenField(id="hid_remove_qualification_id", default="0")
# end of RecordQualificationRemovalForm class


class RoleDepartmentForm(FlaskForm):
    hid_department_id = HiddenField(id="hid_department_id", default="0")
    txt_department_name = StringField(id="txt_department_name", label="Department Name", validators=[InputRequired(), Length(min=3, max=128)])
# end of RoleDepartmentForm class


class RoleForm(FlaskForm):
    hid_role_id = HiddenField(id="hid_role_id", default="0")
    sel_department = SelectField(id="sel_departmen", label="Department", choices=[(0, "IT and Technology"), (1, "Sales and Marketing")], default=0)
    txt_role_name = StringField(id="txt_role_name", label="Role Name", validators=[InputRequired(), Length(min=3, max=128)])
    txt_description = TextAreaField(id="txt_description", label="Description", validators=[Length(min=0, max=255)], render_kw={"wrap": "hard", "rows": "5", "cols": "50"})
# end of RoleForm class

class RoleDepartmentRemovalForm(FlaskForm):
    hid_remove_department_id = HiddenField(id="hid_remove_department_id", default="0")
# end of RoleDepartmentRemovalForm class


class RoleRemovalForm(FlaskForm):
    hid_remove_role_id = HiddenField(id="hid_remove_role_id", default="0")
# end of RoleRemovalForm class


class UploadRemovalForm(FlaskForm):
    hid_remove_upload_id = HiddenField(id="hid_remove_upload_id", default="0")
# end of UploadRemovalForm class


class UploadForm(FlaskForm):
    hid_upload_id = HiddenField(id="hid_upload_id", default="0")
    sel_upload_type = SelectField(id="sel_upload_type", label="Upload Type", choices=[(0, "Original CV"), (1, "Alteram CV"), (2, "Certification|Diploma|Degree"), (3, "I.D. Document or Passport")], default=0)
    sel_match = SelectField(id="sel_match", label="Matching Qualification", choices=[(0, "---n/a---")])
    fil_upload_document = FileField(id="fil_upload_document", label="Upload Document", validators=[FileRequired(), FileAllowed(["jpg", "png", "doc", "docx", "pdf"])], render_kw={"multiple": "true", "accept": ".doc,.docx,.pdf,.jpg,.png"})
    txt_description = TextAreaField(id="txt_description", label="Description", validators=[Length(min=0, max=256)])
# end of UploadForm class


class FilterForm(FlaskForm):
    chk_case_sensitive = BooleanField(id="chk_case_sensitive", label="(case-sensitivity for string values)", default=False)
    sel_role_department = SelectField(id="sel_role_department", label="Department", choices=[(0, "---")], default=0, coerce=int)
    sel_role = SelectField(id="sel_role", label="Role", choices=[(0, "---")], default=0, coerce=int)
    txt_name = StringField(id="txt_name", label="Name fields", validators=[Length(min=0, max=50)])
    txt_surname = StringField(id="txt_surname", label="Surname", validators=[Length(min=0, max=50)])
    txt_id_number = StringField(id="txt_id_number", label="I.D./Passport number", validators=[Length(min=0, max=50)])
    sel_sap_k_level = SelectField(id="sel_sap_k_level", label="SAP K Level", choices=[("", "---n/a---"), ("K1", "K1"), ("K2", "K2"), ("K3", "K3"), ("K4", "K4"), ("K5", "K5"), ("K6", "K6"), ("K7", "K7"), ("K8", "K8")], default="", coerce=str)
    sel_language = SelectField(id="sel_language", label="Language", choices=[("", "---")], default="", coerce=str)
    sel_qualification_type_1 = SelectField(id="sel_qualification_type_1", label="Qualification Type 1", choices=[(0, "---")], default=0, coerce=int)
    sel_qualification_1 = SelectField(id="sel_qualification_1", label="Qualification 1", choices=[(0, "---")], default=0, coerce=int)
    sel_qualification_type_2 = SelectField(id="sel_qualification_type_2", label="Qualification Type 2", choices=[(0, "---")], default=0, coerce=int)
    sel_qualification_2 = SelectField(id="sel_qualification_2", label="Qualification 2", choices=[(0, "---")], default=0, coerce=int)
    hid_page = HiddenField(id="hid_page", default=1)
# end of FilterForm class


class UserForm(FlaskForm):
    hid_user_id = HiddenField(id="hid_user_id", default="0")
    txt_user_id = StringField(id="txt_user_id", label="User ID", validators=[InputRequired(), Length(min=3, max=50)])
    txt_password = PasswordField(id="txt_password", label="Password", validators=[Length(min=0, max=50)])
    txt_password_confirm = PasswordField(id="txt_password_confirm", label="Password Confirmation", validators=[Length(min=0, max=50)])
    chk_admin = BooleanField(id="chk_admin", label="Admin role", default=False)
    chk_capture = BooleanField(id="chk_capture", label="Capture role", default=False)
# end of UserForm class


class UserRemovalForm(FlaskForm):
    hid_remove_user_id = HiddenField(id="hid_remove_user_id", default="0")
# end of UserRemovalForm class


class TenderForm(FlaskForm):
    hid_tender_id = HiddenField(id="hid_tender_id", default="0")
    txt_reference_number = StringField(id="txt_reference_number", label="Reference Number", validators=[InputRequired(), Length(min=1, max=64)])
    txt_description = TextAreaField(id="txt_description", label="Description", validators=[Length(min=0, max=512)], render_kw={"wrap": "hard", "rows": "5", "cols": "50"})
# end of TenderForm class


class TenderRemovalForm(FlaskForm):
    hid_remove_tender_id = HiddenField(id="hid_remove_tender_id", default="0")
# end of TenderRemovalForm class


class TenderAllocationForm(FlaskForm):
    sel_tender = SelectField(id="sel_tender", label="Tender to be Allocated", choices=[(0, "---none---")], default=0)
# end of TenderAllocationForm class

class TenderCVRemovalForm(FlaskForm):
    hid_tender_cv_id = HiddenField(id="hid_tender_cv_id", default="0")
# end of TenderCVRemovalForm class
