o
    ¯¢¯h¦  ã                   @   sb   d dl mZmZ d dlmZ d dlmZmZmZ eƒ Z	dZ
dd„ Ze	jdedd	efd
d„ƒZdS )é    )Ú	APIRouterÚRequest)ÚHTMLResponse)Ú	templatesÚsbÚloggerzYid,parent_id,department,order_no,level,leader_id,leader_name,leader_position,leader_phonec                 C   sj   |   d¡|   d¡|   d¡|   d¡pd|   d¡pd|   d¡|   d¡p"d	 ¡ |   d
¡p*d	 ¡ |   d¡p2d	dœ	S )NÚidÚ	parent_idÚ
departmentÚorder_nor   ÚlevelÚ	leader_idÚleader_nameÚ Úleader_positionÚleader_phone)	r   Úparentr
   Úorderr   r   ÚnameÚpositionÚphone)ÚgetÚstrip)Úr© r   ú+/var/www/html/bot/app/web/pages/orgchart.pyÚ_row	   s   ÷r   z/org/motie/chart)Úresponse_classÚrequestc              
   Ã   s‚   zt  d¡ t¡ d¡ ¡ }dd„ |jpg D ƒ}W n ty6 } zt 	d|› ¡ g }W Y d }~nd }~ww t
 d| |ddœ¡S )	NÚv_motie_org_chartiˆ  c                 S   s   g | ]}t |ƒ‘qS r   )r   )Ú.0r   r   r   r   Ú
<listcomp>   s    zmotie_chart.<locals>.<listcomp>zmotie_org_chart fetch failed: zorg/motie_chart.htmlu   ì‚°ì—…í†µìƒìžì›ë¶€ ì¡°ì§ë„)r   ÚnodesÚtitle)r   ÚtableÚselectÚFIELDSÚlimitÚexecuteÚdataÚ	Exceptionr   Úerrorr   ÚTemplateResponse)r   ÚresÚrowsÚer   r   r   Úmotie_chart   s   €€þ
þr0   N)Úfastapir   r   Úfastapi.responsesr   Úapp.web.depsr   r   r   Úrouterr&   r   r   r0   r   r   r   r   Ú<module>   s    