Subversion Repositories SmartDukaan

Rev

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

Rev 17402 Rev 17459
Line 300... Line 300...
300
		$pendingCashbacks = $this->make_request($url,null);
300
		$pendingCashbacks = $this->make_request($url,null);
301
		//Get credited cashbacks
301
		//Get credited cashbacks
302
		$url = $this->apihost.'refund/user/'.$userId;
302
		$url = $this->apihost.'refund/user/'.$userId;
303
		$creditedCashbacks = $this->make_request($url,null);
303
		$creditedCashbacks = $this->make_request($url,null);
304
 
304
 
305
		// if(!empty($creditedCashbacks)){
-
 
306
		// 	foreach ($creditedCashbacks['data'] as $key => $value) {
-
 
307
		// 		$creditedAmount += $value['userAmount'];				
-
 
308
		// 		$data = array('subOrders.batchId'=>$value['batch']);
-
 
309
		// 		$jsonVar = json_encode($data);
-
 
310
		// 		$url = $this->apihost."storeorder/user/".$userId."?page=1&window=50&searchMap=$jsonVar";
-
 
311
		// 		$creditedOrders[$value['batch']] = $this->make_request($url,null);
-
 
312
		// 		// debug($creditedOrders);
-
 
313
		// 	}
-
 
314
		// }
-
 
315
 
-
 
316
		$creditKeyArray = array();
305
		$creditKeyArray = array();
317
		$creditValueArray = array();
306
		$creditValueArray = array();
318
		$total_credited_amount = 0;
307
		$total_credited_amount = 0;
319
		if(!empty($creditedCashbacks)){
308
		if(!empty($creditedCashbacks)){
320
			foreach ($creditedCashbacks['data'] as $key => $value) {
309
			foreach ($creditedCashbacks['data'] as $key => $value) {
321
				$creditedAmount += $value['userAmount'];				
310
				$creditedAmount += $value['userAmount'];				
322
				$data = array('subOrders.batchId'=>$value['batch']);
311
				$data = array('subOrders.batchId'=>$value['batch']);
323
				$jsonVar = json_encode($data);
312
				$jsonVar = json_encode($data);
324
				$url = $this->apihost."storeorder/user/".$this->Auth->User('id')."?page=1&window=50&searchMap=$jsonVar";
313
				$url = $this->apihost."storeorder/user/".$userId."?page=1&window=50&searchMap=$jsonVar";
325
				$creditedOrders[$value['batch']] = $this->make_request($url,null);
314
				$creditedOrders[$value['batch']] = $this->make_request($url,null);
326
				$total_credited_amount =$total_credited_amount + $value['userAmount'];
315
				$total_credited_amount =$total_credited_amount + $value['userAmount'];
327
				if($value['type']== 'Order')
316
				if($value['type']== 'Order')
328
				{
317
				{
329
					$creditValueArray['amount'] = $value['userAmount'];
318
					$creditValueArray['amount'] = $value['userAmount'];
Line 337... Line 326...
337
			}
326
			}
338
		}
327
		}
339
 
328
 
340
		$storemapping = Configure::read('storemapping');
329
		$storemapping = Configure::read('storemapping');
341
		$activestores = Configure::read('activestores');
330
		$activestores = Configure::read('activestores');
342
 
-
 
343
	// App Credit Start
331
		//App related cashbacks
344
		$creditedFortnight = array();
332
		$this->loadModel('UserAppCashback');
345
		$url = $this->apihost.'appUserCashBack/'.$userId.'/Credited';
333
		$this->loadModel('UserAppInstall');
346
		$getcredited = $this->make_request($url,null);
334
		//Compute last two fortnight ids
347
		// debug($getcredited);
335
		$fortnightIds = array();
348
		foreach ($getcredited['UserAppCashBack'] as $key => $value) {
336
		if(date('d',time())<=15){
349
 
-
 
350
 
-
 
351
 
-
 
352
			$url = $this->apihost.'appUserBatchDrillDown/'.$userId.'/'.$value['fortnightOfYear'].'/'.$value['yearVal'];
-
 
353
			$creditedFortnight[$value['fortnightOfYear']] = $this->make_request($url,null);
-
 
354
 
-
 
355
			$creditValueArray['amount'] = $value['amount'];
337
			$fortnightIds[] = 2*(date('m',time())-1)-1;
356
			// $total_credited_amount = $total_credited_amount + $value['amount'];
338
			$fortnightIds[] = 2*(date('m',time())-1);
357
			$creditValueArray['type'] = 'App';
339
		}else{
358
			$creditValueArray['fortbatchid'] = $value['fortnightOfYear'];
-
 
359
			$creditValueArray['creditedDate'] = $value['creditedDate'];
340
			$fortnightIds[] = 2*(date('m',time())-1);
360
			$creditKeyArray[$value['creditedDate'].'App'] = $creditValueArray;
-
 
361
			// echo "total credit",$total_credited_amount;
341
			$fortnightIds[] = 2*(date('m',time())-1)+1;
362
			// echo $url;
-
 
363
		}
342
		}
364
		
-
 
365
		ksort($creditKeyArray);
343
		$cashBacks = array();
366
		// debug($creditKeyArray);
-
 
367
		$this->set(compact('getcredited','creditedFortnight','creditKeyArray','total_credited_amount'));
-
 
368
		// debug($creditedFortnight);
-
 
369
	// App Credit End
-
 
370
 
344
 
371
		// Approved Start
345
		// Approved Start
372
 
346
 
373
		$url = $this->apihost.'appUserCashBack/'.$userId.'/Approved';
347
		$url = $this->apihost.'appUserCashBack/'.$userId.'/Approved';
374
		$getapproved = $this->make_request($url,null);
348
		$getapproved = $this->make_request($url,null);
Line 392... Line 366...
392
		}
366
		}
393
		// debug($approvedFortnight);
367
		// debug($approvedFortnight);
394
		$this->set(compact('fortnight','total_approved_amount','fortnight_amount','approvedFortnight'));		
368
		$this->set(compact('fortnight','total_approved_amount','fortnight_amount','approvedFortnight'));		
395
	// Approved End	
369
	// Approved End	
396
 
370
 
-
 
371
	// App Credit Start
-
 
372
		$creditedFortnight = array();
-
 
373
		$url = $this->apihost.'appUserCashBack/'.$userId.'/Credited';
-
 
374
		$getcredited = $this->make_request($url,null);
397
		if(!empty($response['data'])){
375
		// debug($getcredited);
-
 
376
		foreach ($getcredited['UserAppCashBack'] as $key => $value) {
-
 
377
 
-
 
378
 
-
 
379
 
398
			$this->set(compact('storemapping','activestores','pendingOrders','approvedOrders','creditedOrders','pendingCashbacks','creditedCashbacks','pendingAmount','approvedAmount','creditedAmount'));
380
			$url = $this->apihost.'appUserBatchDrillDown/'.$userId.'/'.$value['fortnightOfYear'].'/'.$value['yearVal'];
-
 
381
			$creditedFortnight[$value['fortnightOfYear']] = $this->make_request($url,null);
-
 
382
 
-
 
383
			$creditValueArray['amount'] = $value['amount'];
-
 
384
			// $total_credited_amount = $total_credited_amount + $value['amount'];
-
 
385
			$creditValueArray['type'] = 'App';
-
 
386
			$creditValueArray['fortbatchid'] = $value['fortnightOfYear'];
-
 
387
			$creditValueArray['creditedDate'] = $value['creditedDate'];
-
 
388
			$creditKeyArray[$value['creditedDate'].'App'] = $creditValueArray;
-
 
389
			// echo "total credit",$total_credited_amount;
-
 
390
			// echo $url;
399
		}
391
		}
-
 
392
		
-
 
393
		ksort($creditKeyArray);
-
 
394
		$this->set(compact('getcredited','creditedFortnight','creditKeyArray','total_credited_amount', 'creditedOrders'));
-
 
395
 
400
	}
396
	}
401
 
397
 
402
/*
398
/*
403
	public function index() {
399
	public function index() {
404
		throw new NotFoundException(__('Access Denied'));
400
		throw new NotFoundException(__('Access Denied'));
Line 708... Line 704...
708
			$users[$user['User']['id']] = $user['User']['first_name'];
704
			$users[$user['User']['id']] = $user['User']['first_name'];
709
		}
705
		}
710
		$this->layout = 'admin';
706
		$this->layout = 'admin';
711
		$this->set(compact('ignoredFields','page','totalPages','userId','activestores','storemapping','amazonorderurl','users', 'orderFilters', 'filter', 'apihost'));
707
		$this->set(compact('ignoredFields','page','totalPages','userId','activestores','storemapping','amazonorderurl','users', 'orderFilters', 'filter', 'apihost'));
712
	}
708
	}
713
}
709
}
714
710