o
    %Ah1                     @   s   d dl mZ d dlmZ ddlmZmZmZmZm	Z	m
Z
 G dd dejZG dd dejZG d	d
 d
ejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZdS )    )forms)Group   )Employee
Department	DeductionBonusEmployeeDocument
Attendancec                   @      e Zd ZG dd dZdS )EmployeeFormc                   @   s0  e Zd ZeZg dZi dejddiddejddiddejddiddejddidd	ejddidd
ejddiddejddiddejddiddej	dddddej	dddddej
ddiddejddiddej
ddiddej
ddiddejdddddejdddddejddddejddddej
ddidejddddejddddejddddejddddejddidejddidejddidejddidejddidejddidejddddej	ddddd Zd!S )"zEmployeeForm.Meta)
first_name	last_nameemailphone	id_numberkra_pinnssf_numbernhif_numberphysical_addresspostal_address
department	job_titleemployment_typeemployment_status	hire_dateprobation_end_datetermination_datebasic_salarypay_frequency
daily_ratehourly_ratecontract_start_datecontract_end_date	bank_namebank_account_numberbank_branchemergency_contact_nameemergency_contact_phoneemergency_contact_relationshipprofile_picturenotesr   classform-controlattrsr   r   r   r   r   r   r   r      rowsr,   r   r   form-selectr   r   r   r   datetyper,   r   r   0.01stepr,   zimage/*r,   accept   )r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   N)__name__
__module____qualname__r   modelfieldsr   	TextInput
EmailInputTextareaSelect	DateInputNumberInput	FileInputwidgets rJ   rJ   (/var/www/html/optinet_system/hr/forms.pyMeta   sj    	
rL   Nr=   r>   r?   rL   rJ   rJ   rJ   rK   r          r   c                       *   e Zd ZG dd dZ fddZ  ZS )DepartmentFormc                   @   sf   e Zd ZeZg dZejddidejddddej	ddidej	ddidej
ddiddZd	S )
zDepartmentForm.Meta)namedescriptionmanager
user_group	is_activer,   r-   r.   r<   r,   r2   r3   form-check-inputN)r=   r>   r?   r   r@   rA   r   rB   rD   rE   CheckboxInputrI   rJ   rJ   rJ   rK   rL   7   s    
rL   c                    sV   t  j|i | tjjdd| jd _tj | jd _d| jd _	d| jd _	d S )Nactiver   rS   rT   F)
super__init__r   objectsfilterrA   querysetr   allrequiredselfargskwargs	__class__rJ   rK   r\   B   s
   zDepartmentForm.__init__r=   r>   r?   rL   r\   __classcell__rJ   rJ   rf   rK   rP   6       rP   c                       rO   )DeductionFormc                
   @   s   e Zd ZeZg dZejddidejddidejddidej	ddddej
ddidejdd	d
dejdd	d
dej
ddiddZdS )zDeductionForm.Meta)employeededuction_typereasonamountis_recurring
start_dateend_daterU   r,   r3   r.   r-   r7   r8   rW   r4   r,   r6   N)r=   r>   r?   r   r@   rA   r   rE   rB   rG   rX   rF   rI   rJ   rJ   rJ   rK   rL   J   s    
rL   c                    s8   t  j|i | tjjdd| jd _d| jd _d S )NrY   rZ   rl   Frr   )r[   r\   r   r]   r^   rA   r_   ra   rb   rf   rJ   rK   r\   [   s   zDeductionForm.__init__rh   rJ   rJ   rf   rK   rk   I   s    rk   c                       rO   )	BonusFormc                	   @   s   e Zd ZeZg dZejddidejddidejddidej	ddddej
ddidejdd	d
dej
ddiddZdS )zBonusForm.Meta)rl   
bonus_typern   ro   rp   date_earnedrU   r,   r3   r.   r-   r7   r8   rW   r4   rs   N)r=   r>   r?   r   r@   rA   r   rE   rB   rG   rX   rF   rI   rJ   rJ   rJ   rK   rL   a   s    
rL   c                    s,   t  j|i | tjjdd| jd _d S )NrY   rZ   rl   )r[   r\   r   r]   r^   rA   r_   rb   rf   rJ   rK   r\   q   s   zBonusForm.__init__rh   rJ   rJ   rf   rK   rt   `   s    rt   c                       rO   )EmployeeDocumentFormc                   @   sj   e Zd ZeZg dZejddidejddidejddddej	ddd	dej
dd
dddZdS )zEmployeeDocumentForm.Meta)rl   document_typetitledocument_filer+   r,   r3   r.   r-   z#Enter document title or descriptionr,   placeholderz.pdf,.doc,.docx,.jpg,.jpeg,.pngr:   r0   rV   N)r=   r>   r?   r	   r@   rA   r   rE   rB   rH   rD   rI   rJ   rJ   rJ   rK   rL   v   s    
rL   c                    s\   | dd }t j|i | |r!|| jd _t | jd _d S tj	j
dd| jd _d S )Nrl   rY   rZ   )popr[   r\   rA   initialr   HiddenInputwidgetr   r]   r^   r_   )rc   rd   re   rl   rf   rJ   rK   r\      s   zEmployeeDocumentForm.__init__rh   rJ   rJ   rf   rK   rw   u   rj   rw   c                       sT   e Zd ZejdejddddddZejejddddd	Z fd
dZ  Z	S )EmployeeAccountSetupForm   r-   z(Create a password (minimum 8 characters)r{   r.   z,Password must be at least 8 characters long.)
min_lengthr   	help_textzConfirm your passwordr   c                    s<   t   }|d}|d}|r|r||krtd|S )Npasswordconfirm_passwordzPasswords don't match.)r[   cleangetr   ValidationError)rc   cleaned_datar   r   rf   rJ   rK   r      s   



zEmployeeAccountSetupForm.clean)
r=   r>   r?   r   	CharFieldPasswordInputr   r   r   ri   rJ   rJ   rf   rK   r      s     r   c                       |   e Zd ZdZejddejddidddZejdd	ej	d
dddddZ
ejddejddidddZ fddZ  ZS )CreateUserAccountFormzHForm for creating a user account for an employee with temporary passwordTFr,   rW   r.   z+Check to auto-generate a temporary passwordr~   ra   r   r   r   r-   z Enter custom password (optional)r{   %Leave blank to auto-generate passwordra   r   r   r   z Send login credentials via emailc                    N   t   }|d}|d}|s|std|r%t|dk r%td|S )Ngenerate_passwordcustom_passwordBEither enable auto-generate password or provide a custom password.r   3Custom password must be at least 8 characters long.r[   r   r   r   r   len)rc   r   r   r   rf   rJ   rK   r         




zCreateUserAccountForm.clean)r=   r>   r?   __doc__r   BooleanFieldrX   r   r   r   r   
send_emailr   ri   rJ   rJ   rf   rK   r      0    	r   c                       r   )ResetUserPasswordFormz6Form for resetting an employee's user account passwordTFr,   rW   r.   z/Check to auto-generate a new temporary passwordr   r   r-   zEnter new password (optional)r{   r   r   zSend new password via emailc                    r   )Ngenerate_new_passwordcustom_reset_passwordr   r   r   r   )rc   r   r   r   rf   rJ   rK   r      r   zResetUserPasswordForm.clean)r=   r>   r?   r   r   r   rX   r   r   r   r   send_reset_emailr   ri   rJ   rJ   rf   rK   r      r   r   c                   @   r   )AttendanceFormc                	   @   s~   e Zd ZeZg dZejddddejddddejddddej	ddddej	ddddej
d	dd
ddZdS )zAttendanceForm.Meta)rl   r4   statuscheck_in_timecheck_out_timehours_workedovertime_hoursr+   r4   r-   r5   r.   timez0.25r8      r1   )r4   r   r   r   r   r+   N)r=   r>   r?   r
   r@   rA   r   rF   	TimeInputrG   rD   rI   rJ   rJ   rJ   rK   rL      s    
rL   NrM   rJ   rJ   rJ   rK   r      rN   r   c                   @   s^   e Zd ZejejdddddZejej	j
ddejdd	Zejejejd
diddZdS )BulkAttendanceFormr4   r-   r5   r.   r   rY   rZ   F)r_   r   ra   r,   )choicesr   N)r=   r>   r?   r   	DateFieldrF   r4   ModelMultipleChoiceFieldr   r]   r^   CheckboxSelectMultiple	employeesChoiceFieldr
   STATUS_CHOICESrE   r   rJ   rJ   rJ   rK   r      s     r   N)djangor   django.contrib.auth.modelsr   modelsr   r   r   r   r	   r
   	ModelFormr   rP   rk   rt   rw   Formr   r   r   r   r   rJ   rJ   rJ   rK   <module>   s     1%%