function _report_error($subject)
 {
     $CI =& get_instance();
     $CI->load->library('Rabbitmq');
     $CI->load->helper('email_sender');
     $body = '';
     $body .= 'Request: <br/><br/><code>';
     foreach ($_REQUEST as $k => $v) {
         $body .= $k . ' => ' . $v . '<br/>';
     }
     $body .= '</code>';
     $body .= '<br/><br/>Server: <br/><br/><code>';
     foreach ($_SERVER as $k => $v) {
         $body .= $k . ' => ' . $v . '<br/>';
     }
     $body .= '</code>';
     $body .= '<br/><br/>Stacktrace: <br/><br/>';
     $body .= serialize($subject);
     $data = array();
     $data['to'] = "*****@*****.**";
     $data['to_name'] = "shakaib";
     $data['from'] = ADMIN_EMAIL;
     $data['from_name'] = ADMIN_NAME;
     $data['from_pass'] = ADMIN_EMAIL_PASSWORD;
     $data['subject'] = "Exception";
     $data['body'] = $body;
     mail_me($data);
 }
function leaderboard_competition_winner_email($email_data)
{
    $CI =& get_instance();
    $CI->load->helper('email_sender');
    $body = '<h3>A new Developer has registered in ' . APP_NAME . ' with the following details: </h3><br /><b>Title: </b>' . $email_data['name'] . '<br /><b>Email: </b>' . $email_data['email'] . '<br />';
    $data = array();
    $data['to'] = $email_data['email'];
    $data['to_name'] = $email_data['userName'];
    $data['from'] = ADMIN_EMAIL;
    $data['from_name'] = ADMIN_NAME;
    $data['from_pass'] = ADMIN_EMAIL_PASSWORD;
    $data['subject'] = "Ozoneplay open leaderboard competition Winners!";
    $data['body'] = $body;
    // calling function in email_sender_helper
    mail_me($data);
    return TRUE;
}
 public function adaptive_implicit_payment_developer()
 {
     # Get the Player's Paypal ID
     $this->load->model('Developer_model');
     $this->load->model('Paymenthistory_model');
     $this->load->model('Withdrawal_requests_model');
     $where = 'id = ' . $this->input->post('player_id');
     $player = $this->Developer_model->findByCondition($where);
     $response['status'] = false;
     $response['message'] = ERROR_MESSAGE . ':Something went wrong, the request could not be completed';
     if (!empty($player) && $player[0]['paypal_id'] != '' && $player[0]['paypal_id'] != null && $this->input->post('amount') > 0 && $player[0]['amount'] >= $this->input->post('amount')) {
         $payRequest = new PayRequest();
         $receiver = array();
         $receiver[0] = new Receiver();
         $receiver[0]->amount = $this->input->post('amount');
         $receiver[0]->email = $player[0]['paypal_id'];
         $receiverList = new ReceiverList($receiver);
         $payRequest->receiverList = $receiverList;
         $payRequest->senderEmail = "*****@*****.**";
         $requestEnvelope = new RequestEnvelope("en_US");
         $payRequest->requestEnvelope = $requestEnvelope;
         $payRequest->actionType = "PAY";
         $payRequest->cancelUrl = base_url() . 'admin/payment_error';
         $payRequest->returnUrl = base_url() . 'admin/payment_success';
         $payRequest->currencyCode = "USD";
         $sdkConfig = array("mode" => "sandbox", "acct1.UserName" => "jb-us-seller_api1.paypal.com", "acct1.Password" => "WX4WTU3S8MY44S7F", "acct1.Signature" => "AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy", "acct1.AppId" => "APP-80W284485P519543T");
         $adaptivePaymentsService = new AdaptivePaymentsService($sdkConfig);
         $payResponse = $adaptivePaymentsService->Pay($payRequest);
         $ack = strtoupper($payResponse->responseEnvelope->ack);
         if ($ack != "SUCCESS") {
         } else {
             $insertDataPaymentHistory = array('userID' => $player[0]['id'], 'type' => 'debit', 'reason' => 'Payment to a developer on behalf of a request', 'amount' => $this->input->post('amount'), 'referrer_id' => $player[0]['id'], 'referrer_type' => 'Developer', 'transaction_id' => '', 'gateway' => 'Paypal');
             $id = $this->Paymenthistory_model->save($insertDataPaymentHistory);
             if ($this->input->post('withdrawal_id') != '' && $this->input->post('withdrawal_id') != null) {
                 $where = 'id = ' . $this->input->post('withdrawal_id');
                 $updateDataWithdrawal = array('approved' => is_withdrawal_approved(), 'payment_id' => $id);
                 $this->Withdrawal_requests_model->updateByCondition($where, $updateDataWithdrawal);
                 $body = 'You sent a withdrawal request on your paypal id: ' . $player[0]['paypal_id'] . ' which has been approved and an amount of $' . $this->input->post('amount') . ' has been sent to your paypal account, please verify.';
             } else {
                 $new_balance = floatval(floatval($player[0]['amount']) - floatval($this->input->post('amount')));
                 $where = 'id = ' . $player[0]['id'];
                 $updateDataPlayer = array('amount' => $new_balance);
                 $id = $this->Developer_model->updateByCondition($where, $updateDataPlayer);
                 $body = 'An amount of $' . $this->input->post('amount') . ' has been sent on your paypal id: ' . $player[0]['paypal_id'] . ', please verify.';
             }
             mail_me(array('to' => $player[0]['email'], 'to_name' => $player[0]['fName'] . ' ' . $player[0]['lName'], 'from' => $this->config->item('adminEmail'), 'from_name' => $this->config->item('adminName'), 'from_pass' => $this->config->item('adminEmail_pass'), 'subject' => 'Payment Made', 'body' => $body));
             $response['status'] = true;
             $response['message'] = 'Payment Sucessfully made';
         }
     }
     return $response;
 }