[% site_config.title = c.loc('Off-peak-times for [_1]', profile.name) -%]

<div class="row">
    <span>
        <a class="btn btn-primary btn-large" href="[% c.uri_for('/back') %]"><i class="icon-arrow-left"></i>[% c.loc('Back') %]</a>
    </span>
</div>
[% back_created = 1 -%]

[% IF messages -%]
<div class="row">
    [% FOREACH m IN messages -%]
        <div class="alert alert-[% m.type %]">[% m.text %]</div>
    [% END -%]
</div>
[% END -%]

<div class="ngcp-separator"></div>

<h3>[% c.loc('Weekdays') %]</h3>

<table class="table table-bordered table-striped table-highlight table-hover">
    <thead>
        <tr>
            <th>[% c.loc('Weekday') %]</th>
            <th>[% c.loc('Start - End') %]</th>
            <th class="ngcp-actions-column"></th>[% #Actions %]
        </tr>
    </thead>
    <tbody>
    [% FOR w IN weekdays %]
        <tr class="sw_action_row">
            <td>[% w.name %]</td>
            <td>
            [% FOR r IN w.ranges %]
                [% r.start %] – [% r.end %] <br/>
            [% END %]
            </td>
            <td class="ngcp-actions-column">
            [% IF w.edit_link %]
                <div class="sw_actions pull-right">
                    <a class="btn btn-small btn-primary" href="[% w.edit_link %]">
                        <i class="icon-edit"></i> [% c.loc('Edit') %]
                    </a>
                </div>
            [% END %]
            </td>
        </tr>
    [% END %]
    </tbody>
</table>

<h3>[% c.loc('Dates') %]</h3>

[%
    helper.name = c.loc('Date Definition');
    helper.identifier = 'date_definition';
    helper.dt_columns = special_dt_columns;

    helper.create_flag = peaktimes_special_createflag;
    helper.edit_flag = peaktimes_special_editflag;
    helper.ajax_uri = c.uri_for_action("/billing/peaktime_specials_ajax", [c.req.captures.0]);
    helper.form_object = peaktimes_special_form;
    helper.close_target = close_target;

    helper.tmpuri = c.uri_for(c.req.captures.0, "peaktimes","date");

    UNLESS c.user.read_only;
        helper.dt_buttons = [
            { name = c.loc('Edit'), uri = helper.tmpuri _ "/'+full.id+'/edit", class = 'btn-small btn-primary', icon = 'icon-edit' },
            { name = c.loc('Delete'), uri = helper.tmpuri _ "/'+full.id+'/delete", class = 'btn-small btn-secondary', icon = 'icon-trash' },
        ];
        helper.top_buttons = [
            { name = c.loc('Create Special Off-Peak Date'), uri = helper.tmpuri _ "/create", icon = 'icon-star' },
        ];
    END;

    PROCESS 'helpers/datatables.tt';
-%]

[% IF edit_flag -%]
[% 
    PROCESS "helpers/modal.tt";
    modal_header(m.name = weekday.name);
-%]

<div class="modal-body">
    [% FOREACH r IN weekday.ranges %]
    <div class="row-fluid">
        <input type="text" value="[% r.start %]" disabled="disabled" class="ngcp_time_range"> –
        <input type="text" value="[% r.end %]" disabled="disabled" class="ngcp_time_range">
        <a class="btn btn-primary pull-right" href="?delete=[% r.id %]"><i class="icon-trash"></i></a>
    </div>
    [% END %]
    <div class="row-fluid">
    <form action="[% form.action || c.uri_for(c.action,c.req.captures) %]" method="POST">
        [% form.field('start').render %] –
        [% form.field('end').render %]
        [% form.field('add').render %]
    </form>
    </div>
</div>

[%        
    modal_footer();
    modal_script(m.close_target = c.uri_for_action('/billing/peaktimes', [c.req.captures.0]));
-%]
[% END -%]
[% # vim: set tabstop=4 syntax=html expandtab: -%]
