<?php
$vError = isset($validation_error) && !empty($validation_error) ? $validation_error : array();
$vSaved = isset($saved_data) && !empty($saved_data) ? $saved_data : array();
$vPosted = array();
if(!empty(set_value('username'))){
    $vPosted['username'] = set_value('username');
}
if(!empty(set_value('usermail'))){
    $vPosted['usermail'] = set_value('usermail');
}
$vDefault = array_merge($vSaved, $vPosted);
?>
<div class="row clearfix">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <div class="card">
            <div class="header">
                <h2>
                    Profile Settings
                </h2>
            </div>
            <div class="body">
                <?php echo form_open_multipart('lbadmin/profile', array("id"=>"profileForm") ); ?>
                <?php if(isset($upload_error) && count($upload_error)>0) : ?>
                    <?php foreach($upload_error as $upError) : ?>
                        <div class="alert alert-danger alert-dismissible" role="alert">
                            <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
                            <?php echo $upError ?>
                        </div>
                    <?php endforeach; ?>
                <?php endif;?>
                <div class="row clearfix">
                    <div class="col-lg-2 col-md-2 col-sm-3 col-xs-12 form-control-label">
                        <label for="username">Full Name</label>
                    </div>
                    <div class="col-lg-10 col-md-10 col-sm-9 col-xs-12">
                        <div class="form-group">
                            <input type="text" value="<?php echo getValue('username', $vDefault) ?>" name="username" id="username" class="form-control" placeholder="Enter Your Name" required>
                        </div>
                    </div>
                </div>
                <div class="row clearfix">
                    <div class="col-lg-2 col-md-2 col-sm-3 col-xs-12 form-control-label">
                        <label for="usermail">Email Address</label>
                    </div>
                    <div class="col-lg-10 col-md-10 col-sm-9 col-xs-12">
                        <div class="form-group">
                            <div class="form-line">
                                <input type="email" value="<?php echo getValue('usermail', $vDefault) ?>" name="usermail" id="usermail" class="form-control" placeholder="Enter Your Email Address" required>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row clearfix">
                    <div class="col-lg-2 col-md-2 col-sm-3 col-xs-12 form-control-label">
                        <label for="oldpassword">Old Password</label>
                    </div>
                    <div class="col-lg-10 col-md-10 col-sm-9 col-xs-12">
                        <div class="form-group">
                            <div class="form-line">
                                <input type="password" name="oldpassword" id="oldpassword" class="form-control" placeholder="Insert Old Password If You Want to change">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row clearfix">
                    <div class="col-lg-2 col-md-2 col-sm-3 col-xs-12 form-control-label">
                        <label for="newpassword">New Password</label>
                    </div>
                    <div class="col-lg-10 col-md-10 col-sm-9 col-xs-12">
                        <div class="form-group">
                            <div class="form-line">
                                <input type="password" name="newpassword" id="newpassword" class="form-control" placeholder="Insert New Password If You Want to change">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row clearfix">
                    <div class="col-lg-offset-2 col-md-offset-2 col-sm-offset-3 col-xs-offset-0">
                        <button type="submit" class="btn btn-success m-l-15 waves-effect">Save Changes</button>
                    </div>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var profileError = <?php echo json_encode($vError) ?>;
    var success = <?php echo isset($savesuccess)?($savesuccess?'true':'false'):'false' ?>;
</script>