mirror of
https://github.com/itflow-org/itflow
synced 2026-08-26 17:35:16 +00:00
Add Fake Demo Data Seed stretching over 2 year span
This commit is contained in:
2402
admin/post/demo_data_model.php
Normal file
2402
admin/post/demo_data_model.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -45,3 +45,49 @@ if (isset($_POST['load_starter_content'])) {
|
||||
redirect();
|
||||
|
||||
}
|
||||
|
||||
if (isset($_POST['load_demo_data'])) {
|
||||
|
||||
validateCSRFToken();
|
||||
|
||||
require_once 'demo_data_model.php';
|
||||
|
||||
$counts = demoDataLoad($mysqli);
|
||||
|
||||
if (!$counts['clients']) {
|
||||
flashAlert("Nothing to add - every demo client is already here", 'info');
|
||||
redirect();
|
||||
}
|
||||
|
||||
$summary = "{$counts['clients']} clients, {$counts['contacts']} contacts, {$counts['assets']} assets, {$counts['documentation']} documentation records, {$counts['tickets']} tickets, {$counts['projects']} projects, {$counts['billing']} billing records, {$counts['company']} company financial records";
|
||||
|
||||
logAudit("Demo Data", "Create", "$session_name loaded demo data - $summary");
|
||||
|
||||
if ($counts['skipped_credentials']) {
|
||||
flashAlert("Added demo data: $summary. Credentials were skipped - the credential vault did not open for this session", 'warning');
|
||||
} else {
|
||||
flashAlert("Added demo data: $summary");
|
||||
}
|
||||
|
||||
redirect();
|
||||
|
||||
}
|
||||
|
||||
if (isset($_POST['remove_demo_data'])) {
|
||||
|
||||
validateCSRFToken();
|
||||
|
||||
require_once 'demo_data_model.php';
|
||||
|
||||
$clients_removed = demoDataRemove($mysqli);
|
||||
|
||||
if ($clients_removed) {
|
||||
logAudit("Demo Data", "Deleted", "$session_name removed demo data - $clients_removed demo clients and all associated records");
|
||||
flashAlert("Removed <strong>$clients_removed</strong> demo clients and everything associated with them", 'error');
|
||||
} else {
|
||||
flashAlert("No demo clients found - nothing to remove", 'info');
|
||||
}
|
||||
|
||||
redirect();
|
||||
|
||||
}
|
||||
|
||||
@@ -4,10 +4,14 @@ require_once "includes/inc_all_admin.php";
|
||||
|
||||
define('FROM_STARTER_CONTENT', true);
|
||||
require_once "post/starter_content_model.php";
|
||||
require_once "post/demo_data_model.php";
|
||||
|
||||
$starter_content_packs = starterContentPacks();
|
||||
$starter_content_status = starterContentStatus($mysqli);
|
||||
|
||||
$demo_data_status = demoDataStatus($mysqli);
|
||||
$demo_data_loaded = count($demo_data_status['loaded']);
|
||||
|
||||
$total_missing = 0;
|
||||
foreach ($starter_content_status as $pack_status) {
|
||||
$total_missing = $total_missing + $pack_status['missing'];
|
||||
@@ -106,4 +110,79 @@ foreach ($starter_content_status as $pack_status) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card card-dark mt-3">
|
||||
<div class="card-header py-3">
|
||||
<h3 class="card-title"><i class="fas fa-fw fa-flask me-2"></i>Demo Data</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
||||
<p>
|
||||
A fictional book of business for demos, training and screenshots - <?= intval($demo_data_status['total']) ?> clients
|
||||
with the people, equipment, documentation, tickets and billing a typical MSP would be carrying for them, plus the
|
||||
bank accounts, operating costs and transfers on your own side of the books.
|
||||
It is generated across the <strong>last two years</strong> and dated relative to today, so the dashboard, ticket
|
||||
queue, aging, profit and loss and every other report have real history behind them rather than a single flat month.
|
||||
</p>
|
||||
<p class="text-muted">
|
||||
This is sample data, not configuration. Every demo client carries the <strong>Demo Data</strong> client tag and
|
||||
everything created hangs off one of them, so removing it takes the whole lot back out again. Contacts use
|
||||
addresses on the reserved <strong>.example</strong> domain, which cannot receive mail, and the demo
|
||||
agreements are created with email notification switched off.
|
||||
</p>
|
||||
|
||||
<?php if ($demo_data_status['other_clients'] && !$demo_data_loaded) { ?>
|
||||
<div class="alert alert-warning">
|
||||
<i class="fas fa-fw fa-exclamation-triangle me-2"></i>
|
||||
This install already has <strong><?= intval($demo_data_status['other_clients']) ?></strong> client(s) of its own.
|
||||
Demo data is meant for a demo or training install - it will sit alongside your real clients in every list, report and total until it is removed.
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (!$demo_data_loaded) { ?>
|
||||
|
||||
<?php if (!empty($starter_content_status['categories']['missing']) || !empty($starter_content_status['tags']['missing'])) { ?>
|
||||
<p class="text-warning">
|
||||
<i class="fas fa-fw fa-exclamation-triangle me-1"></i>Add the Categories and Tags packs above first, or the demo tickets, invoices and tags come in bare.
|
||||
</p>
|
||||
<?php } ?>
|
||||
|
||||
<form action="post.php" method="POST" autocomplete="off">
|
||||
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
||||
<button type="submit" name="load_demo_data" value="1" class="btn btn-primary">
|
||||
<i class="fas fa-fw fa-flask me-2"></i>Add demo data
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<?php } else { ?>
|
||||
|
||||
<p>
|
||||
<strong><?= intval($demo_data_loaded) ?></strong> demo client(s) are here:
|
||||
<?= escapeHtml(implode(', ', $demo_data_status['loaded'])) ?>
|
||||
</p>
|
||||
|
||||
<div class="d-flex gap-2">
|
||||
|
||||
<form action="post.php" method="POST" autocomplete="off" onsubmit="return confirm('Delete every client tagged Demo Data, along with all of their contacts, assets, documentation, credentials, tickets, quotes, invoices and payments? This cannot be undone.');">
|
||||
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
||||
<button type="submit" name="remove_demo_data" value="1" class="btn btn-danger">
|
||||
<i class="fas fa-fw fa-trash me-2"></i>Remove demo data
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<?php if ($demo_data_loaded < $demo_data_status['total']) { ?>
|
||||
<form action="post.php" method="POST" autocomplete="off">
|
||||
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
||||
<button type="submit" name="load_demo_data" value="1" class="btn btn-primary">
|
||||
<i class="fas fa-fw fa-plus me-2"></i>Add the missing <?= intval($demo_data_status['total'] - $demo_data_loaded) ?>
|
||||
</button>
|
||||
</form>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require_once "../includes/footer.php"; ?>
|
||||
|
||||
Reference in New Issue
Block a user