
    vgYO                    v   d Z ddlZddlZddlZddlZddlZddlmZmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZ ddlmZ dd	lmZmZ dd
lmZmZmZ ddlmZ ddlmZ ddlmZ ddlm Z  ddl!m"Z" ddl#m$Z$m%Z%m&Z& ddl'm(Z( ddl)m*Z* ddl+m,Z, ddl-m.Z. ddl/m0Z1 ddl/m2Z3 ddl4m5Z5 ddl6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZW ddlXmYZY ddlZm[Z[ ddl\m]Z] ddl^m_Z_ ddl`maZa ddlbmcZc ddldmeZe dd lfmgZg dd!lhmiZi d" Zjd# e3d$      fd% e3d&      fd' e3d(      fgZkd) Zld* Zm G d+ d,ej                        Zn G d- d.ej                        Zo G d/ d0en      Zp G d1 d2eo      Zq G d3 d4eo      Zr G d5 d6en      Zs G d7 d8en      Zt G d9 d:en      Zu G d; d<en      Zv G d= d>en      Zw G d? d@en      Zx G dA dBen      Zy G dC dDen      Zz G dE dFej                        Z{ G dG dHen      Z| G dI dJen      Z} G dK dLen      Z~ G dM dNen      Z G dO dPen      Z G dQ dRej                        Z G dS dTen      Z G dU dVen      Z G dW dXen      Z G dY dZen      Z G d[ d\ej                        Z G d] d^e      Zg d_Z G d` daej                        Z G db dcej                        Z G dd deej                        Z G df dgej                        Z G dh dien      Z G dj dken      Z G dl dmen      Z G dn doen      Z G dp dqen      Z G dr dsej                        Z G dt duen      Z G dv dwen      Z G dx dyen      Z G dz d{ej,                        Z G d| d}ej0                        Z[ G d~ den      Z G d den      Z G d den      Z G d dej                        Z e       Z G d dej                        Zd Z G d dej                        Z G d den      Z G d den      Z G d den      Z G d dej                        Z G d den      Z G d den      Zy)zA
forms.py

This module is used to register forms for base module
    N)date	timedelta)Any)forms)apps)messages)get_user_model)SetPasswordForm_unicode_ci_compare)Group
PermissionUser)default_token_generator)get_current_site)ValidationError)EmailMultiAlternatives)validate_ipv46_address)	DateInputHiddenInput	TextInput)loaderrender_to_string)force_bytes)urlsafe_base64_encode)gettext)gettext_lazy)reload_queryset)!AnnouncementAnnouncementCommentAnnouncementExpire
AttachmentAttendanceAllowedIPBaserequestFileCompanyCompanyLeaves
DepartmentDriverViewedDynamicEmailConfigurationDynamicPaginationEmployeeShiftEmployeeShiftDayEmployeeShiftScheduleEmployeeTypeHolidaysHorillaMailTemplateJobPositionJobRoleMultipleApprovalConditionPenaltyAccountsRotatingShiftRotatingShiftAssignRotatingWorkTypeRotatingWorkTypeAssignShiftRequestShiftRequestCommentTagsTrackLateComeEarlyOutWorkTypeWorkTypeRequestWorkTypeRequestComment)EmployeeFilter)MultipleFileField)Employee)horilla_middlewares)_thread_locals)get_horilla_model_class)AuditTag)HorillaMultiSelectField)HorillaMultiSelectWidgetc                 Z   t        |       dkD  rt        t        d            	 | j                  d      \  }}t	        |      }t	        |      }t        t        |            dkD  s|t        d      vrt        t        d            y# t        $ r}t        t        d            |d}~ww xY w)zM
    this method is used to validate the format of duration like fields.
       z)Invalid format, it should be HH:MM format:   <   N)lenr   _splitintstrrange
ValueError)valuehourminuteerrors       /var/www/horilla/base/forms.pyvalidate_time_formatrZ   S   s     5zA~a KLMMY{{3'f4yVs4y>AuRy!8!!$O"PQQ "9 Ya KLMSXXYs   A"B 	B*B%%B*afterAfterweeklyWeekendmonthlyMonthlyc                     |j                         | k(  r|S | |j                         z
  dz  }|dk(  rd}|t        |      z   S )ap  
    Calculates the date of the next occurrence of the target day within the next week.

    Parameters:
        target_day (int): The target day of the week (0-6, where Monday is 0 and Sunday is 6).
        start_date (datetime.date): The starting date.

    Returns:
        datetime.date: The date of the next occurrence of the target day within the next week.
       r   days)weekdayr   )
target_day
start_datedays_until_target_days      rY   get_next_week_dateri   j   sS     z)'**<*<*>>!C! !	'<===    c                 B   |dk(  r8t        j                  | j                  | j                        d   }t	        |      }t        |      }| j                  |k  s|dk(  r.	 t        j                  | j                  | j                  |      }|S t        j                  | j                  | j                        d   }| j                  |      t        d      z   }	 |j                  |      }|S # t        $ r] t        j                  | j                  | j                  dz   d      }t        j                  |j                  |j                  |      }Y |S w xY w# t        $ r@ |j                  |j                  dz         t        d      z   j                  |      }Y |S w xY w)ar  
    Given a start date and a rotation day (specified as an integer between 1 and 31, or
    the string 'last'),calculates the next rotation date for a monthly rotation schedule.

    If the rotation day has not yet occurred in the current month, the next rotation date
    will be on the rotation day of the current month. If the rotation day has already
    occurred in the current month, the next rotation date will be on the rotation day of
    the next month.

    If 'last' is specified as the rotation day, the next rotation date will be on the
    last day of the current month.

    Parameters:
    - start_date: The start date of the rotation schedule, as a datetime.date object.
    - rotate_every: The rotation day, specified as an integer between 1 and 31, or the
      string 'last'.

    Returns:
    - A datetime.date object representing the next rotation date.
    last   r   dayrc   )month)calendar
monthrangeyearrp   rR   rQ   ro   datetimer   rT   replacer   )rg   rotate_everylast_daynext_changenext_month_starts        rY   get_next_monthly_daterz   }   s   , v&&z
8H8HI!L8}|$L ~~%):		"--
9I9I<XK,  &&z
8H8HI!L%--(-;iQ>OO	(*22|2DK +  	"--!1!1A!5qK #--  +"3"3\K  +	  	( ((/?/E/E/I(J#$g,g' 
 	(s&   +C, E ,A"EEAFFc                   "     e Zd ZdZ fdZ xZS )	ModelFormz=
    Override django model's form to add initial styling
    c                    t        |   |i | t        | j                         t	        t
        j                  dd       }| j                  j                         D ]  \  }}|j                  }t        |t        j                        rt        j                         |_        t        |t        j                  t        j                   t        j"                  t        j$                  f      r[d}|j&                  #t)        |j&                  j+                               }|j                  j,                  j/                  d|d       nPt        |t        j0                  f      rd |_        t        |t        j4                        sCd}|j&                  t)        |j&                        }t)        d      j7                  |      |_        |j                  j,                  j/                  ddi       nt        |t        j8                        r>|j                  j,                  j/                  dt)        |j&                        d	d
d       nQt        |t        j:                  t        j<                  f      r'|j                  j,                  j/                  ddi       	 |j>                  j@                  | j                  d   _        	 |j>                  j@                  jB                  | j                  d   _         y #  Y ;xY w#  Y xY w)Nrequest oh-input w-100classplaceholder---Choose {label}---labelr   /oh-select oh-select-2 select2-hidden-accessible   (   r   r   rowscolsoh-switch__checkboxemployee_id
company_id)"super__init__r   fieldsgetattrrC   rD   itemswidget
isinstancer   r   r   todayinitialNumberInput
EmailInputr   	FileInputr   rO   titleattrsupdateSelectempty_labelModelMultipleChoiceFieldformatTextareaCheckboxInputCheckboxSelectMultipleuseremployee_getget_company)	selfargskwargsr~   
field_namefieldr   r   	__class__s	           rY   r   zModelForm.__init__   sT   $)&)$-<<iN!%!2!2!4 5	J\\F&5??4 $

""E$4$4eoouW ;;*ekk//12E"")).uE FU\\O4$(!!%)G)GHE{{. !%++()*@(A(H(Hu(H(UE%""))OP FU^^5""))!1'(~ ! "	 ''00 ""))74I*JK5<\\5N5NM*2LL--99 L)1c5	Zs   (K4>2K;4K8;L __name__
__module____qualname____doc__r   __classcell__r   s   @rY   r|   r|      s    9 9rj   r|   c                   "     e Zd ZdZ fdZ xZS )FormzF
    Overrides to add initial styling to the django Form instance
    c                    t        |   |i | | j                  j                         D ]  \  }}|j                  }t        |t        j                  t        j                  t        j                  f      rK|j                  Yt        |j                        }|j                  j                  j                  d|d       t        |t        j                  f      rsd}|j                  |j                  j                  dd      }t        d      j!                  |      |_        |j                  j                  j                  dd	i       %t        |t        j$                        rAt        |j                        }|j                  j                  j                  d|d
dd       t        |t        j&                  t        j(                  f      s|j                  j                  j                  ddi        y )Nr   r   r   id r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   rO   r   r   r   ru   r   r   r   r   r   )r   r   r   r   r   r   r   r   s          rY   r   zForm.__init__   s   $)&)!%!2!2!4 #	LJ\\F**E,<,<eooN ;;*ekkNELL&&--"25I FU\\O4;;*!KK//c:E$%&<$=$D$D5$D$Q!""))OP FU^^5%++""))!1', ! "	 ''00 ""))74I*JKG#	Lrj   r   r   s   @rY   r   r      s    %L %Lrj   r   c                       e Zd ZdZ	  ej
                  ej                  j                         D  cg c]  }|j                  |j                  f c}} dddi      Z G d d      Zd	fd	ZxZS c c}} w #  Y xY w)
UserGroupFormz!
    Django user groups form
    FrequiredPlease choose a permission.)choicesr   error_messagesc                       e Zd ZdZeZddgZy)UserGroupForm.Meta3
        Meta class for additional options
        namepermissionsN)r   r   r   r   r   modelr    rj   rY   Metar   5  s    	 -(rj   r   c                 0   t         |   d      }| j                  r| j                  }|j                          | j                  d   }t        j
                  j                  |      }|j                  j                  |       |r|j                          |S )z)
        ModelForm save override
        Fcommitr   codename__in)	r   saveinstancecleaned_datar   objectsfilterr   set)r   r   grouppermissions_codenamesr   r   s        rY   r   zUserGroupForm.save=  s     E*==MME

 !% 1 1- @ ((//=R/S 	k*JJLrj   T)r   r   r   r   r   MultipleChoiceFieldr   r   allcodenamer   r   r   r   r   .0permr   s   00@rY   r   r   %  s{    	/e//<F<N<N<R<R<TUDdmmTYY/U9
) ) # Vs   )A8 A2
A8 2A8 8A<r   c                        e Zd ZdZ ej
                  ej                  j                         d      Z	 ej                  ej                  j                               Z fdZd Z xZS )AssignUserGroupz
    Form to assign groups
    F)querysetr   r   c                 N    t        |   |i | t        | j                         y Nr   r   r   r   r   r   r   r   s      rY   r   zAssignUserGroup.__init__]  !    $)&)$rj   c                     | j                   d   }| j                   d   }|j                  j                          |D ]'  }|j                  j                  j                  |       ) |S )z:
        Save method to assign group to employees
        employeer   )r   user_setclearemployee_user_idgroupsadd)r   	employeesr   r   s       rY   r   zAssignUserGroup.savea  sb     %%j1	!!'*! 	8H%%,,007	8rj   )r   r   r   r   r   r   rB   r   r   r   ModelChoiceFieldr   r   r   r   r   r   s   @rY   r   r   S  s[     .u--!!%%'%H #E""EMM,=,=,?@E%	rj   r   c            
       R   e Zd ZdZ eej                  j                          ede	ddd      d      Z
	  ej                  ej                  j                         D  cg c]  }|j                  |j                  f c}} d	d
i      ZfdZfdZd ZxZS c c}} w #  Y xY w)AssignPermissionz(
    Forms to assign user permision
    employee-widget-filterfemployee_filters.htmlT)filter_route_namefilter_classfilter_instance_contex_namefilter_template_pathr   rB   r   r   r   r   r   )r   r   c                 N    t        |   |i | t        | j                         y r   r   r   s      rY   r   zAssignPermission.__init__  r   rj   c                     | j                   j                  d      }|r| j                  j                  dd        t        |           y )Nr   )datagetlisterrorspopr   clean)r   empsr   s     rY   r   zAssignPermission.clean  s8    yy  ,KKOOJ-rj   c                 |   t         j                  j                  | j                  j	                  d            j                  dd      }| j                  d   }t        j                  j                  |      }t        j                  j                  |      }|D ]  }|j                  j                  |        | S )z>
        Save method to assign permission to employee
        r   id__inr   Tflatr   r   )rB   r   r   r   r   values_listr   r   r   user_permissionsr   )r   user_idsr   usersr   s        rY   r   zAssignPermission.save  s     ##**99$$Z0 + 

+(t+
4 	 ''6 ((//[/I##8#4 	3D!!%%k2	3 rj   )r   r   r   r   rG   rB   r   r   rH   r@   r   r   r   r   r   r   r   r   r   r   r   r   s   00@rY   r   r   m  s     '!!%%''6'(+!8
 
H/e//<F<N<N<R<R<TUDdmmTYY/U9
%' V
s   )B"  B
?B" B" "B&r   c                   0    e Zd ZdZ G d d      Zd Zd Zy)CompanyFormz
    Company model's form
    c                        e Zd ZdZeZdZg dZy)CompanyForm.Metar   __all__)date_formattime_format	is_activeN)r   r   r   r   r%   r   r   excluded_fieldsr   rj   rY   r   r    s    	 Erj   r   c                     d}|j                   |kD  rt        d      g d}t        j                  j	                  |j
                        d   j                         }||vrt        d      y )Ni  P z"File size should be less than 5MB.)z.jpgz.jpegz.pngz.webpz.svgrm   zUnsupported file extension.)sizer   ospathsplitextr   lower)r   filemax_sizevalid_extensionsexts        rY   validate_imagezCompanyForm.validate_image  sh    "99x!"FGG Fggtyy)!,224&&!"?@@ 'rj   c                 b    | j                   j                  d      }|r| j                  |       |S )Nicon)r   getr  )r   r  s     rY   
clean_iconzCompanyForm.clean_icon  s.      $$V,%rj   N)r   r   r   r   r   r  r!  r   rj   rY   r  r    s    F F
Arj   r  c                   $    e Zd ZdZ G d d      Zy)DepartmentFormz!
    Department model's form
    c                       e Zd ZdZeZdZdgZy)DepartmentForm.Metar   r  r  N)r   r   r   r   r'   r   r   excluder   rj   rY   r   r%    s    	 -rj   r   Nr   r   r   r   r   r   rj   rY   r#  r#           rj   r#  c                   $    e Zd ZdZ G d d      Zy)JobPositionForm"
    JobPosition model's form
    c                       e Zd ZdZeZdZdgZy)JobPositionForm.Metar   r  r  N)r   r   r   r   r1   r   r   r&  r   rj   rY   r   r-    s    	 -rj   r   Nr'  r   rj   rY   r*  r*    r(  rj   r*  c                        e Zd ZdZ eej                  j                               Z G d d      Z	 fdZ
 fdZ xZS )JobPositionMultiFormr+  r   c                   L    e Zd ZeZdZddgZd ej                  ddd      iZ	y)	JobPositionMultiForm.Metar  department_idr  oh-select oh-select2 w-100height:45px;r   styler   N)
r   r   r   r1   r   r   r&  r   SelectMultiplewidgetsr   rj   rY   r   r1    s;    "K01U119+
rj   r   c                    t         |          }| j                  j                  d      }| j                  j	                  d      }t
        j                  j                  ||      }|j                         rx|j                  dd      }t        j                  j                  |      j                  dd      }t        dt        d      j                  d	j                  |            i      |S )
zd
        Validate that the job position does not already exist in the selected departments.
        r2  job_position)department_id__inr;  Tr  r  
departmentz$Job position already exists under {}, )r   r   r   r   r   r1   r   r   existsr  r'   r   rO   r   join)r   r   department_idsr;  existing_positionsexisting_deps	dep_namesr   s          rY   r   zJobPositionMultiForm.clean  s     w}**?;yy}}^4(0077,< 8 
 $$&.::?QU:VM"**111GSS4 T I "#Q'M%N%U%U		),&  rj   c                 p   | j                   j                  st        t        d      }| j                  j                  d      }| j                  j                  d      }g }|D ]  }t        j                  j                  |      }t        j                  j                  ||      j                         rt        j                  |d|        lt        ||      }	|	j                          |j                  |	j                          t        j                  j                  |      S t!        
| 8  |i |S )zF
        Save the job positions for each selected department.
        r~   r2  r;  r   )r2  r;  z"Job position already exists under r  )r   pkr   rD   r   r   r   r'   r   r1   r   r?  r   rX   r   appendr   )r   r   r   r~   rA  r;  	positionsdep_iddeppositionr   s             rY   r   zJobPositionMultiForm.save  s    }}ni8G!YY..?N99==8LI( 	2 ((,,,7&&--"%L . &( NN7.PQTPU,VW*<XHMMO$$X[[1	2 &&--Y-??w|T,V,,rj   )r   r   r   r   rG   r'   r   r   r2  r   r   r   r   r   s   @rY   r/  r/    s<     ,Z5G5G5K5K5MNM
 
4- -rj   r/  c                   F     e Zd ZdZ fdZ G d d      Zdef fdZ xZS )JobRoleFormz
    JobRole model's form
    c                     t        |   |i | | j                  j                  sht	        j
                  | j                  d   j                        | j                  d<   | j                  d   j                  j                  }d|d<   d|d<   y y )Njob_position_idr   r3  r   r4  r6  )
r   r   r   rG  r   r   r   r   r   r   )r   r   r   r   r   s       rY   r   zJobRoleForm.__init__-  s    $)&)}}-2-K-K%67@@.DKK)* KK 1299??E9E'N+E'N  rj   c                       e Zd ZdZeZdZdgZy)JobRoleForm.Metar   r  r  N)r   r   r   r   r2   r   r   r&  r   rj   rY   r   rR  7  s    	 -rj   r   returnc                    | j                   j                  st        t        d      }t        j
                  j                  | j                  j                  d            }g }|D ]S  }t               }||_
        | j                  d   |_        	 |j                          |j                  |j                         U t        j
                  j                  |      S t!        	| 0  |g|i | y #  t        j                  |d|        Y nxY w)Nr~   rP  r  job_rolezRole already exists under )r   rG  r   rD   r1   r   r   r   r   r2   rP  rU  r   r   inforH  r   )
r   r   r   r   r~   job_positionsrolesrL  roler   s
            rY   r   zJobRoleForm.save@  s    }}ni8G'//66yy(():; 7 M E) &y'/$ $		* 5TIIK TWW%& ??)))77V-d-f-	TMM'-Gz+RSs   C//D)	r   r   r   r   r   r   r   r   r   r   s   @rY   rN  rN  (  s(    ,   .s . .rj   rN  c                   $    e Zd ZdZ G d d      Zy)WorkTypeFormz
    WorkType model's form
    c                       e Zd ZdZeZdZdgZy)WorkTypeForm.Metar   r  r  N)r   r   r   r   r=   r   r   r&  r   rj   rY   r   r]  Y  s    	 -rj   r   Nr'  r   rj   rY   r[  r[  T  r(  rj   r[  c                   R     e Zd ZdZ G d d      Z fdZd Z fdZd fd	Z xZ	S )	RotatingWorkTypeFormz'
    RotatingWorkType model's form
    c                   Z    e Zd ZdZeZdZddgZ eddi       e	j                         dZy	)
RotatingWorkTypeForm.Metar   r  r   r  typer   r7  )rg   additional_dataN)r   r   r   r   r7   r   r   r&  r   r   r   r9  r   rj   rY   r   ra  h  s?    	 ! +.#66*:;0u002
rj   r   c                 j    t        	   |i | d}d
 fd	} j                  j                         D ]%  }|j	                  d      s|dz  } |||dk         '  j
                  j                  d      }|r|j                  d      nd }|rd}|D ]  } |d| |dk  |	       |dz  } | _        y )Nr   c           	          t        j                  t        j                  j	                         t        j
                  d| d|  d      |t        d      |      j                  | <   y )Noh-select oh-select-2 mb-3id_r   r   r   r7  z---Choose Work Type---r   r   r   r   r   )r   r   r=   r   r   r   rO   r   )work_type_keyr   r   r   s      rY   create_work_type_fieldz=RotatingWorkTypeForm.__init__.<locals>.create_work_type_fieldy  s`    ).)?)?!))--/||!= - #M?3 "67*DKK&rj   	work_typerm   r   rc  additional_work_typesrL   r   r   )r   r   r   keys
startswithr   r   work_type_counts)
r   r   r   rq  rk  keyrc  rm  work_type_idr   s
   `        rY   r   zRotatingWorkTypeForm.__init__u  s    $)&)	 99>># 	CC~~k* A% &s,<,AB	C
 ,,**+<=<KO 78QU 	 !  5 && 012$)(
 !A% & !1rj   c                 "    d| i}t        d|      S )Nformz9base/rotating_work_type/htmx/rotating_work_type_as_p.htmlr   r   r   r   contexts       rY   as_pzRotatingWorkTypeForm.as_p  s    4.G
 	
rj   c                 R   t         |          }g }t        | j                  j                  j                               }| j                  j                         D ]3  \  }}| d|vs|j                  d      s |s#|j                  |       5 |rd|vs|d   i |d<   ||d   d<   |S )N_idrl  rc  rm  
r   r   listr   __dict__ro  r   r   rp  rH  )r   r   rm  model_fieldsrr  rU   r   s         rY   r   zRotatingWorkTypeForm.clean  s    w} "DMM22779:))//+ 	4JC%s</NN;/%,,U3	4 !!5 12:24./ & *+' rj   c                 .   t         |   d      }| j                  j                  d      r?|j                  i |_        | j                  d   j                  d      |j                  d<   nd |_        |r |j                          | j                          |S )NFr   rc  rm  r   r   r   r   rc  save_m2mr   r   r   r   s      rY   r   zRotatingWorkTypeForm.save  s    7<u<-  !23''/+-(@D@Q@Q!Ac)* $$%<= (,H$MMOMMOrj   r   
r   r   r   r   r   r   rx  r   r   r   r   s   @rY   r_  r_  c  s,    
 
&1P
2 rj   r_  c            	           e Zd ZdZ eej                  j                  d       ede	dd       e
d      	      Z ej                  ed
 e
d            Z ej                   d e
d            Z ej$                  ej(                  j*                  ej,                   e
d            Z G d d      Z fdZd Z fdZddZ xZS )RotatingWorkTypeAssignForm-
    RotatingWorkTypeAssign model's form
    Femployee_work_info__isnullr   r   r   r   r   r   r   	Employeesr   dailyBased onr   r   r      Rotate after dayr   r   
Start dater   r   r   c                   v    e Zd ZdZeZdZg dZ eddi       e	       dZ
 ed       ed	       ed
      dZy)RotatingWorkTypeAssignForm.Metar   r  next_change_datecurrent_work_typenext_work_typer  rc  rb  r   r7  )rg   r  	Is ActiveRotate every weekendRotate every)r  rotate_every_weekendrv   N)r   r   r   r   r8   r   r   r&  r   r   r9  _translabelsr   rj   rY   r   r    sW    	 '
 $66*:;$

  ,$*+A$B">2
rj   r   c                    t        |   |i | t        | j                         | j                  j	                         D ]&  \  }}|j
                  sd| j                  |   _        ( | j                  d   j                  j                  j                  dddd       | j                  d   j                  j                  j                  dddd       | j                  d   j                  j                  j                  d	d
d       | j                  d   j                  j                  j                  ddd       t        j                  d	dd
d      | j                  d   _        | j                  d   j                  j                  j                  ddi       | j                  d   j                  j                  j                  ddi       y )N *r  w-100ddisplay:none; height:50px; border-radius:0;border:1px                     solid hsl(213deg,22%,84%);Tr   r6  zdata-hiddenrv   rotate_after_dayw-100 oh-input height:50px; border-radius:0;r5  based_onC height:50px; border-radius:0;border:1px solid hsl(213deg,22%,84%);r   r   rb  r6  r7  rg   rotating_work_type_idr   oh-select oh-select-2r   r   r   r   r   r   r   label_suffixr   r   r   r   r   r   r   r   r   r   r   s        rY   r   z#RotatingWorkTypeAssignForm.__init__  s   $)&)$!%!2!2!4 	<J~~7;J'4	< 	*+2288?? 0#		
 	N#**0077 0#		
 	&'..44;;)9	
 	J&&,,33 ^	
 ,1??)9,
L!( 	+,3399@@0	

 	M"))//660	
rj   c                 n    | j                   j                  d      }|r|d   S t        t        d            S )Nr   r   This field is requiredr   r   r   rO   r   employee_idss     rY   clean_employee_idz,RotatingWorkTypeAssignForm.clean_employee_id1  s6    ((,,];?""1%=#>??rj   c                    t         |           t        j                  j	                  | j
                  j                  d            j                         | j                  _	        | j                  j                  dd        | j                  j                  t        dt        d      i      t         |           t         |          }d| j                  v r| j                  d= |S Nr   rF  r  r  r   r   rB   r   r   r   r   firstr   r   r   r   r   rO   r   r   r   s     rY   r   z RotatingWorkTypeAssignForm.clean8      $,$4$4$;$;yy}}]+ %< %

%' 	! 	t,==$$,!=!4L2M"NOOw},./rj   c           	         | j                   j                  d      }t        j                  j	                  | j                   d         }| j
                  d   }g d}|j                  |j                               }|D ]  }t        j                  j                  |      j                         }	t               }
||
_        |	|
_        | j
                  d   |
_        | j
                  d   |
_        | j
                  d   |
_        | j                   j	                  d      |
_        | j
                  d	   |
_        | j
                  d   |
_        | j
                  d   |
_        |	j(                  j*                  |
_        |j.                  |
_        d
|
j2                  d<   | j
                  d   }| j
                  d   }|dk(  rt5        ||      }||
_        n|dk(  r2| j
                  d	   }| j
                  d   }t7        ||      }||
_        nO|dk(  rJ|
j                  t9        j:                  t=        | j                   j	                  d                  z   |
_        |
j?                           y )Nr   r  rF  r  mondaytuesday	wednesdaythursdayfridaysaturdaysundayr  rg   r  rv   rm   next_shift_indexr]   r_   r[   rc   ) r   r   r7   r   r   r   indexr  rB   r   r  r8   r  r   r  rg   r  r  rv   r  employee_work_infors  r  
work_type1r  rc  ri   rz   rt   r   rQ   r   )r   r   managerr  rotating_work_typeday_name	day_namesrf   r   r   rotating_work_type_assignr  rg   	next_daterv   s                  rY   r   zRotatingWorkTypeAssignForm.saveG  sX   yy((7-5599yy01 : 
 $$%;<
	 __X^^%56
' &	-K''..+.>DDFH(>(@%>P%;4<%1151B1B:1N%.373D3D\3R%09=9J9J<9X%69=":%6 6:5F5F~5V%2=A=N=N&>%: :>9J9J<9X%6++88 &7 8J7T7T%4LM%556HI((4H**<8J8#.z:F	=F):Y&#00@!..|<
1*lK	=F):W$-88((c$))--@R2S.TUV *:
 &**,M&	-rj   )FNr   r   r   r   rG   rB   r   r   rH   r@   r  r   r   ChoiceFieldBASED_ONr  IntegerFieldr  	DateFieldrt   r   r   r   rg   r   r   r  r   r   r   r   s   @rY   r  r    s     *!!((E(J'6'(+!8	
 [!	K !u  '
1CH *u))!6BT;UV ##EOO6,CWJ
 
03
j@8-rj   r  c                   v     e Zd ZdZ ej
                  ed ed            Z G d d      Z	 fdZ
 fdZ xZS )	 RotatingWorkTypeAssignUpdateFormr  r  r  r  c                       e Zd ZdZeZdZg dZd eddi      iZ	 e
d       e
d	       e
d
       e
d       e
d       e
d      dZy)%RotatingWorkTypeAssignUpdateForm.Metar   r  r  rg   rb  r   r7  r  r  r  r  r  r  rg   r  r  rv   r  r  N)r   r   r   r   r8   r   r   r&  r   r9  r  r  r   rj   rY   r   r    sm    	 '
 )66*:;
 !. &'9 :$*+A$B">2z*,
rj   r   c                    t        |   |i | t        | j                         | j                  j	                         D ]&  \  }}|j
                  sd| j                  |   _        ( | j                  d   j                  j                  j                  dddd       | j                  d   j                  j                  j                  dddd       | j                  d	   j                  j                  j                  d
dd       | j                  d   j                  j                  j                  ddd       t        j                  d
ddd      | j                  d   _        | j                  d   j                  j                  j                  ddi       | j                  d   j                  j                  j                  ddi       y )Nr  r  r  zcdisplay:none; height:50px; border-radius:0;border:1px                    solid hsl(213deg,22%,84%);Tr  rv   r  r  r  r  r5  r  zX height:50px; border-radius:0; border:1px solid                     hsl(213deg,22%,84%);r   r  r7  rg   r  r   r  r   r  r  s        rY   r   z)RotatingWorkTypeAssignUpdateForm.__init__  s   $)&)$!%!2!2!4 	<J~~7;J'4	< 	*+2288?? 0#		
 	N#**0077 0#		
 	&'..44;;)9	
 	J&&,,33 *	
 ,1??)9,
L!( 	+,3399@@0	

 	M"))//660	
rj   c                 x   | j                   d   }g d}|j                  |j                               }| j                   d   }| j                  j                  }|dk(  rt        ||      }|| j                  _        n|dk(  rJ| j                  j                  }	| j                  j                  }t        ||	      }|| j                  _        nc|dk(  r^| j                  j                  t        j                  t        | j                  j                  d                  z   | j                  _        t        
| =         S 	Nr  r  r  r]   r_   r[   r  rc   r   r  r  r   rg   ri   r  rv   rz   rt   r   rQ   r   r   r   r   r   r   r   r  r  rf   r  rg   r  rv   r   s             rY   r   z%RotatingWorkTypeAssignUpdateForm.save     $$%;<
	 __X^^%56
$$Z0]]--
x*:zBI-6DMM*"==55L11J-j,GI-6DMM* (($$#diimm<N.O*PQR MM* w|~rj   r   r   r   r   r   r  r  r  r  r   r   r   r   r   s   @rY   r  r    sB     !u  '
1CH
 
44
l rj   r  c                   $    e Zd ZdZ G d d      Zy)EmployeeTypeFormz
    EmployeeType form
    c                       e Zd ZdZeZdZdgZy)EmployeeTypeForm.Metar   r  r  N)r   r   r   r   r.   r   r   r&  r   rj   rY   r   r    s    	 -rj   r   Nr'  r   rj   rY   r  r    r(  rj   r  c                   6     e Zd ZdZ G d d      Z fdZ xZS )EmployeeShiftFormz
    EmployeeShift Form
    c                        e Zd ZdZeZdZddgZy)EmployeeShiftForm.Metar   r  rd   r  N)r   r   r   r   r+   r   r   r&  r   rj   rY   r   r    s    	 ;'rj   r   c                     | j                   d   }t        |       | j                   d   }t        |       t        |          S )N	full_timeweekly_full_time)r   rZ   r   r   )r   r  r   s     rY   r   zEmployeeShiftForm.clean  s<    IIk*	Y'II01	Y'w}rj   )r   r   r   r   r   r   r   r   s   @rY   r  r  	  s    ( ( rj   r  c                   F     e Zd ZdZ G d d      Z fdZd Z fdZ xZS )EmployeeShiftScheduleUpdateForm,
    EmployeeShiftSchedule model's form
    c                   v    e Zd ZdZeZdZddgZ ej                  ddi       ej                  ddi      dZ
y	)
$EmployeeShiftScheduleUpdateForm.Metar   r  r  is_night_shiftrb  timer7  
start_timeend_timeN)r   r   r   r   r-   r   r   r&  r   	TimeInputr9  r   rj   rY   r   r  $  sK    	 & 01)%//0@A'vv.>?
rj   r   c                 0   t        |   |i | |j                  d      }|r|j                  r|j                  j	                  d      nd | j
                  d   _        |j                  r|j                  j	                  d      nd | j
                  d   _        t        j                  d      r;|j                  r|j                  j	                  d      nd | j
                  d   _        t        j                  d      s9| j
                  j                  dd        | j
                  j                  dd        y t        j                  dd	d
      | j
                  d   _        | j
                  d   j                  j                  j!                  ddi       y )Nr   %H:%Mr  r  
attendanceauto_punch_out_timeis_auto_punch_out_enabledr  oh-input w-100 form-controlrb  r   r7  onchangetoggleDivVisibility(this))r   r   r   r  strftimer   r   r  r   is_installedr  r   r   r  r   r   r   )r   r   r   r   r   s       rY   r   z(EmployeeShiftScheduleUpdateForm.__init__1  sW   $)&)::j)9A9L9L##,,W5RV KK%- 8@7H7H!!**73d KK
#+   .  33 0099'B 12:   .KKOO148KKOO7>8=%0MN9DKK-.5 KK34;;AAHH89rj   c                 &    d| i}t        d|      }|S zS
        Render the form fields as HTML table rows with Bootstrap styling.
        ru  zhorilla_form.htmlr   r   rw  
table_htmls      rY   rx  z$EmployeeShiftScheduleUpdateForm.as_pN       
 4.%&97C
rj   c                    t         |          }t        j                  d      rh|j	                  d      }|j	                  d      }|j	                  d      }|r3|st        dt        d      i      ||k  rt        dt        d      i      |S Nr  r  r  r  zIAutomatic punch out time is required when automatic punch out is enabled.z=Automatic punch out time cannot be earlier than the end time.)r   r   r   r  r   r   rO   r   r   auto_punch_out_enabledr  r  r   s        rY   r   z%EmployeeShiftScheduleUpdateForm.cleanW  s    w}\*%1%5%56Q%R""."2"23H"I#''
3H%*)11 k4  )83)11 _4  rj   )	r   r   r   r   r   r   rx  r   r   r   s   @rY   r  r    s&    
 
: rj   r  c                        e Zd ZdZ ej
                  ej                  j                               Z	 G d d      Z
 fdZd Z fdZd
 fd	Zd	 Z xZS )EmployeeShiftScheduleFormr  r   c                   N    e Zd ZdZeZdZddgZ eddi       eddi      dZ	y	)
EmployeeShiftScheduleForm.Metar   r  r  r  rb  r  r7  r  N)
r   r   r   r   r-   r   r   r&  r   r9  r   rj   rY   r   r  |  s>    	 &#[1#66*:;!(89
rj   r   c                    |j                  d      x}r}|j                  j                  d      |j                  j                  d      d}t	        j
                  d      r,|j                  r|j                  j                  d      nd |d<   ||d<   t        |    |i | | j                  d   j                  j                  j                  dt        t        j                               i       | j                  d	   j                  j                  j                  dt        t        j                               i       t	        j
                  d      s9| j                  j!                  dd        | j                  j!                  d
d        y t#        j$                  ddd      | j                  d   _
        | j                  d
   j                  j                  j                  ddi       y )Nr   r  r  r  r  r   ro   r   shift_idr  r  r  r  r7  r  r  )r   r  r  r  r   r  r  r   r   r   r   r   r   rR   uuiduuid4r   r   r  )r   r   r   r   r   r   s        rY   r   z"EmployeeShiftScheduleForm.__init__  s   zz*--8- '11::7C$--66w?G   .  33 0099'B -.
 !(F9$)&)E!!''..c$**,6G/HIJ&&,,33T3tzz|;L4MN  .KKOO148KKOO7>8=%0MN9DKK-.5 KK34;;AAHH89rj   c                 &    d| i}t        d|      }|S r  r   r  s      rY   rx  zEmployeeShiftScheduleForm.as_p  r  rj   c                    t         |          }t        j                  d      rh| j                  d   }| j                  d   }| j                  d   }|r|st        dt        d      i      |r|r|r||k  rt        dt        d      i      |S r  )r   r   r   r  r   r   rO   r  s        rY   r   zEmployeeShiftScheduleForm.clean  s    w}\*%)%6%67R%S""&"3"34I"J((4H%*)11 k4  &*=(&1)11 _4  rj   c                    t         |   d      }| j                  j                  d      D ]  }t	        |      t	        |j
                  j                        k7  s/| j                  j                         }|j                  dt        |      i       t        |      j                  d      }|j                           |r|j                          |S )NFr   ro   )r   r   r   r   rQ   ro   r   copyr   rR   r  )r   r   r   ro   	data_copyshift_scheduler   s         rY   r   zEmployeeShiftScheduleForm.save  s    7<u<-99$$U+ 	&C3x3x||// IINN,	  %S!23!@!K!P!P  "Q " ##%	& MMOrj   c                    | j                   d   }|D ]w  }t        j                  j                  || j                  d         j                         }|Bt        t        d      j                  t        |j                                     |j                         t        t        d            |j                         S )z)
        Validation to day field
        ro   r  )ro   r  z)Shift schedule is already exist for {day}rn   zEmployee not chosen)
r   r-   r   r   r   r  r   rO   r   ro   )r   rd   ro   r  s       rY   	clean_dayz#EmployeeShiftScheduleForm.clean_day  s       ' 		C.66==$))J"7 > eg  %%ABIIcggJ J  		 ::<!!$9":;;zz|rj   r   )r   r   r   r   r   r   r,   r   r   ro   r   r   rx  r   r   r  r   r   s   @rY   r
  r
  s  sQ     )%
(
(!))--/C
 
>4rj   r
  c                   R     e Zd ZdZ G d d      Z fdZd Z fdZd fd	Z xZ	S )	RotatingShiftFormz$
    RotatingShift model's form
    c                   F    e Zd ZdZeZdZddgZd ej                         iZ
y)RotatingShiftForm.Metar   r  r   r  rc  N)r   r   r   r   r5   r   r   r&  r   r   r9  r   rj   rY   r   r    s3    	  +.$&7e&7&7&9:rj   r   c                     t        	   |i | d}d
 fd	} j                  j                         D ]5  }|j	                  d      s j                  |   s%|dz  } |||dk         7  j
                  j                  d      }|r|j                  d      nd }|r"d}|D ]  }|s |d| |dk  |	       |dz  } | _        y )Nr   c           	          t        j                  t        j                  j	                         t        j
                  d| d|  d      |t        d      |      j                  | <   y )Nrf  rg  rh  r7  z---Choose Shift---ri  )r   r   r+   r   r   r   rO   r   )	shift_keyr   r   r   s      rY   create_shift_fieldz6RotatingShiftForm.__init__.<locals>.create_shift_field  s`    %*%;%;&..224||!= ) #I;/ "23&DKK	"rj   shiftrm   r   rc  additional_shiftsrL   rn  r   )r   r   r   ro  rp  r   r   shift_counts)
r   r   r   r#  r   rr  rc  r"  r  r   s
   `        rY   r   zRotatingShiftForm.__init__  s    $)&)	 99>># 	;C~~g&499S>!"3(9:	;
 ,,**+<=8GO 34T 	 L- &&~.0A8 !A%L& )rj   c                 "    d| i}t        d|      S )Nru  z1base/rotating_shift/htmx/rotating_shift_as_p.htmlr   rv  s       rY   rx  zRotatingShiftForm.as_p%  s    4.?
 	
rj   c                 R   t         |          }g }t        | j                  j                  j                               }| j                  j                         D ]3  \  }}| d|vs|j                  d      s |s#|j                  |       5 |rd|vs|d   i |d<   ||d   d<   |S )Nrz  r!  rc  r"  r{  )r   r   r"  r~  rr  rU   r   s         rY   r   zRotatingShiftForm.clean+  s    w}DMM22779:))//+ 	0JCc{,.3>>'3Ju!((/	0 !5 12:24./CTL*+,?@rj   c                 .   t         |   d      }| j                  j                  d      r?|j                  i |_        | j                  d   j                  d      |j                  d<   nd |_        |r |j                          | j                          |S )NFr   rc  r"  r  r  s      rY   r   zRotatingShiftForm.save>  s    7<u<-  !23''/+-(<@<M<M!=c%& $$%89 (,H$MMOMMOrj   r   r  r   s   @rY   r  r    s,    ; ;&)P
& rj   r  c            	           e Zd ZdZ eej                  j                  d       ede	dd       e
d      	      Z ej                  ed
 e
d            Z ej                   d e
d            Z ej$                  ej(                  j*                  ej,                   e
d            Z G d d      Z fdZd Z fdZ	 ddZ xZS )RotatingShiftAssignForm*
    RotatingShiftAssign model's form
    Fr  r   r   r   r  r  r   r  r  r  r  r  r  r  r  c                       e Zd ZdZeZdZg dZd eddi      iZ	 e
d       ed	       e
d
       e
d       e
d      dZy)RotatingShiftAssignForm.Metar   r  r  current_shift
next_shiftr  rc  rg   rb  r   r7  zRotating Shiftr  r  r  r  )rotating_shift_idrg   r  r  rv   N)r   r   r   r   r6   r   r   r&  r   r9  r  rO   r  r   rj   rY   r   r+  f  sd    	 $
 )66*:;
 "((8!9L/,$*+A$B">2
rj   r   c                    t        |   |i | t        | j                         | j                  j	                         D ]&  \  }}|j
                  sd| j                  |   _        ( | j                  d   j                  j                  j                  dddd       | j                  d   j                  j                  j                  dddd       | j                  d   j                  j                  j                  d	d
d       | j                  d   j                  j                  j                  ddd       t        j                  d	dd
d      | j                  d   _        | j                  d   j                  j                  j                  ddi       | j                  d   j                  j                  j                  ddi       y )Nr  r  w-100 r  Tr  rv   r  r  r  r5  r  r  r  r   r  r7  rg   r/  r   r  r   r  r  s        rY   r   z RotatingShiftAssignForm.__init__  s   $)&)$!%!2!2!4 	<J~~7;J'4	< 	*+2288??!0#		
 	N#**0077!0#		
 	&'..44;;)9	
 	J&&,,33 ^	
 ,1??)9,
L!( 	'(//55<<0	

 	M"))//660	
rj   c                 n    | j                   j                  d      }|r|d   S t        t        d            S )z1
        Validation to employee_id field
        r   r   r  r  r  s     rY   r  z)RotatingShiftAssignForm.clean_employee_id  s8     ((,,];?""1%=#>??rj   c                    t         |           t        j                  j	                  | j
                  j                  d            j                         | j                  _	        | j                  j                  dd        | j                  j                  t        dt        d      i      t         |           t         |          }d| j                  v r| j                  d= |S r  r  r  s     rY   r   zRotatingShiftAssignForm.clean  r  rj   c           	         | j                   j                  d      }t        j                  j	                  | j                   d         }| j
                  d   }g d}|j                  |j                               }|D ]  }t        j                  j                  |      j                         }t               }	||	_        ||	_        | j
                  d   |	_        | j
                  d   |	_        | j
                  d   |	_        | j                   j	                  d      |	_        | j
                  d	   |	_        | j
                  d   |	_        | j
                  d   |	_        |j(                  j*                  |	_        |j.                  |	_        d
|	j2                  d<   | j
                  d   }
| j
                  d   }|
dk(  rt5        ||      }||	_        n|
dk(  r2| j
                  d	   }| j
                  d   }t7        ||      }||	_        nO|
dk(  rJ|	j                  t9        j:                  t=        | j                   j	                  d                  z   |	_        |	j?                           y )Nr   r/  rF  r  r  r  rg   r  rv   rm   r  r]   r_   r[   rc   ) r   r   r5   r   r   r   r  r  rB   r   r  r6   r/  r   r  rg   r  r  rv   r  r  r  r-  shift1r.  rc  ri   rz   rt   r   rQ   r   )r   r   r  rotating_shiftr  r  rf   r   r   rotating_shift_assignr  rg   r  rv   s                 rY   r   zRotatingShiftAssignForm.save  sI    yy((7&..22dii@S6T2U$$%;<
	 __X^^%56
' !	)K''..+.>DDFH$7$9!6D!308!--1->->z-J!*/3/@/@/N!,595F5F|5T!259YY]]CU5V!2151B1B>1R!.9=9J9J&:!6 6:5F5F|5T!22:2M2M2V2V!//=/D/D!,HI!112DE((4H**<8J8#.z:F	9B%6Y&#00@!..|<
1*lK	9B%6W$)44((c$))--@R2S.TUV &6 "&&(C!	)rj   )Fr  r   s   @rY   r(  r(  O  s     *!!((E(J'6'(+!8	
 [!	K !u  '
1CH *u))!6BT;UV ##EOO6,CWJ
 
23
j@" 3)rj   r(  c                   v     e Zd ZdZ ej
                  ed ed            Z G d d      Z	 fdZ
 fdZ xZS )	RotatingShiftAssignUpdateFormr)  r  r  r  c                       e Zd ZdZeZdZg dZd eddi      iZ	 e
d       e
d	       e
d
       e
d       e
d       e
d      dZy)"RotatingShiftAssignUpdateForm.Metar   r  r,  rg   rb  r   r7  r  r  r  r  r  r  r  N)r   r   r   r   r6   r   r   r&  r   r9  r  r  r   rj   rY   r   r;    sm    	 $
 )66*:;
 !. &'9 :$*+A$B">2z*,
rj   r   c                    t        |   |i | t        | j                         | j                  j	                         D ]&  \  }}|j
                  sd| j                  |   _        ( | j                  d   j                  j                  j                  dddd       | j                  d   j                  j                  j                  dddd       | j                  d   j                  j                  j                  d	d
d       | j                  d   j                  j                  j                  ddd       t        j                  d	dd
d      | j                  d   _        | j                  d   j                  j                  j                  ddi       | j                  d   j                  j                  j                  ddi       y )Nr  r  r1  zedisplay:none; height:50px; border-radius:0; border:1px                     solid hsl(213deg,22%,84%);Tr  rv   r  r  r  r5  r  r  zD height:50px; border-radius:0; border:1px solid hsl(213deg,22%,84%);r   r  r7  rg   r/  r   r  r   r  r  s        rY   r   z&RotatingShiftAssignUpdateForm.__init__&  s   $)&)$!%!2!2!4 	<J~~7;J'4	< 	*+2288??!0#		
 	N#**0077!0#		
 	&'..44;;)9	
 	J&&,,33 _	
 ,1??)9,
L!( 	'(//55<<0	

 	M"))//660	
rj   c                 x   | j                   d   }g d}|j                  |j                               }| j                   d   }| j                  j                  }|dk(  rt        ||      }|| j                  _        n|dk(  rJ| j                  j                  }	| j                  j                  }t        ||	      }|| j                  _        nc|dk(  r^| j                  j                  t        j                  t        | j                  j                  d                  z   | j                  _        t        
| =         S r  r  r  s             rY   r   z"RotatingShiftAssignUpdateForm.save[  r  rj   r  r   s   @rY   r9  r9    sB     !u  '
1CH
 
43
j rj   r9  c                   D     e Zd ZdZ G d d      Zd Zddef fdZ xZS )ShiftRequestForm#
    ShiftRequest model's form
    c                   ~    e Zd ZdZeZdZg dZ eddi       eddi      dZ	 e
d       e
d	       e
d
      dZy)ShiftRequestForm.Metar   r  )reallocate_toapprovedcanceledreallocate_approvedreallocate_canceledprevious_shift_idr  shift_changedrb  r   r7  requested_daterequested_tillDescriptionRequested DateRequested TilldescriptionrK  rL  Nr   r   r   r   r9   r   r   r&  r   r9  r  r  r   rj   rY   r   rB    s`    	 	
 (vv.>?'vv.>?

 "-0$%56$%56
rj   r   c                 &    d| i}t        d|      }|S r  r   r  s      rY   rx  zShiftRequestForm.as_p        4.%&97C
rj   r   c                 *   | j                   j                  sn| j                   j                  }t        |d      rL|j                  j
                  | j                   _        | j                   j                  rd | j                   _        t        | )  |      S Nr  )r   rD  r   hasattrr  r  rH  is_permanent_shiftrL  r   r   r   r   r   r   s      rY   r   zShiftRequestForm.save  sj    }}%%}}00Hx!562:2M2M2V2V/==3337DMM0w|F##rj   .	r   r   r   r   r   rx  boolr   r   r   s   @rY   r?  r?  z  s(    
 
6$4 $ $rj   r?  c                   N     e Zd ZdZ G d d      Z fdZd Zddef fdZ xZ	S )	ShiftAllocationFormr@  c                   |    e Zd ZdZeZdZdZ eddi       eddd      d	Z	 e
d
       e
d       e
d      dZy)ShiftAllocationForm.Metar   r  )rX  rD  rE  rF  rG  rH  r  rI  rb  r   r7  true)rb  r   rJ  rM  rN  rO  rP  NrR  r   rj   rY   r   r`    s`    	 	
 (vv.>?'v6.RS
 "-0$%56$%56
rj   r   c                     t        |   |i | | j                  d   j                  j                  j                  dddd       y )Nr  z#id_reallocate_to_parent_divchangez/update-employee-allocation)	hx-target
hx-triggerhx-getr   r   r   r   r   r   r   s      rY   r   zShiftAllocationForm.__init__  sF    $)&)J&&,,33;&7	
rj   c                 &    d| i}t        d|      }|S r  r   r  s      rY   rx  zShiftAllocationForm.as_p  rT  rj   r   c                 R   | j                   j                  s| j                   j                  }t        |d      r`|j                  j
                  | j                   _        | j                   j                  s%|j                  j                  | j                   _        t        | )  |      S rV  )r   rD  r   rW  r  r  rH  rL  contract_end_dater   r   rY  s      rY   r   zShiftAllocationForm.save  s{    }}%%}}00Hx!562:2M2M2V2V/}}33 33EE MM0 w|F##rj   rZ  )
r   r   r   r   r   r   rx  r\  r   r   r   s   @rY   r^  r^    s-    
 
8
	$4 	$ 	$rj   r^  c                   D     e Zd ZdZ G d d      Zd Zddef fdZ xZS )WorkTypeRequestFormz&
    WorkTypeRequest model's form
    c                   z    e Zd ZdZeZdZdZ eddi       eddi      dZ	 e
d       e
d	       e
d
      dZy)WorkTypeRequestForm.Metar   r  )rD  rE  previous_work_type_idr  work_type_changedrb  r   r7  rJ  rN  rO  rM  )rK  rL  rQ  N)r   r   r   r   r>   r   r   r&  r   r9  r  r  r   rj   rY   r   rn    s`    	  
 (vv.>?'vv.>?

 %%56$%56!-0
rj   r   c                 &    d| i}t        d|      }|S r  r   r  s      rY   rx  zWorkTypeRequestForm.as_p
  rT  rj   r   c                 *   | j                   j                  sn| j                   j                  }t        |d      rL|j                  j
                  | j                   _        | j                   j                  rd | j                   _        t        | )  |      S rV  )r   rD  r   rW  r  rs  ro  is_permanent_work_typerL  r   r   rY  s      rY   r   zWorkTypeRequestForm.save  so    }}%%}}00Hx!56//<< 3 ==7737DMM0w|F##rj   rZ  r[  r   s   @rY   rl  rl    s(    
 
0	$4 	$ 	$rj   rl  c            
           e Zd Z ej                   ed      d ej                  d ed      dd       ed      	      Z ej                   ed
      d ej                  d ed      dd            Z ej                   ed      d ej                  d ed      dd            Z	 fdZ
d Zd Z fdZ xZS )ChangePasswordFormzOld passwordFnew-passwordzEnter Old Password&oh-input oh-input--password w-100 mb-2autocompleter   r   r7  zEnter your old password.r   stripr   	help_textNew passwordzEnter New Password)r   r{  r   New password confirmationRe-Enter Passwordc                 :    || _         t        t        |   |i | y r   )r   r   ru  r   )r   r   r   r   r   s       rY   r   zChangePasswordForm.__init__B  s    	 $0$A&Arj   c                     | j                   j                  d      }| j                  j                  |      st	        j
                  d      |S )Nold_passwordzIncorrect old password.r   r   r   check_passwordr   r   )r   r  s     rY   clean_old_passwordz%ChangePasswordForm.clean_old_passwordF  sB    ((,,^<yy''5''(ABBrj   c                     | j                   j                  d      }| j                  j                  |      rt	        j
                  d      |S )Nnew_passwordz5New password must be different from the old password.r  )r   r  s     rY   clean_new_passwordz%ChangePasswordForm.clean_new_passwordL  sH    ((,,^<99##L1''G  rj   c                     t         |          }|j                  d      }|j                  d      }|r|r||k7  rt        dt	        d      i      |S )Nr  confirm_passwordz.New password and confirm password do not match)r   r   r   r   rO   )r   r   r  r  r   s       rY   r   zChangePasswordForm.cleanU  sa    w}#''7'++,>?,AQ1Q!#S!TU  rj   )r   r   r   r   	CharFieldrO   PasswordInputr  r  r  r   r  r  r   r   r   s   @rY   ru  ru    s    "5??"u"" . !56A
 ./L #5??"u"" . !56A

L 'u+,"u"" . !45A

B	 	rj   ru  c            
           e Zd ZdZ ej
                   ed      d ej                  d ed      dd       ed	      
      Z ej
                   ed      d ej                  d ed      dd       ed      
      Z	d fd	Z
d Z xZS )ResetPasswordFormz
    ResetPasswordForm
    r}  Frv  zEnter Strong Passwordrw  rx  r7  zEnter your new password.rz  r~  r  z4Enter the same password as before, for verification.c                     | j                         r2t        t        dd       }|rt        j                  |t        d             t        |          S )Nr~   zPassword changed successfully)is_validr   rD   r   successrO   r   r   )r   r   r~   r   s      rY   r   zResetPasswordForm.save  s?    ==?ni>G  !,K*LMw|~rj   c                     | j                   j                  d      }| j                   j                  d      }||k(  r|S t        j                  t	        d            )z>
        validation method for confirm password field
        passwordr  zPassword must be same.)r   r   r   r   rO   )r   r  r  s      rY   clean_confirm_passwordz(ResetPasswordForm.clean_confirm_password  sX     $$((4,,001CD''####A&>$?@@rj   r   )r   r   r   r   r   r  rO   r  new_password1new_password2r   r  r   r   s   @rY   r  r  a  s     $EOO"u"" . !89A
 ./M $EOO+,"u"" . !45A
 JKMArj   r  )r   r  rF  rG  rI  rp  
created_at
created_bymodified_byrc  horilla_historyrc  c            
       &   e Zd Zej                  j                         ZeD  cg c]8  }t        |d      r*|j                  t        vr|j                  |j                  f: c}}}} Z ej                  eej                  g d      Zyc c}}}} w )ShiftRequestColumnFormverbose_name)r   r  rK  rL  rH  rD  r   r   r   N)r   r   r   r9   _meta
get_fieldsr~  rW  r   r  r  field_choicesr   r   r   selected_fieldsr   r   rW  r  s   0000rY   r  r    s    %%002L " 5.)ejj.O 
U''(M
 0e//++
O   =B
r  c            
       &   e Zd Zej                  j                         ZeD  cg c]8  }t        |d      r*|j                  t        vr|j                  |j                  f: c}}}} Z ej                  eej                  g d      Zyc c}}}} w )WorkTypeRequestColumnFormr  )r   rs  rK  rL  rH  rD  r  N)r   r   r   r>   r  r  r~  rW  r   r  r  r  r   r   r   r  r  s   0000rY   r  r    s    "((335L " 5.)ejj.O 
U''(M
 0e//++
Or  r  c            
       &   e Zd Zej                  j                         ZeD  cg c]8  }t        |d      r*|j                  t        vr|j                  |j                  f: c}}}} Z ej                  eej                  g d      Zyc c}}}} w )RotatingShiftAssignExportFormr  )r   r/  rg   r  r-  r.  r  r  N)r   r   r   r6   r  r  r~  rW  r   r  r  r  r   r   r   r  r  s   0000rY   r  r    s    &,,779L " 5.)ejj.O 
U''(M
 0e//++
Or  r  c            
       &   e Zd Zej                  j                         ZeD  cg c]8  }t        |d      r*|j                  t        vr|j                  |j                  f: c}}}} Z ej                  eej                  g d      Zyc c}}}} w ) RotatingWorkTypeAssignExportFormr  )r   r  rg   r  r  r  r  r  N)r   r   r   r8   r  r  r~  rW  r   r  r  r  r   r   r   r  r  s   0000rY   r  r    s    )//::<L " 5.)ejj.O 
U''(M
 0e//++
Or  r  c                   *    e Zd ZdZ G d d      Zd Zy)TagsFormz
    Tags form
    c                   <    e Zd ZdZeZdZd eddd      iZddgZ	y	)
TagsForm.Metar   r  colorzheight:50px)rb  r6  r7  r   r  N)
r   r   r   r   r;   r   r   r   r9  r&  r   rj   rY   r   r    s1    	 IW},UVWk*rj   r   c                 &    d| i}t        d|      }|S r  r   )r   r   r   rw  r  s        rY   rx  zTagsForm.as_p  rT  rj   Nr   r   r   r   r   rx  r   rj   rY   r  r    s    + +rj   r  c                   $    e Zd ZdZ G d d      Zy)AuditTagFormz
    Audit Tags form
    c                       e Zd ZdZeZdZy)AuditTagForm.Metar   r  N)r   r   r   r   rF   r   r   r   rj   rY   r   r    s    	 rj   r   Nr'  r   rj   rY   r  r         rj   r  c                   $    e Zd ZdZ G d d      Zy)ShiftRequestCommentFormz$
    Shift request comment form
    c                       e Zd ZdZeZdZy)ShiftRequestCommentForm.Metar   commentN)r   r   r   r   r:   r   r   r   rj   rY   r   r  "  s    	 $rj   r   Nr'  r   rj   rY   r  r         rj   r  c                   $    e Zd ZdZ G d d      Zy)WorkTypeRequestCommentFormz'
    WorkType request comment form
    c                       e Zd ZdZeZdZy)WorkTypeRequestCommentForm.Metar   r  N)r   r   r   r   r?   r   r   r   rj   rY   r   r  0  s    	 'rj   r   Nr'  r   rj   rY   r  r  +  r  rj   r  c                   *    e Zd ZdZ G d d      Zd Zy)DynamicMailConfFormz#
    DynamicEmailConfiguration
    c                       e Zd ZeZdZdgZy)DynamicMailConfForm.Metar  r  N)r   r   r   r)   r   r   r&  r   rj   rY   r   r  >  s    )-rj   r   c                 &    d| i}t        d|      }|S r  r   r  s      rY   rx  zDynamicMailConfForm.as_pF  rT  rj   Nr  r   rj   rY   r  r  9  s       rj   r  c                   8    e Zd ZdZ ej
                  dd      Zy)DynamicMailTestFormz
    DynamicEmailTest
    zTo emailT)r   r   N)r   r   r   r   r   
EmailFieldto_emailr   rj   rY   r  r  O  s      uj4@Hrj   r  c                   *    e Zd ZdZ G d d      Zd Zy)MailTemplateFormz
    MailTemplateForm
    c                   D    e Zd ZeZdZd ej                  ddd      iZy)MailTemplateForm.Metar  bodyr   zdisplay:none;)data-summernoter6  r7  N)	r   r   r   r0   r   r   r   r   r9  r   rj   rY   r   r  \  s+    #NENN*,G
rj   r   c                 |    i ddddddddd	d
dddddddddddddddddddddddd
dd d!d"}|S )#NzReceiver|Full namezinstance.get_full_namezSender|Full namezself.get_full_namezReceiver|Recruitmentzinstance.recruitment_idzSender|Recruitmentzself.recruitment_idzReceiver|Companyzinstance.get_companyzSender|Companyzself.get_companyzReceiver|Job positionzinstance.get_job_positionzSender|Job positionzself.get_job_positionzReceiver|Emailzinstance.get_mailzSender|Emailzself.get_mailzReceiver|Employee Typezinstance.get_employee_typezSender|Employee Typezself.get_employee_typezReceiver|Work Typezinstance.get_work_typezSender|Work Typezself.get_work_typezCandidate|Full namezCandidate|RecruitmentzCandidate|Companyzinstance.get_emailzinstance.get_interview|safe)zCandidate|Job positionzCandidate|EmailzCandidate|Interview Tabler   )r   	mail_datas     rY   get_template_languagez&MailTemplateForm.get_template_languagee  s    
 ":
 4
 #$=
 !"7	

  6
 0
 $%@
 "#:
 1
 O
 %&B
 #$<
 !":
  4
 "#;
  $%>!
"  !7#
$ 'B3)F)
	, rj   N)r   r   r   r   r   r  r   rj   rY   r  r  W  s    
 
rj   r  c                   x    e Zd Zd ed      fd ed      fd ed      fd ed      fd	 ed
      fd ed      fd ed      fd ed      fgZ ej                  g  ej                  ddi       ed      d      Z ej                  e ej                  ddddd            Z	 G d d      Z
 fdZ xZS )MultipleApproveConditionFormequalz
Equal (==)notequalzNot Equal (!=)rS   RangeltzLess Than (<)gtzGreater Than (>)lezLess Than or Equal To (<=)gezGreater Than or Equal To (>=)	icontainsContainsr   zoh-select oh-select-2 mb-2r7  zApproval ManagerT)r   r   r   r   rc  z#conditionValueDivzcondition-value-fields)r   re  rd  rf  )r   r   c                       e Zd ZeZdZdgZy)!MultipleApproveConditionForm.Metar  r  N)r   r   r   r3   r   r   r&  r   rj   rY   r   r    s    )
rj   r   c                     t        |   |i | dt        d      fgt        j                  j                         D cg c]  }|j                  t        |      f c}z   }|| j                  d   _	        y c c}w )Nreporting_manager_idzReporting Managermulti_approval_manager)
r   r   rO   rB   r   r   rG  rR   r   r   )r   r   r   r   r   r   s        rY   r   z%MultipleApproveConditionForm.__init__  sy    $)&)*A.A,BCD9A9I9I9M9M9OH
-5X[[#h-(H
 
 9@,-5H
s   A6)r   r   r   rO   CONDITION_CHOICEr   r  r   r  condition_operatorr   r   r   r   s   @rY   r  r    s    	!L/"	Q'()	!G*	q!"	q#$%	q-./	q012	a
m$	 /U..u||7,H"IJ"#	 +** u||5&12	


 
@ @rj   r  c                   $    e Zd ZdZ G d d      Zy)DynamicPaginationFormz-
    Form for setting default pagination
    c                       e Zd ZeZdZdZy)DynamicPaginationForm.Metar  )user_idN)r   r   r   r*   r   r   r&  r   rj   rY   r   r    s    !rj   r   Nr'  r   rj   rY   r  r    s     rj   r  c                       e Zd ZdZy)MultipleFileInputTN)r   r   r   allow_multiple_selectedr   rj   rY   r  r    s    "rj   r  c                   *     e Zd Z fdZd fd	Z xZS )rA   c                 X    |j                  dt                      t        |   |i | y )Nr   )
setdefaultr  r   r   r   s      rY   r   zMultipleFileField.__init__  s)    ($5$78$)&)rj   c                     t         |   }t        |t        t        f      r|D cg c]  } |||       }}n
 |||      g}|r|d   S d S c c}w )Nr   )r   r   r   r|  tuple)r   r   r   single_file_cleandresultr   s         rY   r   zMultipleFileField.clean  sb    !GMdT5M*=AB'73BFB "$0F #vay,, Cs   Ar   )r   r   r   r   r   r   r   s   @rY   rA   rA     s    *- -rj   rA   c                   L     e Zd ZdZ G d d      Z fdZddedef fdZ xZ	S )	AnnouncementFormz
    Announcement Form
    c                   `    e Zd ZdZeZdZdgZ ej                  ddi       e
ddi      d	Zy
)AnnouncementForm.Metar   r  r  r  r   r7  rb  r   )rQ  expire_dateN)r   r   r   r   r   r   r   r&  r   r   r   r9  r   rj   rY   r   r    sB    	 -)5>>1BB0GH$FF+;<
rj   r   c                 ~    t        |   |i | t        d      | j                  d<   d| j                  d   _        y )NzAttachments r   attachmentsF)r   r   rA   r   r   r   s      rY   r   zAnnouncementForm.__init__  s9    $)&)%6^%LM".3M"+rj   r   rS  c                    g }g }d }| j                   j                  d      rt| j                   j                  d      }|d   | j                  _        g }|D ]>  }t	               }||_        |j                          |j                  |j                         @ t        |   |      }|r |j                  j                  |  ||fS )Nr  r   )filesr   r   attachementr"   r  r   rH  rG  r   attachementsr   )r   r   r  multiple_attachment_idsr   file_instancer   r   s          rY   r   zAnnouncementForm.save  s    "$::m,::--m<L(4QDMM%&(#+ A *%0"""$'..}/?/?@	A
 7<'%H!!%%'>?000rj   rZ  )
r   r   r   r   r   r   r\  r   r   r   r   s   @rY   r  r    s/    
 
4
14 1# 1 1rj   r  c                   $    e Zd ZdZ G d d      Zy)AnnouncementCommentFormz#
    Announcement comment form
    c                       e Zd ZdZeZdgZy)AnnouncementCommentForm.Metar   r  N)r   r   r   r   r    r   r   r   rj   rY   r   r    s    	 $rj   r   Nr'  r   rj   rY   r  r    s     rj   r  c                   $    e Zd ZdZ G d d      Zy)AnnouncementExpireFormz"
    Announcement Expire form
    c                       e Zd ZdZeZdZy)AnnouncementExpireForm.Metar   rc   N)r   r   r   r   r!   r   r   r   rj   rY   r   r
  		  s    	 #rj   r   Nr'  r   rj   rY   r  r  	  r  rj   r  c                   $    e Zd ZdZ G d d      Zy)
DriverFormz
    DriverForm
    c                       e Zd ZeZdZy)DriverForm.Metar  N)r   r   r   r(   r   r   r   rj   rY   r   r  	  s    rj   r   Nr'  r   rj   rY   r  r  	  s     rj   r  c            	       X    e Zd Z ej                         Z	 ddZd Zddddeddddf	dZ	y)	PassWordResetFormNc                 ,   t        j                  ||      }dj                  |j                               }t        j                  ||      }t	        ||||g      }	|(t        j                  ||      }
|	j                  |
d       |	j                          y)zO
        Send a django.core.mail.EmailMultiAlternatives to `to_email`.
        r   Nz	text/html)r   r   r@  
splitlinesr   attach_alternativesend)r   subject_template_nameemail_template_namerw  
from_emailr  html_email_template_namesubjectr  email_message
html_emails              rY   	send_mailzPassWordResetForm.send_mail"	  s     ))*?I''',,./&&':GD.wj8*U#/001I7SJ,,ZErj   c                     t         j                         t        j                  j                  di dz  ddi}fd|D        S )a  
        Given an email, return matching user(s) who should receive a reset.

        This allows subclasses to more easily customize the default policies
        that prevent inactive users and users with unusable passwords from
        resetting their password.
        z
%s__iexactr  Tc              3   n   K   | ],  }|j                         rt        t        |            r| . y wr   )has_usable_passwordr   r   )r   uemailemail_field_names     rY   	<genexpr>z.PassWordResetForm.get_users.<locals>.<genexpr>I	  s7      
$$&#E716F+GH 
s   25r   )	UserModelget_email_field_name_default_managerr   )r   r!  active_usersr"  s    ` @rY   	get_userszPassWordResetForm.get_users:	  sV     %99; 1188 
//T

!
 	
rj   z'registration/password_reset_subject.txtz&registration/password_reset_email.htmlFc
                    | j                   d   }
t        j                  j                  |
      }|j                  }|j
                  }d}	 |j                  j
                  }|r|}|s$t        |      }|j                  }|j                  }n|x}}|rY|j                  |      }|||t        t        |j                              |||rdndd|	xs i }| j                  ||||||       yy# t        $ r
}Y d}~d}~ww xY w)zf
        Generate a one-use only link for resetting password and send it to the
        user.
        r!  )usernameNhttpshttp)r!  domain	site_nameuidr   tokenprotocol)r  )r   r   r   r   r   r!  r  	Exceptionr   r   r-  
make_tokenr   r   rG  r  )r   domain_overrider  r  	use_httpstoken_generatorr  r~   r  extra_email_contextr*  r   r   r!  	work_mailecurrent_siter.  r-  r0  rw  s                        rY   r   zPassWordResetForm.saveP	  s      $$W-||2$$		 3399I E+G4L$))I!((F!00I#..t4E &,[-AB'0Gf	 ',"	G NN%#)A     		s   C+ +	C>9C>r   )
r   r   r   r   r  r!  r  r(  r   r   r   rj   rY   r  r  	  sA    EOOE "&0
0 GD/!% 5rj   r  c                     	 t        j                  |        y # t        $ r6 	 t        j                  | d       Y y # t        $ r t	        |  d      w xY ww xY w)NF)strictz, is not a valid IP address or CIDR notation.)	ipaddress
ip_addressrT   
ip_networkr   )rU   s    rY   validate_ip_or_cidrr@  	  s`    U# 	  u5 	!'EF 	s    	A;AAc                        e Zd Z ej                   ej
                  ddd      dd      Z G d d	      Zd
 Zd fd	Z	 xZ
S )AttendanceAllowedIPFormrL   zform-control w-100)r   r   r7  z(Allowed IP Addresses or Network PrefixeszEEnter multiple IP addresses or network prefixes, separated by commas.)r   r   r|  c                       e Zd ZeZdgZy)AttendanceAllowedIPForm.Metaip_addressesNr   r   r   r#   r   r   r   rj   rY   r   rD  	  s    # !rj   r   c                    | j                   j                  dd      j                         j                  d      }g }|D ]G  }|j                         j                  d      }|s%|D ]  }t	        |       |j                  |         I |S )NrE  r   
r>  )r   r   r{  rP   r@  rH  )r   rE  cleaned_ipsipip_addrs        rY   clean_ip_addressesz*AttendanceAllowedIPForm.clean_ip_addresses	  s    ((,,^R@FFHNNtT 	0B!!$'B! 0G'0&&w/0	0 rj   c                 ^   t         |   d      }|j                  rgt        |j                  j                  dg             }t        | j                  d         }t        |j                  |            }||j                  d<   nd| j                  d   i|_        |r|j                          |S )NFr   allowed_ipsrE  )	r   r   rG  r   rc  r   r   r|  union)r   r   r   existing_ipsnew_ips
merged_ipsr   s         rY   r   zAttendanceAllowedIPForm.save	  s    7<u<-;;x77;;M2NOL$++N;<Gl009:J6@H$$]3 t00@(H$ MMOrj   r   )r   r   r   r   r  r   rE  r   rL  r   r   r   s   @rY   rB  rB  	  sF    "5??u~~Q9M$NO8YL" "	 rj   rB  c                   `     e Zd Z ej                  dd      Z G d d      Zd Z fdZ xZ	S )AttendanceAllowedIPUpdateForm   z
IP Address)
max_lengthr   c                       e Zd ZeZdgZy)"AttendanceAllowedIPUpdateForm.Metar>  NrF  r   rj   rY   r   rX  	  s    #rj   r   c                 N    	 t        |       |S # t        $ r t        d      w xY w)Nz#Enter a valid IPv4 or IPv6 address.)r   r   )r   rU   s     rY   validate_ip_addressz1AttendanceAllowedIPUpdateForm.validate_ip_address	  s6    	I"5)   	I!"GHH	Is    $c                     t         |          }| j                  j                         D ]  \  }}| j	                  |      ||<    |S r   )r   r   r   r   rZ  )r   r   r   rU   r   s       rY   r   z#AttendanceAllowedIPUpdateForm.clean	  sL    w}!%!2 	GJ'+'?'?'FL$	G rj   )
r   r   r   r   r  r>  r   rZ  r   r   r   s   @rY   rT  rT  	  s.     BlCJ    rj   rT  c                   2     e Zd Z G d d      Z fdZ xZS )TrackLateComeEarlyOutFormc                       e Zd ZeZdgZy)TrackLateComeEarlyOutForm.Meta	is_enableN)r   r   r   r<   r   r   r   rj   rY   r   r_  	  s    %rj   r   c                     t        |   |i | | j                  d   j                  j                  j                  dddd       y )Nr`  z7/attendance/enable-disable-tracking-late-come-early-outthisrc  )zhx-postrd  re  rg  r   s      rY   r   z"TrackLateComeEarlyOutForm.__init__	  sF    $)&)K ''--44T#&	
rj   )r   r   r   r   r   r   r   s   @rY   r]  r]  	  s     
 
rj   r]  c                        e Zd ZdZ ej
                   ej                  ddi            Z ej
                   ej                  ddi            Zd Z	 G d d      Z
 fd	Z xZS )
HolidayFormaW  
    Form for creating or updating a holiday.

    This form allows users to create or update holiday data by specifying details such as
    the start date and end date.

    Attributes:
        - start_date: A DateField representing the start date of the holiday.
        - end_date: A DateField representing the end date of the holiday.
    rb  r   r7  )r   c                     | j                   j                  d      }| j                   j                  d      }|r|r||k  rt        t        d            |S )Nrg   end_datez3End date should not be earlier than the start date.r  )r   rg   rf  s      rY   clean_end_datezHolidayForm.clean_end_date	  sW    &&**<8
$$((4(x*'<!GH  rj   c                   2    e Zd ZdZeZdZdgZd ed      iZ	y)HolidayForm.Metar   r  r  r   NameN)
r   r   r   r   r/   r   r   r&  rO   r  r   rj   rY   r   ri  
  s*    	 -AfI
rj   r   c                 x    t        t        | 
  |i | d| j                  d   j                  j
                  d<   y )Nr   ry  )r   rd  r   r   r   r   r   s      rY   r   zHolidayForm.__init__
  s6    k4)4:6:;AF""((8rj   )r   r   r   r   r   r  r   rg   rf  rg  r   r   r   r   s   @rY   rd  rd  	  sm    	 !uff%56J uuff%56H	

 

B Brj   rd  c            
       F   e Zd ZdZej
                  j                         ZeD  cg c]F  }t        |d      r8|j                  t        vr&|j                  |j                  j                         fH c}}}} Z ej                  eej                   g d      Zyc c}}}} w )HolidaysColumnExportForma}  
    Form for selecting columns to export in holiday data.

    This form allows users to select specific columns from the Holidays 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 Holidays 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.
    r  )r   rg   rf  	recurringr  N)r   r   r   r   r/   r  r  r~  rW  r   r  r  
capitalizer  r   r   r   r  r  s   0000rY   rm  rm  
  s     >>,,.L " 5.)ejj.O 
U''2245M
 0e//++
	Os   AB
rm  c                   6     e Zd ZdZ G d d      Z fdZ xZS )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                       e Zd ZdZeZdZdgZy)CompanyLeaveForm.Metar   r  r  N)r   r   r   r   r&   r   r   r&  r   rj   rY   r   rs  B
  s    	 -rj   r   c                 `    t        |   |i | d| j                  d   j                  _        y)zJ
        Custom initialization to configure the 'based_on' field.
        z"horilla_widgets/select_option.htmlbased_on_weekN)r   r   r   r   option_template_namer   s      rY   r   zCompanyLeaveForm.__init__K
  s1     	$)&)0 	O$++@rj   r   r   r   r   r   r   r   r   s   @rY   rq  rq  4
  s       
 
rj   rq  c                   6     e Zd ZdZ G d d      Z fdZ xZS )PenaltyAccountFormz
    PenaltyAccountForm
    c                       e Zd ZeZdZdgZy)PenaltyAccountForm.Metar  r  N)r   r   r   r4   r   r   r&  r   rj   rY   r   r{  Z
  s    -rj   r   c                 J   |j                  dd       }t        |   |i | t        j                  d      rl|rit        dd      }|j                  j                         }|j                  j                  |j                  dd            }|| j                  d   _        y y y )	Nr   leave	leavetype)	app_labelr   leave_type_idTr  r  )r   r   r   r   r  rE   available_leaver   r   r   r  r   r   )r   r   r   r   	LeaveTypeavailable_leavesassigned_leave_typesr   s          rY   r   zPenaltyAccountForm.__init___
  s    ::j$/$)&)W%(/'UI'77;;=#,#4#4#;#;'33O$3O $< $  5IDKK(1 +3%rj   rw  r   s   @rY   ry  ry  U
  s       
	I 	Irj   ry  )r   rq   rt   r=  r  r  r   r   typingr   djangor   django.appsr   django.contribr   django.contrib.authr	   django.contrib.auth.formsr
   r   django.contrib.auth.modelsr   r   r   django.contrib.auth.tokensr   django.contrib.sites.shortcutsr   django.core.exceptionsr   django.core.mailr   django.core.validatorsr   django.formsr   r   r   django.templater   django.template.loaderr   django.utils.encodingr   django.utils.httpr   django.utils.translationr   rO   r   r  base.methodsr   base.modelsr   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   employee.filtersr@   employee.formsrA   employee.modelsrB   horillarC   horilla.horilla_middlewaresrD   horilla.methodsrE   horilla_audit.modelsrF   2horilla_widgets.widgets.horilla_multi_select_fieldrG   &horilla_widgets.widgets.select_widgetsrH   rZ   r  ri   rz   r|   r   r   r   r   r  r#  r*  r/  rN  r[  r_  r  r  r  r  r  r
  r  r(  r9  r?  r^  rl  ru  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  ClearableFileInputr  	FileFieldr  r  r  r  r$  r  r@  rB  rT  r]  rd  rm  rq  ry  r   rj   rY   <module>r     s      	  $    # . J > > > ; 2 3 9 : : " 3 - 3 1 ; (" " " " " " " " "F , , $ ' 6 3 ) V K
Y" fWovi !y!">&7t> >B*L5:: *LZ+I +\d 42t 2j) B Y   i  D-9 D-N).) ).X 9  g9 gTr- r-juu up y  	 ,Qi Qhx	 xv^	 ^Bq)eoo q)htI tn/$y /$h<$) <$~.$) .$b@ @F-A -A` UZZ *

 *EJJ ,uzz ,y 09 i  ) ,A%** A%y %P*@9 *@ZI #00 #- - (1y (1Vi Y   	f

 fR	%eoo %PI .
	 
 ,B) ,B^uzz D
y 
BI Irj   