if (!isset($field['type'])) {
            $field['type'] = 'text';
        }
        if ($key == 'customer_status' && empty($field['value'])) {
            $default_status = get_option('wc_crm_default_status_crm');
            $field['value'] = !empty($default_status) ? $default_status : 'Customer';
        }
        if ($id > 0 && $the_customer->user_id == 0 && in_array($key, $disabled)) {
            $field['custom_attributes']['disabled'] = true;
        }
        switch ($field['type']) {
            case "select":
                woocommerce_wp_select($field);
                break;
            case "multiselect":
                wc_crm_wp_multiselect($field);
                break;
            default:
                woocommerce_wp_text_input($field);
                break;
        }
    }
}
?>
						</div>
					</div>
					<div class="order_data_column" id="order_data_column_billing">
						<h4>
							<?php 
_e('Billing Details ', 'woocommerce');
?>
    /**
     * Get customer detail
     */
    function get_customer_detail()
    {
        global $thepostid, $post, $woocommerce;
        $b_country = '';
        $s_country = '';
        if ($this->user_id) {
            $b_country = get_user_meta($this->user_id, 'billing_country', true);
            $s_country = get_user_meta($this->user_id, 'shipping_country', true);
        } else {
            if ($this->order_id) {
                $b_country = $this->order->billing_country;
                $s_country = $this->order->shipping_country;
                $thepostid = $this->order_id;
            }
        }
        if (!$this->order_id) {
            $this->init_general_fields($this->user_id);
            $thepostid = true;
        }
        $this->init_address_fields($b_country, $s_country);
        ?>
			<div class="panel-wrap woocommerce" id="customer_data">
				<div id="order_data" class="panel">
					<?php 
        echo get_avatar($this->user_id, 100);
        ?>
					<?php 
        if ($this->user_id) {
            ?>
						<h2><?php 
            echo __('Customer', 'wc_customer_relationship_manager') . ' #' . $this->user_id . ' ';
            _e('Details', 'wc_customer_relationship_manager');
            ?>
</h2>
					<?php 
        } else {
            if ($this->order_id) {
                ?>
						<h2><?php 
                _e('Customer Details', 'wc_customer_relationship_manager');
                ?>
</h2>
					<?php 
            }
        }
        ?>
					<?php 
        if ($this->user_id) {
            $user_data = get_userdata(intval($this->user_id));
            ?>
						<p class="order_number total_value" style="float: left; margin-right: 10px;">
							<?php 
            _e('Value:', 'wc_customer_relationship_manager');
            ?>
							<?php 
            $identifier = get_option('woocommerce_crm_unique_identifier');
            if ($identifier == 'username_email') {
                $total_spent = wc_crm_get_order_value($this->user_id);
                $num_orders = wc_crm_get_num_orders($this->user_id);
            } else {
                $email = get_user_meta($this->user_id, 'billing_email', true);
                $num_orders = wc_crm_get_num_orders($email, '_billing_email', true);
                $total_spent = wc_crm_get_order_value($email, '_billing_email', true);
            }
            echo wc_price($total_spent);
            ?>
						</p>
						<p class="order_number num_orders" style="float: left; margin-right: 10px;">
							<?php 
            _e('Orders:', 'wc_customer_relationship_manager');
            ?>
							<?php 
            echo sprintf(_n('1 order', '%s orders', $num_orders, 'wc_customer_relationship_manager'), $num_orders);
            ?>
						</p>
						<p class="order_number created_date" style="float: left; margin-right: 10px;">
							<?php 
            _e('Created:', 'wc_customer_relationship_manager');
            ?>
							<?php 
            echo wc_crm_get_customer_pretty_time($user_data->user_registered);
            ?>
						</p>
					<?php 
        } else {
            if ($this->order_id) {
                ?>
					<?php 
            }
        }
        ?>
					<div class="order_data_column_container">
						<?php 
        if (!$this->order_id) {
            ?>
						<div class="order_data_column">
							<h4><?php 
            _e('General Details', 'wc_customer_relationship_manager');
            ?>
</h4>
							<div id="customer_general_details">
								<?php 
            if ($this->general_fields) {
                foreach ($this->general_fields as $key => $field) {
                    $field['id'] = $key;
                    if (!isset($field['type'])) {
                        $field['type'] = 'text';
                    }
                    if ($key == 'customer_status' && empty($field['value'])) {
                        $default_status = get_option('wc_crm_default_status_crm');
                        $field['value'] = !empty($default_status) ? $default_status : 'Customer';
                    }
                    switch ($field['type']) {
                        case "select":
                            woocommerce_wp_select($field);
                            break;
                        case "multiselect":
                            wc_crm_wp_multiselect($field);
                            break;
                        default:
                            woocommerce_wp_text_input($field);
                            break;
                    }
                }
            }
            ?>
							</div>
						</div>
						<?php 
        } else {
            global $wpdb;
            $ID = (int) $this->order_id;
            $user_email = $wpdb->get_var("SELECT email FROM {$wpdb->prefix}wc_crm_customer_list WHERE order_id = {$ID} LIMIT 1");
            ?>
						<div class="order_data_column" style=" float: none;">
							<p class="form-field form-field-wide"><label for="account_name"><?php 
            _e('Account Name:', 'wc_customer_relationship_manager');
            ?>
</label>
							<select id="account_name" name="account_name" class="chosen_select" data-allow_clear="true" data-placeholder="<?php 
            _e('Select an account', 'wc_customer_relationship_manager');
            ?>
">
								<option value=""></option>
								<?php 
            $selected = wc_crm_get_customer_account($user_email);
            $accounts = wc_crm_get_accounts();
            foreach ($accounts as $account) {
                echo '<option value="' . esc_attr($account->ID) . '" ' . selected($account->ID, $selected, false) . '>' . esc_html($account->post_title) . '</option>';
            }
            ?>
							</select>
							</p>
						</div>
						<div class="clear"></div>
						<?php 
        }
        ?>
						<div class="order_data_column" id="order_data_column_billing">
							<h4><?php 
        _e('Billing Details ', 'wc_customer_relationship_manager');
        ?>
<a class="edit_address" href="#" <?php 
        echo empty($this->user_id) ? 'style="display: none;"' : '';
        ?>
 ><img src="<?php 
        echo WC()->plugin_url();
        ?>
/assets/images/icons/edit.png" alt="Edit" width="14" /></a></h4>
							<?php 
        if ($this->user_id || $this->order_id) {
            // Display values
            echo '<div class="address">';
            if ($this->get_formatted_billing_address()) {
                echo '<p><strong>' . __('Address', 'wc_customer_relationship_manager') . ':</strong>' . wp_kses($this->get_formatted_billing_address(), array('br' => array())) . '</p>';
            } else {
                echo '<p class="none_set"><strong>' . __('Address', 'wc_customer_relationship_manager') . ':</strong> ' . __('No billing address set.', 'wc_customer_relationship_manager') . '</p>';
            }
            foreach ($this->billing_fields as $key => $field) {
                if (isset($field['show']) && $field['show'] === false) {
                    continue;
                }
                $field_name = 'billing_' . $key;
                if ($this->user_id) {
                    $field_value = get_user_meta($this->user_id, $field_name, true);
                } elseif ($this->order_id) {
                    $name_var = 'billing_' . $key;
                    $field_value = $this->order->{$field_name};
                }
                if (!empty($field_value)) {
                    echo '<p><strong>' . esc_html($field['label']) . ':</strong> ' . make_clickable(esc_html($field_value)) . '</p>';
                }
            }
            if (WC()->payment_gateways()) {
                $payment_gateways = WC()->payment_gateways->payment_gateways();
            }
            if ($this->user_id) {
                $payment_method = get_user_meta($this->user_id, 'preferred_payment_method', true);
            } else {
                $payment_method = !empty($this->order->payment_method) ? $this->order->payment_method : '';
            }
            if ($payment_method) {
                echo '<p><strong>' . __('Preferred Payment Method', 'wc_customer_relationship_manager') . ':</strong> ' . (isset($payment_gateways[$payment_method]) ? esc_html($payment_gateways[$payment_method]->get_title()) : esc_html($payment_method)) . '</p>';
            }
            echo '</div>';
        }
        if (!$this->order_id) {
            // Display form
            echo '<div class="edit_address" ' . (!$this->user_id ? 'style="display: block;"' : '') . '>';
            foreach ($this->billing_fields as $key => $field) {
                if (!isset($field['type'])) {
                    $field['type'] = 'text';
                }
                if (isset($data['_billing_' . $key]) && $data['_billing_' . $key]) {
                    $value = $data['_billing_' . $key];
                } elseif ($this->user_id) {
                    $value = get_user_meta($this->user_id, 'billing_' . $key, true);
                } elseif ($this->order_id) {
                    $var_name = 'billing_' . $key;
                    $value = $this->order->{$var_name};
                } else {
                    $value = '';
                }
                $post = new WC_Order($this->order_id);
                $class_ = '';
                if (!empty($field['class']) && is_array($field['class'])) {
                    $class_ = implode(' ', $field['class']);
                }
                switch ($field['type']) {
                    case "select":
                        woocommerce_wp_select(array('id' => '_billing_' . $key, 'class' => $class_, 'label' => $field['label'], 'options' => $field['options'], 'value' => $value));
                        break;
                    default:
                        woocommerce_wp_text_input(array('id' => '_billing_' . $key, 'class' => $class_, 'label' => $field['label'], 'value' => $value));
                        break;
                }
            }
            ?>
								<p class="form-field form-field-wide">
									<label><?php 
            _e('Payment Method:', 'wc_customer_relationship_manager');
            ?>
</label>
									<select name="_payment_method" id="_payment_method" class="first">
										<option value=""><?php 
            _e('N/A', 'wc_customer_relationship_manager');
            ?>
</option>
										<?php 
            $found_method = false;
            foreach ($payment_gateways as $gateway) {
                if ($gateway->enabled == "yes") {
                    echo '<option value="' . esc_attr($gateway->id) . '" ' . selected($payment_method, $gateway->id, false) . '>' . esc_html($gateway->get_title()) . '</option>';
                    if ($payment_method == $gateway->id) {
                        $found_method = true;
                    }
                }
            }
            if (!$found_method && !empty($payment_method)) {
                echo '<option value="' . esc_attr($payment_method) . '" selected="selected">' . __('Other', 'wc_customer_relationship_manager') . '</option>';
            } else {
                echo '<option value="other">' . __('Other', 'wc_customer_relationship_manager') . '</option>';
            }
            ?>
									</select>
								</p>
								<?php 
            echo '</div>';
        }
        ?>
						</div>
						<div class="order_data_column" id="order_data_column_shipping">

							<h4><?php 
        _e('Shipping Details', 'wc_customer_relationship_manager');
        ?>
 <a class="edit_address" href="#" <?php 
        echo empty($this->user_id) ? 'style="display: none;"' : '';
        ?>
 ><img src="<?php 
        echo WC()->plugin_url();
        ?>
/assets/images/icons/edit.png" alt="Edit" width="14" /></a></h4>
							<?php 
        if ($this->user_id || $this->order_id) {
            // Display values
            echo '<div class="address">';
            if ($this->get_formatted_shipping_address()) {
                echo '<p><strong>' . __('Address', 'wc_customer_relationship_manager') . ':</strong>' . wp_kses($this->get_formatted_shipping_address(), array('br' => array())) . '</p>';
            } else {
                echo '<p class="none_set"><strong>' . __('Address', 'wc_customer_relationship_manager') . ':</strong> ' . __('No shipping address set.', 'wc_customer_relationship_manager') . '</p>';
            }
            if ($this->shipping_fields) {
                foreach ($this->shipping_fields as $key => $field) {
                    if (isset($field['show']) && $field['show'] === false) {
                        continue;
                    }
                    $field_name = 'shipping_' . $key;
                    if ($this->user_id) {
                        $field_value = get_user_meta($this->user_id, $field_name, true);
                    } elseif ($this->order_id) {
                        $name_var = 'billing_' . $key;
                        $field_value = $this->order->{$field_name};
                    }
                    if (!empty($order->{$field_name})) {
                        echo '<p><strong>' . esc_html($field['label']) . ':</strong> ' . make_clickable(esc_html($field_value)) . '</p>';
                    }
                }
            }
            echo '</div>';
        }
        if (!$this->order_id) {
            // Display form
            echo '<div class="edit_address" ' . (empty($this->user_id) ? 'style="display: block;"' : '') . '><p><button class="button" id="copy-billing-same-as-shipping" type="button">' . __('Copy from billing', 'wc_customer_relationship_manager') . '</button></p>';
            if ($this->shipping_fields) {
                foreach ($this->shipping_fields as $key => $field) {
                    if (!isset($field['type'])) {
                        $field['type'] = 'text';
                    }
                    if (isset($data['copy']) && $data['copy']) {
                        if (isset($data['_billing_' . $key]) && $data['_billing_' . $key]) {
                            $value = $data['_billing_' . $key];
                        } elseif ($this->user_id) {
                            $value = get_user_meta($this->user_id, 'billing_' . $key, true);
                        } elseif ($this->order_id) {
                            $var_name = 'billing_' . $key;
                            $value = $this->order->{$var_name};
                        } else {
                            $value = '';
                        }
                    } elseif (isset($data['_shipping_' . $key]) && $data['_shipping_' . $key]) {
                        $value = $data['_shipping_' . $key];
                    } elseif ($this->user_id) {
                        $value = get_user_meta($this->user_id, 'shipping_' . $key, true);
                    } elseif ($this->order_id) {
                        $var_name = 'shipping_' . $key;
                        $value = $this->order->{$var_name};
                    } else {
                        $value = '';
                    }
                    $class_ = '';
                    if (!empty($field['class']) && is_array($field['class'])) {
                        $class_ = implode(' ', $field['class']);
                    }
                    switch ($field['type']) {
                        case "select":
                            woocommerce_wp_select(array('id' => '_shipping_' . $key, 'class' => $class_, 'label' => $field['label'], 'options' => $field['options'], 'value' => $value));
                            break;
                        default:
                            woocommerce_wp_text_input(array('id' => '_shipping_' . $key, 'class' => $class_, 'label' => $field['label'], 'value' => $value));
                            break;
                    }
                }
            }
            echo '</div>';
        }
        ?>
						</div>
					</div>
					<?php 
        if ($this->user_id || $this->order_id) {
            $address_l = str_replace('<br/>', ', ', $this->get_formatted_billing_address(true));
            ?>
					<div id="customer_address_map_canvas" >
						<div class="acf-google-map active" data-zoom="14" data-zoom="14" data-lng="144.96328" data-lat="-37.81411" data-id="map-crm" >
			
							<div style="display:none;">
								<div style="display:none;">
								<input class="input-address" type="hidden" value="<?php 
            echo $address_l;
            ?>
" >
								<input class="input-lat" type="hidden" value="" >
								<input class="input-lng" type="hidden" value="" >
								</div>
							</div>
							<div class="title" style="display:none;">
								<div class="no-value">
									<a title="Find current location" class="acf-sprite-locate ir" href="#">Locate</a>
									<input type="text" class="search" placeholder="Search for address..." value="<?php 
            echo $address_l;
            ?>
">
								</div>								
							</div>
							<div class="canvas" style="height: 300px"></div>
							
						</div>
					</div>
						<script>
						var wc_pos_customer_formatted_billing_address = '<?php 
            echo $address_l;
            ?>
';						
						</script>
					<?php 
        }
        ?>
					<div class="clear"></div>
				</div>
			</div>
			<script>
				jQuery('.form-row-left').parent().css('float', 'left');
				jQuery('.form-row-right').parent().css('float', 'right');
			</script>
			<?php 
    }