| Line 535... |
Line 535... |
| 535 |
// Close connection
|
535 |
// Close connection
|
| 536 |
curl_close($ch);
|
536 |
curl_close($ch);
|
| 537 |
$this->log("For $user_id ".$registatoin_ids[0]." ".print_r($result,1),'pushnotifications');
|
537 |
$this->log("For $user_id ".$registatoin_ids[0]." ".print_r($result,1),'pushnotifications');
|
| 538 |
}
|
538 |
}
|
| 539 |
|
539 |
|
| 540 |
public function admin_index() {
|
540 |
public function admin_index() {
|
| 541 |
$this->User->recursive = 0;
|
541 |
$this->User->recursive = 0;
|
| 542 |
$options = array('limit'=>100,'order'=>array('id'=>'desc'));
|
542 |
$options = array('limit'=>100,'order'=>array('id'=>'desc'));
|
| 543 |
$this->Paginator->settings = $options;
|
543 |
$this->Paginator->settings = $options;
|
| 544 |
$users = $this->Paginator->paginate();
|
544 |
$users = $this->Paginator->paginate();
|
| - |
|
545 |
|
| 545 |
$groups = $this->User->Group->find('list');
|
546 |
$groups = $this->User->Group->find('list');
|
| - |
|
547 |
|
| - |
|
548 |
$postOfficeQuery="select pincode,state from postoffices group by pincode";
|
| - |
|
549 |
$postOfficeResult=$this->User->query($postOfficeQuery);
|
| - |
|
550 |
$postOffice=array();
|
| - |
|
551 |
foreach($postOfficeResult as $value){
|
| - |
|
552 |
$postOffice[$value['postoffices']['pincode']]=$value['postoffices']['state'];
|
| - |
|
553 |
}
|
| - |
|
554 |
foreach ($users as $key => $value) {
|
| - |
|
555 |
$userId=$value['User']['id'];
|
| - |
|
556 |
$retailerLinksQuery="select r.city,r.state,r.pin from retaileraddresses r join retailerlinks rl on r.retailer_id=rl.retailer_id where rl.user_id=$userId";
|
| - |
|
557 |
$retailerAddress=$this->User->query($retailerLinksQuery);
|
| - |
|
558 |
if(empty($retailerAddress)){
|
| - |
|
559 |
$directRetailerAddress="select r.city,r.state,r.pin from retailers r join retailerlinks rl on r.id=rl.retailer_id where rl.user_id=$userId";
|
| - |
|
560 |
$retailerDirectAddress=$this->User->query($directRetailerAddress);
|
| - |
|
561 |
if(empty($retailerDirectAddress)){
|
| - |
|
562 |
$userAddressQuery="select ua.city,ua.state,ua.pincode from useraddresses ua join users u on ua.user_id=u.id where ua.user_id=$userId";
|
| - |
|
563 |
$userUpdateAddress=$this->User->query($userAddressQuery);
|
| - |
|
564 |
if(empty($userUpdateAddress)){
|
| - |
|
565 |
$userQuery="select city,state,pincode from users where id=$userId and pincode is not null";
|
| - |
|
566 |
$myProfileAddress=$this->User->query($userQuery);
|
| 546 |
$this->set(compact('groups','users'));
|
567 |
if(empty($myProfileAddress)){
|
| - |
|
568 |
|
| - |
|
569 |
}else{
|
| - |
|
570 |
if(empty($myProfileAddress[0]['users']['state'])){
|
| - |
|
571 |
$users[$key]['User']['state']=$postOffice[$myProfileAddress[0]['users']['pincode']];
|
| - |
|
572 |
}
|
| - |
|
573 |
else{
|
| - |
|
574 |
}
|
| - |
|
575 |
}
|
| - |
|
576 |
}
|
| - |
|
577 |
else{
|
| - |
|
578 |
$users[$key]['User']['city']=$userUpdateAddress[0]['ua']['city'];
|
| - |
|
579 |
if(!(isset($userUpdateAddress[0]['ua']['state']))||empty($userUpdateAddress[0]['ua']['state'])){
|
| - |
|
580 |
$users[$key]['User']['state']=$postOffice[$retailerAddress[0]['r']['pincode']];
|
| - |
|
581 |
}else{
|
| - |
|
582 |
$users[$key]['User']['state']=$userUpdateAddress[0]['ua']['state'];
|
| - |
|
583 |
}
|
| - |
|
584 |
}
|
| - |
|
585 |
}
|
| - |
|
586 |
else{
|
| - |
|
587 |
$users[$key]['User']['city']=$retailerDirectAddress[0]['r']['city'];
|
| - |
|
588 |
if(!(isset($retailerDirectAddress[0]['r']['state']))||empty($retailerDirectAddress[0]['r']['state'])){
|
| - |
|
589 |
$users[$key]['User']['state']=$postOffice[$retailerDirectAddress[0]['r']['pincode']];
|
| - |
|
590 |
}else{
|
| - |
|
591 |
$users[$key]['User']['state']=$retailerDirectAddress[0]['r']['state'];
|
| - |
|
592 |
}
|
| - |
|
593 |
}
|
| - |
|
594 |
}else{
|
| - |
|
595 |
$users[$key]['User']['city']=$retailerAddress[0]['r']['city'];
|
| - |
|
596 |
if(!(isset($retailerAddress[0]['r']['state']))||empty($retailerAddress[0]['r']['state'])){
|
| - |
|
597 |
$users[$key]['User']['state']=$postOffice[$retailerAddress[0]['r']['pincode']];
|
| - |
|
598 |
}else{
|
| - |
|
599 |
$users[$key]['User']['state']=$retailerAddress[0]['r']['state'];
|
| - |
|
600 |
}
|
| 547 |
}
|
601 |
}
|
| - |
|
602 |
}
|
| - |
|
603 |
|
| - |
|
604 |
$this->set(compact('groups','users'));
|
| - |
|
605 |
}
|
| 548 |
|
606 |
|
| 549 |
/**
|
607 |
/**
|
| 550 |
* admin_view method
|
608 |
* admin_view method
|
| 551 |
*
|
609 |
*
|
| 552 |
* @throws NotFoundException
|
610 |
* @throws NotFoundException
|