
    siR                        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 ddlmZ dd	lmZmZ dd
lmZ ddlmZmZ ddlmZmZ ddlmZmZmZmZ  eed       e ed      d       G d de                    Z  eed       e ed      d       G d de                    Z! eed       e ed      d       G d de                    Z" G d de      Z#y)zN
this page is handling the cbv methods for Employee shift shedule in settings
    )Any)messages)HttpResponse)render)reverse)method_decorator)gettext_lazy)EmployeeShiftFilterEmployeeShiftScheduleFilter)EmployeeShiftScheduleForm)EmployeeShiftEmployeeShiftSchedule)login_requiredpermission_required)HorillaDetailedViewHorillaFormViewHorillaListViewHorillaNavViewdispatch)namezbase.view_employeeshiftschedule)permc                   N     e Zd ZdZdeddf fdZ ed      ZdZ e	       Z
 xZS )EmployeeShiftSheduleNavz4
    nav bar of the employee shift sheduel view
    kwargsreturnNc                     t        |   di | t        d      | _        | j                  j
                  j                  d      rdt        d       d| _        y y )Nemployee-shift-shedule-listbase.add_employeeshiftschedulea&  
                                onclick = "event.stopPropagation();"
                                data-toggle="oh-modal-toggle"
                                data-target="#genericModal"
                                hx-target="#genericModalBody"
                                hx-get="z&settings-employee-shift-shedule-createz""
                                 )super__init__r   
search_urlrequestuserhas_permcreate_attrsselfr   	__class__s     C/var/www/python-projects/worksol/base/cbv/employee_shift_shedule.pyr!   z EmployeeShiftSheduleNav.__init__#   sb    "6"!"?@<<%%&FG%)
 *11Y)Z([ \!!$D H    zShift Schedulez#listContainer)__name__
__module____qualname____doc__r   r!   _	nav_titlesearch_swap_targetr
   filter_instance__classcell__r)   s   @r*   r   r      s6    

$ 
$ 
$ "#I))+Or+   r   r   c                   R     e Zd ZdZeZeZ ed      Z	dZ
 fdZdedef fdZ xZS )EmployeeShiftSheduleCreateFormzG
    form view for creating  and updating job position in settings
    zCreate Employee Shift Schedulez.cbv/settings/employee_shift_schedule_form.htmlc                    t        |   di |}| j                  j                  j                  rV| j                  j                  j
                  | j                  j                  d   _        t        d      | j                  _
        |S )NdayzUpdate Employee Shift Scheduler   )r    get_context_dataforminstancepkr9   fieldsinitialr0   
form_classverbose_name)r(   r   contextr)   s      r*   r:   z/EmployeeShiftSheduleCreateForm.get_context_dataB   sf    '*4V499  .2ii.@.@.D.DDIIU#++,-M+NDOO(r+   r;   r   c                    |j                         r| j                  j                  j                  rd|j                  }||d   j	                         }|r||_        |j                          t        j                  | j                  t        d             n9|j                          t        j                  | j                  t        d             | j                  d      S t        | 5  |      S )Nr9   zShift schedule Updated!.z6Employee Shift Schedule has been created successfully!z)<script>window.location.reload()</script>)is_validr;   r<   r=   valueday_idsaver   successr#   r0   r   r    
form_valid)r(   r;   shiftsdaysr)   s       r*   rI   z)EmployeeShiftSheduleCreateForm.form_validI   s    ==?yy!!$$%;,,.D(,KKM$$T\\15O3PQ		  LLNO $$%PQQw!$''r+   )r,   r-   r.   r/   r   modelr   r@   r0   new_display_titletemplate_namer:   r   rI   r4   r5   s   @r*   r7   r7   4   sC    
 "E*J:;DM(8 (\ ( (r+   r7   c                        e Zd Zdeddf fdZg dZeZeZ	dZ
 ed      dd	f ed
      df ed      df ed      df ed      dfgZddiZdZdZ xZS )EmployeeShiftSheduleListr   r   Nc                     t        |   di | d| _        t        d      | _        | j
                  j                  j                  d      s.| j
                  j                  j                  d      sd | _        y y y )Nzday-containerr   z!base.change_employeeshiftschedulez!base.delete_employeeshiftscheduler   )	r    r!   view_idr   r"   r#   r$   r%   action_methodr'   s     r*   r!   z!EmployeeShiftSheduleList.__init__c   sn    "6"&!"?@||  ))/
,,##,,-PQ!%D R
r+   )
start_timeend_timeminimum_working_hourFDayday_col
get_avatar
Start TimerT   End TimerU   Minimum Working HoursrV   Auto Check Outauto_punch_out_colactionzI
                    style="width:200px !important;"
                    a  
                id = "scheduleTr{get_instance_id}"
                hx-get='{get_detail_url}?instance_ids={ordered_ids}'
                hx-target="#genericModalBody"
                data-target="#genericModal"
                data-toggle="oh-modal-toggle"
                actions_col)r,   r-   r.   r   r!   bulk_update_fieldsr   rL   r   filter_classshow_filter_tagsr0   columnsheader_attrs	row_attrsrS   r4   r5   s   @r*   rP   rP   ]   s    & & & L!E.L 
59l+	
<,'	
:
#	
"	#%;<	
	23G 	 LI "Mr+   rP   c                       e Zd ZdZeZ ed      ZddddZ ed      df ed	      d
f ed      df ed      df ed      ddfgZ	dZ
y)EmployeeShiftSheduleDetailViewz!
    detail view of the page
    Detailsr9   shift_idrY   )titlesubtitleavatarrZ   rT   r[   rU   r\   rV   r]   r^   zAutomatic Check Out Timeget_automatic_check_out_timeTdetail_actions_colN)r,   r-   r.   r/   r   rL   r0   rk   headerbodyrS   r   r+   r*   rh   rh      sx     "EiLE*MF	
<,'	
:
#	
"	#%;<	
	23	
%	&(FMD )Mr+   rh   N)$r/   typingr   django.contribr   django.httpr   django.shortcutsr   django.urlsr   django.utils.decoratorsr   django.utils.translationr	   r0   base.filtersr
   r   
base.formsr   base.modelsr   r   horilla_views.cbv_methodsr   r   horilla_views.generic.cbv.viewsr   r   r   r   r   r7   rP   rh   r   r+   r*   <module>r~      s     # $ #  4 6 I 0 < I  .z2>?j,n , 3,, .z2=>Z"(_ "( 3"(J .z2>?j'" '" 3'"T)%8 )r+   