<div class="usc_app_page_wrap" style="min-height:500px">
<h1>Edit Operator</h1>

<form role="form" method="post" enctype="multipart/form-data">

    <div class="col-lg-6">
        <div class="box-body">

            <div class="form-group">
                <label>Display name</label><span id="username_ajax_return"></span>
                <input type="text" class="form-control" id="username" name="username" value="{$smarty.post.username}"
                       placeholder="Enter display name" required onblur="checkUsername()">
            </div>

            <div class="form-group">
                <label>First name</label>

                <input type="text" class="form-control" name="firstname" value="{$smarty.post.firstname}"
                       placeholder="Enter first name">
            </div>

            <div class="form-group">
                <label>Last name</label>
                <input type="text" class="form-control" name="lastname" value="{$smarty.post.lastname}"
                       placeholder="Enter last name">
            </div>

            <div class="form-group">
                <label>Email address</label><span id="email_ajax_return"></span>
                <input type="email" class="form-control" id="email" value="{$smarty.post.email}" name="email"
                       placeholder="Enter email" required onblur="checkEmail()">
            </div>

            <div class="form-group">
                <label>Password</label>
                <input type="password" class="form-control" name="password" value=""
                       placeholder="Password">
            </div>

			{if $smarty.session.user.permissions == 1}
			
            	<div class="checkbox">
                	<label>
                    	<input type="checkbox" name="role" value="admin" {if $smarty.post.permissions == 1}checked{/if}> Admin
                    	<p class="help-block">Can manage operators, departments, settings and widget customization</p>
                	</label>
            	</div>
			
			{/if}


        </div>
        <!-- /.box-body -->

        <div class="box-footer">
            <button type="submit" name="submit" value="true" class="btn btn-primary">Save</button>
        </div>
    </div>



<div class="col-lg-6">

    <div class="form-group">
        <label>Operator avatar</label><br/>

        {if $smarty.post.avatar == ''}
             <span id="operator_avatar"><img id="op_avatar" src="{$data_server}config/themes/img/avatars/default.png"></span>
        {else}
             <span id="operator_avatar"><img id="op_avatar" src="{$data_server}{$smarty.post.avatar}"></span>
        {/if}

    </div>


    <div class="form-group">
        <label>Upload avatar</label>

            <input type="file" name="file" id="file" onchange="uploadFile();"/>
            <input type="hidden" name="user_id" id="user_id" value="{$smarty.get.user_id}"/>
            <input type="hidden" name="avatar" id="selected_avatar" value="{$smarty.post.avatar}">

            <p class="help-block">JPG or PNG (Max: 90px by 90px)</p>

            <button type="button" value="Upload File" class="btn btn-primary" onclick="remove_avatar()">Remove</button>
            <br/><br/>

            <p id="error_handling"></p>

            <progress id="progressBar" value="0" max="100"></progress>
            <p id="loaded_n_total"></p>

            <p id="status"></p>
    </div>

</div>

</form>
</div>

{if $smarty.session.user.user_id == $smarty.get.user_id}
	{literal}<script>var editingLoggedOperator = true; </script>{/literal}
{else}
	{literal}<script>var editingLoggedOperator = false; </script>{/literal}
{/if}

<script src="{$data_server}js/users_edit.min.js" type="text/javascript"></script>