feat: ESC/POS 영수증 프린터로 특이사항 인쇄 기능
- pos_printer.py: ESC/POS 유틸리티 (192.168.0.174:9100)
- POST /api/print/cusetc API 추가
- admin.html: 특이사항 옆 [🖨️ 인쇄] 버튼 추가
- EUC-KR 인코딩으로 한글 지원
This commit is contained in:
@@ -3929,6 +3929,44 @@ def api_update_cusetc(cuscode):
|
||||
return jsonify({'success': False, 'error': str(e)}), 500
|
||||
|
||||
|
||||
@app.route('/api/print/cusetc', methods=['POST'])
|
||||
def api_print_cusetc():
|
||||
"""특이(참고)사항 영수증 인쇄 API"""
|
||||
try:
|
||||
from pos_printer import print_cusetc
|
||||
|
||||
data = request.get_json() or {}
|
||||
customer_name = data.get('customer_name', '').strip()
|
||||
cusetc = data.get('cusetc', '').strip()
|
||||
phone = data.get('phone', '').strip()
|
||||
|
||||
if not customer_name:
|
||||
return jsonify({'success': False, 'error': '고객 이름이 필요합니다.'}), 400
|
||||
|
||||
if not cusetc:
|
||||
return jsonify({'success': False, 'error': '특이사항이 비어있습니다.'}), 400
|
||||
|
||||
# ESC/POS 프린터로 출력
|
||||
result = print_cusetc(customer_name, cusetc, phone)
|
||||
|
||||
if result:
|
||||
return jsonify({
|
||||
'success': True,
|
||||
'message': f'{customer_name}님의 특이사항이 인쇄되었습니다.'
|
||||
})
|
||||
else:
|
||||
return jsonify({
|
||||
'success': False,
|
||||
'error': '프린터 연결 실패. 프린터가 켜져있는지 확인하세요.'
|
||||
}), 500
|
||||
|
||||
except ImportError:
|
||||
return jsonify({'success': False, 'error': 'pos_printer 모듈을 찾을 수 없습니다.'}), 500
|
||||
except Exception as e:
|
||||
logging.error(f"특이사항 인쇄 오류: {e}")
|
||||
return jsonify({'success': False, 'error': str(e)}), 500
|
||||
|
||||
|
||||
@app.route('/api/members/history/<phone>')
|
||||
def api_member_history(phone):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user