<?
$title = $this->_('Group List');
$this->headTitle($title, 'SET');
$this->textDelay('breadcrumbText', $title);
if($this->form){
	$form = $this->form;
} else {
    $form = new Group\Form\PostSearchForm();
}

$form
->setView($this)
->setMethod('get')
->setAction($this->uri('/admin/group/'))
->bind($this->query)
->prepare();

$lableMap = array(
    'draft' => '',
    'active' => 'label-success',
    'pending' => 'label-warning',
    'deleted' => 'label-inverse',
);

?>
<div class="row">
    <div class="span10">
        <div class="slate">
            <form <?=$this->formAttr($form)?> class="form-inline">
                <?=$form->helper('keyword', array('class' => 'input-large', 'placeholder' => 'Keyword...'))?>
                <?=$form->helper('status', 'formSelect', array('class' => 'span2'))?>
                <button class="btn" type="submit"><?=$this->_('Filter Groups')?></button>
            </form>
        </div>
    </div>
</div>


<div class="row">
    <div class="span10 listing-buttons">
        <div class="btn-group pull-right">
            <a href="<?=$this->uri('/admin/group/create')?>" class="btn btn-info"><?=$this->_('Add New Group')?></a>
        </div>
        <form action="<?=$this->uri('/admin/group/multi/')?>" method="post" class="pull-left" data-multiform="post">
            <input type="hidden" name="id" class="multiform-container-main" value="" />
            <div class="btn-group">
                <span class="btn"><input type="checkbox" class="multiform-checker" /></span>
                <span data-toggle="dropdown" class="btn dropdown-toggle">
                    <?=$this->_('Status')?>
                    <span class="caret"></span>
                </span>
                <ul class="dropdown-menu">
                    <li><a href="#" class="multiform-submiter" data-multiform-action="<?=$this->uri('/admin/group/multi/status/active')?>"><?=$this->_('Active')?></a></li>
                    <li><a href="#" class="multiform-submiter" data-multiform-action="<?=$this->uri('/admin/group/multi/status/pending')?>"><?=$this->_('Pending')?></a></li>
                    <li><a href="#" class="multiform-submiter" data-multiform-action="<?=$this->uri('/admin/group/multi/status/deleted')?>"><?=$this->_('Deleted')?></a></li>
                </ul>
            </div>
        </form>
    </div>

    <div class="span10">
        <div class="slate">
            <div class="page-header">
                <div class="btn-group pull-right">
                    <span data-toggle="dropdown" class="btn dropdown-toggle">
                        <?=$this->_('Order')?> <span class="caret"></span>
                    </span>
                    <ul class="dropdown-menu">
                        <li><a href="<?=$this->uri('/admin/group/', 'dq', array('Q' => $this->query, 'q' => array('order' => 'idasc',),));?>" class=""><i class="icon-arrow-up"></i> <?=$this->_('Id')?></a></li>
                        <li><a href="<?=$this->uri('/admin/group/', 'dq', array('Q' => $this->query, 'q' => array('order' => 'iddesc',),));?>" class=""><i class="icon-arrow-down"></i> <?=$this->_('Id')?></a></li>
                        <li><a href="<?=$this->uri('/admin/group/', 'dq', array('Q' => $this->query, 'q' => array('order' => 'titleasc',),));?>" class=""><i class="icon-arrow-up"></i> <?=$this->_('Title')?></a></li>
                        <li><a href="<?=$this->uri('/admin/group/', 'dq', array('Q' => $this->query, 'q' => array('order' => 'titledesc',),));?>" class=""><i class="icon-arrow-down"></i> <?=$this->_('Title')?></a></li>
                        <li><a href="<?=$this->uri('/admin/group/', 'dq', array('Q' => $this->query, 'q' => array('order' => 'timeasc',),));?>" class=""><i class="icon-arrow-up"></i> <?=$this->_('Time')?></a></li>
                        <li><a href="<?=$this->uri('/admin/group/', 'dq', array('Q' => $this->query, 'q' => array('order' => 'timedesc',),));?>" class=""><i class="icon-arrow-down"></i> <?=$this->_('Time')?></a></li>
                    </ul>
                </div>
                <h2><?=$title?></h2>
            </div>

            <table class="orders-table table">
                <thead>
                    <tr>
                        <th class="span1">
                        </th>
                        <th><?=$this->_('Group Title')?></th>
                        <th class="span1"><?=$this->_('Summary')?></th>
                        <th class="actions"><?=$this->_('Actions')?></th>
                    </tr>
                </thead>
                <tbody>
                    <?if($this->items):?>
                    <?foreach($this->items as $key=>$item):?>
                    <tr class="">
                        <td>
                            <input name="id" type="checkbox" class="multiform-item-checkbox"  data-multiform="post" data-multiform-itemid="<?=$item['id'] ?>" value="<?=$item['id'] ?>" />
                        </td>	
                        <td>
                            <a href="<?=$this->uri('/admin/group/' . $item['id'])?>" class="title"><?=$item['groupName'] ?></a>
                            <span class="label <?=$lableMap[$item['status']]?>"><?=$this->_($item['status'])?></span>
                            <p>
                            <span class="meta"><?=$item['createTime'];?></span>
                            </p>
                        </td>
                        <td>
                            <?=$item['summary'] ?>
                        </td>
                        <td class="actions">
                            <a href="<?=$this->uri('/admin/group/remove/' . $item['id'], 'c', array('c' => $this->uri('/admin/group/', array('page' => $this->page)))); ?>" class="btn btn-small btn-danger"><?=$this->_('Delete')?></a>
                            <a href="<?=$this->uri('/group/' . $item['groupKey'])?>" class="btn btn-small"><?=$this->_('View')?></a>
                            <a href="<?=$this->uri('/admin/group/' . $item['id'])?>" class="btn btn-small"><?=$this->_('Edit')?></a>
                        </td>
                    </tr>
                    <?endforeach;?>
                    <?endif;?>
                </tbody>
            </table>
        </div>
    </div><!--span10 end-->

    <div class="span10">
        <?if($this->paginator):?>
        <?=$this->paginator->setPath('/admin/group/')->setBaseQuery($this->query);?>
        <?=$this->widget('Core', 'widgets/paginator', $this->vars())?>
        <?endif;?>
    </div>

</div>
