public function years_Add()
 {
     //If the top level user has not set org name
     //they will redirect to profile editing page.
     $data['login_user_data'] = $this->user_info;
     $this->load->library('form_validation', '', 'frm_val');
     $this->frm_val->set_rules('new_section', 'Class Name', 'trim|required|xss_clean|strip_tags|callback_is_section_exist');
     $this->frm_val->set_rules('invite_user_id', 'Teacher Name', 'trim|xss_clean');
     $data['add_class_success'] = $this->session->flashdata('add_class_success');
     $data['add_class_error'] = $this->session->flashdata('add_class_error');
     if ($this->frm_val->run() == false) {
     } else {
         $creation_info = array('section_id' => unique_id_generator(), 'section_hash_organisation_id' => md5($this->user_info->id), 'section_name' => set_value('new_section'));
         $assign_info = array();
         if ($accessible_user_info = $this->super_admin->get_user_info(set_value('invite_user_id')) and $accessible_user_info->num_rows() == '1') {
             $assign_info = array('assign_id' => unique_id_generator(), 'assign_access_id' => $accessible_user_info->row()->hashing_email);
             //print_r($accessible_user_info);exit;
         }
         $this->load->model('section_model');
         if ($this->section_model->create_section_and_assign_to($creation_info, $assign_info)) {
             $this->session->set_flashdata('add_class_success', '<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button><strong>Success! </strong>Class added successfully.</div>');
         } else {
             $this->session->set_flashdata('add_class_error', '<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button><strong>Error! </strong>Something went wrong. Please try again.</div>');
         }
         redirect(base_url('user/' . $this->uri->segment('2')));
     }
     $this->_render_admin('sections/add_sections', $data);
 }
 /**
  * Insert member information into database section_member table
  *
  * @param $section_member_info
  * @return bool
  */
 public function create_section_member_info_from_file($file_info, $section_id, $organization_id)
 {
     $this->load->library('csv_reader');
     $this->load->model('payment_model');
     $this->load->helper('function');
     $this->csv_reader->read($file_info['full_path']);
     $row_count = $this->csv_reader->rowCount();
     /*if( $row_count < 6 or $this->session->userdata('CN_user_package_code') == false ) {
           return false;
       }*/
     //Direct Query will be like this
     //INSERT INTO `cb_cloudenote`.`section_member` (`id`, `section_member_first_name`, `section_member_last_name`, `section_member_section_id`, `section_member_fathers_first_name`, `section_member_fathers_last_name`, `section_member_fathers_email`, `section_member_fathers_email_hash`, `section_member_fathers_work_phone`, `section_member_fathers_home_phone`, `section_member_fathers_mobile`, `section_member_fathers_first_address_line`, `section_member_fathers_second_address_line`, `section_member_fathers_zip_code`, `section_member_fathers_city_name`, `section_member_fathers_state_id`, `section_member_fathers_time_zone_id`, `section_member_fathers_country_id`, `section_member_mothers_first_name`, `section_member_mothers_last_name`, `section_member_mothers_email`, `section_member_mothers_email_hash`, `section_member_mothers_work_phone`, `section_member_mothers_home_phone`, `section_member_mothers_mobile`, `section_member_mothers_first_address_line`, `section_member_mothers_second_address_line`, `section_member_mothers_zip_code`, `section_member_mothers_city_name`, `section_member_mothers_state_id`, `section_member_mothers_time_zone_id`, `section_member_mothers_country_id`, `section_member_caregiver_first_name`, `section_member_caregiver_last_name`, `section_member_caregiver_email`, `section_member_caregiver_email_hash`, `section_member_caregiver_work_phone`, `section_member_caregiver_home_phone`, `section_member_caregiver_mobile`, `section_member_caregiver_first_address_line`, `section_member_caregiver_second_address_line`, `section_member_caregiver_zip_code`, `section_member_caregiver_city_name`, `section_member_caregiver_state_id`, `section_member_caregiver_time_zone_id`, `section_member_caregiver_country_id`, `section_member_caregiver_phone_number`, `section_member_group_id`, `section_member_remove`) VALUES ('sdfsdf', 'Kuddus', 'Boati', 'dakjfhdf', 'ssddff', 'sdfsdf', 'sdfdsf', 'sdfdsf', 'sdfsdf', 'sdfdsf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfdsf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfdsf', 'fgdfg', 'dfgff', 'dfgdf', 'dfgfdg', 'dfgdfg', 'dfgfdg', 'dfgdfg', 'dfgdfg', 'dfgfdg', 'dfgfdg', 'dfgdfg', 'dfgdfg', 'dfgfdg', 'dfgdfg', 'dfgdfg', 'dfgdfg', 'dgfgdf', 'dfgfdg', 'dfgfd', 'gfdgfdg', 'dfgfdg', 'dfgfdg', 'dfgdf', 'gdfgfd', 'gdfgfdg', 'dfgdfg', 'dfgfdg', '0', '0'), ('sdsdffdsf', 'sdfdsf', 'sdfdsf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', 'sdfsdf', '0', '0');
     $data_batch_array = array();
     for ($row = 6; $row <= $row_count; $row++) {
         $single_row_info = array('id' => md5($organization_id . unique_id_generator() . $section_id . microtime()), 'section_member_first_name' => $this->csv_reader->cellValue($row, 1), 'section_member_last_name' => $this->csv_reader->cellValue($row, 2), 'section_member_roll_number' => $this->csv_reader->cellValue($row, 3), 'section_member_email' => $this->csv_reader->cellValue($row, 4), 'section_member_email_hash' => md5($this->csv_reader->cellValue($row, 4)), 'section_member_date_of_birth' => $this->csv_reader->cellValue($row, 5), 'section_member_section_id' => $section_id, 'section_member_package_code' => 'pk5', 'section_member_organisation_id' => $this->session->userdata('CN_user_organisation_id'), 'section_member_fathers_first_name' => $this->csv_reader->cellValue($row, 6), 'section_member_fathers_last_name' => $this->csv_reader->cellValue($row, 7), 'section_member_fathers_email' => $this->csv_reader->cellValue($row, 8), 'section_member_fathers_email_hash' => md5($this->csv_reader->cellValue($row, 8)), 'section_member_mothers_first_name' => $this->csv_reader->cellValue($row, 9), 'section_member_mothers_last_name' => $this->csv_reader->cellValue($row, 10), 'section_member_mothers_email' => $this->csv_reader->cellValue($row, 11), 'section_member_mothers_email_hash' => md5($this->csv_reader->cellValue($row, 11)), 'section_member_group_id' => 0, 'section_member_remove' => 0);
         $data_batch_array[] = $single_row_info;
     }
     //Use Transaction for , if one row data insert fail then previously inserted data will be wipe
     $this->db->trans_start();
     //start transaction
     $this->db->insert_batch('section_member', $data_batch_array);
     //doing batch operation
     $this->db->trans_complete();
     //stop transaction
     if ($this->db->trans_status() === false) {
         return false;
     } else {
         return true;
     }
 }
 public function update_note_response($note_id, $organisation_id, $note_receiver_info)
 {
     $this->remove_note_response($note_id);
     $note_form_json = $this->get_note_json_data($note_id);
     $this->load->helper('function');
     $single_note_info = array();
     $batch_note = array();
     if (!is_array($note_receiver_info)) {
         return false;
     }
     $batch_operation_format_ok = true;
     foreach ($note_receiver_info as $receiver_info) {
         $single_note_info['response_id'] = md5(md5(unique_id_generator(12)) . microtime());
         $single_note_info['response_note_id'] = $note_id;
         $single_note_info['response_organisation_id'] = $organisation_id;
         if (!isset($receiver_info['caregiver_id'])) {
             $batch_operation_format_ok = false;
             break;
         } else {
             $single_note_info['response_receiver_id'] = $receiver_info['caregiver_id'];
         }
         if (!isset($receiver_info['caregiver_unique_id'])) {
             $batch_operation_format_ok = false;
             break;
         } else {
             $single_note_info['response_receiver_unique_id'] = $receiver_info['caregiver_unique_id'];
         }
         if (!isset($receiver_info['section_member_id'])) {
             $batch_operation_format_ok = false;
             break;
         } else {
             $single_note_info['response_section_member_id'] = $receiver_info['section_member_id'];
         }
         if (!isset($receiver_info['caregiver_email'])) {
             $batch_operation_format_ok = false;
             break;
         } else {
             $single_note_info['response_public_view_id'] = md5($note_id . $receiver_info['section_member_id'] . $receiver_info['caregiver_email']);
             $single_note_info['response_note_receiver_email'] = $receiver_info['caregiver_email'];
         }
         if (!isset($receiver_info['caregiver_first_name'])) {
             $batch_operation_format_ok = false;
             break;
         } else {
             $single_note_info['response_note_receiver_first_name'] = $receiver_info['caregiver_first_name'];
         }
         if (!isset($receiver_info['caregiver_last_name'])) {
             $batch_operation_format_ok = false;
             break;
         } else {
             $single_note_info['response_note_receiver_last_name'] = $receiver_info['caregiver_last_name'];
         }
         $single_note_info['response_note_response_json'] = $note_form_json->note_json_form_options;
         $batch_note[] = $single_note_info;
     }
     if ($batch_operation_format_ok) {
         $this->db->insert_batch('note_response', $batch_note);
         if ($this->db->affected_rows() > 0) {
             return true;
         }
     }
     return false;
 }
 public function saveclass()
 {
     $this->load->library('session');
     $user_id = $this->session->userdata('DX_user_id');
     $organisation_id = $this->session->userdata('CN_user_organisation_id');
     $this->load->model('user_model');
     //var_dump($session_id2);
     // var_dump($session_id);
     if ($user_id > 0) {
         $classdata = array();
         $classdata = $this->input->post();
         $post = array();
         foreach ($_POST as $key => $value) {
             if ($value == '') {
                 $this->session->set_flashdata('add_class_fill_error', '<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button><strong>Error! </strong>Please Fill All The Fields.</div>');
                 redirect(base_url('/setupschool'));
             }
             $post[$key] = $this->input->post($key);
         }
         $parent_array = array();
         $child_array = array();
         foreach ($post as $key => $value) {
             if (strpos($key, 'parent') !== false) {
                 $parent_array[$key] = $value;
             } elseif (strpos($key, 'parent') == false) {
                 $child_array[$key] = $value;
                 $pattern = '/_p_/';
                 $string = $key;
                 preg_match($pattern, $string, $matches, PREG_OFFSET_CAPTURE);
                 $length = strlen($string) - 1;
                 $parent_id = substr($string, $matches[0][1] + 3, $length);
                 foreach ($classdata as $parentkey => $parentvalue) {
                     if ($parentkey == 'parent_new_' . $parent_id) {
                         $return_value = $parentvalue;
                         $creation_info = array('group_id' => unique_id_generator() . rand() . time(), 'group_name' => $return_value, 'section_id' => unique_id_generator() . rand() . time(), 'section_name' => $value, 'user_id' => $user_id, 'organisation_id' => $organisation_id);
                         $this->load->model('createclass_model');
                         $this->createclass_model->create_year($creation_info);
                         $insert = true;
                     } else {
                         $return_value = '';
                     }
                 }
             }
         }
         /*foreach ( $parent_array as $key => $value )
         		{
         			
         		  $creation_info = array(
                         'group_id'                   => unique_id_generator(). rand(). time(),               
                         'group_name'                 => $value
                     );
         			//var_dump($creation_info);
         		  $this->load->model('createclass_model');
         		  $this->createclass_model->create_year($creation_info);
         		  
         		  	$insert=true;
         		 
         		}*/
         if ($insert) {
             $this->session->set_flashdata('add_class_success', '<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button><strong>Success! </strong>Class added successfully.</div>');
             redirect(base_url('/addstaff'));
         } else {
             $this->session->set_flashdata('add_class_error', '<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button><strong>Error! </strong>Something went wrong. Please try again.</div>');
             redirect(base_url('/setupschool'));
         }
     } else {
         $this->session->set_flashdata('add_class_notpermitted', '<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button><strong>Alert! </strong>Not A Logged In USER.Cant Add Data.</div>');
         redirect(base_url('setupschool'));
     }
 }
 public function post_staff_class_with_ajax()
 {
     $this->load->model('user_model');
     $this->load->model('section_model');
     $getclassname = $this->input->post('dataClassName');
     //$this->debug($getAjaxData); exit();
     $getstaffname = $this->input->post('dataStaffName');
     $getstaffemail = $this->input->post('dataStaffEmail');
     //$this->debug($getMoveClass); //exit();
     $getclassorg = $this->input->post('dataClassOrgId');
     $sizeOfData = sizeof($getclassname);
     //var_dump($sizeOfData);
     // var_dump($getstaffemail);
     // var_dump($getstaffname);
     // var_dump($getclassorg);
     $sectionIdArr = '';
     $stuIdArr = '';
     for ($i = 0; $i < $sizeOfData; $i++) {
         //var_dump('hello');
         $staffId = $getstaffemail[$i];
         $staffId = md5($staffId);
         $sectionUniqueId = unique_id_generator();
         $classname = $getclassname[$i];
         $class_org_id = $getclassorg[$i];
         $staff_organisation = $this->user_model->get_user_organisation($getstaffemail[$i]);
         if ($staff_organisation == false) {
             $staff_organisation = '';
         }
         // var_dump($staffId);
         // var_dump($sectionUniqueId);
         // var_dump($class_org_id);
         // var_dump($staff_organisation);
         // var_dump($classname);
         // var_dump($organisation);
         $result = $this->user_model->update_staff_class($sectionUniqueId, $staffId, $classname, $staff_organisation, $class_org_id);
         //if()
     }
     //$this->debug($sectionIdArr); exit();
     $result = true;
     if ($result) {
         echo json_encode(array('output' => 1));
     } else {
         echo json_encode(array('output' => 0));
     }
     exit;
     die;
 }
 public function create_taken_package_for_existing_user($user_email, $package_code, $recurring = true)
 {
     $end_date = date('Y-m-d', strtotime('+1 years') - 1 * 24 * 60 * 60);
     if ($recurring) {
         $end_date = date('Y-m-d', strtotime('+1 month') - 1 * 24 * 60 * 60);
     }
     $data = array('taken_packages_id' => md5($user_email . time() . unique_id_generator()), 'taken_packages_organisation_email_hash' => md5($user_email), 'taken_packages_package_code' => $package_code, 'taken_packages_start_date' => date('Y-m-d'), 'taken_packages_end_date' => $end_date, 'taken_packages_purchase_date' => date('Y-m-d'), 'taken_packages_package_status_id' => 2);
     if ($this->db->insert($data)) {
         return true;
     } else {
         return false;
     }
 }
 public function index($package_code = '')
 {
     $data = array();
     if ($package_code == '') {
         redirect(base_url('pricing'));
     }
     if (!($result = $this->payment_model->get_package_ammount($package_code))) {
         redirect(base_url('pricing'));
     }
     $this->package_code = $package_code;
     $this->package_yearly_price = $result[0]->package_yearly_price;
     $this->package_monthly_price = sprintf('%.2f', $this->package_yearly_price / 12);
     $this->package_recurring_payment = $result[0]->package_recurring_payment;
     $data['amount'] = $this->package_yearly_price;
     $data['recurring_payment'] = $this->package_recurring_payment;
     $data['package_min_member'] = $result[0]->package_min_members;
     $data['package_max_member'] = $result[0]->package_max_members;
     $data['package_description'] = $result[0]->package_description;
     $css_js_for_pricing = array('codeboxr_css' => array('bootstrap-switch', 'bootstrap-select.min'), 'codeboxr_js' => array('jquery.smooth-scroll', 'bootstrap-select.min', 'bootsrap-collapse'));
     $this->load->library('form_validation', '', 'frm_val');
     $this->load->model('dx_auth/users', 'users');
     $this->load->model('dx_auth/user_temp', 'user_temp');
     if ($this->dx_auth->is_logged_in() and $this->dx_auth->is_admin()) {
         //if the logged in user is admin just redirect to dashboard
         redirect(base_url('dashboard'));
     } else {
         if ($this->input->post('user_email') and $this->users->check_email($this->input->post('user_email'))) {
             //if user in user table
             $this->user_exist = true;
             if ($this->check_user_running_package($this->input->post('user_email'))) {
                 // if the user already have a running or pending package
                 $transaction_result = $this->braintree_ci->transactionSettlement($this->transaction_id);
                 $result->payment_model->update_order_info($transaction_result, $this->order_id, $this->user_taken_package_id);
                 /*$braintree_response_data = array(
                                     'recurring_transaction'                     => 1,
                                     'recurring_customer_id'                     => $webHookNotification->subscription->transactions[0]->customer[id],
                                     'recurring_subscription_id'                 => $webHookNotification->subscription->id,
                                     'recurring_subscription_status'             => $webHookNotification->subscription->status,
                                     'recurring_next_billing_amount'             => $webHookNotification->subscription->nextBillAmount,
                                     'recurring_next_billing_date'               => $webHookNotification->subscription->nextBillingDate->format( 'Y-m-d' ),
                                     'recurring_current_billing_cycle'           => $webHookNotification->subscription->currentBillingCycle,
                                     'recurring_payment_method_token'            => $webHookNotification->subscription->paymentMethodToken,
                                     'recurring_currency_code'                   => $webHookNotification->subscription->transactions[0]->currencyIsoCode,
                                     'recurring_transaction_failure'             => 0,
                 
                                     'transaction_id'                            => $webHookNotification->subscription->transactions[0]->id,
                                     'transaction_status'                        => $webHookNotification->subscription->transactions[0]->status,
                 
                                     'customer_billing_country_code_alpha_2'     => $webHookNotification->subscription->transactions[0]->billing[countryCodeAlpha2],
                                     'customer_billing_country_code_alpha_3'     => $webHookNotification->subscription->transactions[0]->billing[countryCodeAlpha3],
                                     'amount'                                    => $webHookNotification->subscription->transactions[0]->amount,
                                     'credit_card_type'                          => '',
                                 );*/
                 if ($this->dx_auth->is_logged_in() or $this->dx_auth->login($this->input->post('user_email'), $this->input->post('user_password'))) {
                     //if user logged in redirect with package code
                     redirect(base_url('user/upgrade/' . $package_code));
                 } else {
                     redirect(base_url('login/?return_url=' . base64_encode(base_url('user/upgrade/' . $package_code)) . '&email=' . $this->input->post('user_email') . '&eauth=' . md5($this->input->post('user_email'))));
                 }
             } else {
                 if ($this->have_any_order_in_queue($this->input->post('email'))) {
                     // check if user have previous order for processing
                     //braintree process code
                     if ($this->dx_auth->is_logged_in()) {
                         //if user logged in redirect with package code
                         redirect(base_url('user/upgrade/' . $package_code));
                     } else {
                         if ($this->dx_auth->login($this->input->post('user_email'), $this->input->post('user_password'))) {
                             redirect(base_url('user/upgrade/' . $package_code));
                         } else {
                             redirect(base_url('login/?return_url=' . base_url('user/upgrade/' . $package_code) . '&email=' . $this->input->post('user_email') . '&eauth=' . md5($this->input->post('user_email'))));
                         }
                     }
                 } else {
                     // set validate rules if user have no running package or no previous order
                     $this->validation_for_new_order = true;
                     $this->create_new_order = true;
                 }
             }
         } else {
             if ($this->input->post('user_email') and $this->have_any_order_in_queue($this->input->post('user_email'))) {
                 // if user have any previous order
                 $this->validation_for_new_user = true;
                 $this->user_already_has_a_transaction = true;
             } else {
                 $this->validation_for_both = true;
             }
         }
     }
     if ($this->validation_for_both or $this->validation_for_new_user) {
         //for new user
         // User registration info
         $min_password = 4;
         $max_password = 20;
         $this->frm_val->set_rules('user_email', 'Email', 'trim|required|xss_clean|valid_email');
         $this->frm_val->set_rules('user_password', 'Password', 'trim|required|xss_clean|min_length[' . $min_password . ']|max_length[' . $max_password . ']');
         $this->frm_val->set_rules('register_as', 'User Type', 'trim|required|xss_clean|numeric');
     }
     if ($this->validation_for_both or $this->validation_for_new_order) {
         // credit card details validation
         $this->frm_val->set_rules('number', 'Card Number', 'trim|required|min_length[15]|max_length[16]|xss_clean');
         $this->frm_val->set_rules('cvv', 'CVV', 'trim|required|min_length[3]|max_length[3]|xss_clean');
         $this->frm_val->set_rules('month', 'Expiration (MM/YYYY)', 'required|min_length[1]|max_length[2]|trim|xss_clean|required|is_natural_no_zero');
         $this->frm_val->set_rules('year', 'Expiration (MM/YYYY)', 'required|trim|min_length[3]|max_length[4]|xss_clean|required|is_natural_no_zero');
         $this->frm_val->set_rules('chname', 'Card Holder Name', 'required|trim|xss_clean');
         // customer details validation
         $this->frm_val->set_rules('customer_fname', 'First Name', 'required|trim|xss_clean');
         $this->frm_val->set_rules('customer_lname', 'Last Name', 'required|trim|xss_clean');
         $this->frm_val->set_rules('customer_email', 'Email', 'required|trim|xss_clean|valid_email');
         $this->frm_val->set_rules('customer_company', 'Company', 'required|trim|xss_clean');
         $this->frm_val->set_rules('customer_phone', 'Phone', 'required|trim|xss_clean');
         $this->frm_val->set_rules('customer_fax', 'Fax', 'required|trim|xss_clean');
         $this->frm_val->set_rules('customer_web', 'Website', 'required|trim|xss_clean');
         // customer details validation
         $this->frm_val->set_rules('customer_billing_fname', 'First Name', 'required|trim|xss_clean');
         $this->frm_val->set_rules('customer_billing_lname', 'Last Name', 'required|trim|xss_clean');
         $this->frm_val->set_rules('customer_billing_company', 'Company', 'required|trim|xss_clean');
         $this->frm_val->set_rules('customer_billing_country', 'Country', 'required|trim|xss_clean');
         $this->frm_val->set_rules('customer_billing_countryCodeAlpha3', 'Country Code', 'required|trim|xss_clean');
         $this->frm_val->set_rules('customer_billing_locality', 'Locality', 'required|trim|xss_clean');
         $this->frm_val->set_rules('customer_billing_postcode', 'Post Code', 'required|trim|xss_clean');
         $this->frm_val->set_rules('customer_billing_region', 'Region', 'required|trim|xss_clean');
         $this->frm_val->set_rules('customer_billing_streetAddress', 'Stree Address', 'required|trim|xss_clean');
         $this->frm_val->set_rules('customer_billing_streetAddress2', 'Stree Address 2', 'trim|xss_clean');
     }
     if ($this->frm_val->run() === false) {
     } else {
         $this->load->helper('function');
         $this->new_order_id = md5(time() . unique_id_generator());
         $order_info = array('order_id' => $this->new_order_id, 'package_code' => $package_code, 'customer_identity' => md5(set_value('user_email')), 'order_email' => set_value('user_email'), 'customer_fname' => set_value('customer_fname'), 'customer_lname' => set_value('customer_lname'), 'customer_email' => set_value('customer_email'), 'customer_phone' => set_value('customer_phone'), 'customer_web' => set_value('customer_web'), 'customer_fax' => set_value('customer_fax'), 'customer_company' => set_value('customer_company'), 'customer_billing_fname' => set_value('customer_billing_fname'), 'customer_billing_lname' => set_value('customer_billing_lname'), 'customer_billing_locality' => set_value('customer_billing_locality'), 'customer_billing_postcode' => set_value('customer_billing_postcode'), 'customer_billing_street_address_1' => set_value('customer_billing_streetAddress'), 'customer_billing_street_address_2' => set_value('customer_billing_streetAddress2'), 'customer_billing_country' => set_value('customer_billing_country'), 'customer_billing_region' => set_value('customer_billing_region'), 'customer_billing_company' => set_value('customer_billing_company'), 'customer_billing_country_code_alpha_3' => set_value('customer_billing_countryCodeAlpha3'), 'amount' => strtolower($this->package_recurring_payment) == 'y' ? $this->package_monthly_price : $this->package_yearly_price, 'credit_card_number' => set_value('number'), 'credit_card_cvv' => set_value('cvv'), 'credit_card_holder_name' => set_value('chname'), 'credit_card_exp_month' => set_value('month'), 'credit_card_exp_year' => set_value('year'));
         $new_user = array('password' => md5(set_value('user_password')), 'email' => set_value('user_email'), 'hashing_email' => md5(set_value('user_email')), 'package_code' => $package_code, 'last_ip' => $this->input->ip_address(), 'register_as' => set_value('register_as'), 'login_password' => set_value('user_password'));
         if ($this->user_exist) {
             //If user Already exist but dose not have any running package precess the new order
             if ($this->input->post('recurring_check')) {
                 $this->process_new_order($this->new_order_id, $order_info, true);
             } else {
                 $this->process_new_order($this->new_order_id, $order_info);
             }
         } else {
             if ($this->user_already_has_a_transaction) {
                 // if a transaction is already made with current provided email but have no existence in system just crate an account for his/her
                 $this->create_new_user($new_user);
             } else {
                 //if user is fresher just create an account and process the order
                 if ($this->input->post('recurring_check')) {
                     $this->process_new_order($this->new_order_id, $order_info, true);
                 } else {
                     $this->process_new_order($this->new_order_id, $order_info);
                 }
                 $this->create_new_user($new_user);
             }
         }
     }
     //$this->_render('payment/braintree/form', $data,$css_js_for_pricing);
     $this->_render('payment/braintree/form', $data, $css_js_for_pricing);
 }