Rev 17838 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?phpApp::uses('AppController', 'Controller');/*** Exceptionalnlcs Controller** @property Exceptionalnlc $Exceptionalnlc* @property PaginatorComponent $Paginator*/class ShippingsController extends AppController {/*** Components** @var array*/public $components = array('Paginator');public function beforeFilter() {parent::beforeFilter();// Configure::load('live');$this->apihost = Configure::read('pythonapihost');$this->mobileapihost = Configure::read('saholicapihost');}public function index(){$userId = $this->Auth->User('id');if ($this->request->is('post')) {$data = $this->request->data;// debug($data);}$this->layout = 'innerpages';$url = 'http://shop2020.in:8080/mobileapi/address?userId=41&isLoggedIn=true';// $url = $this->mobileapihost."address?userId=41&isLoggedIn=true";// echo $url;$response = $this->make_request($url,null);// debug($response);if(empty($response['addresses'])){$this->redirect(array('action' => 'add'));}$firstshowaddress = array();$findedaddress = array();$moreshowaddress = array();$current_address_id = -1;$defaultpin = -1;$defaultcookiepin = -1;foreach ($response['addresses'] as $key => $value) {// debug($value['']);if($value['id'] == intval($response['defaultAddress']) && $value['pin']== 201302){$defaultcookiepin = $key;}else if($value['pin']== 123456){$current_address_id = $key;array_push($findedaddress,$key);}else if($value['id'] == intval($response['defaultAddress'])){$defaultpin = $key;}else{array_push($moreshowaddress,$key);}}if($defaultcookiepin != -1){array_push($firstshowaddress,$defaultcookiepin);}for($i= 0; $i<count($findedaddress);$i++){array_push($firstshowaddress,$findedaddress[$i]);}if($defaultpin != -1){array_push($firstshowaddress,$defaultpin);}for($i= 0; $i<count($moreshowaddress);$i++){array_push($firstshowaddress,$moreshowaddress[$i]);}if($current_address_id == -1){foreach ($response['addresses'] as $key => $value) {// debug($value['']);if($value['id']== $response['defaultAddress']){$current_address_id = $key;break;}}}debug($firstshowaddress);$this->set('address', $response);$this->set('current_address_id', $current_address_id);$this->set(compact('firstshowaddress'));}public function add() {$this->layout = 'innerpages';$pinval = 232104;setcookie('pin', $pinval, -1, '/');$nameval = "Supermans";setcookie('name', $nameval, -1, '/');if ($this->request->is('post')) {$data = $this->request->data;if($data['name'] == ""){$senddata['name'] = $_COOKIE['name'];}else{$senddata['name'] = $data['name'];}$senddata['line1'] = $data['line1'];$senddata['line2'] = "";$senddata['city'] = $data['city'];$senddata['state'] = $data['state'];if($data['pin'] == ""){$senddata['pin'] = $_COOKIE['pin'];}else{$senddata['pin'] = $data['pin'];}$senddata['phone'] = $data['phone'];$senddata['country'] = 'India';// debug($senddata);$url = "http://shop2020.in:8080/mobileapi/address?userId=41&isLoggedIn=true&cartId=41&isPrivateDealUser=true";$response = $this->post_request($url,$senddata);// debug($response);$this->redirect(array('action' => 'index'));// $data = $this->request->data['Objects'];// $data['template_id'] = 1;// // debug(json_encode($data,JSON_NUMERIC_CHECK));// $url = $this->apihost."addDealObject";// $response = $this->make_request($url,json_encode($data,JSON_NUMERIC_CHECK));// // debug($response);// if (key($response)) {// $this->Session->setFlash(current($response));// return $this->redirect(array('action' => 'index'));// } else {// $this->Session->setFlash(current($response));// }}// debug($_COOKIE['pin']);$url = "http://dtr:8057/pincodeValidation/".$_COOKIE['pin'];$getstate =$this->make_request($url , null);$getstateval = "";if($getstate != "{}"){$getstateval =ucwords(strtolower($getstate['state']));}// debug($getstate);// debug($getstateval);// $getpin = ;$this->set(compact('getstateval'));}public function change(){$this->layout = 'innerpages';if($this->request->is('post')){echo "Hello";}}public function isServicable($pin){$this->autoRender = false;$this->request->onlyAllow('ajax');// $url = "http://shop2020.in:8080/mobileapi/address!serviceable?pincode=".$pin;// $response = $this->make_request($url,null);if($pin == 110096){$res = 'false';}else{$res = 'true';}return $res;}}