191 lines
4.1 KiB
PHP
191 lines
4.1 KiB
PHP
<?php
|
|
require_once('config.php');
|
|
require_once('lib/DAO.class.php');
|
|
require_once('lib/crowdfunding/Crowdfunding.class.php');
|
|
require_once('lib/crowdfunding/Chart.class.php');
|
|
require_once('lib/crowdfunding/Graph.class.php');
|
|
|
|
if (!isValidPubkey($_GET['pubkey'])) {
|
|
|
|
die('Clef publique invalide');
|
|
include('footer.php');
|
|
}
|
|
|
|
$creatorPubkey = $_GET['pubkey'];
|
|
|
|
$CF = new Crowdfunding($creatorPubkey,
|
|
'relative');
|
|
|
|
$dao = DAO::getInstance();
|
|
|
|
|
|
$json = $dao->fetchJson('/user/profile/' . $creatorPubkey, 'cesiumplus');
|
|
$data = json_decode($json);
|
|
|
|
include('header.php');
|
|
|
|
echo '<h1>' . htmlspecialchars($data->_source->title) . '</h1>';
|
|
|
|
|
|
if (isset($data->_source->avatar)) {
|
|
|
|
echo '
|
|
<p class="avatar">
|
|
<img src="data:'. $data->_source->avatar->_content_type . ';base64, '. $data->_source->avatar->_content . '" />
|
|
</p>';
|
|
}
|
|
|
|
$fourMonthsAgo = (new DateTime())->sub(new DateInterval('P4M'));
|
|
$lastMonth = (new DateTime())->sub(new DateInterval('P1M'));
|
|
$threeMonths = new Crowdfunding($creatorPubkey,
|
|
'relative',
|
|
$fourMonthsAgo->format('Y-m-') . '01',
|
|
$lastMonth->format('Y-m-t'));
|
|
|
|
echo '<p>' . round($threeMonths->getAmountCollected()/3) . ' DU<sub>G1</sub> collectés par mois</p>';
|
|
|
|
echo '<p>' . $threeMonths->getDonorsNb() . ' donateurs</p>';
|
|
|
|
echo '<p><a href="g1://pubkey:'. $creatorPubkey . '">Faire un don</a></p>';
|
|
|
|
echo '
|
|
<div class="CTA">
|
|
|
|
<p class="pubkey-and-copy-button">
|
|
<input id="pubkey" type="text" value="'. $creatorPubkey. '" readonly />
|
|
<button id="copy">
|
|
Copier la clef
|
|
</button>
|
|
</p>
|
|
|
|
<div id="successMsg">
|
|
<p>Et maintenant collez-la dans votre client Ğ1 (Cesium par exemple) afin de faire votre don 😉</p>
|
|
<p class="politesse">Merci pour votre générosité ❤️</p>
|
|
</div>
|
|
</div>';
|
|
?>
|
|
|
|
|
|
|
|
<h2>Que soutenez-vous ?</h2>
|
|
|
|
<?php
|
|
|
|
echo '
|
|
<p>
|
|
'. nl2br(htmlspecialchars($data->_source->description)) .'
|
|
</p>';
|
|
|
|
|
|
|
|
|
|
echo '
|
|
<h2>Ils soutiennent ' . htmlspecialchars($data->_source->title) . '</h2>';
|
|
|
|
$donors = $threeMonths->getDonors();
|
|
|
|
|
|
if (empty($donors)) {
|
|
|
|
echo _('Pas encore de donnateur.');
|
|
|
|
} else {
|
|
|
|
echo '
|
|
<ul class="donorsList">';
|
|
|
|
foreach ($donors as $donor) {
|
|
|
|
$donorProfile = $threeMonths->getDonorCesiumPlusProfile($donor);
|
|
|
|
echo '
|
|
|
|
<li>';
|
|
echo '
|
|
<a href="https://demo.cesium.app/#/app/wot/'. $donor .'/">';
|
|
|
|
$avatar = $donorProfile->getAvatar();
|
|
|
|
echo '
|
|
<span class="avatar">';
|
|
|
|
if (!empty($avatar)) {
|
|
|
|
echo '<img src="data:'. $avatar->getContentType(). ';base64, '. $avatar->getContent() .'" />';
|
|
|
|
} else {
|
|
|
|
echo '<img class="default" src="'. DEFAULT_AVATAR .'" />';
|
|
}
|
|
|
|
echo '
|
|
|
|
</span>';
|
|
|
|
|
|
echo '
|
|
<span class="name">
|
|
<span>
|
|
'. $donorProfile->getName() .'
|
|
</span>
|
|
</span>
|
|
</a>
|
|
|
|
</li>';
|
|
}
|
|
|
|
echo '</ul>';
|
|
}
|
|
?>
|
|
|
|
|
|
<!--
|
|
<h2>État actuel des finances</h2>
|
|
|
|
<figure id="chart"></figure>
|
|
-->
|
|
|
|
<?php
|
|
|
|
$CF->setTarget(1000);
|
|
$chart = new Chart($CF);
|
|
|
|
$amountCumulativeGraph = new Graph($chart->getAmountCollectedByDayCumulativePoints(), _('Montant total récolté'));
|
|
$amountCumulativeGraph->setStyle('type', 'line');
|
|
$amountCumulativeGraph->setStyle('borderColor', '#662b00');
|
|
$amountCumulativeGraph->setStyle('backgroundColor', 'green');
|
|
$amountCumulativeGraph->setStyle('lineTension', 0);
|
|
$amountCumulativeGraph->setStyle('pointRadius', 1);
|
|
$amountCumulativeGraph->setStyle('borderWidth', 2);
|
|
$amountCumulativeGraph->setStyle('steppedLine', true);
|
|
$chart->addGraph($amountCumulativeGraph);
|
|
|
|
$footerScripts = '';
|
|
|
|
$footerScripts .= $chart->getScripts('fr', '#chart', ROOT_URL . 'lib/crowdfunding/');
|
|
|
|
$footerScripts .= '
|
|
<script>
|
|
function copy() {
|
|
|
|
var copyText = document.querySelector("input#pubkey");
|
|
copyText.select();
|
|
document.execCommand("copy");
|
|
|
|
var successMsg = document.querySelector("#successMsg");
|
|
successMsg.style.opacity = "1";
|
|
/*successMsg.style.height = "3em";*/
|
|
|
|
var copyButton = document.querySelector("button#copy");
|
|
copyButton.style.animation = "none";
|
|
|
|
}
|
|
|
|
|
|
document.querySelector("button#copy").addEventListener("click", copy);
|
|
</script>';
|
|
|
|
include('footer.php');
|
|
|
|
|