<?php
/**
 * Copyright (c) 2016 Serhii Borodai <clarifying@gmail.com>.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 *  all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 *
 */


/** @var $this \Zend\View\Renderer\PhpRenderer */

$this->headScript()
    ->appendFile('/js/adm/feeds.js')
    
;

$this->headLink()
    ->appendStylesheet('/css/styles-offers-list.css')
;

$lang = $this->lang;

$feeds = $this->feeds;

$btn_create_link = $this->url('adm.feed.create', [                    
    'lang' => $lang,
]);                 

$form_link = $this->url('adm.feed.edit',['lang' => $lang, 'id' => 0]);


?>



<section class="b-content__work">
    <div class="panel panel-info">
        
        <div class="panel-heading">
            <h1 style="padding: 0 0 10px 0;"><?= _t('Список фидов') ?></h1>
            <div class="btn-toolbar">
                <div class="btn-group" role="group">
                    <a class="btn btn-primary" href="<?= $btn_create_link ?>"><?= _t('Добавить фида') ?></a>
                </div>
                
            </div>
        </div>
        
        <div class="panel-body all" style="min-height: 500px;">
            
            <?php /* ?>
            <div class="b-offers-list_controls form-group">
                <span><?= _t('Отображать:') ?></span>
                <select class="form-control items-select data-active">
                    <option value=""><?= _t('все') ?></option>
                    <option value="enabled"><?= _t('активные') ?></option>
                    <option value="disabled"><?= _t('не активные') ?></option>
                </select>
                <span class="b-data-item_action">
                    <span class="mark-count">выделено: <b></b></span>&emsp;
                </span>
            </div>
            <?php */ ?>
            
            <table class="table table-striped offers" id="table2excel" data-action="<?= $form_link ?>" data-content="feeds">
                <thead>
                    <tr>                        
                        <th width="110px"><input class="select-all" type="checkbox"><b class="action hidden activate" title="сделать активными"></b><b class="action hidden deactivate" title="сделать неактивными"></b><span class="sort" data-sort="id" data-sortasc="1">#ID</span></th>
                        <th><span class="sort" data-sort="title" data-sortasc="1">Название<b class="asc">&#9650;</b><b class="desc">&#9660;</b></span></th>
                        <th><span class="sort" data-sort="clientid" data-sortasc="1">Пользователь<b class="asc">&#9650;</b><b class="desc">&#9660;</b></span></th>
                        <th><span class="sort" data-sort="url" data-sortasc="1">URL<b class="asc">&#9650;</b><b class="desc">&#9660;</b></span></th>
                        <th><span class="sort" data-sort="format" data-sortasc="1">Format<b class="asc">&#9650;</b><b class="desc">&#9660;</b></span></th>
                        <th><span class="sort" data-sort="status" data-sortasc="1">Status<b class="asc">&#9650;</b><b class="desc">&#9660;</b></span></th>
                        <th><span class="sort" data-sort="defaultcur" data-sortasc="1">DefaultCUR<b class="asc">&#9650;</b><b class="desc">&#9660;</b></span></th>
                        <th><span class="sort" data-sort="goodscount" data-sortasc="1">GoodsCount<b class="asc">&#9650;</b><b class="desc">&#9660;</b></span></th>
                        <th><span class="sort" data-sort="lastcheck" data-sortasc="1">LastCheck<b class="asc">&#9650;</b><b class="desc">&#9660;</b></span></th>
                    </tr>
                </thead>
                <tbody>
                    
                <?php foreach ($feeds as $feed) : ?>
                    <tr <?= (!$feed['active'] ? 'class="disabled"' : '')?>>
                        <td>
                            <input class="is-active" type="checkbox">
                            <span class="feed-id"><?= $feed['id'] ?></span>
                        </td>
                        <td class="row-user">
                             <?php 
                                $btn_link = $this->url('adm.feed.edit', [
                                    'lang' => $this->lang,
                                    'id' => $feed['id'],
                                ]);                 
                             ?>
                            <span class="feed-title"><a href="<?= $btn_link?>"><?= $feed['title'] ?></a></span>
                        </td>                  
                        <td>
                            <span class="feed-clientid"><?= $feed['clientid'] ?></span>
                        </td>
                        <td>
                            <span class="feed-url"><?= $feed['url'] ?></span>
                        </td>
                        <td>
                            <span class="feed-format"><?= $feed['format'] ?></span>
                        </td>
                        <td>
                            <span class="feed-status"><?= $feed['status'] ?></span>
                        </td>
                        <td>
                            <span class="feed-defaultcur"><?= $feed['defaultcur'] ?></span>
                        </td>
                        <td>
                            <span class="feed-goodscount"><?= $feed['goodscount'] ?></span>
                        </td>
                        <td>
                            <span class="feed-lastcheck"><?= $feed['lastcheck'] ?></span>
                        </td>
                    </tr>
                <?php endforeach; ?>
                    
                    
                </tbody>
            </table>
            
        </div>
        <div class="panel-footer">
        </div>    
    </div>
</section>
