B
    b                 @   sh   d dl Z d dlmZ d dlmZmZmZmZmZm	Z	m
Z
mZ d dlmZ d dlmZ G dd deZdS )    N)ladonize)request_valid
user_photointerface_responseSUCCESS_CODEMESSAGE_CODESYSTEM_EXCEPTIONDATA_EXCEPTIONonline_employee_new)Q)gettext_lazyc               @   sV   e Zd ZdZeeeeeeeddd Zeeeeeeeeeeeed
dd Z	dS )BioTimeAppReportu   
    【Report】
    )Zrtypec             C   s   dd tdddd tdddd tddd	d td
ddd tdddd tdddd tdddd tdddd tdddd tdddd tddg}ttt|ddS )u  
         Report Fields
        @param source:          data source(1: IOS， 2：Android)
        @param device_token:    message push Token
        @param language:
        @param token:
        @rtype:
            success:
                {"code":1,"error":"","describe":"","message":"","data":[{"field":"Field", "field_name": "Field Name"}, ]}Default select all fields
            fail:
                {"code": -10001, "error": "", "describe": "exception detail", "message": "pop up info", "data":""}
        Zpinz{0}Zreport_column_empCode)fieldZ
field_namenameZreport_column_firstNameZatt_dateZreport_column_attendanceDateZcheck_inZreport_column_checkInTimeZ	break_outZreport_column_breakOutTimeZbreak_inZreport_column_breakInTimeZ	check_outZreport_column_checkOutTimeZ
break_timeZreport_column_breakTimeZ
total_timeZreport_column_totalTimeDurationZ
leave_timeZreport_column_leaveDurationZovertimeZreport_column_overtimeDuration 
successful)format_r   r   jsondumps)selfsourcedevice_tokenlanguagetokendata r   :G:\easytimepro\master/mysite/mobile\services\app_report.pyfields   s    zBioTimeAppReport.fieldsc
          	   C   s   ddl m}
m} t|}|jjj}|j}| }|rjd}|
j	 j
||d}| rrddd |D }n|rrd}d	|||||||}tttd
|iddS )u  
        @param start:           start date(stamp)
        @param end:             end date(stamp)
        @param search:          search (emp code/first name)
        @param field:           query field, join by ','
        @param department:      search department, join by ','
        @param source:          data source(1: IOS， 2：Android)
        @param device_token:    message push Token
        @param language:
        @param token:
        @rtype:
            success:
                {"code":1,"error":"","describe":"","message":"","data":{"address":"the app report request address"}}
            fail:
                {"code": -10001, "error": "", "describe": "exception detail", "message": "pop-up message", "data":""}
        r   )EmployeeEmployeeProfile)Zemp_codecompany,c             S   s   g | ]}t |jqS r   )strid).0ir   r   r   
<listcomp>K   s    z,BioTimeAppReport.display.<locals>.<listcomp>r   zu/webservice/rpc/app/att/AppReport/?fields={0}&department={1}&start={2}&end={3}&userid={4}&language={5}&company_id={6}addressr   )Zmysite.personnel.modelsr   r    r
   
departmentr"   r%   stripZobjectsallfilterexistsjoinr   r   r   r   r   )r   startendsearchr   r*   r   r   r   r   r   r    ZempZ
company_idZsearch_emp_idZempsr)   r   r   r   display/   s    
zBioTimeAppReport.displayN)
__name__
__module____qualname____doc__r   r   intr$   r   r3   r   r   r   r   r      s
   r   )r   Zmysite.ladon.ladonizerr   Zmysite.mobile.utilsr   r   r   r   r   r   r	   r
   Zdjango.db.modelsr   Zdjango.utils.translationr   r   objectr   r   r   r   r   <module>   s
   (