| 13532 |
anikendra |
1 |
<?php
|
|
|
2 |
App::uses('AppController', 'Controller');
|
|
|
3 |
/**
|
|
|
4 |
* Administration Controller
|
|
|
5 |
*
|
|
|
6 |
* @property Administration $Administration
|
|
|
7 |
* @property PaginatorComponent $Paginator
|
|
|
8 |
*/
|
|
|
9 |
class AdministrationController extends AppController {
|
|
|
10 |
|
|
|
11 |
/**
|
|
|
12 |
* Components
|
|
|
13 |
*
|
|
|
14 |
* @var array
|
|
|
15 |
*/
|
|
|
16 |
public $components = array('Paginator');
|
|
|
17 |
|
|
|
18 |
public function beforeFilter() {
|
|
|
19 |
parent::beforeFilter();
|
|
|
20 |
$this->layout = 'admin';
|
|
|
21 |
}
|
|
|
22 |
|
|
|
23 |
public function dashboard(){
|
| 15077 |
anikendra |
24 |
$this->loadModel('User');
|
|
|
25 |
//daily userbase
|
| 15128 |
anikendra |
26 |
$sql = "SELECT count(User.id) AS count,date(User.created) AS date FROM users User WHERE datediff(now(),created) <= 30 AND activated = 1 GROUP BY date(created) ORDER BY id DESC";
|
| 15077 |
anikendra |
27 |
$userbase = $this->User->query($sql);
|
|
|
28 |
$sql = "SELECT count(Click.id) AS count,date(created) AS date FROM clicks Click WHERE datediff(now(),created) <= 30 GROUP BY date(created) ORDER BY id DESC";
|
|
|
29 |
$clicks = $this->User->query($sql);
|
|
|
30 |
$this->set(compact('userbase','clicks'));
|
|
|
31 |
$sql = "SELECT count(id) AS count,date(created) AS date FROM orders WHERE datediff(now(),created) <= 30 AND status = 'ORDER_CREATED' GROUP BY date(created) ORDER BY id DESC";
|
|
|
32 |
$orders = $this->User->query($sql);
|
| 15607 |
anikendra |
33 |
// $sql = "select count(id) AS count,versioncode from devices group by versioncode";
|
|
|
34 |
$sql = "SELECT COUNT( * ) AS count, a.c AS versioncode FROM (SELECT MAX( versioncode ) c, user_id FROM devices GROUP BY user_id) a GROUP BY a.c";
|
| 15077 |
anikendra |
35 |
$devices = $this->User->query($sql);
|
| 15093 |
anikendra |
36 |
$sql = "SELECT count(distinct user_id) AS count,date(created) AS date FROM `brand_preferences` WHERE datediff(now(),created) <= 30 group by date(created) order by id desc";
|
| 15128 |
anikendra |
37 |
$preferences_set = $this->User->query($sql);
|
|
|
38 |
$sql = "select count(distinct user_id) AS count from brand_preferences";
|
|
|
39 |
$usersWithBrandPreferencesSet = $this->User->query($sql);
|
|
|
40 |
$sql = "select count(id) AS count from users";
|
| 15188 |
anikendra |
41 |
$totalUsers = $this->User->query($sql);
|
| 15654 |
anikendra |
42 |
$sql = "SELECT DATE( created ) AS date, COUNT( DISTINCT (user_id) ) AS count FROM user_urls WHERE DATE( created ) > CURDATE( ) - INTERVAL 30 DAY GROUP BY date order by id desc";
|
|
|
43 |
$activeUsers = $this->User->query($sql);
|
|
|
44 |
$sql = "select date(created) date, count(distinct user_id) count from (select id,user_id, created from orders union all select id,user_id, created from flipkartorders) a where date(created) > curdate() - interval 30 day group by date order by a.id desc";
|
|
|
45 |
$activeBuyers = $this->User->query($sql);
|
| 15670 |
manas |
46 |
$sql = "SELECT count(id) as count,date(mobile_number_last_updated) as date from users where mobile_verified=1 and datediff(now(),mobile_number_last_updated) <= 30 group by date(mobile_number_last_updated) ORDER BY date(mobile_number_last_updated) desc";
|
|
|
47 |
$dailyVerifications = $this->User->query($sql);
|
|
|
48 |
$this->set(compact('userbase','clicks','orders','devices','preferences_set','usersWithBrandPreferencesSet','totalUsers','activeUsers','activeBuyers','dailyVerifications'));
|
| 13532 |
anikendra |
49 |
}
|
| 15128 |
anikendra |
50 |
}
|