from django.urls import path
from . import views
from . import notification_views
from . import backup_views

app_name = 'utils'

urlpatterns = [
    path('maintenance/', views.maintenance, name='maintenance'),
    path('settings/', views.settings, name='settings'),
    path('settings/update/', views.update_setting, name='update_setting'),
    path('settings/default-permission/', views.update_default_permission, name='update_default_permission'),
    path('backup/', backup_views.backup_system, name='backup_system'),
    path('backup/download/<str:filename>/', backup_views.download_backup, name='download_backup'),
    path('notifications/', views.notifications, name='notifications'),
    path('documents/', views.documents, name='documents'),
    path('documents/all-customers/', views.all_customer_documents, name='all_customer_documents'),
    path('documents/share/', views.share_document, name='share_document'),
    path('documents/preview/<str:document_id>/', views.get_document_preview, name='document_preview'),
    path('documents/tags/', views.get_document_tags, name='document_tags'),
    path('documents/<str:document_id>/tags/', views.add_document_tags, name='add_document_tags'),
    path('documents/<str:document_id>/tags/<int:tag_id>/', views.remove_document_tag, name='remove_document_tag'),
    path('documents/bulk-download/', views.bulk_download_documents, name='bulk_download_documents'),
    path('documents/<str:document_type>/', views.get_document, name='get_document'),
    path('documents/<str:document_id>/delete/', views.delete_document, name='delete_document'),
    path('api/notifications/', views.get_notifications, name='get_notifications'),
    path('api/notifications/new/', views.get_new_notifications, name='get_new_notifications'),
    path('api/notifications/unread/', views.get_unread_count, name='get_unread_count'),
    path('api/notifications/<uuid:notification_id>/mark-read/', views.mark_notification_read, name='mark_notification_read'),
    path('api/notifications/mark-all-read/', views.mark_all_notifications_read, name='mark_all_notifications_read'),
    path('api/notifications/stats/', views.get_notification_stats, name='get_notification_stats'),
    path('api/recent-activity/', views.get_recent_activity, name='get_recent_activity'),
    path('api/client/<uuid:client_id>/loan-history/', views.client_loan_history, name='client_loan_history'),
    path('api/client/<uuid:client_id>/credit-score/', views.client_credit_score, name='client_credit_score'),
    path('credit-scores/', views.credit_scores_management, name='credit_scores_management'),
    
    # Enhanced Notification System URLs
    path('notifications/preferences/', notification_views.notification_preferences, name='notification_preferences'),
    path('notifications/rules/', notification_views.notification_rules, name='notification_rules'),
    path('notifications/templates/', notification_views.notification_templates, name='notification_templates'),
    path('notifications/analytics/', notification_views.notification_analytics, name='notification_analytics'),
    path('notifications/escalations/', notification_views.notification_escalations, name='notification_escalations'),
    path('notifications/batch/', notification_views.notification_batch_management, name='notification_batch_management'),
    path('notifications/test-routing/', notification_views.test_notification_routing, name='test_notification_routing'),
    
    # Receipt URLs
    path('receipts/', views.receipts_list, name='receipts_list'),
    path('receipt/<uuid:receipt_id>/', views.view_receipt, name='receipt_detail'),
    path('receipt/<uuid:receipt_id>/download/', views.download_receipt, name='download_receipt'),
    path('receipt/<uuid:receipt_id>/view/', views.view_receipt, name='view_receipt'),
    path('receipt/<uuid:receipt_id>/print/', views.view_receipt, name='receipt_print'),
    path('receipt/<uuid:receipt_id>/edit/', views.edit_receipt, name='edit_receipt'),
    path('receipt/<uuid:receipt_id>/delete/', views.delete_receipt, name='delete_receipt'),
    path('loan/<uuid:loan_id>/generate-receipt/', views.generate_receipt, name='generate_receipt'),
    path('receipts/bulk-generate/', views.bulk_generate_receipts, name='bulk_generate_receipts'),
    # Enhanced Reports and Statements URLs (moved to different path to avoid conflict)
    path('report-generator/', views.reports_dashboard, name='utils_reports_dashboard'),
    path('report-generator/generate/', views.generate_report_api, name='generate_report_api'),
    path('report-generator/download/<str:report_type>/<str:format_type>/', views.download_report, name='download_report'),
    
    # Individual Statement URLs
    path('loan/<uuid:loan_id>/statement/', views.loan_statement_view, name='loan_statement_view'),
    path('client/<uuid:client_id>/statement/', views.client_statement_view, name='client_statement_view'),
    
    # Legacy Loan Statement URLs (for backward compatibility)
    path('loan/<uuid:loan_id>/statement/download/', views.download_loan_statement, name='download_loan_statement'),
    path('loan/<uuid:loan_id>/statement/view/', views.view_loan_statement, name='view_loan_statement'),
    path('test-media/', views.simple_media_test, name='test_media_access'),
    path('test-media-serving/', views.test_media_serving, name='test_media_serving'),
]