
    sih                        d 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 dd	lmZ dd
lmZ ddlmZmZmZmZmZ  G d de      Z G d de      Z G d de      Z G d de      Z G d de      Zy)z

forms.py
    )Any)forms)widgetsrender_to_string)gettext_lazy)Form	ModelForm)MultipleFileField)Employee)get_active_employees)ContractEncashmentGeneralSettingsPayrollGeneralSettingReimbursementFileReimbursementrequestCommentc                        e Zd ZdZ ed      Z ej                         Z ej                  d      Z	 G d d      Z
 fdZd Zd	 Z xZS )
ContractFormz
    ContactForm
    r   F)requiredc                       e Zd ZdZdZdgZeZy)ContractForm.Meta3
        Meta class for additional options
        __all__	is_activeN)__name__
__module____qualname____doc__fieldsexcluder   model     7/var/www/python-projects/worksol/payroll/forms/forms.pyMetar   "   s    	 
 r#   r%   c                 t   t        |   |i | | j                  d   j                  j                  j                  ddi       t        j                  dddd      | j                  d	   _        t        j                  dddd      | j                  d
   _        | j                  d   j                  j                  j                  ddi       | j                  rg| j                  j                  rQ| j                  | j                        }| j                  d   j                  j                  j                  d|dd       t        j                  j                         }|r/| j                  j                  |j                  | j                  d<   d| j                  d   j                  j                  d<   y )Nemployee_idonchangezcontractInitial(this)dateoh-input w-100zSelect a date)typeclassplaceholderattrscontract_start_datecontract_end_datecontract_statusr,   z	oh-selectthisbeforebegin)z	hx-targetzhx-postzhx-swapnotice_period_in_days.jpg, .jpeg, .png, .pdfcontract_documentaccept)super__init__r   widgetr/   updater   	DateInputinstancepkget_dynamic_hx_post_urlr   objectsfirstnotice_periodinitial)selfargskwargsdynamic_urlrB   	__class__s        r$   r:   zContractForm.__init__-   s   $)&)M"))//6601	
 5<4E4E).5
)*1 3:2C2C).3
'(/ 	%&--33::	

 ==T]]--66t}}EKKK)*1177>>!'*, &--335T]]%%-494G4GDLL01 & 	'(//55	
r#   c                 &    d| i}t        d|      }|S )S
        Render the form fields as HTML table rows with Bootstrap styling.
        formzcontract_form.htmlr   rE   context
table_htmls      r$   as_pzContractForm.as_pU   s      4.%&:GD
r#   c                      d|j                    S )zN
        Render the url for contract status update through hx request
        z /payroll/update-contract-status/)r?   )rE   r>   s     r$   r@   z$ContractForm.get_dynamic_hx_post_url]   s     2(++??r#   )r   r   r   r   _verbose_namer   	DateFieldr0   r1   r%   r:   rP   r@   __classcell__rI   s   @r$   r   r      sN     Z=L)%//+'7	 	&&P@r#   r   c                   $    e Zd ZdZ G d d      Zy)ReimbursementRequestCommentFormz.
    ReimbursementRequestCommentForm form
    c                       e Zd ZdZeZdZy)$ReimbursementRequestCommentForm.Metar   )commentNr   r   r   r   r   r!   r   r"   r#   r$   r%   rZ   i   s    	 ,r#   r%   N)r   r   r   r   r%   r"   r#   r$   rX   rX   d   s     r#   rX   c                   V     e Zd ZdZdZ G d d      Z fdZd Zd
dede	f fd	Z
 xZS )reimbursementCommentFormz2
    Reimbursement request comment model form
    zAdd Commentc                       e Zd ZdZeZdZy)reimbursementCommentForm.Metar   r   Nr\   r"   r#   r$   r%   r`   y   s    	 ,r#   r%   c                     t        |   |i | t        d      | j                  d<   d| j                  d   _        d| j                  d   j
                  j                  d<   y )Nfiles)labelFr6   r8   )r9   r:   r   r   r   r;   r/   )rE   rF   rG   rI   s      r$   r:   z!reimbursementCommentForm.__init__   sX    $)&)0w?G(-G%6OG##))(3r#   c                 &    d| i}t        d|      }|S )rK   rL   zcommon_form.htmlr   rM   s      r$   rP   zreimbursementCommentForm.as_p   s      4.%&8'B
r#   commitreturnc                    g }d }| j                   j                  d      rt| j                   j                  d      }|d   | j                  _        g }|D ]>  }t	               }||_        |j                          |j                  |j                         @ t        |   |      }|r |j                   j                  |  ||fS )Nrb   r   )rb   getlistr>   
attachemntr   filesaveappendr?   r9   add)rE   re   multiple_files_idsrb   ri   file_instancer>   rI   s          r$   rk   zreimbursementCommentForm.save   s    ::g&JJ&&w/E',QxDMM$!## <
 1 3%/"""$"))-*:*:;	<
 7<'HNN 23r#   ).)r   r   r   r   rS   r%   r:   rP   boolr   rk   rU   rV   s   @r$   r^   r^   r   s<     !L P4 #  r#   r^   c                        e Zd Z G d d      Zy)EncashmentGeneralSettingsFormc                       e Zd ZeZdZy)"EncashmentGeneralSettingsForm.Metar   N)r   r   r   r   r!   r   r"   r#   r$   r%   rt      s    )r#   r%   N)r   r   r   r%   r"   r#   r$   rr   rr      s     r#   rr   c            
       Z   e Zd Zg dZ ej
                  d ej                  ddd            Z ej
                  d ej                  ddd            Z ej                  de
j                  j                         D  cg c]  }|j                  |j                         f  c}} ej                        Z ej                  de	      Z ej                  d ed
      d   D  cg c]  }|j                  |j                         f  c}} ej                        Zy
c c}} w c c}} w )DashboardExport)) rw   )draftDraft)review_ongoingzReview Ongoing)	confirmed	Confirmed)paidPaidFr)   r*   )r+   r,   r.   )r   r;   )r   choicesr;   )r   r   Nr   )r   r   r   status_choicesr   rT   r=   
start_dateend_dateChoiceFieldr   rA   allidget_full_nameSelectMultiple	employeesstatusr   contributions).0emps   00r$   rv   rv      s    N !uf?O%PQJ uuf?O%PQH "!!:B:J:J:N:N:PQ3#&&#++-.Q##I
 U~FF%E%% ,D12HI
 VVS&&()
 ##M	 R
s   #D!)#D'rv   N) r   typingr   djangor   django.formsr   django.template.loaderr   django.utils.translationr   rR   
base.formsr	   r
   employee.formsr   employee.modelsr   payroll.context_processorsr   payroll.models.modelsr   r   r   r   r   r   rX   r^   rr   rv   r"   r#   r$   <module>r      ss        3 6 & , $ ; H@9 H@Vi ,y ,^I d r#   