| Line 127... |
Line 127... |
| 127 |
// debug($creditedOrders);
|
127 |
// debug($creditedOrders);
|
| 128 |
}
|
128 |
}
|
| 129 |
}
|
129 |
}
|
| 130 |
$storemapping = Configure::read('storemapping');
|
130 |
$storemapping = Configure::read('storemapping');
|
| 131 |
$activestores = Configure::read('activestores');
|
131 |
$activestores = Configure::read('activestores');
|
| - |
|
132 |
//App related cashbacks
|
| - |
|
133 |
$this->loadModel('UserAppCashback');
|
| - |
|
134 |
$this->loadModel('UserAppInstall');
|
| - |
|
135 |
//Compute last two fortnight ids
|
| - |
|
136 |
$fortnightIds = array();
|
| - |
|
137 |
if(date('d',time())<=15){
|
| - |
|
138 |
$fortnightIds[] = 2*(date('m',time())-1)+1;
|
| - |
|
139 |
}else{
|
| - |
|
140 |
$fortnightIds[] = 2*(date('m',time())-1)+1;
|
| - |
|
141 |
$fortnightIds[] = 2*(date('m',time())-1)+2;
|
| - |
|
142 |
}
|
| - |
|
143 |
$cashBacks = array();
|
| - |
|
144 |
foreach ($fortnightIds AS $fortnightId){
|
| - |
|
145 |
$options = array('conditions'=>array('fortnightOfYear'=>$fortnightId,'user_id'=>$this->Auth->User('id')),'fields'=>array('status','amount'));
|
| - |
|
146 |
$temp = $this->UserAppCashback->find('first',$options);
|
| - |
|
147 |
$cashBacks[$temp['UserAppCashback']['status']]['amount'] = $temp['UserAppCashback']['amount'];
|
| - |
|
148 |
$options = array('conditions'=>array('fortnightOfYear'=>$fortnightId,'user_id'=>$this->Auth->User('id')),'fields'=>array('sum(payoutAmount) AS amount','sum(installCount) AS installs','transaction_date'),'group'=>'transaction_date');
|
| - |
|
149 |
$installs = $this->UserAppInstall->find('all',$options);
|
| - |
|
150 |
if(!empty($installs)){
|
| - |
|
151 |
foreach ($installs as $key => $value) {
|
| - |
|
152 |
$appInstalls[$value['UserAppInstall']['transaction_date']] = $value[0];
|
| - |
|
153 |
}
|
| - |
|
154 |
$cashBacks[$temp['UserAppCashback']['status']]['installs'] = $appInstalls;
|
| - |
|
155 |
}
|
| - |
|
156 |
}
|
| 132 |
if(!empty($response['data'])){
|
157 |
if(!empty($response['data'])){
|
| 133 |
$this->set(compact('storemapping','activestores','pendingOrders','approvedOrders','creditedOrders','pendingCashbacks','creditedCashbacks','pendingAmount','approvedAmount','creditedAmount'));
|
158 |
$this->set(compact('storemapping','activestores','pendingOrders','approvedOrders','creditedOrders','pendingCashbacks','creditedCashbacks','pendingAmount','approvedAmount','creditedAmount','cashBacks'));
|
| 134 |
}
|
159 |
}
|
| 135 |
}
|
160 |
}
|
| 136 |
|
161 |
|
| 137 |
public function usercashbacks($userId) {
|
162 |
public function usercashbacks($userId) {
|
| 138 |
$this->layout = "innerpages";
|
163 |
$this->layout = "innerpages";
|