Subversion Repositories SmartDukaan

Rev

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

Rev 16873 Rev 16911
Line 586... Line 586...
586
	}	
586
	}	
587
	$this->set('appTransactions', $approvedCounts);
587
	$this->set('appTransactions', $approvedCounts);
588
	$this->set('totalClicks', $totalClicks);
588
	$this->set('totalClicks', $totalClicks);
589
	$this->set('totalApproved', $totalApproved);
589
	$this->set('totalApproved', $totalApproved);
590
	}
590
	}
-
 
591
 
-
 
592
	public function admin_user($retailer_id=null){
-
 
593
	
-
 
594
	$this->Paginator->settings = array(
-
 
595
    	'fields' => array('AppTransaction.app_id','retailer_id','app_name','transaction_time','count(*) as count'),
-
 
596
    	'conditions' => array('retailer_id'=>$retailer_id),
-
 
597
    	'group' => 'app_id',
-
 
598
    	'order' => 'count desc'
-
 
599
    	);
-
 
600
	$approvedCounts =  $this->Paginator->paginate();
-
 
601
  	$sql="SELECT app_id,count(1) from app_transactions where payout_description='Approved' and retailer_id=$retailer_id group by app_id ";
-
 
602
  	$approved = $this->AppTransaction->query($sql);
-
 
603
  	foreach ($approved as $key => $value1) {
-
 
604
  		$app_id=$value1['app_transactions']['app_id'];
-
 
605
  		$value22=$value1['0']['count(1)'];
-
 
606
  		foreach ($approvedCounts as $key2 => $value) {
-
 
607
			if($app_id==$value['AppTransaction']['app_id']){
-
 
608
			 	$approvedCounts[$key2]['AppTransaction']['approved'] = $value22;
-
 
609
			 	$approvedCounts[$key2]['AppTransaction']['conversion_percentage']=ceil(($value22/$value[0]['count'])*100);
-
 
610
			}
-
 
611
		}
-
 
612
	}
-
 
613
	$url=$_SERVER['REQUEST_URI'];
-
 
614
	if (strpos($url,'sort') == false) {
-
 
615
    	
-
 
616
	}else{
-
 
617
	$new1=explode("/sort:", $url);
-
 
618
	$new2=explode("/direction:", $new1[1]);
-
 
619
	$new2=explode("/direction:", $new1[1]);
-
 
620
	$sortType=$new2[0];
-
 
621
	if (strpos($new2[1],'page') == false) {
-
 
622
		$sortDirection=$new2[1];
-
 
623
	}else{
-
 
624
		$new3=explode("/page:", $new2[1]);
-
 
625
		$sortDirection=$new3[0];
-
 
626
	}
-
 
627
	if (strpos($new2[1],'date') == false) {
-
 
628
		$sortDirection=$new2[1];
-
 
629
	}else{
-
 
630
		$new3=explode("?date", $new2[1]);
-
 
631
		$sortDirection=$new3[0];
-
 
632
	}
-
 
633
	if($sortType=='approved' && $sortDirection=='desc'){
-
 
634
		$newApprovedCount = array();
-
 
635
		foreach ($approvedCounts as $key => $row)
-
 
636
		{
-
 
637
			if(!(isset($row['AppTransaction']['approved']))){
-
 
638
			$newApprovedCount[$key]['AppTransaction']['approved']=0;	
-
 
639
			}else{
-
 
640
		    $newApprovedCount[$key]['AppTransaction']['approved'] = $row['AppTransaction']['approved'];
-
 
641
		    }
-
 
642
		}
-
 
643
		array_multisort($newApprovedCount, SORT_DESC, $approvedCounts);
-
 
644
	}
-
 
645
	else if($sortType=='approved' && $sortDirection=='asc'){
-
 
646
			$newApprovedCount = array();
-
 
647
			foreach ($approvedCounts as $key => $row)
-
 
648
			{
-
 
649
				if(!(isset($row['AppTransaction']['approved']))){
-
 
650
				$newApprovedCount[$key]['AppTransaction']['approved']=0;	
-
 
651
				}else{
-
 
652
			    $newApprovedCount[$key]['AppTransaction']['approved'] = $row['AppTransaction']['approved'];
-
 
653
			    }
-
 
654
			}
-
 
655
			array_multisort($newApprovedCount, SORT_ASC, $approvedCounts);
-
 
656
	}
-
 
657
	else if($sortType=='conversion_percentage' && $sortDirection=='desc'){
-
 
658
		$newApprovedCount = array();
-
 
659
		foreach ($approvedCounts as $key => $row)
-
 
660
		{
-
 
661
			if(!(isset($row['AppTransaction']['conversion_percentage']))){
-
 
662
			$newApprovedCount[$key]['AppTransaction']['conversion_percentage']=0;	
-
 
663
			}else{
-
 
664
		    $newApprovedCount[$key]['AppTransaction']['conversion_percentage'] = $row['AppTransaction']['conversion_percentage'];
-
 
665
		    }
-
 
666
		}
-
 
667
		array_multisort($newApprovedCount, SORT_DESC, $approvedCounts);
-
 
668
	}
-
 
669
	else if($sortType=='conversion_percentage' && $sortDirection=='asc'){
-
 
670
		$newApprovedCount = array();
-
 
671
		foreach ($approvedCounts as $key => $row)
-
 
672
		{
-
 
673
			if(!(isset($row['AppTransaction']['conversion_percentage']))){
-
 
674
			$newApprovedCount[$key]['AppTransaction']['conversion_percentage']=0;	
-
 
675
			}else{
-
 
676
		    $newApprovedCount[$key]['AppTransaction']['conversion_percentage'] = $row['AppTransaction']['conversion_percentage'];
-
 
677
		    }
-
 
678
		}
-
 
679
		array_multisort($newApprovedCount, SORT_ASC, $approvedCounts);
-
 
680
	}
-
 
681
	else if($sortType=='clicks'&& $sortDirection=='asc'){
-
 
682
		$newApprovedCount = array();
-
 
683
		foreach ($approvedCounts as $key => $row){
-
 
684
		    $newApprovedCount[$key][0]['count'] = $row[0]['count'];
-
 
685
		}
-
 
686
		array_multisort($newApprovedCount, SORT_ASC, $approvedCounts);
-
 
687
	}
-
 
688
	else if($sortType=='clicks'&& $sortDirection=='desc'){
-
 
689
		$newApprovedCount = array();
-
 
690
		foreach ($approvedCounts as $key => $row){
-
 
691
		    $newApprovedCount[$key][0]['count'] = $row[0]['count'];
-
 
692
			}
-
 
693
		array_multisort($newApprovedCount, SORT_DESC, $approvedCounts);
-
 
694
		}
-
 
695
	}	
-
 
696
	$this->set('retailerId',$retailer_id)	;
-
 
697
	$this->set('appTransactions',$approvedCounts)	;
-
 
698
	}
591
}
699
}
592
 
700
 
593
 
701
 
594
 
702