Subversion Repositories SmartDukaan

Rev

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

Rev 19883 Rev 19892
Line 1160... Line 1160...
1160
		
1160
		
1161
	}
1161
	}
1162
	
1162
	
1163
	public function admin_usersanctions(){
1163
	public function admin_usersanctions(){
1164
		$url = Configure::read('saholicapihost').'counter!getUsersSanctionDetails?limit=0&offset=0';
1164
		$url = Configure::read('saholicapihost').'counter!getUsersSanctionDetails?limit=0&offset=0';
-
 
1165
		if($this->request->is('post')){
-
 
1166
			$filter = $this->request->data['UserSanctions']['searchUserBy'];
-
 
1167
			if ($filter==1){
-
 
1168
				$url = $url.'&sort=loan';	
-
 
1169
			}
-
 
1170
		}
1165
		$response = $this->make_request ( $url, null );
1171
		$response = $this->make_request ( $url, null );
1166
		$userSanctions = $response['response']['userSanctions']['userSanctions'];
1172
		$userSanctions = $response['response']['userSanctions']['userSanctions'];
1167
		$hasMore = $response['response']['userSanctions']['hasMore'];
1173
		$hasMore = $response['response']['userSanctions']['hasMore'];
1168
		$totalCount = $response['response']['userSanctions']['totalCount'];
1174
		$totalCount = $response['response']['userSanctions']['totalCount'];
1169
		$this->loadModel('UserAccount');
1175
		$this->loadModel('UserAccount');
Line 1178... Line 1184...
1178
				$userName = $this->User->find('first',$opts);
1184
				$userName = $this->User->find('first',$opts);
1179
				$usersName[$userSanction['user_id']] = $userName['User']['first_name'];
1185
				$usersName[$userSanction['user_id']] = $userName['User']['first_name'];
1180
				$usersMap[$userSanction['user_id']]=$userId;
1186
				$usersMap[$userSanction['user_id']]=$userId;
1181
			}
1187
			}
1182
		}
1188
		}
1183
					
-
 
1184
		$this->set(compact('usersName','userSanctions','usersMap','hasMore','totalCount'));
1189
		$this->set(compact('usersName','userSanctions','usersMap','hasMore','totalCount'));
1185
	}
1190
	}
1186
	
1191
	
1187
	public function admin_credithistory($cuid = 0){
1192
	public function admin_credithistory($cuid = 0){
1188
		$page = $this->request->query('page');
1193
		$page = $this->request->query('page');
Line 1490... Line 1495...
1490
		$response = $this->make_request($url,null); 
1495
		$response = $this->make_request($url,null); 
1491
		
1496
		
1492
		return json_encode($response['result']);
1497
		return json_encode($response['result']);
1493
		
1498
		
1494
	}
1499
	}
-
 
1500
	
-
 
1501
	public function admin_outstanding($type,$userId=null) {
-
 
1502
		$url = Configure::read('saholicapihost').'counter!getOutstandingLoans?fetchType='.$type;
-
 
1503
		if(isset($userId)){
-
 
1504
			$url = $url.'&userId='.$userId;
-
 
1505
		}
-
 
1506
		$response = $this->make_request ( $url, null );
-
 
1507
		$outstandingPayments = $response['response'];
-
 
1508
		$usersName = array();
-
 
1509
		$usersMap = array();
-
 
1510
		$this->loadModel('UserAccount');
-
 
1511
		foreach($outstandingPayments AS $loanH){
-
 
1512
			if (!array_key_exists($loanH['user_id'], $usersMap)) {
-
 
1513
				$options = array('conditions'=>array('account_key'=>$loanH['user_id'],'account_type'=>'saholic'),'recursive'=>-1,'fields'=>'user_id');
-
 
1514
				$userId = $this->UserAccount->find('first',$options);
-
 
1515
				$userId = $userId['UserAccount']['user_id'];
-
 
1516
				$opts = array('conditions'=>array('id'=>$userId),'recursive'=>-1,'fields'=>array('first_name','email'));
-
 
1517
				$userName = $this->User->find('first',$opts);
-
 
1518
				$usersName[$loanH['user_id']] = $userName['User']['first_name'];
-
 
1519
				$usersMap[$loanH['user_id']]=$userName['User']['email'];
-
 
1520
			}
-
 
1521
		}
-
 
1522
		$this->set(compact('usersName','outstandingPayments','usersMap'));
-
 
1523
		if($type=='credit'){
-
 
1524
			$this->render('admin_outstandingcredits');
-
 
1525
		}
-
 
1526
	}
1495
}
1527
}
1496
1528