mirror of https://github.com/IoTcat/cp-acc.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
853 lines
30 KiB
853 lines
30 KiB
<!DOCTYPE html> |
|
<html lang="en"> |
|
|
|
<head> |
|
<meta charset="UTF-8"> |
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0"> |
|
<title>CP Accountant</title> |
|
|
|
<!-- Google font file. If you want you can change. --> |
|
<link href="https://fonts.googleapis.com/css?family=Nunito:300,400,600,700,900" rel="stylesheet"> |
|
|
|
<!-- Fontawesome font file css --> |
|
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css"> |
|
|
|
<!-- Animate css file for css3 animations. for more : https://daneden.github.io/animate.css --> |
|
<!-- Only use animate action. If you dont use animation, you don't have to add.--> |
|
<link rel="stylesheet" type="text/css" href="https://cdn.yimian.xyz/smart-settlement/css/animate.css"> |
|
<link rel="stylesheet" type="text/css" href="https://cdn.yimian.xyz/smart-settlement/css/cryptocoins.css"> |
|
<link rel="stylesheet" type="text/css" href="https://cdn.yimian.xyz/smart-settlement/plugins/c3-chart/c3.css"> |
|
|
|
<!-- Template global css file. Requared all pages --> |
|
<link rel="stylesheet" type="text/css" href="https://cdn.yimian.xyz/smart-settlement/css/global.style.css"> |
|
|
|
<!-- Swiper slider css file --> |
|
<link rel="stylesheet" href="https://cdn.yimian.xyz/smart-settlement/css/swiper.min.css"> |
|
|
|
<!--turbo slider plugin css file --> |
|
<link rel="stylesheet" type="text/css" href="https://cdn.yimian.xyz/smart-settlement/css/bootstrap.min.css"> |
|
<link rel="stylesheet" type="text/css" href="https://cdn.yimian.xyz/smart-settlement/plugins/turbo-slider/turbo.css"> |
|
|
|
<link rel="stylesheet" type="text/css" href="https://cdn.yimian.xyz/shaky/shaky.css"> |
|
<script>var block_aplayer = true;lang = ['en'];</script> |
|
<script type="text/javascript" src="https://cdn.yimian.xyz/ushio-js/ushio-head.min.js"></script> |
|
<script>page.auth = ['email', 'nickname'];page.proj = 'iotcat/cp-acc';</script> |
|
</head> |
|
|
|
<body> |
|
|
|
<div class="wrapper "> |
|
<div class="nav-menu"> |
|
<nav class="menu"> |
|
|
|
<!-- Menu navigation start --> |
|
<div class="nav-container"> |
|
<ul class="main-menu"> |
|
<li class="active"> |
|
<a href="index.html" id="index"><img src="https://cdn.yimian.xyz/smart-settlement/img/content/icons/1.png" alt=""><strong class="special">Dashboard</strong> </a> |
|
</li> |
|
<li class=""> |
|
<a href="records.html" id="records"><img src="https://cdn.yimian.xyz/smart-settlement/img/content/icons/6.png" alt=""><strong class="special">History Payment</strong> </a> |
|
</li> |
|
<li class=""> |
|
<a href="#" id="setTable"><img src="img/content/icons/11.png" alt=""><strong>Group Setting</strong> </a> |
|
</li> |
|
<li class=""> |
|
<a href="#" id="checkout" data-loader="show"><img src="https://cdn.yimian.xyz/smart-settlement/img/content/icons/2.png" alt=""><strong>Checkout</strong></a> |
|
</li> |
|
<li class=""> |
|
<a href="#" id="switch"><img src="https://cdn.yimian.xyz/smart-settlement/img/content/icons/4.png" alt=""><strong>Other Groups</strong></a> |
|
</li> |
|
<li class=""> |
|
<a href="https://login.yimian.xyz/logout.html" data-loader="show"><img src="https://cdn.yimian.xyz/smart-settlement/img/content/icons/7.png" alt=""><strong>Log out</strong></a> |
|
</li> |
|
</ul> |
|
</div> |
|
<!-- Menu navigation end --> |
|
</nav> |
|
</div> |
|
<div class="wrapper-inline"> |
|
<!-- Header area start --> |
|
<header class="no-background"> <!-- extra class no-background --> |
|
|
|
<div class="search-button" data-search="open"> |
|
<img id="no-icon" src="https://cdn.yimian.xyz/smart-settlement/img/content/notification-no.png" class="not-icon1" alt=""> |
|
<img id="no-icon2" src="https://cdn.yimian.xyz/smart-settlement/img/content/notification2-no.png" class="not-icon2" alt=""> |
|
</div> |
|
|
|
<div class="navi-menu-button"> |
|
<em></em> |
|
<em></em> |
|
<em></em> |
|
</div> |
|
|
|
</header> |
|
<!-- Header area end --> |
|
|
|
<!--NOTIFICATION BOX CONTENT START--> |
|
<div class="search-form"> |
|
<span class="close-search-form" data-search="close"><i class="fa fa-times"></i> </span> |
|
<form> |
|
<div class="search-input"> |
|
<br/> |
|
</div> |
|
</form> |
|
<ul class="notification-list list-unstyled" id="no-content"> |
|
</ul> |
|
</div> |
|
<!--NOTIFICATION BOX CONTENT END--> |
|
|
|
<!-- Page content start --> |
|
<main class="margin mt-0"> |
|
|
|
<div class="dash-balance"> |
|
<div class="dash-content relative"> |
|
<h3 class="w-text" id="title"></h3> |
|
<div class="notification"> |
|
<h3 class="w-text" id="usr">xxx</h3> |
|
</div> |
|
</div> |
|
</div> |
|
|
|
<div id="body"> |
|
|
|
<section class="bal-section container"> |
|
<div class="balance-card mb-15"> |
|
<div class="d-flex align-items-center"> |
|
<div class="d-flex flex-grow"> |
|
<div class="mr-auto"> |
|
<h1 class="b-val"> £<span id="week-avg"></span> </h1> |
|
<p class="g-text mb-10">Average Daily Payment</p> |
|
<div class="badge badge-pill" id="week-avg-rate"> 43.55% <i style="color:red;" class="fa fa-arrow-down ml-10"></i></div> |
|
</div> |
|
<div class="ml-auto align-self-end"> |
|
<div id="sparkline1"></div> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
<div class="resources-card-wrapper"> |
|
<div class="resources-card mr-10"> |
|
<div class="d-flex flex-column flex-md-row"> |
|
<i class="fa fa-shield text-primary"></i> |
|
<div class="d-flex flex-column ml-md-2"> |
|
<p class="text-muted mb-10 font-weight-medium">Total Payment</p> |
|
<div class="progress"> |
|
<div class="progress-bar bg-primary" id="total-bar" role="progressbar" style="width: 97%"></div> |
|
</div> |
|
<h4 class="mt-10 mb-0">£<span id="total"></span> </h4> |
|
</div> |
|
</div> |
|
</div> |
|
<div class="resources-card ml-10"> |
|
<div class="d-flex flex-column flex-md-row"> |
|
<i class="fa fa fa-shopping-cart txt-green"></i> |
|
<div class="d-flex flex-column ml-md-2"> |
|
<p class="text-muted mb-10 font-weight-medium">Your Payment</p> |
|
<div class="progress"> |
|
<div class="progress-bar bg-success" id="total-usr-bar" role="progressbar" style="width: 67%"></div> |
|
</div> |
|
<h4 class="mt-10 mb-0">£<span id="total-usr"></span> </h4> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
</section> |
|
<br/> |
|
<section> |
|
<div class="content"> |
|
<div class="wallet-address"> |
|
<h4 class="w-text mt-0">Report New Payment</h4> |
|
<div class="form-row-group with-icons"> |
|
<div class="form-row no-padding"> |
|
<i>£</i> |
|
<input type="text" id="aaa" class="form-element"> |
|
</div> |
|
</div> |
|
<h4><a id="submit-a" href="#">Submit</a></h4> |
|
<p class="g-text mb-0">Be Careful when Input..</p> |
|
</div> |
|
</div> |
|
</section> |
|
|
|
<section class="container"> |
|
<div class="content"> |
|
<h4 class="title-main">Daily Payment Trend</h4> |
|
<div class="c-panel pl-0"> |
|
|
|
<div class="row align-items-center"> |
|
<div class="col-12"> |
|
<div class="advertising-wrapper"> |
|
<div id="barAreaGraph" ></div> |
|
</div> |
|
</div> |
|
|
|
</div> |
|
</div> |
|
</div> |
|
</section> |
|
<section class="container"> |
|
<div class="content"> |
|
<h4 class="title-main">Bill Split</h4> |
|
<div class="c-panel"> |
|
|
|
<div class="row align-items-center"> |
|
<div class="col-12 col-sm-6"> |
|
<div class="advertising-wrapper"> |
|
<div id="advertising" class="chart-height-sm"></div> |
|
<h3 class="info-label"><span>Variance</span> <span id="a-balance"></span></h3> |
|
</div> |
|
</div> |
|
<div class="col-12 col-sm-6"> |
|
<div class="split-list"> |
|
<ul class="adv-stats"> |
|
</ul> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
</section> |
|
|
|
<section class="container"> |
|
<h4 class="title-main">Recent Transactions</h4> |
|
<ul class="transaction-list list-unstyled" id="account-events"> |
|
</ul> |
|
</section> |
|
|
|
</div> |
|
|
|
<footer> |
|
<div class="container"> |
|
<ul> |
|
<li><a id="ushio-blog" href="https://www.eee.dog"><i class="fa fa-home"></i></a></li> |
|
<li><a href="https://github.com/iotcat"><i class="fa fa-github"></i></a></li> |
|
<li><a href="mailto:i@iotcat.me"><i class="fa fa-envelope"></i></a></li> |
|
<li><a href="https://guide.yimian.xyz/"><i class="fa fa-superpowers"></i></a></li> |
|
</ul> |
|
<p>© 2018-<script type="text/javascript">document.write(new Date().getFullYear());</script> Made with <span class="shaky"><i style="color:red;" class="fa fa-heart"></i></span> by <a id="ushio-tome" href="https://iotcat.me">iotcat</a></p> |
|
</div> |
|
</footer> |
|
</main> |
|
<!-- Page content end --> |
|
</div> |
|
</div> |
|
|
|
<!--Page loader DOM Elements. Requared all pages--> |
|
<div class="sweet-loader"> |
|
<div class="box"> |
|
<div class="circle1"></div> |
|
<div class="circle2"></div> |
|
<div class="circle3"></div> |
|
</div> |
|
</div> |
|
<script type="text/javascript" src="https://cdn.yimian.xyz/ushio-js/ushio-footer.min.js"></script> |
|
|
|
<!-- JQuery library file. requared all pages --> |
|
|
|
<!-- Swiper JS --> |
|
<script src="https://cdn.yimian.xyz/smart-settlement/js/swiper.min.js"></script> |
|
|
|
<!-- Initialize Swiper --> |
|
|
|
<!-- Flot Charts --> |
|
<script src="https://cdn.yimian.xyz/smart-settlement/plugins/c3-chart/c3.min.js"></script> |
|
<script src="https://cdn.yimian.xyz/smart-settlement/plugins/c3-chart/d3.min.js"></script> |
|
<!--<script src="./plugins/c3-chart/c3.custom.js"></script>--> |
|
<!-- Flot Charts --> |
|
<script src="https://cdn.yimian.xyz/smart-settlement/plugins/flot/jquery.flot.min.js"></script> |
|
<script src="https://cdn.yimian.xyz/smart-settlement/plugins/flot/jquery.flot.time.min.js"></script> |
|
<script src="https://cdn.yimian.xyz/smart-settlement/plugins/flot/jquery.flot.pie.min.js"></script> |
|
<script src="https://cdn.yimian.xyz/smart-settlement/plugins/flot/jquery.flot.tooltip.min.js"></script> |
|
<script src="https://cdn.yimian.xyz/smart-settlement/plugins/flot/jquery.flot.resize.min.js"></script> |
|
<!-- Sparkline--> |
|
<script src="https://cdn.yimian.xyz/smart-settlement/plugins/jquery-sparkline/jquery.sparkline.js"></script> |
|
|
|
<!-- Template global script file. requared all pages --> |
|
<script src="./js/app-charts.js"></script> |
|
<script src="./js/global.script.js"></script> |
|
|
|
|
|
<script type="text/javascript"> |
|
try{ |
|
if(cookie.get('cache')){ |
|
data = JSON.parse(decodeURIComponent(escape(atob(cookie.get('cache'))))); |
|
|
|
$('#title').html(data.name); |
|
$('#total').html(data.total); |
|
$('#total-usr').html(data.userTotal); |
|
$('#week-avg').html(data.lastWeekTotal); |
|
|
|
|
|
} |
|
}catch(e){} |
|
|
|
|
|
function load(){ |
|
session.onload(function(){ |
|
$('#usr').html('Hi~ '+session.get('nickname')); |
|
if(!session.get('email')) return; |
|
if(page.params.hasOwnProperty('tableId')){ |
|
|
|
window.location.href="./api/joinTable.php?hash="+session.get('hash')+'&tableId='+page.params.tableId; |
|
return; |
|
} |
|
|
|
|
|
function localLoad(data){ |
|
if(!session.get('hash')) return; |
|
if(!data.length) return; |
|
var buttons = []; |
|
|
|
|
|
data.forEach(function(item){ |
|
if(item.id != cookie.get('tableId')){ |
|
buttons.push( |
|
['<button><b>'+item.name+'</b></button>', function (instance, toast) { |
|
instance.hide({ transitionOut: 'fadeOut' }, toast, 'button'); |
|
cookie.set('tableId', item.id); |
|
load(); |
|
$('.nav-menu').trigger('click'); |
|
}, true] |
|
); |
|
} |
|
}); |
|
|
|
if(cookie.get('tableId')){ |
|
var id = -1; |
|
for(var i = 0; i < data.length; i ++){ |
|
if(data[i].id == cookie.get('tableId')){ |
|
data = data[i]; |
|
id = i; |
|
} |
|
} |
|
if(id == -1){ |
|
cookie.set('tableId', data[0].id); |
|
data = data[0]; |
|
} |
|
}else{ |
|
cookie.set('tableId', data[0].id); |
|
data = data[0]; |
|
} |
|
window.data = data; |
|
|
|
buttons.push( |
|
['<button><b>Create New Group</b></button>', function (instance, toast) { |
|
instance.hide({ transitionOut: 'fadeOut' }, toast, 'button'); |
|
window.location.href="./setTable.html"; |
|
}, true] |
|
); |
|
|
|
|
|
buttons.push( |
|
['<button><b>close</b></button>', function (instance, toast) { |
|
instance.hide({ transitionOut: 'fadeOut' }, toast, 'button'); |
|
}, true] |
|
); |
|
|
|
$('#switch').unbind(); |
|
$("#switch").click(function(){ |
|
tips.question({ |
|
timeout: 20000, |
|
close: false, |
|
overlay: true, |
|
displayMode: 'once', |
|
//id: 'question', |
|
zindex: 999, |
|
title: 'Groups', |
|
message: '', |
|
position: 'center', |
|
buttons: buttons |
|
}); |
|
}); |
|
|
|
|
|
|
|
$('#setTable').unbind(); |
|
$('#setTable').click(function(){ |
|
window.location.href="./setTable.html?tableId="+data.id; |
|
}); |
|
|
|
$('#title').html(data.name); |
|
$('#total').html(Number(data.total)); |
|
$('#total-usr').html(Number(data['actualTotals'][session.get('hash')])); |
|
$('#total-usr-bar').css('width', (data['virtualTotals'][session.get('hash')] / data.average)*100+'%'); |
|
$('#checkout').unbind(); |
|
$('#checkout').click(function(){ |
|
alert('You will checkout and quit from group '+data.name+'!!'); |
|
window.location.href="https://cp-acc.yimian.xyz/api/checkout.php?hash="+session.get('hash')+"&tableId="+data.id; |
|
}); |
|
|
|
|
|
var lastWeekTotal = Number(0), lastSecodeWeekTotal = Number(0); |
|
lastWeekByUser = {}; |
|
data.users.forEach(function(user){ |
|
lastWeekByUser[user] = 0; |
|
}); |
|
data.items.forEach(function(item){ |
|
if(item.state == '0') return; |
|
if(item.timestamp > new Date().valueOf()/1000 - 7*24*60*60){ |
|
lastWeekTotal += Number(item.value); |
|
lastWeekByUser[item.user] += Number(item.value); |
|
}else if(item.timestamp > new Date().valueOf()/1000 - 14*24*60*60){ |
|
lastSecodeWeekTotal += Number(item.value); |
|
} |
|
}); |
|
|
|
|
|
|
|
$('#week-avg').html(Number(lastWeekTotal/(7*data.users.length)).toFixed(2)); |
|
$('#total-bar').css('width', (data['actualTotals'][session.get('hash')] / lastWeekTotal)*100+'%'); |
|
if(lastWeekTotal > lastSecodeWeekTotal) $('#week-avg-rate').html(((lastWeekTotal - lastSecodeWeekTotal)/lastSecodeWeekTotal).toFixed(2)+'% <i style="color:red;" class="fa fa-arrow-up ml-10"></i>'); |
|
if(lastSecodeWeekTotal < lastSecodeWeekTotal) $('#week-avg-rate').html(((lastSecodeWeekTotal - lastWeekTotal)/lastSecodeWeekTotal).toFixed(2)+'% <i style="color:green;" class="fa fa-arrow-down ml-10"></i>'); |
|
|
|
|
|
var briefData = { |
|
name: data.name, |
|
total: data.total, |
|
lastWeekTotal: Number(lastWeekTotal/(7*data.users.length)).toFixed(2), |
|
userTotal: Number(data['actualTotals'][session.get('hash')]), |
|
threshold: data.threshold |
|
}; |
|
try{ |
|
cookie.set('cache', btoa(unescape(encodeURIComponent(JSON.stringify(briefData))))); |
|
}catch(e){console.log(e, briefData)} |
|
var show = []; |
|
for(var i = data['items'].length - 1; i > data['items'].length-10 && i >= 0; i --){ |
|
if(data['items'][i]['value'] > 0 && (data['items'][i]['type'] == 'innerF' || data['items'][i]['type'] == 'external')) |
|
show.push(data['items'][i]); |
|
} |
|
var s = ''; |
|
show.forEach((i)=>{ |
|
|
|
|
|
s += ` |
|
<li> |
|
<div class="d-flex align-items-center justify-content-between"> |
|
<div class="d-flex align-items-center"> |
|
<img class="img-xs" src="https://cdn.yimian.xyz/smart-settlement/img/content/coin`; |
|
if(i.type == "external") s += 3; |
|
if(i.type == "innerF" && !(i.state == '1')) s += 4; |
|
if(i.type == "innerF" && (i.state == '1')) s += 5; |
|
s += `.png" alt="coin image"> |
|
<div class="ml-10"> |
|
<h4 class="coin-name">`; |
|
if(i.type == 'external') s += 'payment'; |
|
if(i.type == 'innerF') s += 'circulation'; |
|
if(i.type == "external") s += ' - ' + data.usersName[i.user] |
|
if(i.type == "innerF" && !(i.state == '1')) s += ' - ' + data.usersName[i.user] + ' -> ' + data.usersName[i.comments]; |
|
if(i.type == "innerF" && (i.state == '1')) s += ' - ' + data.usersName[i.comments] + ' 👍 ' + data.usersName[i.user]; |
|
s += `</h4> |
|
<small class="text-muted">`; |
|
s += i.created_at; |
|
s += `</small> |
|
</div> |
|
</div> |
|
<div> |
|
`; |
|
if(i.type == 'external') s += `<small class="d-block mb-0 txt-red">£`+(Number(i.value).toFixed(2) )+ `</small>`; |
|
|
|
s += ` |
|
<small class="text-muted d-block">£`; |
|
s += Number(i.value); |
|
|
|
s += `</small> |
|
</div> |
|
</div> |
|
</li> |
|
`; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
$('#account-events').html(s); |
|
|
|
|
|
var userNotice = []; |
|
data['itemsByUser'][session.get('hash')].forEach((item)=>{ |
|
if(!(item.state == '1') && item.type != 'placeholde'){ |
|
userNotice.push(item); |
|
} |
|
}); |
|
userNotice.reverse(); |
|
|
|
function notice(){ |
|
var s = ''; |
|
|
|
if(!userNotice.length){ |
|
s += ` |
|
<li> |
|
<div class="d-flex align-items-center justify-content-between"> |
|
<div class="d-flex align-items-center"> |
|
<div class=""> |
|
<h5 class="coin-name">You have NO notifications!!</h5> |
|
</div> |
|
</div> |
|
<div> |
|
<a href=""></a> |
|
</div> |
|
</div> |
|
</li>`; |
|
$('#no-content').html(s); |
|
$("#no-icon").attr("src", 'https://cdn.yimian.xyz/smart-settlement/img/content/notification-no.png'); |
|
$("#no-icon2").attr("src", 'https://cdn.yimian.xyz/smart-settlement/img/content/notification2-no.png'); |
|
return; |
|
} |
|
|
|
|
|
s += ` |
|
<li> |
|
<div class="d-flex align-items-center justify-content-between"> |
|
<div class="d-flex align-items-center"> |
|
<div class=""> |
|
<h5 class="coin-name">Your last `; |
|
|
|
s += userNotice.length; |
|
s += ` notifications</h5> |
|
</div> |
|
</div> |
|
<div> |
|
<a href=""></a> |
|
</div> |
|
</div> |
|
</li>`; |
|
|
|
userNotice.forEach(function(item){ |
|
s += ` |
|
<li> |
|
<div class="d-flex align-items-center justify-content-between"> |
|
<div class="d-flex align-items-center"> |
|
<div class="notice-icon `; |
|
if(item.value < 0) s += `available`; |
|
if(item.value > 0) s += `away`; |
|
|
|
s += `"> |
|
<i class="fa fa-`; |
|
if(item.value < 0) s += `check`; |
|
if(item.value > 0) s += `clock-o`; |
|
s += `"></i> |
|
</div> |
|
<div class="ml-10"> |
|
<h4 class="coin-name">`; |
|
|
|
if(item.value < 0) s += `You will Get £`+Number(-item.value)+` from `+ data.usersName[item.comments] + ` <button style="color: green;" onClick="javascript:page.confirm('`+item.created_at+`');">Confirm to Recived</button>`; |
|
if(item.value > 0) s += `Please Give £`+Number(item.value)+` to `+ data.usersName[item.comments]; |
|
|
|
s += `</h4> |
|
<small class="text-muted">`; |
|
s += timeago(new Date(item.created_at.replace(/-/g, '/')).getTime()); |
|
s += `</small> |
|
</div> |
|
</div> |
|
</div> |
|
</li>`; |
|
}); |
|
|
|
s += ` |
|
<li> |
|
<div class="d-flex align-items-center justify-content-between"> |
|
<div class="d-flex align-items-center"> |
|
<a href="" class="text-muted">The end of all notifications</a> |
|
</div> |
|
</div> |
|
</li>`; |
|
|
|
$('#no-content').html(s); |
|
$("#no-icon").attr("src", 'https://cdn.yimian.xyz/smart-settlement/img/content/notification-yes.png'); |
|
$("#no-icon2").attr("src", 'https://cdn.yimian.xyz/smart-settlement/img/content/notification2-yes.png'); |
|
|
|
}; |
|
|
|
notice(); |
|
|
|
page.confirm = function(created_at){ |
|
|
|
var arr = []; |
|
|
|
data['items'].forEach((item)=>{ |
|
if((item.type == 'innerF' || item.type == 'innerT') && item.created_at == created_at){ |
|
arr.push(item.id); |
|
} |
|
}); |
|
|
|
$.get('https://cp-acc.yimian.xyz/api/confirmBalance.php?type=ajax&first='+arr[0]+'&last='+arr[1], function(res){ |
|
|
|
load(); |
|
|
|
}); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
var advStats = ''; |
|
|
|
|
|
|
|
|
|
var variance = 0; |
|
|
|
var Piedata, chartOptions; |
|
|
|
var colors = ['#F782AA', '#0084B4', '#3FC5AC', '#FFD06B', '#CCCCCC', '#8F3D39', '#9A3481', '#492034', '#593204', '#71e39d', '#B32083', '#D39D32']; |
|
Piedata = []; |
|
Object.keys(data.virtualTotals).forEach((user, index)=>{ |
|
advStats += '<li style="color: '+colors[index]+';"><i class="fa fa-circle-o" style="color: '+colors[index]+';"></i>'+data.usersName[user]+' <span >'+((lastWeekByUser[user]/lastWeekTotal)*100).toFixed(2)+'%</span></li>'; |
|
Piedata.push({ label: "", data: Math.floor(data.virtualTotals[user]) }); |
|
variance += Math.pow(data.virtualTotals[user] - data.average, 2); |
|
}); |
|
|
|
//Piedata.reverse(); |
|
variance = variance/data.users.length; |
|
$('#a-balance').html(variance.toFixed(2)); |
|
chartOptions = { |
|
series: { |
|
pie: { |
|
show: true, |
|
innerRadius: .8, |
|
stroke: { |
|
width: 1, |
|
} |
|
} |
|
}, |
|
shadowSize: 0, |
|
legend: { |
|
position: 'sw' |
|
}, |
|
tooltip: true, |
|
|
|
tooltipOpts: { |
|
content: '%s: %y' |
|
}, |
|
grid:{ |
|
hoverable: false, |
|
clickable: false, |
|
borderWidth: 0, |
|
}, |
|
shadowSize: 0, |
|
colors: colors |
|
}; |
|
var holder = $('#advertising'); |
|
if (holder.length) { |
|
$.plot(holder, Piedata, chartOptions ); |
|
$('.adv-stats').html(advStats); |
|
} |
|
|
|
|
|
var daily_avg = [], daily_avg_week = ['data2']; |
|
|
|
for(var i = 0; i <= 30; i ++){ |
|
daily_avg[i] = 0; |
|
} |
|
|
|
var i = data.items.length - 1; |
|
for(; i >= 0; i--){ |
|
var day = parseInt((new Date().valueOf()/1000 + (24-new Date().getHours())*3600 - data.items[i].timestamp)/(24*60*60)); |
|
if(day > 30){ |
|
break; |
|
} |
|
console.log(day) |
|
if(!daily_avg.hasOwnProperty(day)) daily_avg[day] = 0; |
|
daily_avg[day] += Number(data.items[i].value); |
|
} |
|
|
|
for(var i = daily_avg.length - 1; i > 0 && daily_avg[i] == 0; i --){ |
|
daily_avg.pop(); |
|
} |
|
|
|
console.log(daily_avg) |
|
daily_avg.push('data1'); |
|
daily_avg = daily_avg.reverse(); |
|
|
|
for(var i = daily_avg.length - 1; i >0; i --){ |
|
daily_avg_week[i] = 0; |
|
var ii = i |
|
for(; ii > i-7 && ii >0; ii --){ |
|
daily_avg_week[i] += daily_avg[ii]; |
|
} |
|
daily_avg_week[i] = daily_avg_week[i]/(i-ii); |
|
} |
|
|
|
|
|
|
|
console.log(daily_avg, daily_avg_week) |
|
c3.generate( { |
|
bindto:"#barAreaGraph", data: { |
|
columns:[daily_avg, daily_avg_week], types: { |
|
data1: "bar", data2: "area" |
|
} |
|
, names: { |
|
data1: "Payment", data2: "Ghost Payment" |
|
} |
|
, colors: { |
|
data1: "#E9BB27", data2: "#3a86c8" |
|
} |
|
} |
|
} |
|
|
|
); |
|
|
|
var s = ''; |
|
data['items'].reverse(); |
|
data['items'].forEach((i)=>{ |
|
if(i.type == 'external'){ |
|
s += ` |
|
<li> |
|
<div class="d-flex align-items-center justify-content-between"> |
|
<div class="d-flex align-items-center"> |
|
<img class="img-xs" src="https://cdn.yimian.xyz/smart-settlement/img/content/coin3.png" alt="coin image"> |
|
<div class="ml-10"> |
|
<h4 class="coin-name">payment`; |
|
s += ' - ' + data.usersName[i.user]; |
|
s += `</h4> |
|
<small class="text-muted">`; |
|
s += i.created_at; |
|
s += `</small> |
|
</div> |
|
</div> |
|
<div> |
|
`; |
|
s += `<small class="d-block mb-0 txt-red">£-`+Number(i.value).toFixed(2) + `</small>`; |
|
|
|
s += ` |
|
<small class="text-muted d-block"><a href='`+atob(i.url)+`'>see invoice</a></small> |
|
</div> |
|
</div> |
|
</li> |
|
`; |
|
} |
|
|
|
}); |
|
data.items.reverse(); |
|
$('#account-events-2').html(s); |
|
|
|
|
|
}; |
|
|
|
|
|
if(window.localStorage[session.get('hash')]){ |
|
try{ |
|
data = JSON.parse(window.localStorage[session.get('hash')]); |
|
localLoad(data); |
|
}catch(e){ |
|
} |
|
} |
|
|
|
|
|
$.get('./api/getData.php?hash='+session.get('hash'), function(data){ |
|
window.localStorage[session.get('hash')] = JSON.stringify(data); |
|
if(!data.length){ |
|
alert('请先创建一个公共账户!'); |
|
window.location.href="./setTable.html"; |
|
return; |
|
} |
|
localLoad(data); |
|
}); |
|
|
|
}); |
|
} |
|
load(); |
|
$("#aaa").bind("input propertychange",function(event){ |
|
console.log($("#aaa").val()); |
|
$("#aaa").val(clearNoNum($("#aaa").val())) |
|
}); |
|
$("#submit-a").click(function(){ |
|
if(!$('#aaa').val()) { |
|
alert('illegal input'); |
|
return; |
|
} |
|
window.location.href='https://imgbed.yimian.xyz/api.html?redirect=https://cp-acc.yimian.xyz/api/newItem.php&passby='+btoa(JSON.stringify({ |
|
tableId: cookie.get('tableId'), |
|
hash: session.get('hash'), |
|
value: $("#aaa").val() |
|
})); |
|
}); |
|
|
|
|
|
/* notification func */ |
|
|
|
function timeago(dateTimeStamp){ //dateTimeStamp是一个时间毫秒,注意时间戳是秒的形式,在这个毫秒的基础上除以1000,就是十位数的时间戳。13位数的都是时间毫秒。 |
|
var minute = 1000 * 60; //把分,时,天,周,半个月,一个月用毫秒表示 |
|
var hour = minute * 60; |
|
var day = hour * 24; |
|
var week = day * 7; |
|
var halfamonth = day * 15; |
|
var month = day * 30; |
|
var now = new Date().getTime(); //获取当前时间毫秒 |
|
var diffValue = now - dateTimeStamp;//时间差 |
|
|
|
if(diffValue < 0){ |
|
return; |
|
} |
|
var minC = diffValue/minute; //计算时间差的分,时,天,周,月 |
|
var hourC = diffValue/hour; |
|
var dayC = diffValue/day; |
|
var weekC = diffValue/week; |
|
var monthC = diffValue/month; |
|
if(monthC >= 1 && monthC <= 3){ |
|
result = " " + parseInt(monthC) + "month ago" |
|
}else if(weekC >= 1 && weekC <= 3){ |
|
result = " " + parseInt(weekC) + "week ago" |
|
}else if(dayC >= 1 && dayC <= 6){ |
|
result = " " + parseInt(dayC) + "day ago" |
|
}else if(hourC >= 1 && hourC <= 23){ |
|
result = " " + parseInt(hourC) + "hours ago" |
|
}else if(minC >= 1 && minC <= 59){ |
|
result =" " + parseInt(minC) + "minutes ago" |
|
}else if(diffValue >= 0 && diffValue <= minute){ |
|
result = "just now" |
|
}else { |
|
var datetime = new Date(); |
|
datetime.setTime(dateTimeStamp); |
|
var Nyear = datetime.getFullYear(); |
|
var Nmonth = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1; |
|
var Ndate = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate(); |
|
var Nhour = datetime.getHours() < 10 ? "0" + datetime.getHours() : datetime.getHours(); |
|
var Nminute = datetime.getMinutes() < 10 ? "0" + datetime.getMinutes() : datetime.getMinutes(); |
|
var Nsecond = datetime.getSeconds() < 10 ? "0" + datetime.getSeconds() : datetime.getSeconds(); |
|
result = Nyear + "-" + Nmonth + "-" + Ndate |
|
} |
|
return result; |
|
} |
|
|
|
|
|
|
|
</script> |
|
|
|
|
|
<script language="JavaScript" type="text/javascript"> |
|
function clearNoNum(value){ |
|
value = value.replace(/[^\d.]/g,""); //清除“数字”和“.”以外的字符 |
|
value = value.replace(/^\./g,""); //验证第一个字符是数字而不是. |
|
value = value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的. |
|
value = value.replace(".","$#$").replace(/\./g,"").replace("$#$","."); |
|
return value; |
|
} |
|
</script> |
|
<script src="https://cdn.yimian.xyz/pjax/pjax.min.js"></script> |
|
<script> |
|
window.pjax = new Pjax({ |
|
elements: '#index, #records', |
|
selectors: ["head title", "#body", '.main-menu'], |
|
}); |
|
|
|
document.addEventListener("pjax:send", function () { |
|
$('.nav-menu').trigger('click'); |
|
}); |
|
|
|
|
|
document.addEventListener("pjax:complete", function () { |
|
/* 重载带data-pjax的script,或者.pjax-reload属性内容的script */ |
|
$("#index, #records").each(function () { |
|
$(this).parent().append($(this).remove()); |
|
}); |
|
load(); |
|
}); |
|
|
|
</script> |
|
</body> |
|
|
|
</html>
|
|
|