function acui_options()
{
    global $url_plugin;
    if (!current_user_can('create_users')) {
        wp_die(__('You are not allowed to see this content.'));
    }
    if (isset($_GET['tab'])) {
        $tab = $_GET['tab'];
    } else {
        $tab = 'homepage';
    }
    if (isset($_POST) && !empty($_POST)) {
        switch ($tab) {
            case 'homepage':
                acui_fileupload_process($_POST, false);
                return;
                break;
            case 'mail-template':
                acui_save_mail_template($_POST);
                break;
            case 'cron':
                acui_manage_cron_process($_POST);
                break;
        }
    }
    if (isset($_GET['tab'])) {
        acui_admin_tabs($_GET['tab']);
    } else {
        acui_admin_tabs('homepage');
    }
    switch ($tab) {
        case 'homepage':
            $args_old_csv = array('post_type' => 'attachment', 'post_mime_type' => 'text/csv', 'post_status' => 'inherit', 'posts_per_page' => -1);
            $old_csv_files = new WP_Query($args_old_csv);
            acui_check_options();
            ?>
	<div class="wrap">	

		<?php 
            if ($old_csv_files->found_posts > 0) {
                ?>
		<div class="postbox">
		    <div title="Click to open/close" class="handlediv">
		      <br>
		    </div>

		    <h3 class="hndle"><span>&nbsp;Old CSV files uploaded</span></h3>

		    <div class="inside" style="display: block;">
		    	<p>For security reasons you should delete this files, probably they would be visible in the Internet if a bot or someone discover the URL. You can delete each file or maybe you want delete all CSV files you have uploaded:</p>
		    	<input type="button" value="Delete all CSV files uploaded" id="bulk_delete_attachment" style="float:right;"></input>
		    	<ul>
		    		<?php 
                while ($old_csv_files->have_posts()) {
                    $old_csv_files->the_post();
                    if (get_the_date() == "") {
                        $date = "undefined";
                    } else {
                        $date = get_the_date();
                    }
                    ?>
		    		<li><a href="<?php 
                    echo wp_get_attachment_url(get_the_ID());
                    ?>
"><?php 
                    the_title();
                    ?>
</a> uploaded the <?php 
                    echo $date;
                    ?>
 <input type="button" value="Delete" class="delete_attachment" attach_id="<?php 
                    the_ID();
                    ?>
"></input></li>
		    		<?php 
                }
                ?>
		    		<?php 
                wp_reset_postdata();
                ?>
		    	</ul>
		        <div style="clear:both;"></div>
		    </div>
		</div>
		<?php 
            }
            ?>
	

		<div id='message' class='updated'>File must contain at least <strong>2 columns: username and email</strong>. These should be the first two columns and it should be placed <strong>in this order: username and email</strong>. If there are more columns, this plugin will manage it automatically.</div>
		<div id='message-password' class='error'>Please, read carefully how <strong>passwords are managed</strong> and also take note about capitalization, this plugin is <strong>case sensitive</strong>.</div>

		<div style="float:left; width:80%;">
			<h2>Import users from CSV</h2>
		</div>

		<div style="clear:both;"></div>

		<div style="width:100%;">
			<form method="POST" enctype="multipart/form-data" action="" accept-charset="utf-8" onsubmit="return check();">
			<table class="form-table">
				<tbody>
				<tr class="form-field">
					<th scope="row"><label for="role">Role</label></th>
					<td>
					<?php 
            $list_roles = acui_get_editable_roles();
            foreach ($list_roles as $key => $value) {
                if ($key == "subscriber") {
                    echo "<label style='margin-right:5px;'><input name='role[]' type='checkbox' checked='checked' value='{$key}'/>{$value}</label>";
                } else {
                    echo "<label style='margin-right:5px;'><input name='role[]' type='checkbox' value='{$key}'/>{$value}</label>";
                }
            }
            ?>

					<p class="description">If you choose more than one role, the roles would be assigned correctly but you should use some plugin like <a href="https://wordpress.org/plugins/user-role-editor/">User Role Editor</a> to manage them.</p>
					</td>
				</tr>
				<tr class="form-field form-required">
					<th scope="row"><label>CSV file <span class="description">(required)</span></label></th>
					<td>
						<div id="upload_file">
							<input type="file" name="uploadfiles[]" id="uploadfiles" size="35" class="uploadfiles" />
							<em>or you can choose directly a file from your host, <a href="#" class="toggle_upload_path">click here</a>.</em>
						</div>
						<div id="introduce_path" style="display:none;">
							<input placeholder="You have to introduce the path to file, i.e.: <?php 
            $upload_dir = wp_upload_dir();
            echo $upload_dir["path"];
            ?>
/test.csv" type="text" name="path_to_file" id="path_to_file" value="<?php 
            echo dirname(__FILE__);
            ?>
/test.csv" style="width:70%;" />
							<em>or you can upload it directly from your PC, <a href="#" class="toggle_upload_path">click here</a>.</em>
						</div>
					</td>
				</tr>
				<tr class="form-field form-required">
					<th scope="row"><label>What should do the plugin with empty cells?</label></th>
					<td>
						<select name="empty_cell_action">
							<option value="leave">Leave the old value for this metadata</option>
							<option value="delete">Delete the metadata</option>							
						</select>
					</td>
				</tr>

				<?php 
            if (is_plugin_active('buddypress/bp-loader.php')) {
                if (!class_exists("BP_XProfile_Group")) {
                    require_once WP_PLUGIN_DIR . "/buddypress/bp-xprofile/classes/class-bp-xprofile-group.php";
                }
                $buddypress_fields = array();
                $profile_groups = BP_XProfile_Group::get(array('fetch_fields' => true));
                if (!empty($profile_groups)) {
                    foreach ($profile_groups as $profile_group) {
                        if (!empty($profile_group->fields)) {
                            foreach ($profile_group->fields as $field) {
                                $buddypress_fields[] = $field->name;
                            }
                        }
                    }
                }
                ?>

				<tr class="form-field form-required">
					<th scope="row"><label>BuddyPress users</label></th>
					<td>You can insert any profile from BuddyPress using his name as header. Plugin will check, before import, which fields are defined in BuddyPress and will assign it in the update. You can use this fields:
					<ul style="list-style:disc outside none;margin-left:2em;">
						<?php 
                foreach ($buddypress_fields as $buddypress_field) {
                    ?>
<li><?php 
                    echo $buddypress_field;
                    ?>
</li><?php 
                }
                ?>
					</ul>
					Remember that all date fields have to be imported using a format like this: 2016-01-01 00:00:00

					<p class="description"><strong>(Only for <a href="https://wordpress.org/plugins/buddypress/">BuddyPress</a> users)</strong>.</p>
					</td>					
				</tr>

				<?php 
            }
            ?>

				<?php 
            if (is_plugin_active('wp-members/wp-members.php')) {
                ?>

				<tr class="form-field form-required">
					<th scope="row"><label>Y</label></th>
					<td>
						<select name="activate_users_wp_members">
							<option value="no_activate">Do not activate users</option>
							<option value="activate">Activate users when they are being imported</option>
						</select>

						<p class="description"><strong>(Only for <a href="https://wordpress.org/plugins/wp-members/">WP Members</a> users)</strong>.</p>
					</td>
					
				</tr>

				<?php 
            }
            ?>

				<?php 
            if (is_plugin_active('new-user-approve/new-user-approve.php')) {
                ?>

				<tr class="form-field form-required">
					<th scope="row"><label>Approve users at the same time is being created</label></th>
					<td>
						<select name="approve_users_new_user_appove">
							<option value="no_approve">Do not approve users</option>
							<option value="approve">Approve users when they are being imported</option>
						</select>

						<p class="description"><strong>(Only for <a href="https://es.wordpress.org/plugins/new-user-approve/">New User Approve</a> users)</strong>.</p>
					</td>
					
				</tr>

				<?php 
            }
            ?>

				<?php 
            if (is_plugin_active('allow-multiple-accounts/allow-multiple-accounts.php')) {
                ?>

				<tr class="form-field form-required">
					<th scope="row"><label>Repeated email in different users?</label></th>
					<td>
						<select name="allow_multiple_accounts">
							<option value="not_allowed">Not allowed</option>
							<option value="allowed">Allowed</option>
						</select>
						<p class="description"><strong>(Only for <a href="https://wordpress.org/plugins/allow-multiple-accounts/">Allow Multiple Accounts</a> users)</strong>. Allow multiple user accounts to be created having the same email address.</p>
					</td>
				</tr>

				<?php 
            }
            ?>

				<?php 
            if (is_plugin_active('wp-access-areas/wp-access-areas.php')) {
                ?>

				<tr class="form-field form-required">
					<th scope="row"><label>WordPress Access Areas is activated</label></th>
					<td>
						<p class="description">As user of <a href="https://wordpress.org/plugins/wp-access-areas/">WordPress Access Areas</a> you can use the Access Areas created <a href="<?php 
                echo admin_url('users.php?page=user_labels');
                ?>
">here</a> and use this areas in your own CSV file. Please use the column name <strong>wp-access-areas</strong> and in each row use <strong>the name that you have used <a href="<?php 
                echo admin_url('users.php?page=user_labels');
                ?>
">here</a></strong>, like this ones:</p>
						<ol>
							<?php 
                $data = WPAA_AccessArea::get_available_userlabels('0,5', NULL);
                foreach ($data as $access_area_object) {
                    ?>
									<li><?php 
                    echo $access_area_object->cap_title;
                    ?>
</li>
							<?php 
                }
                ?>

						</ol>
						<p class="description">If you leave this cell empty for some user or the access area indicated doesn't exist, user won't be assigned to any access area. You can choose more than one area for each user using pads between them in the same row, i.e.: access_area1#accces_area2</p>
					</td>
				</tr>

				<?php 
            }
            ?>

				<tr class="form-field">
					<th scope="row"><label for="user_login">Send mail</label></th>
					<td>
						<p>Do you wish to send a mail with credentials and other data? <input type="checkbox" name="sends_email" value = "yes"></p>
						<p>Do you wish to send this mail also to users that are being updated? (not only to the one which are being created) <input type="checkbox" name="send_email_updated" value = "yes" checked="checked"></p>
					</td>
				</tr>
				</tbody>
			</table>
			<input class="button-primary" type="submit" name="uploadfile" id="uploadfile_btn" value="Start importing"/>
			</form>
		</div>

	</div>
	<script type="text/javascript">
	function check(){
		if(document.getElementById("uploadfiles").value == "" && jQuery( "#upload_file" ).is(":visible") ) {
		   alert("Please choose a file");
		   return false;
		}

		if( jQuery( "#path_to_file" ).val() == "" && jQuery( "#introduce_path" ).is(":visible") ) {
		   alert("Please enter a path to the file");
		   return false;
		}

		if( jQuery("[name=role\\[\\]]input:checkbox:checked").length == 0 ){
			alert("Please select a role");
		   	return false;	
		}
	}

	jQuery( document ).ready( function( $ ){
		$( ".delete_attachment" ).click( function(){
			var answer = confirm( "Are you sure to delete this file?" );
			if( answer ){
				var data = {
					'action': 'acui_delete_attachment',
					'attach_id': $( this ).attr( "attach_id" )
				};

				$.post(ajaxurl, data, function(response) {
					if( response != 1 )
						alert( "There were problems deleting the file, please check file permissions" );
					else{
						alert( "File successfully deleted" );
						document.location.reload();
					}
				});
			}
		});

		$( "#bulk_delete_attachment" ).click( function(){
			var answer = confirm( "Are you sure to delete ALL CSV files uploaded? There can be CSV files from other plugins." );
			if( answer ){
				var data = {
					'action': 'acui_bulk_delete_attachment',
				};

				$.post(ajaxurl, data, function(response) {
					if( response != 1 )
						alert( "There were problems deleting the files, please check files permissions" );
					else{
						alert( "Files successfully deleted" );
						document.location.reload();
					}
				});
			}
		});

		$( ".toggle_upload_path" ).click( function( e ){
			e.preventDefault();

			$("#upload_file,#introduce_path").toggle();
		} );

	} );
	</script>

	<?php 
            break;
        case 'columns':
            $headers = get_option("acui_columns");
            ?>

		<h3>Custom columns loaded</h3>
		<table class="form-table">
		<tbody>
			<tr valign="top">
				<th scope="row">Columns loaded in previous files</th>
				<td><small><em>(if you load another CSV with different columns, the new ones will replace this list)</em></small>
					<ol>
						<?php 
            if (is_array($headers) && count($headers) > 0) {
                foreach ($headers as $column) {
                    ?>
							<li><?php 
                    echo $column;
                    ?>
</li>
						<?php 
                }
                ?>
						
						<?php 
            } else {
                ?>
							<li>There is no columns loaded yet</li>							
						<?php 
            }
            ?>
					</ol>
				</td>
			</tr>
		</tbody></table>

		<?php 
            break;
        case 'doc':
            ?>

		<h3>Documentation</h3>
		<table class="form-table">
		<tbody>
			<tr valign="top">
				<th scope="row">Columns position</th>
				<td><small><em>(Documents should look like the one presented into screenshot. Remember you should fill the first two columns with the next values)</em></small>
					<ol>
						<li>Username</li>
						<li>Email</li>
					</ol>						
					<small><em>(The next columns are totally customizable and you can use whatever you want. All rows must contains same columns)</em></small>
					<small><em>(User profile will be adapted to the kind of data you have selected)</em></small>
					<small><em>(If you want to disable the extra profile information, please deactivate this plugin after make the import)</em></small>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row">Passwords</th>
				<td>A string that contains user passwords. We have different options for this case:
					<ul style="list-style:disc outside none; margin-left:2em;">
						<li>If user is created: if you set a value for the password, it will be used; if not, it will be generated</li>
						<li>If user is updated: 
							<ul style="list-style:disc outside none;margin-left:2em;">
								<li>If you <strong>don't create a column for passwords</strong>: passwords will be generated automatically</li>
								<li>If you <strong>create a column for passwords</strong>: if cell is empty, password won't be updated; if cell has a value, it will be used</li>
							</ul>
					</ul>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row">WordPress default profile data</th>
				<td>You can use those labels if you want to set data adapted to the WordPress default user columns (the ones who use the function <a href="http://codex.wordpress.org/Function_Reference/wp_update_user">wp_update_user</a>)
					<ol>
						<li><strong>user_nicename</strong>: A string that contains a URL-friendly name for the user. The default is the user's username.</li>
						<li><strong>user_url</strong>: A string containing the user's URL for the user's web site.	</li>
						<li><strong>display_name</strong>: A string that will be shown on the site. Defaults to user's username. It is likely that you will want to change this, for both appearance and security through obscurity (that is if you don't use and delete the default admin user).</li>
						<li><strong>nickname</strong>: The user's nickname, defaults to the user's username.	</li>
						<li><strong>first_name</strong>: The user's first name.</li>
						<li><strong>last_name</strong>: The user's last name.</li>
						<li><strong>description</strong>: A string containing content about the user.</li>
						<li><strong>jabber</strong>: User's Jabber account.</li>
						<li><strong>aim</strong>: User's AOL IM account.</li>
						<li><strong>yim</strong>: User's Yahoo IM account.</li>
						<li><strong>user_registered</strong>: Using the WordPress format for this kind of data Y-m-d H:i:s.</li>
					</ol>
				</td>
			</tr>
			<?php 
            if (is_plugin_active('woocommerce/woocommerce.php')) {
                ?>

				<tr valign="top">
					<th scope="row">WooCommerce is activated</th>
					<td>You can use those labels if you want to set data adapted to the WooCommerce default user columns)
					<ol>
						<li>billing_first_name</li>
						<li>billing_last_name</li>
						<li>billing_company</li>
						<li>billing_address_1</li>
						<li>billing_address_2</li>
						<li>billing_city</li>
						<li>billing_postcode</li>
						<li>billing_country</li>
						<li>billing_state</li>
						<li>billing_phone</li>
						<li>billing_email</li>
						<li>shipping_first_name</li>
						<li>shipping_last_name</li>
						<li>shipping_company</li>
						<li>shipping_address_1</li>
						<li>shipping_address_2</li>
						<li>shipping_city</li>
						<li>shipping_postcode</li>
						<li>shipping_country</li>
						<li>shipping_state</li>
					</ol>
				</td>
				</tr>

				<?php 
            }
            ?>
			<tr valign="top">
				<th scope="row">Important notice</th>
				<td>You can upload as many files as you want, but all must have the same columns. If you upload another file, the columns will change to the form of last file uploaded.</td>
			</tr>
			<tr valign="top">
				<th scope="row">Any question about it</th>
				<td>
					<ul style="list-style:disc outside none; margin-left:2em;">
						<li>Free support (in WordPress forums): <a href="https://wordpress.org/support/plugin/import-users-from-csv-with-meta">https://wordpress.org/support/plugin/import-users-from-csv-with-meta</a>.</li>
						<li>Premium support (with a quote): <a href="mailto:contacto@codection.com">contacto@codection.com</a>.</li>
					</ul>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row">Example</th>
			<td>Download this <a href="<?php 
            echo plugins_url() . "/import-users-from-csv-with-meta/test.csv";
            ?>
">.csv file</a> to test</td> 
			</tr>
		</tbody>
		</table>
		<br/>
		<div style="width:775px;margin:0 auto"><img src="<?php 
            echo plugins_url() . "/import-users-from-csv-with-meta/csv_example.png";
            ?>
"/></div>
	<?php 
            break;
            ?>

	<?php 
        case 'mail-template':
            $from_email = get_option("acui_mail_from");
            $from_name = get_option("acui_mail_from_name");
            $body_mail = get_option("acui_mail_body");
            $subject_mail = get_option("acui_mail_subject");
            ?>
		<h3>Customize the email that can be sent when importing users</h3>

		<p class="description">You can set your own SMTP and other mail details <a href="<?php 
            echo admin_url('tools.php?page=acui-smtp');
            ?>
" target="_blank">here</a>.
		
		<form method="POST" enctype="multipart/form-data" action="" accept-charset="utf-8">
			<p>Mail subject : <input name="subject_mail" size="100" value="<?php 
            echo $subject_mail;
            ?>
" id="title" autocomplete="off" type="text"></p>
			<?php 
            wp_editor($body_mail, 'body_mail');
            ?>

			<br/>
			<input class="button-primary" type="submit" value="Save mail template"/>
		</form>
		
		<p>You can use:</p>
		<ul style="list-style-type:disc; margin-left:2em;">
			<li>**username** = username to login</li>
			<li>**password** = user password</li>
			<li>**loginurl** = current site login url</li>
			<li>**email** = user email</li>
			<li>You can also use any WordPress user standard field or an own metadata, if you have used it in your CSV. For example, if you have a first_name column, you could use **first_name** or any other meta_data like **my_custom_meta**</li>
		</ul>

	<?php 
            break;
            ?>

	<?php 
        case 'cron':
            $cron_activated = get_option("acui_cron_activated");
            $send_mail_cron = get_option("acui_send_mail_cron");
            $send_mail_updated = get_option("acui_send_mail_updated");
            $cron_delete_users = get_option("acui_cron_delete_users");
            $path_to_file = get_option("acui_cron_path_to_file");
            $period = get_option("acui_cron_period");
            $role = get_option("acui_cron_role");
            $log = get_option("acui_cron_log");
            if (empty($cron_activated)) {
                $cron_activated = false;
            }
            if (empty($send_mail_cron)) {
                $send_mail_cron = false;
            }
            if (empty($send_mail_updated)) {
                $send_mail_updated = false;
            }
            if (empty($cron_delete_users)) {
                $cron_delete_users = false;
            }
            if (empty($path_to_file)) {
                $path_to_file = dirname(__FILE__) . '/test.csv';
            }
            if (empty($period)) {
                $period = 'hourly';
            }
            if (empty($role)) {
                $role = "subscriber";
            }
            if (empty($log)) {
                $log = "No tasks done yet.";
            }
            ?>
		<h3>Execute an import of users periodically</h3>

		<form method="POST" enctype="multipart/form-data" action="" accept-charset="utf-8">
			<table class="form-table">
				<tbody>
				<tr class="form-field">
					<th scope="row"><label for="path_to_file">Path of file that are going to be imported</label></th>
					<td>
						<input placeholder="Insert complete path to the file" type="text" name="path_to_file" id="path_to_file" value="<?php 
            echo $path_to_file;
            ?>
" style="width:70%;" />
						<p class="description">You have to introduce the path to file, i.e.: <?php 
            $upload_dir = wp_upload_dir();
            echo $upload_dir["path"];
            ?>
/test.csv</p>
					</td>
				</tr>
				<tr class="form-field form-required">
					<th scope="row"><label for="period">Period</label></th>
					<td>
						<select id="period" name="period">
							<option <?php 
            if ($period == 'hourly') {
                echo "selected='selected'";
            }
            ?>
 value="hourly">Hourly</option>
							<option <?php 
            if ($period == 'twicedaily') {
                echo "selected='selected'";
            }
            ?>
 value="twicedaily">Twicedaily</option>
							<option <?php 
            if ($period == 'daily') {
                echo "selected='selected'";
            }
            ?>
 value="daily">Daily</option>
						</select>
						<p class="description">How often the event should reoccur?</p>
					</td>
				</tr>
				<tr class="form-field form-required">
					<th scope="row"><label for="cron-activated">Activate periodical import?</label></th>
					<td>
						<input type="checkbox" name="cron-activated" value="yes" <?php 
            if ($cron_activated == true) {
                echo "checked='checked'";
            }
            ?>
/>
					</td>
				</tr>
				<tr class="form-field form-required">
					<th scope="row"><label for="send-mail-cron">Send mail when using periodical import?</label></th>
					<td>
						<input type="checkbox" name="send-mail-cron" value="yes" <?php 
            if ($send_mail_cron == true) {
                echo "checked='checked'";
            }
            ?>
/>
					</td>
				</tr>
				<tr class="form-field form-required">
					<th scope="row"><label for="send-mail-updated">Send mail also to users that are being updated?</label></th>
					<td>
						<input type="checkbox" name="send-mail-updated" value="yes" <?php 
            if ($send_mail_updated == true) {
                echo "checked='checked'";
            }
            ?>
/>
					</td>
				</tr>
				<tr class="form-field form-required">
					<th scope="row"><label for="cron-delete-users">Delete users that are not present in the CSV?</label></th>
					<td>
						<input type="checkbox" name="cron-delete-users" value="yes" <?php 
            if ($cron_delete_users == true) {
                echo "checked='checked'";
            }
            ?>
/>
					</td>
				</tr>
				<tr class="form-field form-required">
					<th scope="row"><label for="role">Role</label></th>
					<td>
						<select id="role" name="role">
							<?php 
            $list_roles = acui_get_editable_roles();
            foreach ($list_roles as $key => $value) {
                if ($key == $role) {
                    echo "<option selected='selected' value='{$key}'>{$value}</option>";
                } else {
                    echo "<option value='{$key}'>{$value}</option>";
                }
            }
            ?>
						</select>
						<p class="description">Which role would be used to import users?</p>
					</td>
				</tr>
				<tr class="form-field form-required">
					<th scope="row"><label for="log">Last actions of schedule task</label></th>
					<td>
						<pre><?php 
            echo $log;
            ?>
</pre>
					</td>
				</tr>
				<tr class="form-field form-required">
					<th scope="row"><label for="mails">Mail sending</label></th>
					<td>Please take care: for this option, cron import, mail sending is not available in this version (if you need it <a href="mailto:contacto@codection.com">talk with us</a>)</td>
				</tr>
				</tbody>
			</table>
			<input class="button-primary" type="submit" value="Save schedule options"/>
		</form>

		<script>
		jQuery( document ).ready( function( $ ){
			$( "[name='cron-delete-users']" ).change(function() {
		        if( $(this).is( ":checked" ) ) {
		            var returnVal = confirm("Are you sure to delete all users that are not present in the CSV? This action cannto be undone.");
		            $(this).attr("checked", returnVal);
		        }
		        
		    });
		});
		</script>
	<?php 
            break;
            ?>

	<?php 
        case 'donate':
            ?>

	<div class="postbox">
	    <h3 class="hndle"><span>&nbsp;Do you like it?</span></h3>

	    <div class="inside" style="display: block;">
	        <img src="<?php 
            echo $url_plugin;
            ?>
icon_coffee.png" alt="buy me a coffee" style=" margin: 5px; float:left;">
	        <p>Hi! we are <a href="https://twitter.com/fjcarazo" target="_blank" title="Javier Carazo">Javier Carazo</a> and <a href="https://twitter.com/ahornero" target="_blank" title="Alberto Hornero">Alberto Hornero</a>  from <a href="http://codection.com">Codection</a>, developers of this plugin.</p>
	        <p>We have been spending many hours to develop this plugin. <br>If you like and use this plugin, you can <strong>buy us a cup of coffee</strong>.</p>
	        <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
				<input type="hidden" name="cmd" value="_s-xclick">
				<input type="hidden" name="hosted_button_id" value="QPYVWKJG4HDGG">
				<input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
				<img alt="" border="0" src="https://www.paypalobjects.com/es_ES/i/scr/pixel.gif" width="1" height="1">
			</form>
	        <div style="clear:both;"></div>
	    </div>
	</div>

	<?php 
            break;
            ?>

	<?php 
        case 'help':
            ?>

	<div class="postbox">
	    <h3 class="hndle"><span>&nbsp;Need help with WordPress or WooCommerce?</span></h3>

	    <div class="inside" style="display: block;">
	        <p>Hi! we are <a href="https://twitter.com/fjcarazo" target="_blank" title="Javier Carazo">Javier Carazo</a> and <a href="https://twitter.com/ahornero" target="_blank" title="Alberto Hornero">Alberto Hornero</a>  from <a href="http://codection.com">Codection</a>, developers of this plugin.</p>
	        <p>We work everyday with WordPress and WooCommerce, if you need help hire us, send us a message to <a href="mailto:contacto@codection.com">contacto@codection.com</a>.</p>
	        <div style="clear:both;"></div>
	    </div>
	</div>

	<?php 
            break;
    }
}
function acui_options()
{
    global $url_plugin;
    if (!current_user_can('create_users')) {
        wp_die(__('You are not allowed to see this content.'));
        $acui_action_url = admin_url('options-general.php?page=' . plugin_basename(__FILE__));
    } else {
        if (isset($_POST['uploadfile'])) {
            acui_fileupload_process($_POST);
        } else {
            $args_old_csv = array('post_type' => 'attachment', 'post_mime_type' => 'text/csv', 'post_status' => 'inherit', 'posts_per_page' => -1);
            $old_csv_files = new WP_Query($args_old_csv);
            acui_check_options();
            $from_email = get_option("acui_mail_from");
            $from_name = get_option("acui_mail_from_name");
            $body_mail = get_option("acui_mail_body");
            $subject_mail = get_option("acui_mail_subject");
            ?>
	<script>	
	jQuery(document).ready(function($) {
		$('.postbox').children('h3, .handlediv').click(function(){ $(this).siblings('.inside').toggle();});
	});
	</script>

	<div class="wrap">	

		<div class="postbox">
		    <div title="Click to open/close" class="handlediv">
		      <br>
		    </div>

		    <h3 class="hndle"><span>&nbsp;Do you like it?</span></h3>

		    <div class="inside" style="display: block;">
		        <img src="<?php 
            echo $url_plugin;
            ?>
icon_coffee.png" alt="buy me a coffee" style=" margin: 5px; float:left;">
		        <p>Hi! we are <a href="https://twitter.com/fjcarazo" target="_blank" title="Javier Carazo">Javier Carazo</a> and <a href="https://twitter.com/ahornero" target="_blank" title="Alberto Hornero">Alberto Hornero</a>  from <a href="http://codection.com">Codection</a>, developers of this plugin.</p>
		        <p>We have been spending many hours to develop this plugin. <br>If you like and use this plugin, you can <strong>buy us a cup of coffee</strong>.</p>
		        <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
					<input type="hidden" name="cmd" value="_s-xclick">
					<input type="hidden" name="hosted_button_id" value="QPYVWKJG4HDGG">
					<input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
					<img alt="" border="0" src="https://www.paypalobjects.com/es_ES/i/scr/pixel.gif" width="1" height="1">
				</form>
		        <div style="clear:both;"></div>
		    </div>
		</div>

		<?php 
            if ($old_csv_files->found_posts > 0) {
                ?>
		<div class="postbox">
		    <div title="Click to open/close" class="handlediv">
		      <br>
		    </div>

		    <h3 class="hndle"><span>&nbsp;Old CSV files uploaded</span></h3>

		    <div class="inside" style="display: block;">
		    	<p>For security reasons you should delete this files, probably they would be visible in the Internet if a bot or someone discover the URL. You can delete each file or maybe you want delete all CSV files you have uploaded:</p>
		    	<input type="button" value="Delete all CSV files uploaded" id="bulk_delete_attachment" style="float:right;"></input>
		    	<ul>
		    		<?php 
                while ($old_csv_files->have_posts()) {
                    $old_csv_files->the_post();
                    if (get_the_date() == "") {
                        $date = "undefined";
                    } else {
                        $date = get_the_date();
                    }
                    ?>
		    		<li><a href="<?php 
                    echo wp_get_attachment_url(get_the_ID());
                    ?>
"><?php 
                    the_title();
                    ?>
</a> uploaded the <?php 
                    echo $date;
                    ?>
 <input type="button" value="Delete" class="delete_attachment" attach_id="<?php 
                    the_ID();
                    ?>
"></input></li>
		    		<?php 
                }
                ?>
		    		<?php 
                wp_reset_postdata();
                ?>
		    	</ul>
		        <div style="clear:both;"></div>
		    </div>
		</div>
		<?php 
            }
            ?>
	

		<div id='message' class='updated'>File must contain at least <strong>2 columns: username and email</strong>. These should be the first two columns and it should be placed <strong>in this order: username and email</strong>. If there are more columns, this plugin will manage it automatically.</div>
		<div id='message-password' class='error'>Please, read carefully how <strong>passwords are managed</strong> and also take note about capitalization, this plugin is <strong>case sensitive</strong>.</div>

		<div style="float:left; width:80%;">
			<h2>Import users from CSV</h2>
		</div>

		<div style="clear:both;"></div>

		<div style="width:100%;">
			<form method="POST" enctype="multipart/form-data" action="" accept-charset="utf-8" onsubmit="return check();">
			<table class="form-table">
				<tbody>
				<tr class="form-field">
					<th scope="row"><label for="role">Role</label></th>
					<td>
					<?php 
            $list_roles = acui_get_editable_roles();
            foreach ($list_roles as $key => $value) {
                if ($key == "subscriber") {
                    echo "<label style='margin-right:5px;'><input name='role[]' type='checkbox' checked='checked' value='{$key}'/>{$value}</label>";
                } else {
                    echo "<label style='margin-right:5px;'><input name='role[]' type='checkbox' value='{$key}'/>{$value}</label>";
                }
            }
            ?>

					<p class="description">If you choose more than one role, the roles would be assigned correctly but you should use some plugin like <a href="https://wordpress.org/plugins/user-role-editor/">User Role Editor</a> to manage them.</p>
					</td>
				</tr>
				<tr class="form-field form-required">
					<th scope="row"><label>CSV file <span class="description">(required)</span></label></th>
					<td><input type="file" name="uploadfiles[]" id="uploadfiles" size="35" class="uploadfiles" /></td>
				</tr>
				<tr class="form-field form-required">
					<th scope="row"><label>What should do the plugin with empty cells?</label></th>
					<td>
						<select name="empty_cell_action">
							<option value="leave">Leave the old value for this metadata</option>
							<option value="delete">Delete the metadata</option>							
						</select>
					</td>
				</tr>

				<?php 
            if (is_plugin_active('wp-members/wp-members.php')) {
                ?>

				<tr class="form-field form-required">
					<th scope="row"><label>Activate user at the same time is being created</label></th>
					<td>
						<select name="activate_users_wp_members">
							<option value="no_activate">Do not activate users</option>
							<option value="activate">Activate users when they are being imported</option>
						</select>
					</td>
					<p class="description"><strong>(Only for <a href="https://wordpress.org/plugins/wp-members/">WP Members</a> users)</strong>.</p>
				</tr>

				<?php 
            }
            ?>

				<?php 
            if (is_plugin_active('allow-multiple-accounts/allow-multiple-accounts.php')) {
                ?>

				<tr class="form-field form-required">
					<th scope="row"><label>Repeated email in different users?</label></th>
					<td>
						<select name="allow_multiple_accounts">
							<option value="not_allowed">Not allowed</option>
							<option value="allowed">Allowed</option>
						</select>
						<p class="description"><strong>(Only for <a href="https://wordpress.org/plugins/allow-multiple-accounts/">Allow Multiple Accounts</a> users)</strong>. Allow multiple user accounts to be created having the same email address.</p>
					</td>
				</tr>

				<?php 
            }
            ?>

				<tr class="form-field">
					<th scope="row"><label for="user_login">Send mail</label></th>
					<td>
						<p>Do you wish to send a mail with credentials to new users? <input type="checkbox" name="sends_email" value = "yes" onclick="showMe('email_div')"></p>
						<div id="email_div" style="display:none">
						<p class="description">You can set your own SMTP and other mail details <a href="<?php 
            echo admin_url('tools.php?page=acui-smtp');
            ?>
" target="_blank">here</a>.
						<p>Mail subject : <input name="subject_mail" size="100" value="<?php 
            echo $subject_mail;
            ?>
" id="title" autocomplete="off" type="text"></p>
						<?php 
            wp_editor($body_mail, 'body_mail');
            ?>
						**username** = username to login - **password** = user password - **loginurl** = current site login url - **email** = user email<br/>
						You can also use any WordPress user standard field, if you have used it in your CSV. For example, if you have a first_name column, you could use **first_name**
						</div>
					</td>
				</tr>
				</tbody>
			</table>
			<input class="button-primary" type="submit" name="uploadfile" id="uploadfile_btn" value="Start importing"/>
			</form>
		</div>

		<div style="clear:both; width:100%;"></div>

		<?php 
            $headers = get_option("acui_columns");
            if (is_array($headers) && !empty($headers)) {
                ?>

		<h3>Custom columns loaded</h3>
		<table class="form-table">
		<tbody>
			<tr valign="top">
				<th scope="row">Columns loaded in previous files</th>
				<td><small><em>(if you load another CSV with different columns, the new ones will replace this list)</em></small>
					<ol>
						<?php 
                foreach ($headers as $column) {
                    ?>
							<li><?php 
                    echo $column;
                    ?>
</li>
						<?php 
                }
                ?>
						
					</ol>
				</td>
			</tr>
		</tbody></table>

		<?php 
            }
            ?>

		<h3>Doc</h3>
		<table class="form-table">
		<tbody>
			<tr valign="top">
				<th scope="row">Columns position</th>
				<td><small><em>(Documents should look like the one presented into screenshot. Remember you should fill the first two columns with the next values)</em></small>
					<ol>
						<li>Username</li>
						<li>Email</li>
					</ol>						
					<small><em>(The next columns are totally customizable and you can use whatever you want. All rows must contains same columns)</em></small>
					<small><em>(User profile will be adapted to the kind of data you have selected)</em></small>
					<small><em>(If you want to disable the extra profile information, please deactivate this plugin after make the import)</em></small>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row">Passwords</th>
				<td>A string that contains user passwords. We have different options for this case:
					<ul style="list-style:disc outside none; margin-left:2em;">
						<li>If user is created: if you set a value for the password, it will be used; if not, it will be generated</li>
						<li>If user is updated: 
							<ul style="list-style:disc outside none;margin-left:2em;">
								<li>If you <strong>don't create a column for passwords</strong>: passwords will be generated automatically</li>
								<li>If you <strong>create a column for passwords</strong>: if cell is empty, password won't be updated; if cell has a value, it will be used</li>
							</ul>
					</ul>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row">WordPress default profile data</th>
				<td>You can use those labels if you want to set data adapted to the WordPress default user columns (the ones who use the function <a href="http://codex.wordpress.org/Function_Reference/wp_update_user">wp_update_user</a>)
					<ol>
						<li><strong>user_nicename</strong>: A string that contains a URL-friendly name for the user. The default is the user's username.</li>
						<li><strong>user_url</strong>: A string containing the user's URL for the user's web site.	</li>
						<li><strong>display_name</strong>: A string that will be shown on the site. Defaults to user's username. It is likely that you will want to change this, for both appearance and security through obscurity (that is if you don't use and delete the default admin user).</li>
						<li><strong>nickname</strong>: The user's nickname, defaults to the user's username.	</li>
						<li><strong>first_name</strong>: The user's first name.</li>
						<li><strong>last_name</strong>: The user's last name.</li>
						<li><strong>description</strong>: A string containing content about the user.</li>
						<li><strong>jabber</strong>: User's Jabber account.</li>
						<li><strong>aim</strong>: User's AOL IM account.</li>
						<li><strong>yim</strong>: User's Yahoo IM account.</li>
						<li><strong>user_registered</strong>: Using the WordPress format for this kind of data Y-m-d H:i:s.</li>
					</ol>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row">Important notice</th>
				<td>You can upload as many files as you want, but all must have the same columns. If you upload another file, the columns will change to the form of last file uploaded.</td>
			</tr>
			<tr valign="top">
				<th scope="row">Any question about it</th>
			<td>Please contact: <a href="mailto:contacto@codection.com">contacto@codection.com</a>.</td>
			</tr>
			<tr valign="top">
				<th scope="row">Example</th>
			<td>Download this <a href="<?php 
            echo plugins_url() . "/import-users-from-csv-with-meta/test.csv";
            ?>
">.csv file</a> to test</td> 
			</tr>
		</tbody></table>
		<br/>
		<div style="width:775px;margin:0 auto"><img src="<?php 
            echo plugins_url() . "/import-users-from-csv-with-meta/csv_example.png";
            ?>
"/></div>
	</div>
	<script type="text/javascript">
	function check(){
		if(document.getElementById("uploadfiles").value == "") {
		   alert("Please choose a file");
		   return false;
		}
	}

	function showMe (box) {
	    var chboxs = document.getElementsByName("sends_email");
	    var vis = "none";
	    for(var i=0;i<chboxs.length;i++) { 
	        if(chboxs[i].checked){
	         vis = "block";
	            break;
	        }
	    }
	    document.getElementById(box).style.display = vis;
	}

	jQuery( document ).ready( function( $ ){
		$( ".delete_attachment" ).click( function(){
			var answer = confirm( "Are you sure to delete this file?" );
			if( answer ){
				var data = {
					'action': 'acui_delete_attachment',
					'attach_id': $( this ).attr( "attach_id" )
				};

				$.post(ajaxurl, data, function(response) {
					if( response != 1 )
						alert( "There were problems deleting the file, please check file permissions" );
					else{
						alert( "File successfully deleted" );
						document.location.reload();
					}
				});
			}
		});

		$( "#bulk_delete_attachment" ).click( function(){
			var answer = confirm( "Are you sure to delete ALL CSV files uploaded? There can be CSV files from other plugins." );
			if( answer ){
				var data = {
					'action': 'acui_bulk_delete_attachment',
				};

				$.post(ajaxurl, data, function(response) {
					if( response != 1 )
						alert( "There were problems deleting the files, please check files permissions" );
					else{
						alert( "Files successfully deleted" );
						document.location.reload();
					}
				});
			}
		});

	} );
	</script>
<?php 
        }
    }
}
function acui_options()
{
    if (!current_user_can('edit_users')) {
        wp_die(__('You are not allowed to see this content.'));
        $acui_action_url = admin_url('options-general.php?page=' . plugin_basename(__FILE__));
    } else {
        if (isset($_POST['uploadfile'])) {
            acui_fileupload_process($_POST['role']);
        } else {
            ?>
	<div class="wrap">
<!--
//XTEC ************ ELIMINAT - Removed to simplify user experience
//2015.03.17 @sarjona
/*
		<div id='message' class='updated'>File must contain at least <strong>3 columns: username, password and email</strong>. These should be the first three columns and it should be placed <strong>in this order: username, password and email</strong>. If there are more columns, this plugin will manage it automatically.</div>
*/
//************ FI
-->
		<div style="clear:both; width:100%;">
<!--
//XTEC ************ MODIFICAT - Added language supporting
//2015.03.17 @sarjona
-->
			<h2><?php 
            _e('Import users from CSV', 'import-users-from-csv-with-meta');
            ?>
</h2>
<!--
//************ ORIGINAL
/*
			<h2>Import users from CSV</h2>
*/
//************ FI
-->
		</div>

<!--
//XTEC ************ ELIMINAT - Removed to simplify user experience
//2015.03.17 @sarjona
/*
		<div style="float:right; width:20%;">
			<p><em>If you like this plugin, you can support it.</em></p>
			<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
				<input type="hidden" name="cmd" value="_s-xclick">
				<input type="hidden" name="hosted_button_id" value="T5J5F6XZTSYH2">
				<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
				<img alt="" border="0" src="https://www.paypalobjects.com/es_ES/i/scr/pixel.gif" width="1" height="1">
			</form>
		</div>
*/
//************ FI
-->

		<div style="float:left; width:80%;">
			<form method="POST" enctype="multipart/form-data" action="" accept-charset="utf-8" onsubmit="return check();">
<!--
//XTEC ************ MODIFICAT - Alter table
//2015.03.20 @nacho
-->
				<table class="form-table">
<!-- ************ ORIGINAL
/*
				<table class="form-table" style="width:50%" border="1">
*/
//************ FI
-->
				<tbody>
				<tr class="form-field">
<!--
//XTEC ************ MODIFICAT - Added language supporting
//2015.03.17 @sarjona
-->
					<th scope="row"><label for="role"><?php 
            _e('Role', 'import-users-from-csv-with-meta');
            ?>
</label></th>
<!--
//************ ORIGINAL
/*
					<th scope="row"><label for="role">Role</label></th>
*/
//************ FI
-->
					<td>
					<select name="role" id="role">
						<?php 
            $list_roles = acui_get_editable_roles();
            foreach ($list_roles as $key => $value) {
                //XTEC ************ MODIFICAT - Added language supporting
                //2015.05.27 @nacho
                if ($key == "subscriber") {
                    echo "<option selected='selected' value='{$key}'>" . translate_user_role($value) . "</option>";
                } else {
                    echo "<option value='{$key}'>" . translate_user_role($value) . "</option>";
                }
                //************ ORIGINAL
                /*if($key == "subscriber")
                			echo "<option selected='selected' value='$key'>$value</option>";
                		else
                			echo "<option value='$key'>$value</option>";
                		*/
                //************ FI
            }
            ?>
					</select>
					</td>
<!--
//XTEC ************ AFEGIT - Added function for hidden or display help
//2015.03.20 @nacho
-->
					<td>
					<a href="javascript:void(0)" onClick="toggleproviderhelp()"><?php 
            _e("Where do I get this info?", 'import-users-from-csv-with-meta');
            ?>
</a>
					</td>
<!--
//************ FI
-->
				</tr>

				<tr class="form-field form-required">
<!--
//XTEC ************ MODIFICAT - Added language supporting
//2015.03.17 @sarjona
-->
					<th scope="row"><label for="user_login"><?php 
            _e('CSV file', 'import-users-from-csv-with-meta');
            ?>
 <span class="description">(<?php 
            _e('required', 'import-users-from-csv-with-meta');
            ?>
)</span></label></th>
<!--
//************ ORIGINAL
/*
					<th scope="row"><label for="user_login">CSV file <span class="description">(required)</span></label></th>
*/
//************ FI
-->
					<td><input type="file" name="uploadfiles[]" id="uploadfiles" size="35" class="uploadfiles" /></td>
				</tr>
				</tbody>
			</table>
<!--
//XTEC ************ MODIFICAT - Added language supporting
//2015.03.17 @sarjona
-->
			<input class="button-primary" type="submit" name="uploadfile" id="uploadfile_btn" value="<?php 
            _e('Start importing', 'import-users-from-csv-with-meta');
            ?>
"/>
<!--
//************ ORIGINAL
/*
			<input class="button-primary" type="submit" name="uploadfile" id="uploadfile_btn" value="Start importing"/>
*/
//************ FI
-->
			</form>
		</div>

		<div style="clear:both; width:100%;"></div>

        <!--
        //XTEC ************ AFEGIT - Added Provided Help
        //2015.03.20 @nacho
        -->
        <script>
            function toggleproviderhelp() {
                if (typeof jQuery == "undefined") {
                    alert("<?php 
            $msg = _e("Import Users module require jQuery to be installed on your wordpress in order to work!", "import-users-from-csv-with-meta");
            echo $msg;
            ?>
");
                    return false;
                }
                idp = 'importUsers';
                jQuery('.iu_div_settings_help_' + idp).toggle();
                return false;
            }
        </script>
        <!-- ************ FI -->

        <!--
        //XTEC ************ AFEGIT - Added block for show help
        //2015.03.20 @nacho
        -->
		<div
			class="iu_div_settings_help_importUsers"
			style="<?php 
            if (isset($_REQUEST["enable"]) && $_REQUEST["enable"] == $provider_id) {
                echo "-";
            }
            // <= lolz
            ?>
display:none;">
			<table class="form-table editcomment">
				<tbody>
					<tr valign="top">
						<td>
							<div id="post-body-content">
								<div id="namediv" class="stuffbox">
									<h4 style="padding: 8px 12px; margin: 0.33em 0;">
										<label>
										<?php 
            _e("Help", "import-users-from-csv-with-meta");
            ?>
										</label>
							        </h4>
							        <div class="inside">
								        <hr class="wsl">
									        <strong><?php 
            _e("You should fill the first three rows with the next values", "import-users-from-csv-with-meta");
            ?>
</strong><br/>
									        <ul><ol>
									        	<li>
													<strong>
													<?php 
            _e("Username", "import-users-from-csv-with-meta");
            ?>
													</strong>
													<?php 
            _e("Sets the username.", "import-users-from-csv-with-meta");
            ?>
												</li>
												<li>
													<strong>
													<?php 
            _e("Password", "import-users-from-csv-with-meta");
            ?>
													</strong>
													<?php 
            _e("Sets user password.", "import-users-from-csv-with-meta");
            ?>
												</li>
												<li>
													<strong>
													<?php 
            _e("Email", "import-users-from-csv-with-meta");
            ?>
													</strong>
													<?php 
            _e("Sets user email.", "import-users-from-csv-with-meta");
            ?>
												</li>
									        </ul></ol>

									        <strong><?php 
            _e("The next columns are totally customizable and you can use whatever you want. All rows must contains same columns", "import-users-from-csv-with-meta");
            ?>
</strong><br/>

									        <ol>
												<li>
													<strong>
													<?php 
            _e("user_nicename", "import-users-from-csv-with-meta");
            ?>
													</strong>
													<?php 
            _e("A string that contains a URL-friendly name for the user. The default is the user's username.", "import-users-from-csv-with-meta");
            ?>
												</li>
												<li>
													<strong>
													<?php 
            _e("user_url", "import-users-from-csv-with-meta");
            ?>
													</strong>
													<?php 
            _e("A string containing the user's URL for the user's web site.", "import-users-from-csv-with-meta");
            ?>
												</li>
												<li>
													<strong>
													<?php 
            _e("display_name", "import-users-from-csv-with-meta");
            ?>
													</strong>
													<?php 
            _e("A string that will be shown on the site. Defaults to user's username. It is likely that you will want to change this, for both appearance and security through obscurity (that is if you dont use and delete the default admin user).", "import-users-from-csv-with-meta");
            ?>
												</li>
												<li>
													<strong>
													<?php 
            _e("nickname", "import-users-from-csv-with-meta");
            ?>
													</strong>
													<?php 
            _e("The user's nickname, defaults to the user's username.", "import-users-from-csv-with-meta");
            ?>
												</li>
												<li>
													<strong>
													<?php 
            _e("first_name", "import-users-from-csv-with-meta");
            ?>
													</strong>
													<?php 
            _e("The user's first name.", "import-users-from-csv-with-meta");
            ?>
												</li>
												<li>
													<strong>
													<?php 
            _e("last_name", "import-users-from-csv-with-meta");
            ?>
													</strong>
													<?php 
            _e("The user's last name.", "import-users-from-csv-with-meta");
            ?>
												</li>
												<li>
													<strong>
													<?php 
            _e("description", "import-users-from-csv-with-meta");
            ?>
													</strong>
													<?php 
            _e("A string containing content about the user.", "import-users-from-csv-with-meta");
            ?>
												</li>
											</ol>
								        </hr>
							        </div>
							    </div>
							</div>
						</td>
						<td width="10"></td>
						<td width="400"> </td>
					</tr>
				</tbody>
			</table>
	    </div>
<!--
*/
//************ FI
-->

<!--
//XTEC ************ ELIMINAT - Removed to simplify user experience
//2015.03.17 @sarjona
/*
		<div style="float:right; width:20%;">
			<p><em>If you like this plugin, you can support it.</em></p>
			<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
				<input type="hidden" name="cmd" value="_s-xclick">
				<input type="hidden" name="hosted_button_id" value="T5J5F6XZTSYH2">
				<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
				<img alt="" border="0" src="https://www.paypalobjects.com/es_ES/i/scr/pixel.gif" width="1" height="1">
			</form>
		</div>
		<?php 
            $headers = get_option("acui_columns");
            if (is_array($headers) && !empty($headers)) {
                ?>

		<h3>Custom columns loaded</h3>
		<table class="form-table">
		<tbody>
			<tr valign="top">
				<th scope="row">Columns loaded in previous files</th>
				<td><small><em>(if you load another CSV with different columns, the new ones will replace this list)</em></small>
					<ol>
						<?php 
                foreach ($headers as $column) {
                    ?>
							<li><?php 
                    echo $column;
                    ?>
</li>
						<?php 
                }
                ?>
					</ol>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row">WordPress default profile data</th>
				<td>You can use those labels if you want to set data adapted to the WordPress default user columns (the ones who use the function <a href="http://codex.wordpress.org/Function_Reference/wp_update_user">wp_update_user</a>)
					<ol>
						<li><strong>user_nicename</strong>: A string that contains a URL-friendly name for the user. The default is the user's username.</li>
						<li><strong>user_url</strong>: A string containing the user's URL for the user's web site.	</li>
						<li><strong>display_name</strong>: A string that will be shown on the site. Defaults to user's username. It is likely that you will want to change this, for both appearance and security through obscurity (that is if you dont use and delete the default admin user).	</li>
						<li><strong>nickname</strong>: The user's nickname, defaults to the user's username.	</li>
						<li><strong>first_name</strong>: The user's first name.</li>
						<li><strong>last_name</strong>: The user's last name.</li>
						<li><strong>description</strong>: A string containing content about the user.</li>
						<li><strong>jabber</strong>: User's Jabber account.</li>
						<li><strong>aim</strong>: User's AOL IM account.</li>
						<li><strong>yim</strong>: User's Yahoo IM account.</li>
					</ol>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row">Important notices</th>
				<td>1) You can upload as many files as you want, but all must have the same columns. If you upload another file, the columns will change to the form of last file uploaded.</td>
				<td>2) If you are updating data, leave empty any field to leave it without update. If you want to update it leaving it blank, you can always insert a blank space in this field.</td>
			</tr>
			<tr valign="top">
				<th scope="row">Any question about it</th>
			<td>Please contact: <a href="mailto:contacto@codection.com">contacto@codection.com</a>.</td>
			</tr>
			<tr valign="top">
				<th scope="row">Example</th>
			<td>Download this <a href="<?php 
                echo plugins_url() . "/import-users-from-csv-with-meta/test.csv";
                ?>
">.csv file</a> to test</td>
			</tr>
		</tbody></table>

		<?php 
            }
            ?>

		<h3>Doc</h3>
		<table class="form-table">
		<tbody>
			<tr valign="top">
				<th scope="row">Columns position</th>
				<td><small><em>(Documents should look like the one presented into screenshot. Remember you should fill the first three rows with the next values)</em></small>
					<ol>
						<li>Username</li>
						<li>Password</li>
						<li>Email</li>
					</ol>
					<small><em>(The next columns are totally customizable and you can use whatever you want. All rows must contains same columns)</em></small>
					<small><em>(User profile will be adapted to the kind of data you have selected)</em></small>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row">WordPress default profile data</th>
				<td>You can use those labels if you want to set data adapted to the WordPress default user columns (the ones who use the function <a href="http://codex.wordpress.org/Function_Reference/wp_update_user">wp_update_user</a>)
					<ol>
						<li><strong>user_nicename</strong>: A string that contains a URL-friendly name for the user. The default is the user's username.</li>
						<li><strong>user_url</strong>: A string containing the user's URL for the user's web site.	</li>
						<li><strong>display_name</strong>: A string that will be shown on the site. Defaults to user's username. It is likely that you will want to change this, for both appearance and security through obscurity (that is if you dont use and delete the default admin user).	</li>
						<li><strong>nickname</strong>: The user's nickname, defaults to the user's username.	</li>
						<li><strong>first_name</strong>: The user's first name.</li>
						<li><strong>last_name</strong>: The user's last name.</li>
						<li><strong>description</strong>: A string containing content about the user.</li>
						<li><strong>jabber</strong>: User's Jabber account.</li>
						<li><strong>aim</strong>: User's AOL IM account.</li>
						<li><strong>yim</strong>: User's Yahoo IM account.</li>
						<li><strong>user_registered</strong>: Using the WordPress format for this kind of data Y-m-d H:i:s.</li>
					</ol>
				</td>
			</tr>
			<tr valign="top">
				<th scope="row">Important notice</th>
				<td>You can upload as many files as you want, but all must have the same columns. If you upload another file, the columns will change to the form of last file uploaded.</td>
			</tr>
			<tr valign="top">
				<th scope="row">Any question about it</th>
			<td>Please contact: <a href="mailto:contacto@codection.com">contacto@codection.com</a>.</td>
			</tr>
			<tr valign="top">
				<th scope="row">Example</th>
			<td>Download this <a href="<?php 
            echo plugins_url() . "/import-users-from-csv-with-meta/test.csv";
            ?>
">.csv file</a> to test</td>
			</tr>
		</tbody></table>
		<br/>
		<div style="width:775px;margin:0 auto"><img src="<?php 
            echo plugins_url() . "/import-users-from-csv-with-meta/csv_example.png";
            ?>
"/></div>
*/
//************ FI
-->
	</div>
	<script type="text/javascript">
	function check(){
		if(document.getElementById("uploadfiles").value == "") {
//XTEC ************ MODIFICAT - Added language supporting
//2015.03.20 @nacho
			alert ("<?php 
            $msg = _e("Please choose a file", "import-users-from-csv-with-meta");
            echo $msg;
            ?>
");
//************ ORIGINAL
			//alert("Please choose a file");
//************ FI
			return false;
		}
	}
	</script>
<?php 
        }
    }
}
function acui_cron_process()
{
    $message = "Import cron task starts at " . date("Y-m-d H:i:s") . "<br/>";
    $form_data = array();
    $form_data["path_to_file"] = get_option("acui_cron_path_to_file");
    $form_data["role"] = get_option("acui_cron_role");
    $form_data["empty_cell_action"] = "leave";
    ob_start();
    acui_fileupload_process($form_data, true);
    $message .= "<br/>" . ob_get_contents() . "<br/>";
    ob_end_clean();
    $message .= "--Finished at " . date("Y-m-d H:i:s") . "<br/><br/>";
    update_option("acui_cron_log", $message);
}