mysql_select_db("adminscentral");*/
mysql_connect("adcentral-113786.phpmyadmin.mysql.binero.se", "113786_mw85527", "GmC_k822C#");
//mysql_select_db("mastulbd_mastul");
mysql_select_db("113786-adcentral");
include_once 'payment_method/GetRecurringPaymentsProfileDetails.php';
echo $sql = "SELECT * FROM organization_info org_info, org_billing_info bill_info \n    WHERE (org_info.payment_status=0 AND org_info.approval_status=0) AND \n    (bill_info.payment_method='creditcard' AND bill_info.bill_profileid!='NULL') AND org_info.id=bill_info.org_id";
$result = mysql_query($sql) or die(mysql_error());
$num_rows = mysql_num_rows($result);
if (mysql_num_rows($result) > 0) {
    while ($num_rows > 0) {
        $num_rows -= $num_rows;
        $row = mysql_fetch_array($result) or die(mysql_error());
        $profile_id = $row['bill_profileid'];
        $org_id = $row['org_id'];
        $nvpStr = "&PROFILEID=" . $profile_id;
        $recurringPaymentProfileDetails = getRecurringPaymentProfileDetails('GetRecurringPaymentsProfileDetails', $nvpStr);
        //////////////////////////////print_r($recurringPaymentProfileDetails);
        if ("SUCCESS" == strtoupper($recurringPaymentProfileDetails["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($recurringPaymentProfileDetails["ACK"])) {
            if ($recurringPaymentProfileDetails['NUMCYCLESCOMPLETED'] > 0) {
                $next_scheduled_billing_date = str_replace('%2d', '-', $recurringPaymentProfileDetails['NEXTBILLINGDATE']);
                $next_scheduled_billing_date = str_replace('%3a', ':', $next_scheduled_billing_date);
                $next_scheduled_billing_date = str_replace('Z', '', $next_scheduled_billing_date);
                $no_of_billing_cycle_completed = 1;
                $no_of_billing_cycle_remaining = 3 - 1;
                // $no_of_billing_cycle_remaining = $TOTALBILLINGCYCLES-1;
                $current_outstanding_balance = str_replace('%2e', '.', $recurringPaymentProfileDetails['OUTSTANDINGBALANCE']);
                $amount_of_last_successful_payment = str_replace('%2e', '.', $recurringPaymentProfileDetails['LASTPAYMENTAMT']);
                //$total_paid_amount= "total_paid_amount+".$amount_of_last_successful_payment;
                $total_paid_amount = $amount_of_last_successful_payment;
                $date_of_last_successful_payment = str_replace('%2d', '-', $recurringPaymentProfileDetails['LASTPAYMENTDATE']);
                $date_of_last_successful_payment = str_replace('%3a', ':', $date_of_last_successful_payment);
示例#2
-1
 /**
  * New Customer Registration Form:Step4 and it's final step
  *
  *@access public
  *@return Confirmation or Error Message
  */
 function added_customer_step4($start = 0)
 {
     $to_date = date("Y-m-d H:i:s");
     $this->load->library('form_validation');
     $data_organization['organization_data'] = $this->input->post("organization_data");
     $data_admin_user['admin_user_data'] = $this->input->post("admin_user_data");
     $data['category_name'] = $this->input->post("data_category");
     if (sizeof($data_organization['organization_data']) <= 1 || sizeof($data_admin_user['admin_user_data']) <= 1) {
         redirect("main/add_customer");
     }
     $card_info['credit_card_no'] = $this->input->post("credit_card_no");
     $card_info['credit_card_type'] = $this->input->post("credit_card_type");
     $card_info['credit_card_verification_code'] = $this->input->post("credit_card_verification_code");
     $card_info['card_expire_date_month'] = $this->input->post("card_expire_date_month");
     $card_info['card_expire_date_year'] = $this->input->post("card_expire_date_year");
     $billing_data = $this->input->post("admin_user_data");
     $form_data_billing = array('billing_terms_condition' => "", 'bill_first_name' => $billing_data["first_name"], 'bill_last_name' => $billing_data["last_name"], 'bill_phone_no' => $billing_data["phone_no"], 'bill_email' => $billing_data["email"], 'bill_primary_address' => $billing_data["primary_address"], 'bill_optional_address' => $billing_data["optional_address"], 'bill_zip' => $billing_data["zip"], 'bill_city' => $billing_data["city"], 'bill_country' => $billing_data["country"], 'bill_state' => $billing_data["state"], 'add_date' => $to_date);
     $this->lang->load('customer', $this->session->userdata('lang_file'));
     $this->data['mainTab'] = 'customer';
     $this->data['activeTab'] = 'customer';
     $form_data_step4 = array('payment_method' => $this->input->post("payment_method"), 'bill_first_name' => $this->input->post("bill_first_name"), 'bill_last_name' => $this->input->post("bill_last_name"), 'bill_phone_no' => $this->input->post("bill_phone_no"), 'bill_email' => $this->input->post("bill_email"), 'bill_primary_address' => $this->input->post("bill_primary_address"), 'bill_optional_address' => $this->input->post("bill_optional_address"), 'bill_zip' => $this->input->post("bill_zip"), 'bill_city' => $this->input->post("bill_city"), 'bill_country' => $this->input->post("bill_country"), 'bill_state' => $this->input->post("bill_state"), 'billing_terms_condition' => $this->input->post("billing_terms_condition"), 'credit_card_no' => $this->input->post("credit_card_no"), 'credit_card_type' => $this->input->post("credit_card_type"), 'credit_card_verification_code' => $this->input->post("credit_card_verification_code"), 'credit_card_expire_month' => $this->input->post("card_expire_date_month"), 'credit_card_expire_year' => $this->input->post("card_expire_date_year"), 'name_on_credit_card' => $this->input->post("name_on_credit_card"), 'add_date' => $to_date);
     //Start Validate Credit Card Info
     $cardErrorNo = -1;
     //NO card error, card is valid
     $payment_method = $this->input->post("payment_method");
     if ($payment_method == "creditcard") {
         $this->form_validation->set_rules('name_on_credit_card', $this->lang->line('label_name_on_card'), 'trim|required');
         if (checkCreditCard($card_info, $errornumber, $errortext)) {
             //$errortext = 'This card has a valid format';
             //echo 'card OK';
         } else {
             $cardErrorNo = $errornumber;
         }
     }
     //End Validate Credit Card Info
     $data_billing_address['billing_address_data'] = $form_data_step4;
     $this->load->vars($form_data_step4);
     $this->load->vars($data_admin_user);
     $this->load->vars($data_organization);
     $this->form_validation->set_rules('bill_first_name', $this->lang->line('label_first_name'), 'trim|required');
     $this->form_validation->set_rules('bill_last_name', $this->lang->line('label_last_name'), 'trim|required');
     $this->form_validation->set_rules('bill_phone_no', $this->lang->line('label_phone'), 'trim|required');
     $this->form_validation->set_rules('bill_email', $this->lang->line('label_email'), 'trim|required|valid_email|xss_clean|callback_email_check');
     $this->form_validation->set_rules('bill_primary_address', $this->lang->line('label_address_line_one'), 'trim|required|xss_clean');
     $this->form_validation->set_rules('bill_zip', $this->lang->line('label_zip'), 'trim|required|xss_clean');
     $this->form_validation->set_rules('bill_city', $this->lang->line('label_city'), 'trim|required|xss_clean');
     $this->form_validation->set_rules('bill_country', $this->lang->line('label_country'), 'trim|required|xss_clean');
     $this->form_validation->set_rules('bill_state', $this->lang->line('label_state'), 'trim|required|xss_clean');
     //$this->form_validation->set_message('required', $this->lang->line('label_billing_terms_condition'));
     $this->form_validation->set_rules('billing_terms_condition', $this->lang->line('label_billing_terms_condition'), 'trim|xss_clean|callback_billing_terms_condition_check');
     if ($this->form_validation->run() == FALSE || $cardErrorNo != -1) {
         $error_credit_card = array();
         $error_credit_card['credit_card_type_unknown_error'] = "";
         $error_credit_card['credit_card_no_error'] = "";
         $error_credit_card['credit_card_cvv2_wrong_error'] = "";
         $error_credit_card['credit_card_expired_error'] = "";
         switch ($cardErrorNo) {
             case 0:
                 $error_credit_card['credit_card_type_unknown_error'] = $this->lang->line('credit_card_type_unknown_error');
                 break;
             case 1:
                 $error_credit_card['credit_card_no_error'] = $this->lang->line('credit_card_empty_error');
                 break;
             case 2:
                 $error_credit_card['credit_card_no_error'] = $this->lang->line('credit_card_no_format_invalid_error');
                 break;
             case 3:
                 $error_credit_card['credit_card_no_error'] = $this->lang->line('credit_card_no_invalid_error');
                 break;
             case 4:
                 $error_credit_card['credit_card_no_error'] = $this->lang->line('credit_card_no_length_wrong_error');
                 break;
             case 5:
                 $error_credit_card['credit_card_cvv2_wrong_error'] = $this->lang->line('credit_card_cvv2_wrong_error');
                 break;
             case 6:
                 $error_credit_card['credit_card_expired_error'] = $this->lang->line('credit_card_expired_error');
                 break;
         }
         $this->data['payment_method'] = $payment_method;
         $this->load->vars($data);
         $this->load->vars($error_credit_card);
         $this->load->vars($form_data_billing);
         $this->data['dynamicView'] = 'pages/member/new_customer/entry_step3';
         $this->_commonPageLayout('frontend_viewer');
     } else {
         ///Organization Registration Final Step
         $first_name = $data_admin_user['admin_user_data']['first_name'];
         $rand_no = mt_rand(1000000000, 2000000000);
         $first_name = substr($first_name, 0, 2);
         $password = $first_name . $rand_no;
         $password2 = $this->encrypt($password, 'vaccitvassit');
         $data_admin_user['admin_user_data']['password'] = $password2;
         $data_admin_user['admin_user_data']['admin_user'] = 1;
         //$rand_pass = base64_encode($c);
         $data_global_settings['global_settings_data'] = $this->info_model->get_global_settings();
         // print_r($data['global_settings_data']);
         if ($data_global_settings['global_settings_data']) {
             foreach ($data_global_settings['global_settings_data'] as $rows) {
                 $data_organization['organization_data']['org_allowed_sms_per_month'] = $rows->allowed_sms_per_month;
                 $data_organization['organization_data']['org_allowed_letter_per_month'] = $rows->allowed_letter_per_month;
                 $per_invoice_cost = $rows->per_invoice_cost;
             }
         }
         if ($data['category_name'] != "") {
             $data_val['category_name'] = $data['category_name'];
             $cat_id = $this->info_model->org_category_insert($data_val);
             $data_organization['organization_data']['org_category'] = $cat_id;
         }
         $last_insert_ids = $this->info_model->register_organisation($data_organization['organization_data'], $data_admin_user['admin_user_data'], $form_data_step4);
         //$this->load->vars($form_data_step3);
         if (sizeof($last_insert_ids) > 0) {
             $package_id = $data_organization['organization_data']['package_name'];
             $data['package_info'] = $this->info_model->get_package($package_id);
             if ($data['package_info']) {
                 foreach ($data['package_info'] as $rows) {
                     $currency_info = $this->info_model->get_currency($rows->currency_id);
                 }
                 $package_name = $rows->package_name;
                 $no_of_member = $rows->no_of_member;
                 $amount = $rows->amount;
                 $duration = $rows->duration;
                 $sms_cost = $rows->sms_cost;
                 $letter_cost = $rows->letter_cost;
                 if ($currency_info) {
                     foreach ($currency_info as $currency) {
                         $currency_name = $currency->currency_name;
                     }
                     $package_details = "Package: " . $package_name . "_" . $package_id;
                 }
             }
             ////////////////// Payment Method: Start ////////////
             if ($payment_method == "creditcard") {
                 //$token = urlencode("token_from_setExpressCheckout");
                 $TOTALBILLINGCYCLES = urlencode($duration);
                 if ($duration > 12) {
                     $TOTALBILLINGCYCLES = urlencode("12");
                 }
                 // combination of this and billingPeriod must be at most a year
                 $bill_start_date_mins = date("i");
                 $bill_start_date = date("Y-m-d") . "T" . date("H") . ":" . $bill_start_date_mins . ":" . date("s");
                 $payment_per_cycle = $amount;
                 $paymentAmount = urlencode($payment_per_cycle);
                 $currencyID = urlencode($currency_name);
                 // or other currency code ('GBP', 'EUR', 'JPY', 'CAD', 'AUD')
                 $startDate = str_replace("%3A", ":", urlencode($bill_start_date));
                 $billingPeriod = urlencode("Month");
                 // or "Day", "Week", "SemiMonth", "Year"
                 $billingFreq = urlencode("1");
                 // combination of this and billingPeriod must be at most a year
                 //$TOTALBILLINGCYCLES = urlencode($duration);						// combination of this and billingPeriod must be at most a year
                 //$TOTALBILLINGCYCLES = urlencode("12");						// combination of this and billingPeriod must be at most a year
                 $DESC = urlencode($package_details);
                 $creditCardType = urlencode($card_info['credit_card_type']);
                 $creditCardAccount = urlencode(str_replace(' ', '', $card_info['credit_card_no']));
                 //$creditCardAccount = urlencode("4779297617944965");
                 $cardExpireDate = urlencode($card_info['card_expire_date_month'] . $card_info['card_expire_date_year']);
                 $cardCvv2 = urlencode($card_info['credit_card_verification_code']);
                 $PAYERSTATUS = urlencode("verified");
                 $STREET = urlencode($form_data_step4['bill_primary_address']);
                 $CITY = urlencode($form_data_step4['bill_city']);
                 $STATE = urlencode($form_data_step4['bill_state']);
                 $COUNTRYCODE = urlencode($form_data_step4['bill_country']);
                 $ZIP = urlencode($form_data_step4['bill_zip']);
                 $FIRSTNAME = urlencode($form_data_step4['bill_first_name']);
                 $LASTNAME = urlencode($form_data_step4['bill_last_name']);
                 $EMAIL = urlencode($form_data_step4['bill_email']);
                 $INITAMT = urlencode("0.00");
                 $FAILEDINITAMTACTION = urlencode("ContinueOnFailure");
                 $MAXFAILEDPAYMENTS = urlencode("10");
                 $ITEMCATEGORY0 = urlencode("Digital");
                 $ITEMNAME0 = urlencode($package_details);
                 $ITEMAMT0 = urlencode($amount);
                 $ITEMQTY0 = urlencode("1");
                 $AUTOBILLOUTAMT = urlencode("AddToNextBilling");
                 $TAXAMT = $amount * (25 / 100);
                 /// Tax_rate = 25%
                 $EMAIL = $form_data_step4['bill_email'];
                 $nvpStr = "&AMT={$paymentAmount}&CURRENCYCODE={$currencyID}&PROFILESTARTDATE={$startDate}";
                 $nvpStr .= "&BILLINGPERIOD={$billingPeriod}&BILLINGFREQUENCY={$billingFreq}&TOTALBILLINGCYCLES={$TOTALBILLINGCYCLES}&DESC={$DESC}&CREDITCARDTYPE={$creditCardType}&ACCT={$creditCardAccount}&EXPDATE={$cardExpireDate}&CVV2={$cardCvv2}&PAYERSTATUS={$PAYERSTATUS}&STREET={$STREET}\n                        &CITY={$CITY}&COUNTRYCODE={$COUNTRYCODE}&ZIP={$ZIP}&FIRSTNAME={$FIRSTNAME}&LASTNAME={$LASTNAME}&EMAIL={$EMAIL}\n                        &INITAMT={$INITAMT}&TAXAMT={$TAXAMT}&FAILEDINITAMTACTION={$FAILEDINITAMTACTION}&MAXFAILEDPAYMENTS={$MAXFAILEDPAYMENTS}\n                        &L_PAYMENTREQUEST_0_ITEMCATEGORY0={$ITEMCATEGORY0}&L_PAYMENTREQUEST_0_NAME0={$ITEMNAME0}\n                        &L_PAYMENTREQUEST_0_AMT0={$ITEMAMT0}&L_PAYMENTREQUEST_0_QTY0={$ITEMQTY0}&AUTOBILLOUTAMT={$AUTOBILLOUTAMT}";
                 $httpParsedResponseAr = PPHttpPost('CreateRecurringPaymentsProfile', $nvpStr);
                 if ("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {
                     //$data_payment_success['org_id'] = $last_insert_ids['org_id'];
                     //$data_payment_success['org_billing_info_id'] = $last_insert_ids['org_billing_info_id'];
                     $data_payment_success['profileid'] = str_replace('%2d', '-', $httpParsedResponseAr['PROFILEID']);
                     $data_payment_success['profilestatus'] = $httpParsedResponseAr['PROFILESTATUS'];
                     //$data_payment_success['transactionid'] = $httpParsedResponseAr['TRANSACTIONID'];
                     $data_payment_success['timestamp'] = str_replace('%2d', '-', $httpParsedResponseAr['TIMESTAMP']);
                     $data_payment_success['timestamp'] = str_replace('%3a', ':', $data_payment_success['timestamp']);
                     $data_payment_success['correlationid'] = $httpParsedResponseAr['CORRELATIONID'];
                     $data_payment_success['ack'] = $httpParsedResponseAr['ACK'];
                     $data_payment_success['total_billing_cycle'] = $TOTALBILLINGCYCLES;
                     $data_payment_success['add_date'] = $to_date;
                     //Start : Update Organization Info Based on Successful Payment
                     $nvpStr = "&PROFILEID=" . $data_payment_success['profileid'];
                     $recurringPaymentProfileDetails = getRecurringPaymentProfileDetails('GetRecurringPaymentsProfileDetails', $nvpStr);
                     if ("SUCCESS" == strtoupper($recurringPaymentProfileDetails["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($recurringPaymentProfileDetails["ACK"])) {
                         $org_billing_success_insert_id = $this->info_model->org_billing_success_insert($data_payment_success);
                         if ($org_billing_success_insert_id) {
                             $data_org_billing_info['bill_profileid'] = $data_payment_success['profileid'];
                             $payment_method = "creditcard";
                             $org_id = $last_insert_ids['org_id'];
                             $success = $this->info_model->update_org_billing_info($data_org_billing_info, $payment_method, $org_id);
                         }
                         if ($recurringPaymentProfileDetails['NUMCYCLESCOMPLETED'] > 0) {
                             $data_org_billing_success['next_scheduled_billing_date'] = str_replace('%2d', '-', $recurringPaymentProfileDetails['NEXTBILLINGDATE']);
                             $data_org_billing_success['next_scheduled_billing_date'] = str_replace('%3a', ':', $data_org_billing_success['next_scheduled_billing_date']);
                             $data_org_billing_success['no_of_billing_cycle_completed'] = 1;
                             $data_org_billing_success['no_of_billing_cycle_remaining'] = $TOTALBILLINGCYCLES - 1;
                             $data_org_billing_success['current_outstanding_balance'] = str_replace('%2e', '.', $recurringPaymentProfileDetails['OUTSTANDINGBALANCE']);
                             $data_org_billing_success['amount_of_last_successful_payment'] = str_replace('%2e', '.', $recurringPaymentProfileDetails['LASTPAYMENTAMT']);
                             $data_org_billing_success['total_paid_amount'] = "total_paid_amount+" . $data_org_billing_success['amount_of_last_successful_payment'];
                             $data_org_billing_success['date_of_last_successful_payment'] = str_replace('%2d', '-', $recurringPaymentProfileDetails['LASTPAYMENTDATE']);
                             $data_org_billing_success['date_of_last_successful_payment'] = str_replace('%3a', ':', $data_org_billing_success['date_of_last_successful_payment']);
                             $success = $this->info_model->update_org_billing_success($data_org_billing_success, $org_billing_success_insert_id);
                             $total_days = $duration * 30;
                             $expire_date = time() + $total_days * 24 * 60 * 60;
                             $data_update = array('approval_status' => 1, 'payment_status' => 1, 'activation_date' => time(), 'expire_date' => $expire_date);
                             $success = $this->info_model->update_org_approve($data_update, $last_insert_ids['org_id']);
                             if ($success) {
                                 $data['first_name'] = $data_admin_user['admin_user_data']['first_name'];
                                 $data['username'] = $data_admin_user['admin_user_data']['username'];
                                 $data['email'] = $data_admin_user['admin_user_data']['email'];
                                 $data['org_number'] = $data_organization['organization_data']['org_number'];
                                 $data['org_name'] = $data_organization['organization_data']['org_name'];
                                 $data['org_phone'] = $data_organization['organization_data']['org_phone'];
                                 $data['password'] = $password;
                                 if ($data_admin_user['admin_user_data']['password_receive_by_email']) {
                                     $this->send_password_by_email($data);
                                 }
                                 if ($data_admin_user['admin_user_data']['password_receive_by_sms']) {
                                     $this->send_password_by_sms($data);
                                 }
                             }
                             ///////
                         } else {
                             $data_org_billing_success['no_of_billing_cycle_remaining'] = $TOTALBILLINGCYCLES;
                             $success = $this->info_model->update_org_billing_success($data_org_billing_success, $org_billing_success_insert_id);
                         }
                         //exit('GetTransactionDetails Completed Successfully: '.print_r($recurringPaymentProfileDetails, true));
                     } else {
                         //exit('GetTransactionDetails failed: ' . print_r($recurringPaymentProfileDetails, true));
                     }
                     //End : Update Organization Info Based on Successful Payment
                     //exit('CreateRecurringPaymentsProfile Completed Successfully: '.print_r($httpParsedResponseAr, true));
                 } else {
                     $data_payment_failure['org_id'] = $last_insert_ids['org_id'];
                     $data_payment_failure['org_billing_info_id'] = $last_insert_ids['org_billing_info_id'];
                     $data_payment_failure['l_errodcode0'] = $httpParsedResponseAr['L_ERRORCODE0'];
                     $data_payment_failure['l_shortmessage0'] = str_replace('%20', ' ', $httpParsedResponseAr['L_SHORTMESSAGE0']);
                     $data_payment_failure['l_longmessage0'] = str_replace('%20', ' ', $httpParsedResponseAr['L_LONGMESSAGE0']);
                     $data_payment_failure['l_severitycode0'] = $httpParsedResponseAr['L_SEVERITYCODE0'];
                     $data_payment_failure['timestamp'] = str_replace('%2d', '-', $httpParsedResponseAr['TIMESTAMP']);
                     $data_payment_failure['timestamp'] = str_replace('%3a', ':', $data_payment_failure['timestamp']);
                     $data_payment_failure['correlationid'] = $httpParsedResponseAr['CORRELATIONID'];
                     $data_payment_failure['ack'] = $httpParsedResponseAr['ACK'];
                     $data_payment_failure['add_date'] = $to_date;
                     $success = $this->info_model->org_billing_failure_insert($data_payment_failure);
                     //exit('CreateRecurringPaymentsProfile failed: ' . print_r($httpParsedResponseAr, true));
                 }
             } elseif ($payment_method == "invoice") {
                 //$fak_expire_date = time() + ($total_days * 24 * 60 * 60);
                 $data_faktura['bill_country'] = $form_data_step4['bill_country'];
                 if ($data_faktura['bill_country'] == "DEU") {
                     $data_faktura['bill_country'] = "GERMAN";
                 }
                 if ($data_faktura['bill_country'] == "NOR") {
                     $data_faktura['bill_country'] = "NORWAY";
                 }
                 if ($data_faktura['bill_country'] == "DNK") {
                     $data_faktura['bill_country'] = "DENMARK";
                 }
                 if ($data_faktura['bill_country'] == "FIN") {
                     $data_faktura['bill_country'] = "FINLAND";
                 }
                 if ($data_faktura['bill_country'] == "GBR") {
                     $data_faktura['bill_country'] = "UK";
                 }
                 if ($data_faktura['bill_country'] == "SWE") {
                     $data_faktura['bill_country'] = "SWEDEN";
                 }
                 $data_faktura['org_id'] = $last_insert_ids['org_id'];
                 $data_faktura['package_id'] = $package_id;
                 $data_faktura['fak_active_date'] = time();
                 $data_faktura['fak_expire_date'] = time() + 10 * 24 * 60 * 60;
                 $data_faktura['org_name'] = $data_organization['organization_data']['org_name'];
                 $data_faktura['org_number'] = $data_organization['organization_data']['org_number'];
                 $data_faktura['bill_primary_address'] = $form_data_step4['bill_primary_address'];
                 $data_faktura['bill_zip'] = $form_data_step4['bill_zip'];
                 $data_faktura['bill_city'] = $form_data_step4['bill_city'];
                 $data_faktura['bill_state'] = $form_data_step4['bill_state'];
                 $data_faktura['bill_phone'] = $form_data_step4['bill_phone_no'];
                 $data_faktura['fak_reference_name'] = $data_admin_user['admin_user_data']['first_name'] . " " . $data_admin_user['admin_user_data']['last_name'];
                 $data_faktura['fak_description'] = $package_details;
                 $data_faktura['fak_quantity'] = 1;
                 $data_faktura['fak_unit_price'] = $amount;
                 $data_faktura['fak_invoice_cost'] = $per_invoice_cost;
                 $data_faktura['fak_invoice_cost_applied'] = 0.0;
                 $data_faktura['sms_unit_price'] = $sms_cost;
                 $data_faktura['letter_unit_price'] = $letter_cost;
                 $data_faktura['fak_price_exclusive_vat'] = $data_faktura['fak_quantity'] * $data_faktura['fak_unit_price'];
                 $data_faktura['fak_vat_rate'] = 25;
                 //////// Calculating Total Cost of this faktura //////
                 $pris_exclusive_vat_one = $data_faktura['fak_price_exclusive_vat'];
                 $pris_exclusive_vat_two = $data_faktura['fak_invoice_cost_applied'];
                 $price_total_exclusive_vat = $pris_exclusive_vat_one + $pris_exclusive_vat_two;
                 $data_faktura['fak_vat_price'] = $data_faktura['fak_vat_rate'] / 100 * $price_total_exclusive_vat;
                 $fak_total_price = $price_total_exclusive_vat + $data_faktura['fak_vat_price'];
                 //////// Calculating Total Cost of this faktura //////
                 //$fak_total_price =$data_faktura['fak_price_exclusive_vat']+$data_faktura['fak_vat_price'];
                 $data_faktura['fak_total_price'] = round($fak_total_price);
                 $data_faktura['fak_rounding_price'] = $data_faktura['fak_total_price'] - $fak_total_price;
                 $data_faktura['fak_currency'] = $currency_name;
                 $data_faktura['add_date'] = $to_date;
                 $fak_insert_id = $this->info_model->bill_faktura_insert($data_faktura);
                 $data_faktura['price_total_exclusive_vat'] = $price_total_exclusive_vat;
                 if ($fak_insert_id) {
                     $data['first_name'] = $data_admin_user['admin_user_data']['first_name'];
                     $data['username'] = $data_admin_user['admin_user_data']['username'];
                     $data['email'] = $data_admin_user['admin_user_data']['email'];
                     $data['org_number'] = $data_organization['organization_data']['org_number'];
                     $data['org_name'] = $data_organization['organization_data']['org_name'];
                     $data['org_phone'] = $data_organization['organization_data']['org_phone'];
                     $data['password'] = $password;
                     $this->make_invoice_pdf($data_faktura, $fak_insert_id, $data);
                 }
             }
             //////////////// Payment Method: End /////
             $this->session->set_flashdata('message', '<div id="message1">' . $this->lang->line('org_registration_member_success') . '</div>');
             redirect('main/org_registration_success');
             //$this->data['dynamicView'] = 'pages/admin/new_customer/org_registration_success';
         } else {
             $this->data['dynamicView'] = 'pages/member/new_customer/entry_step3';
         }
         $this->_commonPageLayout('frontend_viewer');
     }
 }