<script data-cfasync="false">
    var oldstatus = <?php echo $this->oldstatus; ?>;
    var oldstatusAliasto = <?php echo $this->oldstatusAliasto;?>;
    var oldgroup = <?php echo $this->oldgroup; ?>;
    var adminid = <?php echo $this->userId; ?>;
    var deleteId = <?php echo $this->userId; ?>;
</script>

<div class="cm-holder">

    <div class="alert alert-info d-flex align-items-center staff-profile-header ce-page-header">
        <div class="staff-profile-image me-3">
            <img class="ce-default-avatar-dark rounded-circle" src="<?php echo $this->profileurl;?>" alt="Profile Image" />
        </div>
        <div class="staff-profile-label">
            <strong><?php echo $this->userName; ?></strong>&nbsp;(<?php echo $this->userId; ?>)<br/>
            <span class="badge <?php echo ($this->statusenum==1) ? "bg-success" : "bg-secondary"; ?>">
                <?php echo $this->statusname;?>
            </span>
        </div>
    </div>
<div class="form-wrapper">
    <?php if ($this->user->hasPermission("admin_staff_view") && $this->backtolist) { ?>
        <div class="mb-3">
            <i class="bi bi-arrow-left"></i>
            <a href="index.php?fuse=admin&controller=staff&view=adminlist">
                <?php echo $this->user->lang("Staff list");?>
            </a>
        </div>
    <?php } ?>

    <ul class="nav nav-tabs mb-3">
        <li class="nav-item">
            <a class="nav-link active" href="#"><?php echo $this->user->lang("Profile");?></a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="index.php?fuse=admin&view=staffsettings&controller=staff<?php echo ($this->backtolist) ? "&adminid=".$this->userId : ""; ?>">
                <?php echo $this->user->lang("Preferences");?>
            </a>
        </li>
    </ul>

    <form method="post" action="index.php?fuse=admin&action=updateadmin&controller=staff">
    <input type="hidden" name="id" value="<?php echo $this->userId; ?>">

    <div class="row mb-3">
        <div class="col-md-6">
            <div class="form-elem">
                <label for="dropdown_adminstatus" class="form-label"><?php echo $this->user->lang('Status'); ?>:</label>
                <select id="dropdown_adminstatus" name="dropdown_adminstatus" class="form-select normalSelect2"
                    <?php if (!$this->parseProfileHeader['editAdminStatus']) { ?> disabled <?php } ?>>
                    <option value="1" <?php echo $this->activeSelected; ?>><?php echo $this->user->lang("Active");?></option>
                    <option value="-1" <?php echo $this->inactiveSelected; ?>><?php echo $this->user->lang("Inactive");?></option>
                </select>
            </div>
        </div>

        <div class="col-md-6">
            <div class="form-elem">
                <label for="dropdown_adminGroup" class="form-label"><?php echo $this->user->lang('Group'); ?>:</label>
                <select id="dropdown_adminGroup" name="dropdown_adminGroup" class="form-select normalSelect2"
                    <?php if (!$this->parseProfileHeader['editAdminGroup']) { ?> disabled <?php } ?>>
                    <?php foreach ($this->parseProfileHeader['adminGroupOption'] as $adminGroupOption) { ?>
                        <option value="<?php echo $adminGroupOption['adminGroupValue']; ?>" <?php echo $adminGroupOption['adminGroupSelected']; ?>>
                            <?php echo $adminGroupOption['adminGroupName']; ?>
                        </option>
                    <?php } ?>
                </select>
            </div>
        </div>
    </div>

    <div class="row">
    <?php foreach ($this->parseCustomFields as $i => $customFields) {
        $NameAddId = trim($customFields['fieldId']);
        if ($NameAddId != 51 && $NameAddId != 52) { ?>
        <div class="col-md-6 mb-3">
            <div class="form-elem">
                <label class="form-label"><?php echo $customFields['rowLabel']; ?></label>
                <?php switch ($customFields['fieldType']) {
                    case 'LANGUAGE': ?>
                        <select name="CT_<?php echo $customFields['fieldId']; ?>" class="form-select searchSelect2">
                            <?php foreach ($customFields['languageOptions'] as $languageOptions) { ?>
                                <option value="<?php echo $languageOptions['typeLanguageOptionValue']; ?>" <?php echo $languageOptions['typeLanguageOptionSelected']; ?>>
                                    <?php echo $languageOptions['typeLanguageOptionLabel']; ?>
                                </option>
                            <?php } ?>
                        </select>
                    <?php break;

                    case 'COUNTRY': ?>
                        <select name="CT_<?php echo $customFields['fieldId']; ?>" class="form-select searchSelect2">
                            <?php echo $customFields['countryOptions']; ?>
                        </select>
                    <?php break;

                    case 'TEXTAREA': ?>
                        <textarea name="CT_<?php echo $customFields['fieldId']; ?>" class="form-control" rows="4"><?php echo $customFields['value']; ?></textarea>
                    <?php break;

                    case 'DROPDOWN': ?>
                        <select name="CT_<?php echo $customFields['fieldId']; ?>" class="form-select normalSelect2">
                            <?php foreach ($customFields['dropdownOptions'] as $dropdownOptions) { ?>
                                <option value="<?php echo $dropdownOptions['typeDropdownOptionValue']; ?>" <?php echo $dropdownOptions['typeDropdownOptionSelected']; ?>>
                                    <?php echo $dropdownOptions['typeDropdownOptionLabel']; ?>
                                </option>
                            <?php } ?>
                        </select>
                    <?php break;

                    case 'DATE': ?>
                        <input type="text" class="form-control datepicker"
                               name="CT_<?php echo $customFields['fieldId']; ?>"
                               id="CT_<?php echo $customFields['fieldId']; ?>"
                               value="<?php echo $customFields['value']; ?>">
                    <?php break;

                    case 'YESNO': ?>
                        <select name="CT_<?php echo $customFields['fieldId']; ?>" class="form-select normalSelect2">
                            <option value="1" <?php echo $customFields['yesSelected']; ?>><?php echo $this->user->lang("Yes");?></option>
                            <option value="0" <?php echo $customFields['noSelected']; ?>><?php echo $this->user->lang("No");?></option>
                        </select>
                    <?php break;

                    default: ?>
                        <input type="text" class="form-control"
                               name="CT_<?php echo $customFields['fieldId']; ?>"
                               value="<?php echo $customFields['value']; ?>">
                    <?php break;
                } ?>

                <?php if ($customFields['parseFieldInformation']) { ?>
                    <img id="fieldInformation_<?php echo $customFields['fieldId']; ?>" class="ms-2" src="../templates/admin/images/information-button.png" alt="Info"/>
                <?php } ?>

                <?php if ($customFields['parseFieldRequired']) { ?>
                    <?php if ($customFields['parseEmailOriginalName']) { ?>
                        <input type="hidden" name="e_CT_<?php echo $customFields['fieldId']; ?>" value="<?php echo $customFields['OriginalName']; ?> Format">
                    <?php } ?>
                    <input type="hidden" name="r_CT_<?php echo $customFields['fieldId']; ?>" value="<?php echo $customFields['OriginalName']; ?>">
                <?php } ?>
            </div>
        </div>
    <?php }} ?>
    </div>

    <div class="row">
        <div class="col-md-6 mb-3">
            <div class="form-elem">
                <label for="signature" class="form-label"><?php echo $this->user->lang("Signature");?></label>
                <textarea class="form-control" rows="5" name="signature" id="signature"><?php echo $this->signature_value; ?></textarea>
            </div>
        </div>
    </div>

    <div class="alert alert-warning">
        <strong><?php echo $this->user->lang("Note");?>:</strong> <?php echo $this->user->lang("Supply only if you want password changed");?>
    </div>

    <div class="row">
        <div class="col-md-6 mb-3">
            <div class="form-elem">
                <label for="new_password" class="form-label"><?php echo $this->user->lang("New Password");?></label>
                <input type="password" class="form-control" id="new_password" name="new_password" autocomplete="off">
            </div>
        </div>
        <div class="col-md-6 mb-3">
            <div class="form-elem">
                <label for="confirm_password" class="form-label"><?php echo $this->user->lang("Confirm password");?></label>
                <input type="password" class="form-control" id="confirm_password" name="confirm_password" autocomplete="off">
            </div>
        </div>
    </div>

    <button class="cm-btns orange me-2" type="submit"><?php echo $this->user->lang('Update'); ?></button>
    <?php if ($this->parseDeleteAdminButtons) { ?>
        <button id="deleteStaffButton" class="cm-btns red" type="button"><?php echo $this->user->lang('Delete'); ?></button>
    <?php } ?>
</form>


    </div>
</div>