public function remoteupdatepass($user_email, $encrypted_pass)
 {
     //$data='email='.$u->email.'&pwd=THI*****SISMYPASS';
     $data = 'email=' . $user_email . '&pwd=' . $encrypted_pass;
     $url = "index.php?r=authentication/updatedetails";
     $method = 'POST';
     $result = Systemconfig::model()->callurl($url, $data, $method);
     $j_result = json_decode($result);
     //echo $j_result[0]->status_message;
     return $j_result[0]->status_message;
 }
 private function verifyserverlogin($e, $p)
 {
     //echo $p;
     $url = "index.php?r=authentication/authentication";
     $data = "email=" . $e . "&pwd=" . $p;
     $method = 'POST';
     $result = Systemconfig::model()->callurl($url, $data, $method);
     //echo $result;
     $j = json_decode($result);
     if ($j) {
         if ($j[0]->{"status"} === 'OK') {
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
 public function actionVerifyengg()
 {
     //echo '<h1>i m caled</h1>';
     $url = "index.php?r=authentication/authentication";
     $e = '*****@*****.**';
     $p = 'c9ebf569947258fc5263bb8d0b00192a988e99280104d5298e80d1b320deaeba';
     $data = "email=" . $e . "&pwd=" . $p;
     $method = 'POST';
     $result = Systemconfig::model()->callurl($url, $data, $method);
     echo $result;
     /*
     		$email='*****@*****.**';
     		$pwd='c9ebf569947258fc5263bb8d0b00192a988e99280104d5298e80d1b320deaeba';
     		
     		$ch = curl_init();
     
     		curl_setopt($ch, CURLOPT_URL,"http://localhost/purva/server/gomobile/index.php?r=authentication/authentication");
     		curl_setopt($ch, CURLOPT_POST, 1);
     		curl_setopt($ch, CURLOPT_POSTFIELDS,"email=sweetpullo@gmail.com&pwd=c9ebf569947258fc5263bb8d0b00192a988e99280104d5298e80d1b320deaeba");
     		
     
     		// in real life you should use something like:
     		// curl_setopt($ch, CURLOPT_POSTFIELDS, 
     		//          http_build_query(array('postvar1' => 'value1')));
     
     		// receive server response ...
     		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     
     		$server_output = curl_exec ($ch);
     		
     
     		curl_close ($ch);
     		echo($server_output);
     */
     ////Step 1: we will send engg id & pass word to go mobile server
     ///you need to send engineer email and pwd to below url
     ///http://localhost/purva/server/gomobile/index.php?r=authentication/authentication
 }
 public function actionSendstatusupdatetoamica()
 {
     $json_array = array();
     $json_array['status'] = 'BAD_REQUEST';
     $json_array['status_message'] = 'This is bad request';
     $email = "";
     $pwd = "";
     if (isset($_POST['email'])) {
         $email = $_POST['email'];
     }
     if (isset($_POST['pwd'])) {
         $pwd = $_POST['pwd'];
     }
     $verify_engg = Systemconfig::model()->verifyengg($email, $pwd);
     $json_array['status_message'] .= "<br> verifyengg" . $verify_engg;
     if ($verify_engg) {
         $json_array['status'] = 'LOGIN_OK';
         $json_array['status_message'] = 'You have been successfully logged in.';
         $service_ref_no = $_POST['remote_ref_no'];
         $status_log = $_POST['status_log'];
         $api_key = $_POST['api_key'];
         $service_id = Servicecalls::model()->getserviceidbyservicerefrencenumber($service_ref_no);
         $json_array['status_message'] .= "<br> service_id" . $service_id;
         if ($service_id) {
         }
         $json_array['status'] = 'SERVICECALL_OK';
         $json_array['status_message'] = 'Service call is found.';
         $model = $this->loadModel($service_id);
         $model->status_log = $status_log;
         if ($model->save()) {
             $data_type = 'status_log';
             //////send to Razzmatazz Server
             $return_data_array = array();
             $return_data_array['type'] = $data_type;
             ///is it a message or  servicecall_data
             $return_data_array['engineer_email'] = $email;
             $return_data_array['service_reference_number'] = $model->service_reference_number;
             $return_data_array['gomobile_account_id'] = $api_key;
             $return_data_array['sent_data'] = array('data_sent' => $model->data_sent, 'communications' => $model->communications, 'status_log' => $model->status_log);
             $data_to_be_sent_string = json_encode(array('data' => $return_data_array));
             $url = "index.php?r=server/getdatafromportal";
             $method = 'POST';
             $data_to_be_sent_string = urlencode($data_to_be_sent_string);
             $data = "engineer_email=" . $email . "&pwd=" . $pwd . "&data=" . $data_to_be_sent_string;
             $result = Systemconfig::model()->callurl($url, $data, $method);
             $json_array['status_message'] .= "Sending result-" . $result;
         }
         /////end of if ($model->save())
         ///end of if($service_id);
     }
     ////end of if ($verify_engg)
     echo json_encode($json_array);
 }
 public function senddatatoserver($data_type)
 {
     ////prepare data for sending
     $return_msg = 'NOTHING';
     $return_data_array = array();
     $return_data_array['type'] = $data_type;
     ///is it a message or  servicecall_data
     $return_data_array['engineer_email'] = $this->engineer_email;
     $return_data_array['service_reference_number'] = $this->service_reference_number;
     $return_data_array['gomobile_account_id'] = Systemconfig::model()->get_valueforparameter('api_key');
     $return_data_array['sent_data'] = array('data_sent' => $this->data_sent, 'communications' => $this->communications, 'status_log' => $this->status_log);
     $data_to_be_sent_string = json_encode(array('data' => $return_data_array));
     $url = "index.php?r=server/getdatafromportal";
     $method = 'POST';
     $data_to_be_sent_string = urlencode($data_to_be_sent_string);
     //echo $data_to_be_sent_string;
     $result = Systemconfig::model()->callurlforsecuredata($this->engineer_email, $url, $data_to_be_sent_string, "POST");
     $result_json = json_decode($result);
     if ($result_json->status == 'OK') {
         $return_msg = '<div class="flash-success">' . $result_json->status_message . '</div>';
     } else {
         $return_msg = '<div class="flash-error">' . $result_json->status_message . '</div>';
     }
     return $return_msg;
     //echo '<h2> RESIUT IS ' . $result . '</h2>';
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Systemconfig the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Systemconfig::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public function get_valueforparameter($param)
 {
     $model = Systemconfig::model()->findByAttributes(array('parameter' => $param));
     return $model->value;
 }