<?php 
$user_type_name = $this->Common->getCurrentUserType();
?>
<style type="text/css">
    div .ka-main-content{
        text-align: left;
    }
</style>

<div class="row">
    <div class="col-md-12">
        <div class="box box-primary">
            <div class="box-body">
                <div class="row">
                    <div class="col-md-6">
                       <h3 class="box-title no-margin">
                    <span> 
                    <?php
                    if(!empty($crmuser->user_photo) && file_exists($crmuser->user_photo)){
                    ?>
                        <img src="<?php echo $this->request->webroot.$crmuser->user_photo;?>" style="width:25px;height:25px;">
                    <?php
                    } else{
                    ?>
                        <img src="<?php echo $this->request->webroot.'media/companies/dummy-image.jpg'?>" style="width:25px;height:25px;">
                    <?php
                        }
                    ?></span> Edit Profile
                </h3>
                    </div>
                </div>
            </div>
        </div> 
    </div>             
</div>




<div class="box box-primary">
    <!-- /.box-header -->
    <div class="box-body">
        <div class="row">
            <div class="col-md-6">
                <?= $this->Form->create(null, array('enctype' => 'multipart/form-data')) ?>
                <div class="form-group" style="display: none;">
                    <?php
                    echo $this->Form->input('previous_img_path', array('type' => 'hidden', 'value' => $crmuser->user_photo));
                    //echo $this->Form->input('language', array('options' => $languages,'class'=>'form-control'));
                    ?>
                </div>
                <!-- /.form-group -->
                <div class="form-group">
                    <?php echo $this->Form->input('email', array('class' => 'form-control required', 'placeholder' => __('Email'), 'value' => $crmuser->email)); ?>
                </div>
                <!-- /.form-group -->

                <div class="form-group">
                    <?php echo $this->Form->input('password', array('class' => 'form-control required', 'id' => 'password1', 'placeholder' => __('Password'), 'value' => $crmuser->hashed_password)); ?>
                </div>
                <!-- /.form-group -->
                <div class="form-group">
                    <label>Retype Password</label>
                    <?php echo $this->Form->password('retype_password', array('id' => 'password2', 'class' => 'form-control required', 'placeholder' => __('Retype Password'), 'value' => $crmuser->hashed_password)); ?>
                </div>
                <!-- /.form-group -->
                <?php if($user_type_name == "AFFILIATE" && !empty($new_client_link_for_affiliate)){ ?>
                    <div class="form-group">
                        <a class="js-copy-link" href="#"><i class="fa fa-copy pull-right btn-small">Copy</i></a>
                        <label for="">Client Registration Link: </label>
                        <p style="word-break: break-all;">
                            <a target="_blank" href="<?php echo $new_client_link_for_affiliate; ?>"><?php echo $new_client_link_for_affiliate;?></a>  
                        </p>
                    </div>
                <?php } ?>    
                <div class="form-group">
                    <?php
                    echo $this->Form->input('img_path', array('type' => 'file', 'label' => __('Profile Picture')));
                    ?><br/>
                    <?php
                    if (!empty($crmuser->user_photo) && file_exists($crmuser->user_photo)) {
                        ?>
                        <img src="<?php echo $this->request->webroot . $crmuser->user_photo; ?>" style="width:70px;height:50px;">
                        <?php
                    } else {
                        ?>
                        <img src="<?php echo $this->request->webroot . 'media/companies/default.jpg' ?>" style="width:70px;height:50px;">
                        <?php
                    }
                    ?>
                </div>
                <!-- /.form-group -->
            </div>



        </div>
        <!-- /.row -->
    </div>
    <!-- /.box-body -->
    <div class="box-footer">
        <a href="<?php echo $this->Url->build('/Statistics/index/'); ?>" class="btn btn-primary">Back</a>
        <?= $this->Form->button(__('Submit'), ['class' => 'btn btn-primary', 'id' => 'btnSubmit']) ?>
    </div>
    <?= $this->Form->end() ?>
</div>
<script src="<?php echo $this->request->webroot; ?>js/jquery-1.11.2.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#btnSubmit").click(function () {
            var password = $("#password1").val();
            var confirmPassword = $("#password2").val();
            if (password != confirmPassword) {
                alert("Passwords do not match.");
                return false;
            }
            return true;
        });
    });
</script>
