<?php
$view->extend('MarketZodacoBundle::base_admin.html.php');
?>
<div class="col-lg-12">
    <div class="panel panel-default">
        <div class="panel-heading"><?php echo $view['translator']->trans("List Categories"); ?></div>
        <div class="panel-body">
            <?php
                if (count($list) > 0) {
                    ?>
                    <form method="POST">
                        <table data-toggle="table"  data-show-refresh="false" data-show-toggle="false" data-show-columns="false" data-search="true" data-select-item-name="toolbar1" data-pagination="false">
                            <thead>
                                <tr>
                                    <th data-field="id" data-sortable="true"><?php echo $view['translator']->trans("ID"); ?></th>
                                    <th data-field="sort" data-sortable="false"><?php echo $view['translator']->trans("Sort"); ?></th>
                                    <th data-field="name"  data-sortable="true"><?php echo $view['translator']->trans("Name"); ?></th>
                                    <th data-field="status" data-sortable="true"><?php echo $view['translator']->trans("Status"); ?></th>
                                    <th><?php echo $view['translator']->trans("Delete"); ?></th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php foreach ($list as $key => $value) { ?>
                                    <tr data-index="<?php echo $value->getId(); ?>">
                                        <td style="">
                                            <?php echo $value->getId(); ?>
                                        </td>
                                        <td style="">
                                            <input name="order_id[]" type="text" style="width: 50px;" value="<?php echo $value->getSort(); ?>"/>
                                            <input name="id[]" type="text" value="<?php echo $value->getId(); ?>" style="display:none;" />
                                        </td>
                                        <td style="">
                                            
                                            <a href="<?php echo $view['router']->generate('edit_categories', array('id' => $value->getId()), true); ?>"><img id="small_img" src="<?php echo $view->escape('/uploads/categories/'); ?><?php echo $value->getSmallIcon(); ?>" style="display: inline; width: 36px; min-height: 36px; height: 36px; margin-bottom: 0px;"> <?php echo $value->getTitle(); ?></a>
                                        </td>
                                        <td style=""><?php
                                            if ($value->getActive() == 1) {
                                                echo "<font color='green'>".$view['translator']->trans("Active")."</font>";
                                            } else {
                                                echo "<font color='red'>".$view['translator']->trans("Disable")."</font>";
                                            }
                                            ?>
                                        </td>
                                        <td style=""><a style="color: red;" onclick="return  confirm('Delete?');" href="<?php echo $view['router']->generate('del_categories', array('id' => $value->getId()), true); ?>"><?php echo $view['translator']->trans("Delete"); ?></a>
                                        </td>
                                    </tr>
                                    <?php if ($arr[$value->getId()] != 0) { ?>
                                        <?php foreach ($arr[$value->getId()] as $key1 => $value1) { ?>
                                            <tr> 
                                        <td style="">
                                            <?php echo $value1->getId(); ?>
                                        </td>
                                                <td style=""><input name="order_id_sub[]" type="text" value="<?php echo $value1->getSort(); ?>" style="width: 50px; margin-left: 20px;" /><input name="id_sub[]" type="text" value="<?php echo $value1->getId(); ?>" style="display:none" /></td> 
                                                <td style="">
                                                    <a style=" margin-left: 20px;" href="<?php echo $view['router']->generate('edit_categories', array('id' => $value1->getId()), true); ?>">-- <img id="small_img" src="<?php echo $view->escape('/uploads/categories/'); ?><?php echo $value1->getSmallIcon(); ?>" style="display: inline; width: 36px; min-height: 36px; height: 36px; margin-bottom: 0px;"> <?php echo $value1->getTitle(); ?></a></td> 
                                                <td style=""><?php
                                                    if ($value1->getActive() == 1) {
                                                        echo "<font color='green'>".$view['translator']->trans("Active")."</font>";
                                                    } else {
                                                        echo "<font color='red'>".$view['translator']->trans("Disable")."</font>";
                                                    }
                                                    ?></td> 
                                                <td style=""><a style="color: red;" onclick="return  confirm('Delete?');" href="<?php echo $view['router']->generate('del_categories', array('id' => $value1->getId()), true); ?>"><?php echo $view['translator']->trans("Delete"); ?></a></td> 
                                            </tr> 
                                        <?php } ?>
                                        <?php
                                    }
                                }
                                ?>
                            </tbody> 
                        </table>
                        <br><br>
                        <input type="submit" class="btn btn-danger" value="<?php echo $view['translator']->trans("Save"); ?>">
                    </form>
                    <?php
                } else {
                    echo $view['translator']->trans("No Data");
                }
                ?>

        </div>
    </div>
</div>