<?php

/**
 * Profile Editor
 *
 * @description  This template is used to display the profile editor with [give_profile_editor]
 * @copyright    Copyright (c) 2015, WordImpress
 * @license      http://opensource.org/licenses/gpl-2.0.php GNU Public License
 */
global $current_user;
if (is_user_logged_in()) {
    $user_id = get_current_user_id();
    $first_name = get_user_meta($user_id, 'first_name', true);
    $last_name = get_user_meta($user_id, 'last_name', true);
    $display_name = $current_user->display_name;
    $address = give_get_donor_address($user_id);
    if (isset($_GET['updated']) && $_GET['updated'] == true && !give_get_errors()) {
        ?>
		<p class="give_success">
			<strong><?php 
        _e('Success', 'give');
        ?>
:</strong> <?php 
        _e('Your profile has been edited successfully.', 'give');
        ?>
		</p>
	<?php 
    }
    ?>

	<?php 
 /**
  * Set Donor Data
  *
  * @param $donor
  */
 private function set_donor_data($i, $data, $donor)
 {
     $columns = $this->csv_cols();
     //Set address variable
     $address = '';
     if (isset($donor->user_id) && $donor->user_id > 0) {
         $address = give_get_donor_address($donor->user_id);
     }
     //Set columns
     if (!empty($columns['full_name'])) {
         $data[$i]['full_name'] = $donor->name;
     }
     if (!empty($columns['email'])) {
         $data[$i]['email'] = $donor->email;
     }
     if (!empty($columns['address_line1'])) {
         $data[$i]['address_line1'] = isset($address['line1']) ? $address['line1'] : '';
         $data[$i]['address_line2'] = isset($address['line2']) ? $address['line2'] : '';
         $data[$i]['address_city'] = isset($address['city']) ? $address['city'] : '';
         $data[$i]['address_state'] = isset($address['state']) ? $address['state'] : '';
         $data[$i]['address_zip'] = isset($address['zip']) ? $address['zip'] : '';
         $data[$i]['address_country'] = isset($address['country']) ? $address['country'] : '';
     }
     if (!empty($columns['userid'])) {
         $data[$i]['userid'] = !empty($donor->user_id) ? $donor->user_id : '';
     }
     if (!empty($columns['date_first_donated'])) {
         $data[$i]['date_first_donated'] = date_i18n(get_option('date_format'), strtotime($donor->date_created));
     }
     if (!empty($columns['donations'])) {
         $data[$i]['donations'] = $donor->purchase_count;
     }
     if (!empty($columns['donation_sum'])) {
         $data[$i]['donation_sum'] = give_format_amount($donor->purchase_value);
     }
     return $data[$i];
 }