B
    ci                 @   s   d dl 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 G dd	 d	ejZG d
d dejZG dd dejZG dd dejZdS )    N)gettext_lazy)admin)forms)STATUS_VALID)db_const)Resignc               @   s   e Zd ZejedddZejedejj	dZ
ejeddejdZejed	ejj	dZejed
ejddZejeddejddZdS )AddEmployeeResignFormZresign_field_employeeF)labelrequiredZresign_field_resignDate)r	   initialZresign_field_resignType   )r	   r   choicesZ$resign_field_reportGenerationEndDateZ&resign_field_disableAttendanceFunction)r	   r   r   Zresign_field_resignReason )r	   r   Z
max_lengthr
   N)__name__
__module____qualname__r   ZEmployeeOneToOneResignField_employeeZ	DateFielddatetimenowresign_dateZChoiceFieldr   Z	LEAVETYPEresign_typereport_generation_end_dateZDISABLE_ATT
disableattZ	TextFieldZMAX_RESIGN_REASONreason r   r   @G:\easytimepro\master/mysite/personnel\actions\resign_actions.pyr      s   
r   c               @   s0   e Zd ZedZedZedZeZdd Z	dS )AddEmployeeResignZresign_action_addEmployeeResignZ&resign_action_addEmployeeResignHelpTxtZ*resign_action_addEmployeeResignDescriptionc          	   O   s   ddl m} | jjd}|s*|tdt| jj}| r|j}t	j	
  }|dd}|d |k rnd}x8|D ]0}	t|	|d |d |d	 ||d
 d}
|
  qtW d S )Nr   )ActionHandleErrorr   Zselect_none_employeer   Tr   r   r   r   )Zemployee_idr   r   r   r   r   )Zmysite.admin.actionr   ZrequestZPOSTZgetlistr   r   Zis_validcleaned_datar   r   dategetr   save)selfargskwargsr   ZempsZformr   r   Zdisable_attZempobjr   r   r   action"   s"    
zAddEmployeeResign.actionN)
r   r   r   r   verbose_namehelp_txtshort_descriptionr   Zaction_formr'   r   r   r   r   r      s
   r   c               @   s8   e Zd ZdZedZedZedZedZdd Z	dS )	ReinstatementTZresign_action_reinstatementZ"resign_action_reinstatementHelpTxtZ&resign_action_reinstatementDescriptionZare_you_sure_to_reinstatementc             O   s   g }xz| j D ]p}ddlm} |j}t|_|js:d|_d|_tj	 |_
|  dt|j }||d |  ||j qW |S )Nr   )cacher   TZemp_change_flag_r   )objectsZdjango.core.cacher,   r   r   statusZ
enable_attZ	enroll_snr   r   Zupdate_timer"   strZ
company_idsetdeleteappendZemp_code)r#   r$   r%   r&   	objects_ir,   Zemployee_objZemp_change_keyr   r   r   r'   =   s    zReinstatement.actionN)
r   r   r   batch_selectr   r(   r)   r*   confirmationr'   r   r   r   r   r+   6   s   r+   c               @   s8   e Zd ZedZedZedZdZedZdd Z	dS )DisableAttendanceFunctionZresign_action_disableAttendanceTz3are_you_sure_to_disable_attendance_function {0} {1}c             O   s"   x| j D ]}d|_|  qW d S )Nr   )r-   r   r"   )r#   r$   r%   r3   r   r   r   r'   V   s    z DisableAttendanceFunction.actionN)
r   r   r   r   r(   r)   r*   r4   r5   r'   r   r   r   r   r6   O   s   r6   )r   Zdjango.utils.translationr   r   mysiter   Zmysite.adminr   Zmysite.admin.modelsr   Zmysite.personnelr   Zmysite.personnel.modelsr   ZZKActionFormr   ZZKModelActionr   r+   r6   r   r   r   r   <module>   s   