From 8e00417fc906751195bcfd33f08edb64d51fc601 Mon Sep 17 00:00:00 2001 From: "cn.yimian.xyz" Date: Sat, 22 Aug 2020 21:09:02 +0800 Subject: [PATCH] before chart --- api/createTable.php | 4 +-- api/functions.php | 12 ++++----- api/getData.php | 4 +-- api/newItem.php | 4 +-- api/updateTable.php | 3 +-- index.html | 61 ++++++++++++++++++++++++++++++++------------- records.html | 32 ++++++++++++++++++++---- setTable.html | 16 +++++++++--- 8 files changed, 95 insertions(+), 41 deletions(-) diff --git a/api/createTable.php b/api/createTable.php index 99c6c56..b2a75cc 100644 --- a/api/createTable.php +++ b/api/createTable.php @@ -34,6 +34,6 @@ db__pushData($cnn, "user", array( )); -return json_encode(array( +echo json_encode(array( "tableId" => $tableId -)); \ No newline at end of file +)); diff --git a/api/functions.php b/api/functions.php index 3333f85..4ecdde2 100644 --- a/api/functions.php +++ b/api/functions.php @@ -592,7 +592,7 @@ function getPostHttpBody($param) /* sms */ -require __DIR__ . "/../../lib/qcloudsms/src/index.php"; +require __DIR__ . "/../../../lib/qcloudsms/src/index.php"; use Qcloud\Sms\SmsSingleSender; use Qcloud\Sms\SmsMultiSender; @@ -656,7 +656,7 @@ function getItems($cnn, $tableId){ return db__getData($cnn, "account", "table", $tableId); } function getTableInfo($cnn, $tableId){ - $res = db__getData($cnn, "table", "table", $tableId); + $res = db__getData($cnn, "table", "id", $tableId); return $res[0]; } function getTableData($cnn, $tableId){ @@ -675,7 +675,7 @@ function getTableDataByUsers($cnn, $tableId){ array_push($arr, $item); } } - array_push($o['itemsByUser'], $arr); + $o['itemsByUser'][$user] = $arr; } return $o; } @@ -716,7 +716,7 @@ function getUsersInfo($tableData){ $auth = db__connect("","","","auth"); $tableData['usersName'] = array(); foreach($tableData['users'] as $user){ - array_push($tableData['usersName'], db__getData($auth, "account", "hash", $user)[0]['nickname']); + $tableData['usersName'][$user] = db__getData($auth, "account", "hash", $user)[0]['nickname']; } return $tableData; } @@ -725,8 +725,8 @@ function getUsersInfo($tableData){ function getFinalData($cnn, $tableId){ $d = getTableDataByUsers($cnn, $tableId); $o = getTotals($d); - $o = getAverage($o); $o = getUsersInfo($o); + $o = getAverage($o); return $o; } @@ -795,4 +795,4 @@ function setBalance($first, $last, $threshold, $tableId, $cnn){ 感谢您使用本站服务,祝您生活愉悦! 呓喵酱(@iotcat)", "CP-ACC"); -} \ No newline at end of file +} diff --git a/api/getData.php b/api/getData.php index 58775ad..5c74b82 100644 --- a/api/getData.php +++ b/api/getData.php @@ -7,7 +7,7 @@ $hash = $_REQUEST['hash']; if(!isset($hash)) die(); -$cnn = connect(); +$cnn = db__connect(); $res = db__getData($cnn, "user", "user", $hash, "state", '1'); $o = []; @@ -18,4 +18,4 @@ foreach($res as $item){ -echo json_encode($o); \ No newline at end of file +echo json_encode($o); diff --git a/api/newItem.php b/api/newItem.php index 1bb52d0..a134f3e 100644 --- a/api/newItem.php +++ b/api/newItem.php @@ -7,7 +7,7 @@ $url = $_REQUEST['url']; $passby = $_REQUEST['passby']; -if(!isset($hash) || !isset($passby)) die(); +if(!isset($url) || !isset($passby)) die(); $passby = json_decode(base64_decode($passby), true); @@ -49,4 +49,4 @@ while(!checkBalance($data, $threshold)){ -header("Location: https://cp-acc.yimian.xyz/"); \ No newline at end of file +header("Location: https://cp-acc.yimian.xyz/"); diff --git a/api/updateTable.php b/api/updateTable.php index e3c22fe..96f9fe4 100644 --- a/api/updateTable.php +++ b/api/updateTable.php @@ -15,8 +15,7 @@ db__pushData($cnn, "table", array( "state" => '1', "name" => $name, "threshold" => $threshold, - "created_by" => $hash, - "created_at" => date("Y-m-d H:i:s", time()) + "updated_at" => date("Y-m-d H:i:s", time()) ), array( "id" => $tableId )); diff --git a/index.html b/index.html index 485ca4a..9c7a30a 100644 --- a/index.html +++ b/index.html @@ -51,7 +51,7 @@
  • - Settings + Setting
  • Log out @@ -97,7 +97,7 @@
    -

    ERP for CP Home

    +

    xxx

    @@ -110,7 +110,7 @@

    £

    -

    Weekly Payment

    +

    Average Daily Payment

    43.55%
    @@ -276,8 +276,8 @@ - - + + + - \ No newline at end of file + diff --git a/records.html b/records.html index 737d502..a317cb9 100644 --- a/records.html +++ b/records.html @@ -59,7 +59,7 @@
    - +
    @@ -93,7 +93,7 @@
    -

    ERP for CP Home

    +

    xxx

    @@ -155,7 +155,29 @@ alert('请先创建一个公共账户!'); window.location.href="./setTable.html"; return; - } + } + + + 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; + + + $('#title').html(data.name); $('#usr').html(session.get('nickname')); var s = ''; @@ -180,7 +202,7 @@ s += `£-`+Number(i.value).toFixed(2) + ``; s += ` - see invoice + see invoice
  • @@ -373,4 +395,4 @@ function confirm(created_at){ - \ No newline at end of file + diff --git a/setTable.html b/setTable.html index f97e806..72a7c2f 100644 --- a/setTable.html +++ b/setTable.html @@ -26,7 +26,7 @@
    - +

    设置公共账户信息

    @@ -61,8 +61,8 @@


    @@ -100,6 +100,14 @@ session.onload(function(){ if(page.params.hasOwnProperty('tableId')){ + $.get('./api/getData.php?hash='+session.get('hash'), function(data){ + data.forEach(function(item){ + if(item.id == page.params.tableId){ + $('#name').val(item.name); + $('#threshold').val(item.threshold); + } + }); + }); $('#qr').show(); $('#url').val('https://cp-acc.yimian.xyz/?type=join&tableId='+page.params.tableId); qrcode.makeCode('https://cp-acc.yimian.xyz/?type=join&tableId='+page.params.tableId); @@ -127,4 +135,4 @@ session.onload(function(){ - \ No newline at end of file +