<link rel="stylesheet" type="text/css" href="/static/css/manage.css" />

<div id="page-manage">
    <div class="title">新增職員</div>
    <?php if (isset($__alert_failure_message)) : ?>
        <div class="alert alert-danger" role="alert" style="text-align: left;"><?php echo $__alert_failure_message; ?><button type="button" class="close" data-dismiss="alert" aria-label="Close"><a aria-hidden="true">×</a></button></div>
    <?php endif; ?>
    <ul class="table-toolbar" style="text-align: left;">
        <li><a class="toolbar-element btn btn-default btn-create" href="/employee"><i class="fa fa-reply" style="margin-right: 8px;"></i>返回</a></li>
    </ul>
    <div class="form-container">
        <form id="form" class="form-horizontal" role="form" method="post" action="/employee/add">
            <div class="form-group mas-col">
                <div class="col-sm-2 text-center mas-title">
                    <label for="username">登入名稱 *</label>
                </div>
                <div class="col-sm-10 text-center mas-title mas-box ">
                    <input id="username" type="text" class="form-control mas-input" name="username" value="<?php echo $username; ?>" style="background-color: rgb(253, 234, 236);">
                </div>
            </div>
            <div class="form-group mas-col">
                <div class="col-sm-2 text-center mas-title">
                    <label for="password">登入密碼 *</label>
                </div>
                <div class="col-sm-10 text-center mas-title mas-box ">
                    <input id="password" type="password" class="form-control mas-input" name="password" value="<?php echo $password; ?>" style="background-color: rgb(253, 234, 236);">
                </div>
            </div>
            <div class="form-group mas-col">
                <div class="col-sm-2 text-center mas-title">
                    <label for="confirm_password">確認登入密碼 *</label>
                </div>
                <div class="col-sm-10 text-center mas-title mas-box">
                    <input id="confirm_password" type="password" class="form-control mas-input" name="confirm_password" value="<?php echo $confirm_password; ?>" style="background-color: rgb(255, 255, 255);">
                </div>
            </div>
            <div class="form-group mas-col">
                <div class="col-sm-2 text-center mas-title">
                    <label for="tenant_no">所屬分校 *</label>
                </div>
                <div class="col-sm-10 mas-box initialized">
                    <?php
                    if ($isSiteAdmin) {
                        $disabled = '';
                    } else {
                        $disabled = ' disabled="disabled"';
                    }
                    ?>
                    <select id="tenant_no" name="tenant_no" style="width: 100%" select2 <?= $disabled; ?>>
                        <option value="-1">-- 請選擇分校 --</option>
                        <?php foreach ($tenants as $k => $v) : ?>
                            <?php //TODO: id => tenant_no 
                            echo sprintf(
                                '<option value="%s"%s>%s</option>',
                                $v['code'],
                                $v['code'] == $tenant_no ? ' selected' : '',
                                $v['name']
                            );
                            ?>
                        <?php endforeach; ?>
                    </select>
                </div>
            </div>
            <div class="form-group mas-col">
                <div class="col-sm-2 text-center mas-title">
                    <label for="chi_name">中文姓名 *</label>
                </div>
                <div class="col-sm-10 mas-box">
                    <input id="chi_name" type="text" class="form-control mas-input" name="chi_name" value="<?php echo $chi_name; ?>" style="background-color: rgb(255, 255, 255);">
                </div>
            </div>
            <div class="form-group mas-col">
                <div class="col-sm-2 text-center mas-title">
                    <label for="eng_name">英文姓名 *</label>
                </div>
                <div class="col-sm-10 mas-box">
                    <input id="eng_name" type="text" class="form-control mas-input" name="eng_name" value="<?php echo $eng_name; ?>" style="background-color: rgb(255, 255, 255);">
                </div>
            </div>
            <div class="form-group mas-col">
                <div class="col-sm-2 text-center mas-title">
                    <label for="display_name">稱呼 *</label>
                </div>
                <div class="col-sm-10 mas-box">
                    <input id="display_name" type="text" class="form-control mas-input" name="display_name" value="<?php echo $display_name; ?>" style="background-color: rgb(255, 255, 255);">
                </div>
            </div>
            <div class="form-group mas-col">
                <div class="col-sm-2 text-center mas-title"><label for="gender">性別 *</label></div>
                <div class="col-sm-10 mas-box initialized">
                    <select id="gender" name="gender" style="width: 100%" select2>
                        <option value="-1">-- 請選擇性別 --</option>
                        <?php foreach ($genders as $k => $v) : ?>
                            <?php
                            echo sprintf(
                                '<option value="%s"%s>%s</option>',
                                $v['id'],
                                $v['id'] === $gender ? ' selected' : '',
                                $v['name']
                            );
                            ?>
                        <?php endforeach; ?>
                    </select>
                </div>
            </div>
            <div class="form-group mas-col">
                <div class="col-sm-2 text-center mas-title"><label for="role_id">職位名稱 *</label></div>
                <div class="col-sm-10 mas-box initialized">
                    <select id="role_id" name="role_id" style="width: 100%" select2>
                        <option value="-1">-- 請選擇職位 --</option>
                        <?php foreach ($roles as $k => $v) : ?>
                            <?php
                            echo sprintf(
                                '<option value="%s"%s>%s</option>',
                                $v['id'],
                                $v['id'] == $role_id ? ' selected' : '',
                                $v['name']
                            );
                            ?>
                        <?php endforeach; ?>
                    </select>
                </div>
            </div>
            <div class="form-group mas-col">
                <div class="col-sm-2 text-center mas-title"><label for="income_type_id">薪酬方式 *</label></div>
                <div class="col-sm-10 mas-box initialized">
                    <select id="income_type_id" name="income_type_id" style="width: 100%" select2>
                        <option value="-1">-- 請選擇薪酬方式 --</option>
                        <?php foreach ($income_types as $k => $v) : ?>
                            <?php
                            echo sprintf(
                                '<option value="%s"%s>%s</option>',
                                $v['id'],
                                $v['id'] == $income_type_id ? ' selected' : '',
                                $v['name']
                            );
                            ?>
                        <?php endforeach; ?>
                    </select>
                    <div class="select2-container"><a href="javascript:void(0)" class="select2-choice" style="font-size: 15px;"> --- 沒有任教課程的記錄 --- </a></div>
                </div>
            </div>
            <div class="form-group mas-col">
                <div class="col-sm-2 text-center mas-title">
                    <label for="income">$ *</label>
                </div>
                <div class="col-sm-4 mas-box">
                    <input id="income" type="text" class="form-control mas-input" name="income" value="<?php echo $income; ?>" style="background-color: rgb(255, 255, 255);">
                </div>

                <div class="col-sm-2 text-center mas-title">
                    <label for="commission">拆賬(%) *</label>
                </div>
                <div class="col-sm-4 mas-box">
                    <input id="commission" type="text" class="form-control mas-input" name="commission" value="<?php echo $commission; ?>" style="background-color: rgb(255, 255, 255);" value="0">
                </div>
            </div>
            <div class="form-group mas-col">
                <div class="col-sm-2 text-center mas-title">
                    <label for="remark">備註</label>
                </div>
                <div class="col-sm-10 mas-box">
                    <textarea id="remark" class="form-control mas-textarea" rows="3" name="remark" value="<?php echo $remark; ?>" style="background-color: rgb(255, 255, 255);"></textarea>
                </div>
            </div>
            <div class="form-footer">
                <a class="btn btn-footer reset" href="javascript:window.location.reload(true)">重設</a>
                <input class="btn btn-footer submit" type="submit" value="遞交">
            </div>
        </form>
    </div>
</div>
<script>
    $(document).ready(function() {
        var li = $('#sidebar-menu li').filter(function(i) {
            return $(this).find('.menu-dropdown').find('.menu-text').text() === '職員';
        });
        li.addClass('active open');
    });
</script>