2025-08-12 13:33:25 +03:00

197 lines
11 KiB
HTML

{% extends 'base.html' %}
{% load static %}
{% block title %}Execute Report - Analytics{% endblock %}
{% block css %}
<link href="{% static 'plugins/datatables.net-bs5/css/dataTables.bootstrap5.min.css' %}" rel="stylesheet" />
{% endblock %}
{% block content %}
<div id="content" class="app-content">
<div class="container">
<div class="row justify-content-center">
<div class="col-xl-10">
<div class="row">
<div class="col-xl-9">
<ul class="breadcrumb">
<li class="breadcrumb-item"><a href="{% url 'core:dashboard' %}">Dashboard</a></li>
<li class="breadcrumb-item"><a href="{% url 'analytics:report_list' %}">Reports</a></li>
<li class="breadcrumb-item active">Execute Report</li>
</ul>
<h1 class="page-header">Execute Report</h1>
<div class="card">
<div class="card-header">
<h4 class="card-title">Report Execution</h4>
</div>
<div class="card-body">
{% if messages %}
{% for message in messages %}
<div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
{{ message }}
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
{% endfor %}
{% endif %}
<form method="post" class="form-horizontal">
{% csrf_token %}
<div class="row mb-3">
<label class="col-form-label col-md-3">Report</label>
<div class="col-md-9">
<select name="report_id" class="form-select" required>
<option value="">Select Report</option>
{% for report in reports %}
<option value="{{ report.id }}">{{ report.name }} - {{ report.category }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="row mb-3">
<label class="col-form-label col-md-3">Date Range</label>
<div class="col-md-4">
<input type="date" name="start_date" class="form-control" required>
<small class="form-text text-muted">Start Date</small>
</div>
<div class="col-md-4">
<input type="date" name="end_date" class="form-control" required>
<small class="form-text text-muted">End Date</small>
</div>
</div>
<div class="row mb-3">
<label class="col-form-label col-md-3">Output Format</label>
<div class="col-md-9">
<select name="output_format" class="form-select">
<option value="html">HTML (View in Browser)</option>
<option value="pdf">PDF Download</option>
<option value="excel">Excel Download</option>
<option value="csv">CSV Download</option>
</select>
</div>
</div>
<div class="row mb-3">
<label class="col-form-label col-md-3">Parameters</label>
<div class="col-md-9">
<textarea name="parameters" class="form-control" rows="3" placeholder="Enter report parameters as JSON (optional)">{"department": "all", "status": "active"}</textarea>
<small class="form-text text-muted">Optional parameters in JSON format</small>
</div>
</div>
<div class="row">
<div class="col-md-9 offset-md-3">
<button type="submit" class="btn btn-primary">
<i class="fa fa-play me-2"></i>Execute Report
</button>
<a href="{% url 'analytics:report_list' %}" class="btn btn-secondary ms-2">Cancel</a>
</div>
</div>
</form>
</div>
</div>
{% if execution_result %}
<div class="card mt-4">
<div class="card-header">
<h4 class="card-title">Execution Results</h4>
</div>
<div class="card-body">
<div class="row mb-3">
<div class="col-md-3"><strong>Status:</strong></div>
<div class="col-md-9">
{% if execution_result.success %}
<span class="badge bg-success">Completed</span>
{% else %}
<span class="badge bg-danger">Failed</span>
{% endif %}
</div>
</div>
<div class="row mb-3">
<div class="col-md-3"><strong>Execution Time:</strong></div>
<div class="col-md-9">{{ execution_result.execution_time }}s</div>
</div>
<div class="row mb-3">
<div class="col-md-3"><strong>Records:</strong></div>
<div class="col-md-9">{{ execution_result.record_count|default:"N/A" }}</div>
</div>
{% if execution_result.download_url %}
<div class="row mb-3">
<div class="col-md-3"><strong>Download:</strong></div>
<div class="col-md-9">
<a href="{{ execution_result.download_url }}" class="btn btn-sm btn-outline-primary">
<i class="fa fa-download me-2"></i>Download Report
</a>
</div>
</div>
{% endif %}
{% if execution_result.preview_data %}
<div class="row">
<div class="col-12">
<h6>Preview Data:</h6>
<div class="table-responsive">
<table class="table table-striped table-sm">
<thead>
<tr>
{% for header in execution_result.headers %}
<th>{{ header }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for row in execution_result.preview_data %}
<tr>
{% for cell in row %}
<td>{{ cell }}</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endif %}
</div>
</div>
{% endif %}
</div>
<div class="col-xl-3">
<div class="card">
<div class="card-header">
<h4 class="card-title">Quick Actions</h4>
</div>
<div class="card-body">
<div class="d-grid gap-2">
<a href="{% url 'analytics:report_list' %}" class="btn btn-outline-primary btn-sm">
<i class="fa fa-list me-2"></i>All Reports
</a>
<a href="{% url 'analytics:report_create' %}" class="btn btn-outline-success btn-sm">
<i class="fa fa-plus me-2"></i>Create Report
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block js %}
<script src="{% static 'plugins/datatables.net/js/dataTables.min.js' %}"></script>
<script src="{% static 'plugins/datatables.net-bs5/js/dataTables.bootstrap5.min.js' %}"></script>
{% endblock %}