<div ng:controller="PollMainController" class="row-fluid" id="body-main" qn:fillheight>
    <div class="col10">
        <div class="toolbar cfix">
            <div class="toolbar-group">
                <h3>
                    <span class="circle circle-small blue"><span class="icon icon-book"></span></span>
                    {{$resource('polls.polls')}}
                </h3>
            </div>
            <div class="toolbar-group">
                <button title="{{$resource('utility.reset')}}" class="button tooltip" ng:show="isSearch()" ng:click="reset()"><i class="icon-angle-left"></i></button>
                <button title="{{$resource('utility.search')}}" class="button tooltip" ng:click="filter()"><i class="icon-search"></i></button>
                <div class="form button-widget" qn:popover>
                    <form style="width: 300px !important">
                        <div class="control-group">
                            <label>{{$resource('polls.title')}}</label>
                            <div class="controls">
                                <input class="input-xlarge" placeholder="i.e. Wordpress" ng:model="query.title" />
                            </div>
                        </div>
                        <div class="control-group">
                            <label>{{$resource('polls.description')}}</label>
                            <div class="controls">
                                <input class="input-xlarge" ng:model="query.summary" />
                            </div>
                        </div>
                        <div class="control-group">
                            <label>{{$resource('polls.status')}}</label>
                            <div class="controls">
                                <select
                                    ng:model="query.Statuses"
                                    name="Statuses"
                                    ng:options="status.id as status.title for status in statuses"
                                    multiple>
                                    <option></option>
                                </select>
                            </div>
                        </div>
                        <div class="control-group">
                            <label>{{$resource('polls.published_on_from')}}</label>
                            <input qn:datepicker="{dateFormat: 'dd-M-y'}" class="col12" type="text" name="PublishedOnFrom" ng:model="query.PublishedOnFrom" />
                        </div>
                        <div class="control-group">
                            <label>{{$resource('polls.published_on_to')}}</label>
                            <input qn:datepicker="{dateFormat: 'dd-M-y'}" class="col12" type="text" name="PublishedOnTo" ng:model="query.PublishedOnTo" />
                        </div>
                        <div class="control-group">
                            <label class="control-label"></label>
                            <div class="controls">
                                <button class="button lightblue" ng:click="search()"><i class="icon-search"></i></button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div class="toolbar-group">
                <button title="{{$resource('utility.refresh')}}" class="button tooltip" ng:click="refresh()"><i class="icon-refresh"></i></button>
            </div>
            <div class="toolbar-group right">
                <span class="info">{{pager.from}}-{{pager.to}} of {{pager.total}}</span>
                <button class="button prev" ng:disabled="!pager.canPrev()" ng:click="pager.prev()"><i class="icon-chevron-left"></i></button>
                <button class="button next" ng:disabled="!pager.canNext()" ng:click="pager.next()"><i class="icon-chevron-right"></i></button>
            </div>
            <div class="toolbar-group" ng:show="aktivan">
                <button title="{{$resource('utility.new')}}" class="button lightblue tooltip"><i class="icon-plus"></i></button>
                <div qn:popover class="button-widget">
                    <form name="NewPoll" class="cfix">
                        <div class="control-group required">
                            <label class="control-label">{{$resource('polls.title')}}</label>
                            <div class="controls">
                                <input type="text" placeholder="Title" name="Title" ng:model="newPoll.Title" required style="width: 300px !important" />
                                <div ng:show="errors['newPoll.Title'][0]" class="error">{{$resource(errors['newPoll.Title'][0])}}</div>
                            </div>
                        </div>
                        <div class="control-group required">
                            <label class="control-label">{{$resource('polls.alias')}}</label>
                            <div class="controls">
                                <input type="text" placeholder="Alias" qn:alias="newPoll.Title" name="Alias" ng:model="newPoll.Alias" style="width: 300px !important" />
                                <div ng:show="errors['newPoll.Alias'][0]" class="error">{{$resource(errors['newPoll.Alias'][0])}}</div>
                            </div>
                        </div>
                        <div class="control-group required">
                            <label class="control-label">{{$resource('polls.description')}}</label>
                            <div class="controls">
                                <textarea name="Summary" ng:model="newPoll.Summary" required style="width: 300px !important"></textarea>
                                <div ng:show="errors['newPoll.Summary'][0]" style="display: block; clear: both; color: red; padding: 10px 0 0;">{{$resource(errors['newPoll.Summary'][0])}}</div>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">{{$resource('articles.expires')}}</label>
                            <div class="controls">
                                <div class="input-prepend">
                                    <span class="add-on"><i class="icon-calendar"></i></span>
                                    <input qn:datepicker="{dateFormat: 'd MM yy'}" class="input-medium" type="text" name="ExpiresOn.Date" ng:model="newPoll.ExpiresOn" />
                                </div>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">&nbsp;</label>
                            <div class="controls">
                                <button type="button" ng:click="create()" class="button lightblue">{{$resource('polls.create')}}</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <div class="table table-hover fillh">
            <table>
                <thead>
                    <tr>
                        <th class="icon">&nbsp;</th>
                        <th>{{$resource('polls.title')}}</th>
                        <th>{{$resource('polls.description')}}</th>
                        <th>{{$resource('polls.published')}}</th>
                        <th>{{$resource('polls.expires')}}</th>
                        <th class="number">{{$resource('polls.number_of_questions')}}</th>
                        <th>{{$resource('newsletters.status')}}</th>
                        <th class="command"></th>
                    </tr>
                </thead>
                <tbody>
                    <tr ng:repeat="poll in filtered = (polls | pollFilter:Status)">
                        <td class="icon">
                            <div title="{{poll.Status.DisplayName}}" class="circle status-{{poll.Status.LowerName}}"><i class="icon icon-book"></i></div>
                        </td>
                        <td class="title" ng:click="select(poll)">
                            <div class="inner">
                                <h2>{{poll.Title}}</h2>
                                <p class="info">{{poll.CreatedBy}}</p>
                            </div>
                        </td>
                        <td>{{poll.Summary}}</td>
                        <td>{{poll.PublishedOn | date}}</td>
                         <td>{{poll.ExpiresOn | date}}</td>
                        <td class="number">{{poll.VoteCount}}</td>
                        <td>{{poll.Status.DisplayName }}</td>
                        <td class="command icon">
                            <a title="{{$resource('utility.options')}}" class="button tooltip" class="trigger"><i class="icon-reorder"></i></a>
                            <div qn:popover="{position: {my: 'right top', at: 'left top'}}">
                                <ul>
                                    <li><a ng:click="setLock(poll)" value="Da li ste sigurni?"><span ng:show="poll.Status.DisplayName == 'Aktivan'"><i class=" icon-ban-circle"></i>{{$resource('newsletters.deaktivacija')}}</span><span ng:show="poll.Status.DisplayName == 'NeAktivan'"><i class="icon-ok-circle"></i>{{$resource('newsletters.aktivacija')}}</span></a></li>
                                    <li ng:click="newQuestion(poll)"><a><i class="icon-trash"></i>{{$resource('polls.pitanje')}}</a></li>
                                    <li ng:click="remove(poll, $index)"><a><i class="icon-trash"></i>{{$resource('polls.delete')}}</a></li>
                                    <li ng:click="updatePoll(poll)"><a><i class="icon-edit"></i>{{$resource('polls.edit')}}</a></li>
                                </ul>
                            </div>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div class="col2 sidebar">
        <div class="toolbar toolbar-strip lightblue cfix">
            <div class="toolbar-group row-fluid">
                <button title="{{$resource('utility.basic')}}" class="button lightblue col3 tooltip" ng:class="{active:sidebarView == 'basic'}" ng:click="switchSidebar('basic')"><i class="icon-star"></i></button>
            </div>
        </div>
        <div class="inner fillh">
            <ul class="nav" ng:show="sidebarView == 'basic'">
                <li ng:class="{active:!isSearch()}"><a ng:click="resets()"><i class="icon-asterisk"></i>{{$resource('newsletters.newsletters_all')}}</a></li>
                <li ng:class="{active:query.Status=='Aktivan'}"><a ng:click="search({Status:'Aktivan'}, true)"><i class="icon-lock lightred"></i>{{$resource('newsletters.newslettersaktivni')}}</a></li>
                <li ng:class="{active:query.Status=='NeAktivan'}"><a ng:click="search({Status:'NeAktivan'}, true)"><i class="icon-lock green"></i>{{$resource('newsletters.newslettersneaktivni')}}</a></li>
                <li>
                    <hr />
                </li>
            </ul>
        </div>
    </div>
    <div qn:dialog="ui.dialogUpdatePoll">
        <div>
            <form class="form-horizontal" name="UpdatePoll">
                <div class="control-group required">
                    <label class="control-label">{{$resource('polls.title')}}</label>
                    <div class="controls">
                        <input class="input-medium" type="text" name="Title" ng:model="poll.Title" required />
                        <div ng:show="errors['poll.Title'][0]" class="error">{{$resource(errors['poll.Title'][0])}}</div>
                    </div>
                </div>
                <div class="control-group required">
                    <label class="control-label">{{$resource('utility.alias')}}</label>
                    <div class="controls">
                        <input type="text" placeholder="Alias" name="Alias" ng:model="poll.Alias" required />
                        <div ng:show="errors['poll.Alias'][0]" class="error">{{$resource(errors['poll.Alias'][0])}}</div>
                    </div>
                </div>
                <div class="control-group required">
                    <label class="control-label">{{$resource('polls.summary')}}</label>
                    <div class="controls">
                        <textarea class="span5" rows="3" type="text" name="Summary" ng:model="poll.Summary" required></textarea>
                        <div ng:show="errors['poll.Summary'][0]" style="display: block; clear: both; color: red; padding: 10px 0 0;">{{$resource(errors['poll.Summary'][0])}}</div>
                    </div>
                </div>
               <!--  <div class="control-group">
                            <label class="control-label">{{$resource('articles.expires')}}</label>
                            <div class="controls">
                                <div class="input-prepend">
                                <span class="add-on"><i class="icon-calendar"></i></span>
                                <input qn:datepicker="{dateFormat: 'd MM yy'}" class="input-medium" type="text" name="ExpiresOn.Date" ng:model="poll.ExpiresOn" />
                           </div>
                      </div>
                  </div>-->
            </form>
        </div>
        <div class="control-group commands">
            <label class="control-label">&nbsp;</label>
            <div class="controls">
                <button type="button" ng:click="edit()" class="button lightblue">{{$resource('polls.save')}}</button>
                &nbsp;
                <button class="button" ng:click="cancelUpdate()">{{$resource('polls.cancel')}}</button>
            </div>
        </div>
    </div>
</div>
