Subversion Repositories SmartDukaan

Rev

Rev 17201 | Rev 17288 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 17201 Rev 17287
Line 19... Line 19...
19
		parent::beforeFilter();
19
		parent::beforeFilter();
20
		$this->Auth->allow('add','mine','pendingcashbacks','all');
20
		$this->Auth->allow('add','mine','pendingcashbacks','all');
21
		$this->apihost = Configure::read('pythonapihost');
21
		$this->apihost = Configure::read('pythonapihost');
22
	}
22
	}
23
	
23
	
-
 
24
	
-
 
25
	public function getOrderFilters($type='user') {
-
 
26
		$cachekey = 'orderfilters-'.$type;
-
 
27
		$filters = Cache::read($cachekey);
-
 
28
		if(empty($filters)) {
-
 
29
			$url = $this->apihost."orderfilters/?type=".$type;
-
 
30
			echo $url;
-
 
31
			$response = $this->make_request($url, null);
-
 
32
			echo $response;
-
 
33
			if(!empty($response)){
-
 
34
				$filters = $response;
-
 
35
				Cache::write($cachekey,$filters);
-
 
36
			}
-
 
37
		}
-
 
38
        return $filters;
-
 
39
	}
-
 
40
	
24
	public function mine() {
41
	public function mine() {
25
		$type = $this->request->query('type');
42
		$type = $this->request->query('type');
26
		$page = $this->request->query('page');
43
		$page = $this->request->query('page');
27
		$page = isset($page)?$page:1;
44
		$page = isset($page)?$page:1;
28
		$userId = $this->request->query('user_id');
45
		$userId = $this->request->query('user_id');
Line 606... Line 623...
606
		}
623
		}
607
		return $this->redirect(array('action' => 'index'));
624
		return $this->redirect(array('action' => 'index'));
608
	}
625
	}
609
 
626
 
610
	public function all() {
627
	public function all() {
-
 
628
		$orderFilters = $this->getOrderFilters("monitor");
611
		$page = $this->request->query('page');
629
		$page = $this->request->query('page');
-
 
630
		$filter = $this->request->query('filter');
612
		$page = isset($page)?$page:1;
631
		$page = isset($page)?$page:1;
613
		// $userId = $this->request->query('user_id');
632
		// $userId = $this->request->query('user_id');
614
		// if(isset($userId) && !empty($userId)){
633
		// if(isset($userId) && !empty($userId)){
615
		// 	$this->loadModel('User');
634
		// 	$this->loadModel('User');
616
		// 	$dbuser = $this->User->findById($userId);
635
		// 	$dbuser = $this->User->findById($userId);
617
		// 	$this->Auth->login($dbuser['User']);	
636
		// 	$this->Auth->login($dbuser['User']);	
618
		// }
637
		// }
619
		$this->layout = "innerpages";
638
		$this->layout = "innerpages";
620
		$url = $this->apihost."orders/?page=$page&window=10";
639
		$url = $this->apihost."orders/?page=$page&window=20";
-
 
640
		if (!empty($filter)) $url .= "&filter=".$filter."&filtertype=monitor";
621
		$response = $this->make_request($url,null);
641
		$response = $this->make_request($url,null);
622
		$totalPages = $response['totalPages'];		
642
		$totalPages = $response['totalPages'];		
623
		if(!empty($response['data'])){
643
		if(!empty($response['data'])){
624
			$this->set('orders',$response['data']);
644
			$this->set('orders',$response['data']);
625
		}
645
		}
Line 630... Line 650...
630
		$allusers = $this->Order->User->find('all',array('fields'=>array('first_name','id'),'recursive'=>-1));
650
		$allusers = $this->Order->User->find('all',array('fields'=>array('first_name','id'),'recursive'=>-1));
631
		foreach($allusers AS $user){
651
		foreach($allusers AS $user){
632
			$users[$user['User']['id']] = $user['User']['first_name'];
652
			$users[$user['User']['id']] = $user['User']['first_name'];
633
		}
653
		}
634
		$this->layout = 'admin';
654
		$this->layout = 'admin';
635
		$this->set(compact('ignoredFields','page','totalPages','userId','activestores','storemapping','amazonorderurl','users'));
655
		$this->set(compact('ignoredFields','page','totalPages','userId','activestores','storemapping','amazonorderurl','users', 'orderFilters', 'type'));
636
	}
656
	}
637
}
657
}