Ejemplo n.º 1
0
 public function send_notification($id = null, $data = null)
 {
     $apiKey = "AIzaSyAOcNSrmgeUJzgL7NMB4lz5uhfI6F5yeOA";
     configure::write('debug', 2);
     // Replace with real client registration IDs
     //        $id=145;
     //        $user_id=26;
     $registrationIDs = array($id);
     // Message to be sent
     // $message = "user_id:".$user_id."user_name:".$name;
     //        $data='{"type":"'.$type.'","id":"'.$user_id.'"}';
     //        $message = array("price" => $user_id . "/" . $name);
     $message = array("price" => $data);
     // Set POST variables
     $url = 'https://android.googleapis.com/gcm/send';
     $fields = array('registration_ids' => $registrationIDs, 'data' => $message);
     $headers = array('Authorization: key=' . $apiKey, 'Content-Type: application/json');
     // Open connection
     $ch = curl_init();
     // Set the url, number of POST vars, POST data
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     //curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $fields ) );
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     //     curl_setopt($ch, CURLOPT_POST, true);
     //     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
     // Execute post
     $result = curl_exec($ch);
     // Close connection
     return $result;
 }
Ejemplo n.º 2
0
 public function add_eventhost()
 {
     configure::write('debug', 2);
     $this->layout = "ajax";
     $this->loadModel('Users');
     if ($this->request->is('post')) {
         $this->request->data['Eventhost']['status'] = '0';
         $this->Eventhost->create();
         if ($this->Eventhost->save($this->request->data)) {
             $response['msg'] = "Success";
             $response['error'] = "0";
         } else {
             $response['msg'] = "Failed";
             $response['error'] = "1";
         }
     }
     $this->set('response', $response);
     $this->render("ajax");
 }
 public function sendGoogleCloudMessage($message = null, $diviceid = null)
 {
     $apiKey = "AIzaSyC6wrulbEusWoqm5m4e4siK8Gzw_YNDZFY";
     configure::write('debug', 2);
     $registrationIDs[] = $diviceid;
     $message = array("price" => $message);
     $url = 'https://android.googleapis.com/gcm/send';
     $fields = array('registration_ids' => $registrationIDs, 'data' => $message);
     $headers = array('Authorization: key=' . $apiKey, 'Content-Type: application/json');
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
     $result = curl_exec($ch);
     curl_close($ch);
     debug($result);
     return $result;
 }
 public function api_view($id = null)
 {
     configure::write('debug', 2);
     if (!$this->Vendor->exists($id)) {
         throw new NotFoundException(__('Invalid vendor'));
     }
     $options = array('recursive' => 3, 'contain' => array('Combination' => array('fields' => array('id', 'vendor_id', 'display_name', 'image', 'price', 'date', 'ratings'), 'conditions' => array("DATE(Combination.date)" => date("Y-m-d")))), 'conditions' => array('Vendor.' . $this->Vendor->primaryKey => $id));
     //$this->Vender->virtualFields['rating'] = 'SUM(`VendorReview`.`ratings`) / COUNT(`VendorReview`.`ratings`) * 5';
     $allRecords = $this->Vendor->find('first', $options);
     //                foreach($allRecords['Combination'] as $feedbacks){
     //                    $this->loadModel('Feedback');
     //                    $feedbackVal = $this->Feedback->find('all',array('conditions'=>array(
     //                        "AND"=>array(
     //                            "Feedback.vender_id" => $id,
     //                            "Feedback.combination_name" => $feedbacks['display_name']
     //                        )
     //                    )));
     //                    $aa = 0;
     //                    $bb = 0;
     //                    $count = 0;
     //                    foreach ($feedbackVal as $avgrate){
     //                        $count++;
     //                        $bb = $aa + $avgrate['Feedback']['rating'];
     //                        $aa = $bb;
     //                    }
     //                    if($aa!=0 && $count!=0){
     //                        $avgr = $aa/$count;
     //                        $feedbacks['avgrate'] = $avgr;
     //                    }else{
     //                        $feedbacks['avgrate'] = '0';
     //                    }
     //                    $allRecord1[] = $feedbacks;
     //                }
     //                $allRecords['Combination'] = $allRecord1;
     $this->set(array('data' => $allRecords, '_serialize' => array('data')));
 }
 public function pdfTrabajo($id = null)
 {
     configure::write('debug', 2);
     $this->set('trabajos', $this->Maquinaria->find('first', array('conditions' => array('Maquinaria.id' => $id), 'recursive' => 2)));
 }
 public function client()
 {
     if ($this->RequestHandler->isAjax()) {
         configure::write('debug', 0);
         $this->layout = 'kabinet';
         // uses an empty layout
         $this->autoRender = false;
         // renders nothing by default
     }
     $this->layout = 'kabinet';
     $this->loadModel('Usermgmt.User');
     $this->loadModel('Usermgmt.UserDetail');
     $userId = $this->UserAuth->getUserId();
     $this->set('user', $userId);
     $detail = $this->UserDetail->Find('list', array('conditions' => array('UserDetail.user_id' => $userId), 'fields' => array('UserDetail.id')));
     $this->set('detail', $detail);
     if (!empty($userId)) {
         if ($this->request->isPut() || $this->request->isPost()) {
             $this->Cookie->write('user_cl', $this->request->data);
             $this->redirect(array('controller' => 'cabinets', 'action' => 'bank'));
         }
     }
 }
Ejemplo n.º 7
0
 public function new_friend_request()
 {
     $this->loadModel('Myfriend');
     $this->layout = "ajax";
     configure::write('debug', 2);
     $new_friend_request = $this->Myfriend->find('all', array('conditions' => array('AND' => array('Myfriend.to_user_id' => $this->Auth->User('id'), 'Myfriend.status' => 0))));
     $this->set('response', $new_friend_request);
 }
Ejemplo n.º 8
0
 public function payment_failure($orderId = null)
 {
     configure::write('debug', 0);
     $this->layout = "webapp_inner";
     $this->set("oid", $orderId);
     if ($orderId != NULL) {
         $this->Order->updateAll(array('Order.status' => "'CANCELED'", 'Order.payment_status' => "'FAILED'"), array('Order.sku' => $orderId));
     }
     $orders = $this->Order->find("all", array("conditions" => array("Order.sku" => $orderId)));
     $this->set("orders", $orders);
 }