<%inherit file="/layout/wizard.html"/>
<%namespace file="/lib.html" import="csrf_hidden_input, wizard_cancel_delete, wizard_errors"/>

<div class="content alertStep2">
    <%include file="_steps.html" args="step=3"/>
    <form method="post" action="${make_url(['scheduledigestwizard', app, 'step3', 'update']) | h}">
        ${wizard_errors(header=_('Your alert settings could not be saved.'), errors=saved_search.errors)}
        ${csrf_hidden_input()}
        <input type="hidden" name="id" value="${saved_search.id | h}"/>
        <table>
            <tbody>
                % if saved_search.metadata.can_share_app:
                    <tr>
                        <td class="col1"><label for="private">${_('Share')}</label></td>
                        <td class="col2">
                            <ul>
                                <li>
                                    <input type="radio" name="metadata.sharing" value="user" id="private" ${'checked="checked"' if saved_search.metadata.sharing=='user' else ''}/>
                                    <label for="private">${_('Keep search private')}</label>
                                </li>
                                <li>
                                    <input type="radio" name="metadata.sharing" value="app" id="share" ${'checked="checked"' if saved_search.metadata.sharing=='app' else ''}/>
                                    <label for="share">${_('Share as read-only to all users of current app')}</label>
                                </li>
                                <li class="note">
                                    ${_('<em>Additional permission settings available in </em><br/><strong>Settings &raquo; Searches, reports, and alerts</strong>')}
                                </li>
                            </ul>
                        </td>
                    </tr>
                % endif
            </tbody>
        </table>
    </form>
</div>

<ul class="buttons splClearfix">
    <li class="left">${wizard_cancel_delete(make_url(['scheduledigestwizard', app, 'delete']), saved_search.id)}</li>
    <li class="right"><button class="splButton-primary" type="submit" onclick="$(document.forms[0]).trigger('submit');"><span>${_('Finish &#187;')}</span></button></li>
    <li class="right"><a href="${make_url(['scheduledigestwizard', app, 'step2'], _qs=dict(id=saved_search.id)) | h}" class="splButton-secondary"><span>${_('&#171; Back')}</span></a></li>
</ul>

<script type="text/javascript">
    (function(){
    })()
</script>
