Ejemplo n.º 1
0
    public function currentRender()
    {
        $pagerView = new ViewPagination();
        $pagerView->formName = $this->dataGrid->getName();
        $menuView = new ViewMenu();
        $this->dataGrid->preparePager();
        $this->dataGrid->fillPager($pagerView);
        $menuView->menu = $this->dataGrid->getMenu();
        $menuView->render();
        ?>
        <hr/>
        <div class="table-responsive">
            <form action="<?php 
        echo $this->dataGrid->getAction();
        ?>
" class="form-inline s-datagrid" name="<?php 
        echo $this->dataGrid->getName();
        ?>
" id="<?php 
        echo $this->dataGrid->getName();
        ?>
">
                <fieldset>
                    <table class="table table-striped table-bordered table-hover">
                        <thead>
                        <tr>
                            <?php 
        if ($this->dataGrid->hasGroupActions()) {
            ?>
                                <th style="width: 30px;">
                                    <span class="glyphicon glyphicon-check"></span>
                                </th>
                            <?php 
        }
        ?>
                            <?php 
        foreach ($this->dataGrid->getHeaders() as $header) {
            ?>
                                <th <?php 
            echo $header->buildAttributes();
            ?>
>
                                    <?php 
            echo $header->getDisplayName();
            ?>
                                </th>
                            <?php 
        }
        ?>
                            <?php 
        if (sizeof($this->dataGrid->getActions()) > 0) {
            ?>
                            <th class="text-center">
                                <span class="glyphicon glyphicon-menu-hamburger" title="Действия"></span>
                            </th>
                            <?php 
        }
        ?>
                        </tr>
                        <?php 
        if ($this->dataGrid->hasFiltered()) {
            ?>
                            <tr class="warning top">
                                <?php 
            if ($this->dataGrid->hasGroupActions()) {
                ?>
                                    <th></th>
                                <?php 
            }
            ?>
                                <?php 
            foreach ($this->dataGrid->getHeaders() as $header) {
                ?>
                                    <th>
                                        <?php 
                if ($header->isFiltered()) {
                    ?>
                                        <input class="form-control input-sm" style="width: 100%;" name="<?php 
                    echo $this->dataGrid->getName();
                    ?>
-filter-<?php 
                    echo $header->getKey();
                    ?>
" id="<?php 
                    echo $this->dataGrid->getName();
                    ?>
-filter-<?php 
                    echo $header->getKey();
                    ?>
" type="text" placeholder="" value="<?php 
                    echo $header->getFilterValue();
                    ?>
">
                                        <?php 
                }
                ?>
                                    </th>
                                <?php 
            }
            ?>
                                <th style="width: 40px;">
                                    <button name="<?php 
            echo $this->dataGrid->getName();
            ?>
-filter" type="submit" class="btn btn-info btn-sm" formmethod="get" title="Фильтровать"><span class="glyphicon glyphicon-filter"></span></button>
                                </th>
                            </tr>
                        <?php 
        }
        ?>
                        </thead>
                        <tbody>
                        <?php 
        foreach ($this->dataGrid->getData() as $row) {
            ?>
                            <tr>
                                <?php 
            if ($this->dataGrid->hasGroupActions()) {
                ?>
                                    <th>
                                        <input name="<?php 
                echo $this->dataGrid->getName();
                ?>
-checked-row-flag-<?php 
                echo $row[$this->dataGrid->getKey()];
                ?>
" type="checkbox" />
                                    </th>
                                <?php 
            }
            ?>
                                <?php 
            foreach ($this->dataGrid->getHeaders() as $header) {
                ?>
                                    <td<?php 
                echo ' ' . $header->buildValueAttributes();
                ?>
><?php 
                echo $header->decorate($row[$header->getKey()], $row);
                ?>
</td>
                                <?php 
            }
            ?>
                                <td>
                                    <?php 
            foreach ($this->dataGrid->getActions() as $action) {
                ?>
                                        <?php 
                $actionURI = $action->getURI();
                foreach ($action->getAdditionalParameters() as $additionalParameter) {
                    $actionURI = CoreFunctions::addGETParamToURI($actionURI, $additionalParameter, $row[$additionalParameter]);
                }
                $actionURI = CoreFunctions::addGETParamToURI($actionURI, $action->getParamName(), $row[$this->dataGrid->getKey()]);
                ?>
                                        <a name="<?php 
                echo $this->dataGrid->getName();
                ?>
-action-<?php 
                echo $action->getName();
                ?>
-<?php 
                echo $this->dataGrid->getKey();
                ?>
" href="<?php 
                echo $actionURI;
                ?>
"><span <?php 
                echo $action->buildAttributes();
                ?>
 title="<?php 
                echo $action->getTitle();
                ?>
"><?php 
                echo $action->getDisplayName();
                ?>
</span></a>
                                    <?php 
            }
            ?>
                                </td>
                            </tr>
                        <?php 
        }
        ?>
                        </tbody>
                        <tfoot>
                        <?php 
        if ($this->dataGrid->hasGroupActions()) {
            ?>
                        <tr>
                            <td>
                                <input type="checkbox" id="<?php 
            echo $this->dataGrid->getName();
            ?>
-group-action-all-check" name="<?php 
            echo $this->dataGrid->getName();
            ?>
-group-action-all-check""/>
                            </td>
                            <td colspan="<?php 
            echo count($this->dataGrid->getHeaders()) + 1;
            ?>
">
                                Групповые операции:&nbsp;
                                <?php 
            foreach ($this->dataGrid->getGroupActions() as $action) {
                ?>
                                    <button name="<?php 
                echo $this->dataGrid->getName();
                ?>
-action-group-<?php 
                echo $action->getName();
                ?>
" id="<?php 
                echo $this->dataGrid->getName();
                ?>
-group-action-<?php 
                echo $action->getName();
                ?>
" formmethod="post" type="submit" formaction="<?php 
                echo $action->buildGroupURI();
                ?>
" title="<?php 
                echo $action->getTitle();
                ?>
">
                                        <span <?php 
                echo $action->buildAttributes();
                ?>
><?php 
                echo $action->getDisplayName();
                ?>
</span>
                                    </button>
                                <?php 
            }
            ?>
                            </td>
                        </tr>
                        <?php 
        }
        ?>
                        <tr>
                            <td colspan="<?php 
        echo count($this->dataGrid->getHeaders()) + ($this->dataGrid->hasGroupActions() ? 2 : 1);
        ?>
" class="text-left">
                                <div class="form-group">
                                    <select name="<?php 
        echo $this->dataGrid->getName();
        ?>
-items-per-page" id="<?php 
        echo $this->dataGrid->getName();
        ?>
-items-per-page" class="form-control input-sm" style="width: 80px;">
                                        <option<?php 
        echo $this->dataGrid->getItemsPerPage() == 5 ? ' selected="selected"' : '';
        ?>
>5</option>
                                        <option<?php 
        echo $this->dataGrid->getItemsPerPage() == 10 ? ' selected="selected"' : '';
        ?>
>10</option>
                                        <option<?php 
        echo $this->dataGrid->getItemsPerPage() == 20 ? ' selected="selected"' : '';
        ?>
>20</option>
                                        <option<?php 
        echo $this->dataGrid->getItemsPerPage() == 50 ? ' selected="selected"' : '';
        ?>
>50</option>
                                        <option<?php 
        echo $this->dataGrid->getItemsPerPage() == 100 ? ' selected="selected"' : '';
        ?>
>100</option>
                                        <option<?php 
        echo $this->dataGrid->getItemsPerPage() == 500 ? ' selected="selected"' : '';
        ?>
>500</option>
                                        <option<?php 
        echo $this->dataGrid->getItemsPerPage() == 1000 ? ' selected="selected"' : '';
        ?>
>1000</option>
                                    </select>
                                    <button name="<?php 
        echo $this->dataGrid->getName();
        ?>
-set-items-per-page-button" type="submit" class="btn btn-info btn-sm" title="Отобразить" formmethod="get"><span class="glyphicon glyphicon-ok"></span></button>
                                </div>
                            </td>
                        </tr>
                        </tfoot>
                    </table>
                </fieldset>
                <?php 
        foreach ($this->dataGrid->getHiddenFields() as $name => $value) {
            ?>
                    <input type="hidden" name="<?php 
            echo $name;
            ?>
" value="<?php 
            echo $value;
            ?>
"/>
                <?php 
        }
        ?>
            </form>
        </div>
        <?php 
        $pagerView->render();
    }