{% include "root_header_begin.html" %}
{% include "scan_paths/header_jquery.html" %}
{% include "root_header_end.html" %}
{% include "scan_paths/sidebar_start.html" %}
{% include "scan_paths/sidebar_main.html" %}
{% include "scan_paths/sidebar_end.html" %}
<!-- !PAGE CONTENT! -->
<div class="w3-main" style="margin-left:300px;margin-top:43px;">

  <!-- Header -->
    <header class="w3-container" style="padding-top:22px">
      <h5><b>Scan Paths - Server Credential</b></h5>
    </header>
    <div class="w3-container">
        <div class="w3-full">
            <!-- http://divtable.com/generator/ -->
            <h6><u>Add a Scan Path Server Credential</u></h6>
            <form action="" method="post" id="share_credential_add_form" enctype="multipart/form-data"><form action="" method="post" id="share_credential_add_form" enctype="multipart/form-data">
                <table border="1">
                    <tbody>
                        <tr>
                            {% for share_credential_key in share_credential_add_keys %}
                                <td>{{ share_credential_title_dict[share_credential_key] }}</td>
                            {% endfor %}
                        </tr>
                        <tr>
                            {% for share_credential_key in share_credential_add_keys %}
                                <td>

                                {% if share_credential_add_dict[share_credential_key] == 'text' %}
                                    <input id="{{ share_credential_key }}"
                                           name="{{ share_credential_key }}"
                                           type="text" value="" size="15">
                                {% elif share_credential_editable_dict[share_credential_key] == 'password' %}
                                    <input id="{{ share_credential_key }}"
                                           name="{{ share_credential_key }}"
                                           type="password" value="" size="15">
                                </td>
                                {% endif %}
                            {% endfor %}
                        </tr>
                    </tbody>
                </table>
            <input type="hidden" value="add" name="type">
            </form>
            <br>
            <button id="share_credential_add_form_submit" type="button">Add</button>
            <br>
            <br>
            <h6><u>Edit a Scan Path Server Credential</u></h6>
            <form action="" method="post" id="share_credential_form" enctype="multipart/form-data">
                <table border="1">
                    <tbody>
                        <tr>
                            {% for share_credential_key in share_credential_keys %}
                                <td>{{ share_credential_title_dict[share_credential_key] }}</td>
                            {% endfor %}
                        </tr>
                        {% for share_credential in share_credential_list %}
                        <tr>
                            {% for share_credential_key in share_credential_keys %}
                                <td>
                                {% if share_credential_key in share_credential_editable_dict %}
                                    {% if share_credential_editable_dict[share_credential_key] == 'bool' %}
                                            <select id="{{ share_credential['zp_share_credential_id'] }}_{{ share_credential_key }}"
                                                    name="{{ share_credential['zp_share_credential_id'] }}_{{ share_credential_key }}">
                                                {% if share_credential[share_credential_key] == 1 %}
                                                    <option value="1" selected>Enabled</option>
                                                    <option value="0">Disabled</option>
                                                {% else %}
                                                    <option value="1">Enabled</option>
                                                    <option value="0" selected>Disabled</option>
                                                {% endif %}
                                            </select>
                                    {% elif share_credential_editable_dict[share_credential_key] == 'text' %}
                                            <input id="{{ share_credential['zp_share_credential_id'] }}_{{ share_credential_key }}"
                                                   name="{{ share_credential['zp_share_credential_id'] }}_{{ share_credential_key }}"
                                                   type="text" value="{{ share_credential[share_credential_key] }}" size="15">
                                    {% elif share_credential_editable_dict[share_credential_key] == 'password' %}
                                            <input id="{{ share_credential['zp_share_credential_id'] }}_{{ share_credential_key }}"
                                                   name="{{ share_credential['zp_share_credential_id'] }}_{{ share_credential_key }}"
                                                   type="password" value="{{ share_credential[share_credential_key] }}" size="15">
                                    {% elif share_credential_editable_dict[share_credential_key] == 'select' %}
                                        {% if share_credential_key in ['zp_share_credential_id', 'zp_share_credential_credential_id', 'zp_share_credential_credential_id'] %}
                                            {% if share_credential['fs_type'] == 2 %}
                                                {% if share_credential_key == 'zp_share_credential_id' %}
                                                    <select id="{{ share_credential['zp_share_credential_id'] }}_{{ share_credential_key }}"
                                                    name="{{ share_credential['zp_share_credential_id'] }}_{{ share_credential_key }}">
                                                        {% for share_credential_key in share_credential_dict|sort %}
                                                            {% if share_credential_key == share_credential['zp_share_credential_id'] %}
                                                                <option value="{{ share_credential_key }}" selected>
                                                                {{ share_credential_dict[share_credential_key]['name'] }}
                                                                </option>
                                                            {% else %}
                                                                <option value="{{ share_credential_key }}">
                                                                {{ share_credential_dict[share_credential_key]['name'] }}
                                                                </option>
                                                            {% endif %}
                                                        {% endfor %}
                                                    </select>
                                                {% elif share_credential_key == 'zp_share_credential_credential_id' %}
                                                    <select id="{{ share_credential['zp_share_credential_id'] }}_{{ share_credential_key }}"
                                                    name="{{ share_credential['zp_share_credential_id'] }}_{{ share_credential_key }}">
                                                        {% for share_credential_credential_key in share_credential_credential_dict|sort %}
                                                            {% if share_credential_credential_key == share_credential['zp_share_credential_credential_id'] %}
                                                                <option value="{{ share_credential_credential_key }}" selected>
                                                                {{ share_credential_credential_dict[share_credential_credential_key]['name'] }}
                                                                </option>
                                                            {% else %}
                                                                <option value="{{ share_credential_credential_key }}">
                                                                {{ share_credential_credential_dict[share_credential_credential_key]['name'] }}
                                                                </option>
                                                            {% endif %}
                                                        {% endfor %}
                                                    </select>
                                                {% elif share_credential_key == 'zp_share_credential_credential_id' %}
                                                    <select id="{{ share_credential['zp_share_credential_id'] }}_{{ share_credential_key }}"
                                                    name="{{ share_credential['zp_share_credential_id'] }}_{{ share_credential_key }}">
                                                        {% for share_credential_credential_key in share_credential_credential_dict|sort %}
                                                            {% if share_credential_credential_key == share_credential['zp_share_credential_credential_id'] %}
                                                                <option value="{{ share_credential_credential_key }}" selected>
                                                                {{ share_credential_credential_dict[share_credential_credential_key]['username'] }}
                                                                </option>
                                                            {% else %}
                                                                <option value="{{ share_credential_credential_key }}">
                                                                {{ share_credential_credential_dict[share_credential_credential_key]['username'] }}
                                                                </option>
                                                            {% endif %}
                                                        {% endfor %}
                                                    </select>
                                                {% endif %}
                                            {% else %}
                                                N/A
                                            {% endif %}
                                        {% elif share_credential_key == 'fs_type' %}
                                              <select id="{{ share_credential['zp_share_credential_id'] }}_{{ share_credential_key }}"
                                                    name="{{ share_credential['zp_share_credential_id'] }}_{{ share_credential_key }}">
                                                {% for share_credential_fs_type_key in share_credential_fs_type_dict|sort %}
                                                    {% if share_credential_fs_type_key == share_credential['fs_type'] %}
                                                        <option value="{{ share_credential_fs_type_key }}" selected>
                                                        {{ share_credential_fs_type_dict[share_credential_fs_type_key]['name'] }}
                                                        </option>
                                                    {% else %}
                                                        <option value="{{ share_credential_fs_type_key }}">
                                                        {{ share_credential_fs_type_dict[share_credential_fs_type_key]['name'] }}
                                                        </option>
                                                    {% endif %}
                                                {% endfor %}
                                            </select>
                                        {% elif share_credential_key == 'zp_library_id' %}
                                            <select id="{{ share_credential['zp_share_credential_id'] }}_{{ share_credential_key }}"
                                                    name="{{ share_credential['zp_share_credential_id'] }}_{{ share_credential_key }}">
                                                {% for share_credential_library_key in share_credential_library_dict|sort %}
                                                    {% if share_credential_library_key == share_credential['zp_library_id'] %}
                                                        <option value="{{ share_credential_library_key }}" selected>
                                                        {{ share_credential_library_dict[share_credential_library_key]['name'] }}
                                                        </option>
                                                    {% else %}
                                                        <option value="{{ share_credential_library_key }}">
                                                        {{ share_credential_library_dict[share_credential_library_key]['name'] }}
                                                        </option>
                                                    {% endif %}
                                                {% endfor %}
                                            </select>
                                        {% endif %}
                                    {% elif share_credential_key == 'fs_type' %}
                                        {% if share_credential[share_credential_key] == 1 %}
                                            local
                                        {% else %}
                                            smb
                                        {% endif %}
                                    {% else %}
                                       {{ share_credential[share_credential_key] }}
                                    {% endif %}
                                {% else %}
                                    {% if share_credential_key == 'zp_library_id' %}
                                        {% if share_credential[share_credential_key] == 1 %}
                                            Film
                                        {% else %}
                                            TV
                                        {% endif %}
                                    {% else %}
                                        {{ share_credential[share_credential_key] }}
                                    {% endif %}
                                {% endif %}
                                        </td>
                            {% endfor %}
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            <input type="hidden" value="edit" name="type">
            </form>
            <br>
            <button id="share_credential_form_submit" type="button">Apply Changes</button>
        </div>
    </div><br>

{% include "root_footer.html" %}