<div class="form-container">
    <div class="row">
        {* -- Begin folders management ----------------------------------- *}
        <div class="col-md-6">
            <div class="well well-sm">
                <div class="form-group">
                    <form method="POST" action="{url path='/admin/content/folder/add'}" id="related_content_form">

                        <p class="title title-without-tabs">{intl l='Additional Folders'}</p>
                        <p>{intl l='A content could be attached to more than one folder. Select here the additional folders for this content.'}
                            {loop name="default_folder" type="folder" id=$DEFAULT_FOLDER}
                            {intl l='You can change the default folder (%title) in the "General" tab.' title={$TITLE}}
                            {/loop}

                            {$exclude_from_tree = "-1"}
                            {loop name="additional_folders" type="folder" exclude=$DEFAULT_FOLDER content=$content_id backend_context="1" lang="$edit_language_id"}
                            {$exclude_from_tree = "$exclude_from_tree,$ID"}
                            {/loop}
                            <input type="hidden" name="content_id" value="{$content_id}" />
                            <input type="hidden" name="current_tab" value="association" />

                            {ifloop rel="folders"}
                        <div class="input-group">

                            <select name="additional_folder_id" id="additional_folder_id" class="form-control">
                                <option value="">{intl l='Select a folder...'}</option>
                                {loop name="folders" type="folder-tree" folder="0" exclude=$exclude_from_tree backend_context="1" lang="$edit_language_id" return_url=false}
                                    <option value="{$ID}" {if $DEFAULT_FOLDER==$ID}disabled="disabled"{/if}>
                                        {option_offset l=$LEVEL label={$TITLE}}{if $DEFAULT_FOLDER==$ID}{intl l=' (default)'}{/if}
                                    </option>
                                {/loop}
                            </select>

                                    <span class="input-group-btn" id="content_add_button">
                                       <button class="btn btn-primary action-btn" type="submit"><span class="glyphicon glyphicon-plus-sign"></span></button>
                                    </span>

                        </div>
                        <span class="help-block">{intl l='Select a folder and click (+) to add it to the additional folder list'}</span>
                        {/ifloop}

                        {elseloop rel="folders"}
                            <div class="alert alert-info">{intl l="No Folders found"}</div>
                        {/elseloop}

                    </form>
                </div>

                <div class="table-responsive">
                    <table class="table table-striped table-condensed table-left-aligned">
                        <thead>
                        <tr>
                            <th>{intl l='ID'}</th>

                            <th>{intl l='Folder title'}</th>

                            {hook name="product.folders-table-header" location="product_folders_table_header" }

                            <th class="actions">{intl l="Actions"}</th>
                        </tr>
                        </thead>

                        <tbody>
                        {loop name="additional_folders" type="folder" content=$content_id exclude=$DEFAULT_FOLDER backend_context="1" lang="$edit_language_id" return_url=false}
                            <tr>
                                <td>{$ID}</td>

                                <td>
                                    {$TITLE}
                                </td>

                                {hook name="product.folders-table-row" location="product_folders_table_row" }

                                <td class="actions">
                                    {loop type="auth" name="can_delete" role="ADMIN" resource="admin.category" access="UPDATE"}
                                        <a class="btn btn-default btn-xs delete-folder" title="{intl l='Remove the product from this category'}" href="#delete_folder_dialog" data-id="{$ID}" data-toggle="modal">
                                            <span class="glyphicon glyphicon-trash"></span>
                                        </a>
                                    {/loop}
                                </td>
                            </tr>
                        {/loop}

                        {elseloop rel="additional_folders"}
                            <tr>
                                <td colspan="3">
                                    <div class="alert alert-info">
                                        {intl l="This product doesn't belong to any additional folder."}
                                    </div>
                                </td>
                            </tr>
                        {/elseloop}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        {* -- End folders management ------------------------------------- *}
    </div>
</div>
