Subversion Repositories SmartDukaan

Rev

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

Rev 17110 Rev 17201
Line 283... Line 283...
283
		$pendingCashbacks = $this->make_request($url,null);
283
		$pendingCashbacks = $this->make_request($url,null);
284
		//Get credited cashbacks
284
		//Get credited cashbacks
285
		$url = $this->apihost.'refund/user/'.$userId;
285
		$url = $this->apihost.'refund/user/'.$userId;
286
		$creditedCashbacks = $this->make_request($url,null);
286
		$creditedCashbacks = $this->make_request($url,null);
287
 
287
 
-
 
288
		// if(!empty($creditedCashbacks)){
-
 
289
		// 	foreach ($creditedCashbacks['data'] as $key => $value) {
-
 
290
		// 		$creditedAmount += $value['userAmount'];				
-
 
291
		// 		$data = array('subOrders.batchId'=>$value['batch']);
-
 
292
		// 		$jsonVar = json_encode($data);
-
 
293
		// 		$url = $this->apihost."storeorder/user/".$userId."?page=1&window=50&searchMap=$jsonVar";
-
 
294
		// 		$creditedOrders[$value['batch']] = $this->make_request($url,null);
-
 
295
		// 		// debug($creditedOrders);
-
 
296
		// 	}
-
 
297
		// }
-
 
298
 
-
 
299
		$creditKeyArray = array();
-
 
300
		$creditValueArray = array();
-
 
301
		$total_credited_amount = 0;
288
		if(!empty($creditedCashbacks)){
302
		if(!empty($creditedCashbacks)){
289
			foreach ($creditedCashbacks['data'] as $key => $value) {
303
			foreach ($creditedCashbacks['data'] as $key => $value) {
290
				$creditedAmount += $value['userAmount'];				
304
				$creditedAmount += $value['userAmount'];				
291
				$data = array('subOrders.batchId'=>$value['batch']);
305
				$data = array('subOrders.batchId'=>$value['batch']);
292
				$jsonVar = json_encode($data);
306
				$jsonVar = json_encode($data);
293
				$url = $this->apihost."storeorder/user/".$userId."?page=1&window=50&searchMap=$jsonVar";
307
				$url = $this->apihost."storeorder/user/".$this->Auth->User('id')."?page=1&window=50&searchMap=$jsonVar";
294
				$creditedOrders[$value['batch']] = $this->make_request($url,null);
308
				$creditedOrders[$value['batch']] = $this->make_request($url,null);
-
 
309
				$total_credited_amount =$total_credited_amount + $value['userAmount'];
295
				// debug($creditedOrders);
310
				if($value['type']== 'Order')
-
 
311
				{
-
 
312
					$creditValueArray['amount'] = $value['userAmount'];
-
 
313
					$creditValueArray['type'] = $value['type'];
-
 
314
					$creditValueArray['fortbatchid'] = $value['batch'];
-
 
315
					$creditValueArray['creditedDate'] = date('Y-m-d',strtotime($value['timestamp']));
-
 
316
					// $creditKeyArray[date('Y-m-d',strtotime($value['timestamp']))] = $creditValueArray;
-
 
317
					$creditKeyArray[date('Y-m-d',strtotime($value['timestamp'])).$value['type']] = $creditValueArray;
-
 
318
				}
-
 
319
				
296
			}
320
			}
297
		}
321
		}
-
 
322
 
298
		$storemapping = Configure::read('storemapping');
323
		$storemapping = Configure::read('storemapping');
299
		$activestores = Configure::read('activestores');
324
		$activestores = Configure::read('activestores');
-
 
325
 
-
 
326
	// App Credit Start
-
 
327
		$creditedFortnight = array();
-
 
328
		$url = $this->apihost.'appUserCashBack/'.$userId.'/Credited';
-
 
329
		$getcredited = $this->make_request($url,null);
-
 
330
		// debug($getcredited);
-
 
331
		foreach ($getcredited['UserAppCashBack'] as $key => $value) {
-
 
332
 
-
 
333
 
-
 
334
 
-
 
335
			$url = $this->apihost.'appUserBatchDrillDown/'.$userId.'/'.$value['fortnightOfYear'].'/'.$value['yearVal'];
-
 
336
			$creditedFortnight[$value['fortnightOfYear']] = $this->make_request($url,null);
-
 
337
 
-
 
338
			$creditValueArray['amount'] = $value['amount'];
-
 
339
			// $total_credited_amount = $total_credited_amount + $value['amount'];
-
 
340
			$creditValueArray['type'] = 'App';
-
 
341
			$creditValueArray['fortbatchid'] = $value['fortnightOfYear'];
-
 
342
			$creditValueArray['creditedDate'] = $value['creditedDate'];
-
 
343
			$creditKeyArray[$value['creditedDate'].'App'] = $creditValueArray;
-
 
344
			// echo "total credit",$total_credited_amount;
-
 
345
			// echo $url;
-
 
346
		}
-
 
347
		
-
 
348
		ksort($creditKeyArray);
-
 
349
		// debug($creditKeyArray);
-
 
350
		$this->set(compact('getcredited','creditedFortnight','creditKeyArray','total_credited_amount'));
-
 
351
		// debug($creditedFortnight);
-
 
352
	// App Credit End
300
		if(!empty($response['data'])){
353
		if(!empty($response['data'])){
301
			$this->set(compact('storemapping','activestores','pendingOrders','approvedOrders','creditedOrders','pendingCashbacks','creditedCashbacks','pendingAmount','approvedAmount','creditedAmount'));
354
			$this->set(compact('storemapping','activestores','pendingOrders','approvedOrders','creditedOrders','pendingCashbacks','creditedCashbacks','pendingAmount','approvedAmount','creditedAmount'));
302
		}
355
		}
303
	}
356
	}
304
 
357