Initial commit
This commit is contained in:
commit
7825abf11c
13 files changed
+672
No files matched your search
@@ -0,0 +1,76 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Ramtops Remedies and Reagents</title>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<!-- UIkit CSS -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-beta.35/css/uikit.min.css" />
|
||||
|
||||
<!-- UIkit JS -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-beta.35/js/uikit.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/3.0.0-beta.35/js/uikit-icons.min.js"></script>
|
||||
|
||||
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
||||
<style>
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="uk-container uk-container-large">
|
||||
<!-- Title -->
|
||||
<h3 class="uk-text-center uk-heading-line uk-margin-small-top">
|
||||
<a href="/" class="">Ramtops Remedies and Reagents</a>
|
||||
</h3>
|
||||
|
||||
<!-- Top Bar -->
|
||||
<div class="" uk-grid>
|
||||
<div class="uk-width-1-3"> {% block left_top_bar %} {% endblock %} </div>
|
||||
<div class="uk-width-1-3 uk-text-center"> {% block center_top_bar %} {% endblock %} </div>
|
||||
<div class="uk-width-1-3">
|
||||
<a href="/shop/data" class="uk-button uk-button-primary uk-button-small uk-align-right uk-border-rounded">
|
||||
Report Stock
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Page Content -->
|
||||
{% block content %} {% endblock %}
|
||||
|
||||
<!-- Footer -->
|
||||
<footer class="uk-text-center uk-margin-large-top uk-margin-small-bottom">
|
||||
© 2017 by <a href="http://binaryatrocity.name">Ruhsbaar</a>
|
||||
|
|
||||
Created for Ramtops Remedies and Reagents
|
||||
|
|
||||
<a href="http://discworld.starturtle.net">DiscworldMUD</a>
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
{% block pagescripts %} {% endblock %}
|
||||
<script>
|
||||
function change_date_strings() {
|
||||
var times = document.querySelectorAll('table > tbody > tr > td:last-child');
|
||||
for(var time of times) {
|
||||
var local = new Date(time.textContent + 'Z');
|
||||
|
||||
var options = {
|
||||
weekday: 'short',
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
hour: 'numeric',
|
||||
minute: 'numeric',
|
||||
timeZoneName: 'short'
|
||||
};
|
||||
time.innerText = local.toLocaleString('en-US', options);
|
||||
}
|
||||
}
|
||||
|
||||
/* On Page Ready */
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
change_date_strings();
|
||||
});
|
||||
</script>
|
||||
</html>
|
||||
@@ -0,0 +1,205 @@
|
||||
{% extends "layout.html" %}
|
||||
|
||||
{% block left_top_bar %}
|
||||
<button class="uk-button uk-button-default uk-button-small uk-border-rounded"
|
||||
uk-toggle="target: #charts-container">Show/Hide Charts</button>
|
||||
{% endblock %}
|
||||
|
||||
{% block center_top_bar %}
|
||||
Total Funds Earned:
|
||||
<span id="total_funds_earned" class="uk-text-primary"></span>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div id="charts-container" uk-grid hidden>
|
||||
<div class="uk-width-1-2">
|
||||
<canvas id="sales-chart"></canvas>
|
||||
</div>
|
||||
<div class="uk-width-1-2">
|
||||
<canvas id="stock-chart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<table id="products" class="uk-table uk-table-small uk-table-striped uk-table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="uk-table-expand">Product Name</th>
|
||||
<th>Current Stock</th>
|
||||
<th>Total Stock</th>
|
||||
<th>Total Sold</th>
|
||||
<th>Total Earned</th>
|
||||
<th>Latest Price</th>
|
||||
<th>Last Update</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for product in products %}
|
||||
{% if product.latest_entry != None %}
|
||||
<tr>
|
||||
<td class="uk-table-link">
|
||||
<a href="/shop/product/{{ product.id }}">
|
||||
{{ product.name }}
|
||||
</a>
|
||||
</td>
|
||||
<td>{{ product.latest_entry.stock }}</td>
|
||||
<td>{{ product.total_stocked }}</td>
|
||||
<td>{{ product.total_sold }}</td>
|
||||
<td>A${{ product.total_earned }}</td>
|
||||
<td>
|
||||
<span title="{{ product.latest_entry.raw_price}}">
|
||||
A${{ product.latest_entry.price }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="uk-text-nowrap">{{ product.latest_entry.date.isoformat() }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock %}
|
||||
|
||||
{% block pagescripts %}
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.1/Chart.js"></script>
|
||||
<script>
|
||||
function highlight_empty_stock() {
|
||||
var rows = document.querySelectorAll('table#products > tbody > tr > td:nth-child(2)');
|
||||
for(var row of rows) {
|
||||
if(parseInt(row.textContent) == 0) {
|
||||
row.parentElement.classList.add('uk-text-danger');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function calculate_total_earnings() {
|
||||
var total_earnings = 0.00;
|
||||
var earnings = document.querySelectorAll('table#products > tbody > tr > td:nth-child(5)');
|
||||
for(var earning of earnings) {
|
||||
total_earnings += parseFloat(earning.textContent.substring(2))
|
||||
}
|
||||
document.getElementById('total_funds_earned').textContent = "A$" + total_earnings.toFixed(2);
|
||||
}
|
||||
|
||||
/* Chart.js */
|
||||
var item_labels = [
|
||||
{% for product in products %}
|
||||
"{{ product.name }}",
|
||||
{% endfor %}
|
||||
];
|
||||
var sale_data = [
|
||||
{% for product in products %}
|
||||
{{ product.total_sold }},
|
||||
{% endfor %}
|
||||
];
|
||||
var earnings_data = [
|
||||
{% for product in products %}
|
||||
{{ product.total_earned }},
|
||||
{% endfor %}
|
||||
];
|
||||
var total_stock_data = [
|
||||
{% for product in products %}
|
||||
{{ product.total_stocked }},
|
||||
{% endfor %}
|
||||
];
|
||||
var current_stock_data = [
|
||||
{% for product in products %}
|
||||
{{ product.latest_entry.stock }},
|
||||
{% endfor %}
|
||||
];
|
||||
|
||||
function init_sales_chart(labels, sold_data, earned_data) {
|
||||
var ctx = document.getElementById("sales-chart").getContext('2d');
|
||||
var chart = new Chart(ctx, {
|
||||
type: 'horizontalBar',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [
|
||||
{
|
||||
label: 'Sold',
|
||||
backgroundColor: 'rgb(93, 173, 226)',
|
||||
borderColor: 'rgb(89, 131, 227)',
|
||||
data: sold_data,
|
||||
xAxisID: 'quantity'
|
||||
},
|
||||
{
|
||||
label: 'Earned',
|
||||
backgroundColor: 'rgb(173, 93, 226)',
|
||||
borderColor: 'rgb(131, 89, 227)',
|
||||
data: earned_data,
|
||||
xAxisID: 'currency'
|
||||
}
|
||||
],
|
||||
},
|
||||
options: {
|
||||
elements: { rectangle: { borderWidth: 2, } },
|
||||
responsive: true,
|
||||
legend: { position: 'bottom', },
|
||||
title: { display: true, text: 'Sales & Earnings'},
|
||||
scales: {
|
||||
xAxes: [
|
||||
{
|
||||
id: 'quantity',
|
||||
type: 'linear',
|
||||
position: 'top'
|
||||
},
|
||||
{
|
||||
id: 'currency',
|
||||
type: 'linear',
|
||||
position: 'bottom'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function init_stock_chart(labels, total_data, current_data) {
|
||||
var ctx = document.getElementById("stock-chart").getContext('2d');
|
||||
var chart = new Chart(ctx, {
|
||||
type: 'horizontalBar',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [
|
||||
{
|
||||
label: 'Total',
|
||||
backgroundColor: 'rgb(54, 84, 126)',
|
||||
data: total_data,
|
||||
xAxisID: 'quantity'
|
||||
},
|
||||
{
|
||||
label: 'Current',
|
||||
backgroundColor: 'rgb(73, 133, 226)',
|
||||
data: current_data,
|
||||
xAxisID: 'big_quantity'
|
||||
}
|
||||
],
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
legend: { position: 'bottom', },
|
||||
title: { display: true, text: 'Total/Current Stock'},
|
||||
scales: {
|
||||
xAxes: [
|
||||
{
|
||||
id: 'quantity',
|
||||
type: 'linear',
|
||||
position: 'top'
|
||||
},
|
||||
{
|
||||
id: 'big_quantity',
|
||||
type: 'linear',
|
||||
position: 'bottom'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* On Page Ready */
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
highlight_empty_stock();
|
||||
calculate_total_earnings();
|
||||
init_sales_chart(item_labels, sale_data, earnings_data);
|
||||
init_stock_chart(item_labels, total_stock_data, current_stock_data);
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,17 @@
|
||||
{% extends "layout.html" %}
|
||||
{% block content %}
|
||||
<form id="mission-form" action="{{ url_for('shop_dataentry') }}" method="post"
|
||||
class="uk-margin-large-left">
|
||||
<label for="mission-data">Enter shops "Mission Item" output:</label> <br/>
|
||||
<textarea class="uk-textarea uk-form-small uk-form-width-large uk-margin-medium-bottom"
|
||||
autofocus=true rows=15 name="mission-data"></textarea>
|
||||
|
||||
<br/>
|
||||
<label for="password">Password</label>
|
||||
<input type="password" name="password"
|
||||
class="uk-input uk-form-small uk-form-width-small uk-margin-medium-left"/>
|
||||
<br/>
|
||||
<input type="submit" value="Parse Entries"
|
||||
class="uk-button uk-button-primary uk-margin-small-top uk-border-rounded"/>
|
||||
</form>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,119 @@
|
||||
{% extends "layout.html" %}
|
||||
|
||||
{% block left_top_bar %}
|
||||
<button class="uk-button uk-button-default uk-button-small uk-border-rounded"
|
||||
uk-toggle="target: #charts-container">Show/Hide Charts</button>
|
||||
{% endblock %}
|
||||
|
||||
{% block center_top_bar %}
|
||||
<h4 class="uk-text-center">{{ product.name }}</h4>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div id="charts-container" uk-grid hidden>
|
||||
<div class="uk-width-1-1">
|
||||
<canvas id="time-chart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<table id="products" class="uk-table uk-table-small uk-table-striped uk-table-hover uk-margin-large-left">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Stock</th>
|
||||
<th>Price (Raw)</th>
|
||||
<th>Price (Cvt)</th>
|
||||
<th>Update</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for entry in product.entries %}
|
||||
<tr>
|
||||
<td>{{ entry.stock }}</td>
|
||||
<td>{{ entry.raw_price }}</td>
|
||||
<td>A${{ entry.price }}</td>
|
||||
<td>{{ entry.date.isoformat() }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<caption class="uk-margin-small-bottom">{{ product.entries | length }} total entries.</caption>
|
||||
</table>
|
||||
{% endblock %}
|
||||
|
||||
{% block pagescripts %}
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.19.3/moment.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.1/Chart.js"></script>
|
||||
<script>
|
||||
/* Chart.js */
|
||||
var item_labels = [
|
||||
"{{ product.name }}",
|
||||
];
|
||||
var time_data = [
|
||||
{% for entry in product.entries %}
|
||||
{x: "{{ entry.date.isoformat() }}", y: {{ entry.stock }}},
|
||||
{% endfor %}
|
||||
];
|
||||
|
||||
function init_time_chart(labels, timedata) {
|
||||
var ctx = document.getElementById("time-chart").getContext('2d');
|
||||
var chart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [
|
||||
{
|
||||
label: 'Entries',
|
||||
backgroundColor: 'rgb(93, 173, 226)',
|
||||
borderColor: 'rgb(89, 131, 227)',
|
||||
fill: false,
|
||||
data: timedata,
|
||||
}
|
||||
],
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
title: { display: true, text: 'Entries'},
|
||||
scales: {
|
||||
xAxes: [
|
||||
{
|
||||
type: 'time',
|
||||
distribution: 'series',
|
||||
display: true,
|
||||
scaleLabel: {
|
||||
display: true,
|
||||
labelString: 'Date'
|
||||
},
|
||||
time: {
|
||||
unit: 'day',
|
||||
unitStepSize: 1,
|
||||
displayFormats: {
|
||||
day: 'MMM D YYYY h:mm a'
|
||||
}
|
||||
},
|
||||
ticks: {
|
||||
major: {
|
||||
fontStyle: "bold",
|
||||
fontColor: "#FF0000"
|
||||
},
|
||||
source: 'data'
|
||||
}
|
||||
}
|
||||
],
|
||||
yAxes: [
|
||||
{
|
||||
display: true,
|
||||
scaleLabel: {
|
||||
display: true,
|
||||
labelString: 'Stock'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* On Page Ready */
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
init_time_chart(item_labels, time_data);
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in new issue
Block a user