人人商城

card.ctrl.php 1.9KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. uni_user_permission_check('stat_card');
  8. $_W['page']['title'] = '会员卡领卡统计-数据统计';
  9. $now = strtotime(date('Y-m-d'));
  10. $starttime = empty($_GPC['time']['start']) ? $now - 30*86400 : strtotime($_GPC['time']['start']);
  11. $endtime = empty($_GPC['time']['end']) ? TIMESTAMP : strtotime($_GPC['time']['end']) + 86399;
  12. $num = ($endtime + 1 - $starttime) / 86400;
  13. if($_W['isajax']) {
  14. $stat = array();
  15. for($i = 0; $i < $num; $i++) {
  16. $time = $i * 86400 + $starttime;
  17. $key = date('m-d', $time);
  18. $stat[$key] = 0;
  19. }
  20. $data = pdo_fetchall('SELECT id,createtime FROM ' . tablename('mc_card_members') . ' WHERE uniacid = :uniacid AND createtime >= :starttime AND createtime <= :endtime', array(':uniacid' => $_W['uniacid'], ':starttime' => $starttime, ':endtime' => $endtime));
  21. if(!empty($data)) {
  22. foreach($data as $da) {
  23. $key = date('m-d', $da['createtime']);
  24. $stat[$key] += 1;
  25. }
  26. }
  27. $out['label'] = array_keys($stat);
  28. $out['datasets'] = array_values($stat);
  29. exit(json_encode($out));
  30. }
  31. $total = floatval(pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('mc_card_members') . ' WHERE uniacid = :uniacid', array(':uniacid' => $_W['uniacid'])));
  32. $today = floatval(pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('mc_card_members') . ' WHERE uniacid = :uniacid AND createtime >= :starttime AND createtime <= :endtime', array(':uniacid' => $_W['uniacid'], ':starttime' => strtotime(date('Y-m-d')), ':endtime' => TIMESTAMP)));
  33. $yesterday = floatval(pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('mc_card_members') . ' WHERE uniacid = :uniacid AND createtime >= :starttime AND createtime <= :endtime', array(':uniacid' => $_W['uniacid'], ':starttime' => strtotime(date('Y-m-d')) - 86400, ':endtime' => strtotime(date('Y-m-d')))));
  34. template('stat/card');