<?php
/**
 * 
 * @author Fred
 * @version 1.0.1
 * @package Backend\SIG
 */

$context = $this->data["contextname"];
$list = $this->data['list'];
?>

<div class="row" >
    <div class="col-lg-12" >
        <h3><?= $this->data['page'] == "services" ? R('page_title_websig_services_catalog') : R('page_title_websig_services_groups') ?></h3>
        <div class="panel panel-default">
            <div class="panel-body">
                <ul class="nav nav-pills">
                    <li class="<?= $this->data['page'] == "services" ? "active" : "" ?>"><a href="<?= __SITEBASE ?>/websigservices/services"><?= R("page_nav_websig_services_catalog") ?></a></li>
                    <li class="<?= $this->data['page'] == "services_groups" ? "active" : "" ?>"><a href="<?= __SITEBASE ?>/websigservices/servicesgroups"><?= R("page_nav_websig_services_groups") ?></a></li>
                </ul>
            </div>
        </div>
        <div class="panel panel-default">
            <div class="panel-body">
                <div class="table-responsive" >
                    <table class="table table-hover table-striped tablesorter">
                        <thead>
                            <tr>
                                <th class="header"><?= R("label_ows_groupname") ?> <i class="fa fa-sort"></i></th>
                                <th class="header"><?= R("label_ows_group_description") ?> </th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($list as $obj) { ?>
                                <tr  onclick="javascript:
                                        $action = 'edit';
                                        $('#form1').attr('action','<?= __SITEBASE ?>/websigservices/action?id=<?= $obj->id ?>') ;
                                        $('#in_name').attr('value','<?= $obj->name ?>') ;
                                        $('#in_descr').attr('value','<?= $obj->description ?>') ;
                                        $('#showgroup').slideDown();
                                        $('#showgroupdetail').hide();
                                        $('#cancelgroupedit').show();
                                        $('#btndelete').show();
                                        $('#btnupdate').show();
                                        $('#btnsubmit').hide();">
                                    <!-------------------------show------------------------------------------------------------------>
                                    <?php
                                    $name = "name";
                                    $type = "text";
                                    ?>
                                    <td><?= print_field($obj->$name, $type) ?></td>
                                    <!------------------------------------------------------------------------------------------->
                                    <!------------------------------------------------------------------------------------------->
                                    <?php
                                    $name = "description";
                                    $type = "text";
                                    ?>
                                    <td><?= print_field($obj->$name, $type) ?></td>
                                    <!------------------------------------------------------------------------------------------->

                                </tr>
                            <?php } ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>

        
        <div class="form-group">
            <label class="col-sm-0 control-label"></label>
            <a href="#" class="btn btn-link" id="showgroupdetail" onclick="javascript:$('#showgroup').slideDown();
                        $action = 'new';
                        $('#form1').attr('action','<?= __SITEBASE ?>/websigservices/action') ;
                        $('#in_name').attr('value','') ;
                        $('#in_descr').attr('value','') ;
                                        $('#btndelete').hide();
                                        $('#btnupdate').hide();
                                        $('#btnsubmit').show();
                        $(this).hide();
                        $('#cancelgroupedit').show();"><?= R("label_addnewservicegroup") ?></a>
            <a href="#" style="display:none" class="btn btn-link" id="cancelgroupedit" onclick="javascript:$('#showgroup').slideUp();
                            $(this).hide();
                            $('#showgroupdetail').show();"><?= R("label_cancel") ?></a>
        </div>
        
        <form id="form1" class="form-horizontal" action="<?= __SITEBASE ?>/websigservices/action" method="post">
        <div class="panel panel-default" id="showgroup" style="display:none">
            <div class="panel-body">
                <div >
                    <div class="form-group ">
                        <label class="col-sm-4 control-label"><?= R('label_servicegroupname') ?>:</label>
                        <div class="col-sm-5">
                            <input type="text"  maxlength="50" required class="form-control"  value="" name="name" id="in_name">
                        </div>
                    </div>
                    <div class="form-group ">
                        <label class="col-sm-4 control-label"><?= R('label_servicegroupdescription') ?>:</label>
                        <div class="col-sm-8">
                            <input type="text" maxlength="100" required class="form-control"  value="" name = "description" id="in_descr">
                        </div>
                    </div>
                </div>
                <p>&nbsp;</p>
                <div class="col-sm-7">
                    <button id="btnsubmit" type="submit" class="btn btn-default" name="btnAction" value='save'><?= R('btn_save') ?></button>
                    <button id="btnupdate" type="submit" class="btn btn-default" name="btnAction" value='update'><?= R('btn_update') ?></button>
                    <button id="btndelete" type="submit" class="btn btn-default" name="btnAction" value='delete'><?= R('btn_delete') ?></button>
                </div>    
            </div>
        </div>
        </form>

    </div>
</div>


