<script type="text/javascript">
    $(function(){
        jQuery("#lines").jqGrid({
            url:'<?= site_url() ?>inventory/productsbywarehouse/getproductwarehouses',
            datatype: "json",
            mtype : "post",
            colNames:['ID','NAME'],
            colModel:[
                {name:'ID',index:'ID', width:20,editable:true,hidden:true,editoptions:{readonly:true,size:10}},
                {name:'NAME',index:'NAME', width:100,editable:true,editoptions:{size:10}}
            ],
            rowNum:15,
            rowList:[15,30,45],
            rownumbers: true,
            key: true,
            rownumWidth: 40,
            height: "auto",
            width: 'auto',
            autowidth:true,
            pager: '#pgtoolbar1',
            sortname: 'id',
            viewrecords: true,
            sortorder: "desc",
            multiselect: true,
            reloadAfterEdit: true,
            reloadAfterSubmit: true,
            editurl:"<?= site_url() ?>.inventory/productgroups",
            beforeSelectRow: function(rowid, e)
{
    jQuery("#lines").jqGrid('resetSelection');
    return(true);
}

        });
//        $("#add").click(function(){
//
//            document.location.href="<?= site_url() ?>productsbywarehouse/addproductgroup";
//        });

        jQuery("#bedata").click( function() {

            var rowid = jQuery("#lines").jqGrid('getGridParam','selarrrow');
                if(rowid != 0){
            var selid = jQuery("#lines").jqGrid('getCell', rowid, 'ID');
            if(selid!=false){
                document.location.href="<?= site_url() ?>inventory/productsbywarehouse/linkproductsbywarehouse/"+selid;
            }
            }
            else alert ("Please select a row !");
        });
        $("#dedata").click(function(){
            var gr = jQuery("#lines").jqGrid('getGridParam','selarrrow');
       if( gr != 0){
            doIt=confirm('do you want to delete the selected productgroup?');
         if(doIt){
            var selid = jQuery("#lines").jqGrid('getCell', gr, 'ID');
            document.location.href="<?= site_url() ?>inventory/productgroups/deleteproductgroup/"+selid;
            }
            }
              else alert ("Please select a row !");
        });
    });


    $(document).ready(function() {
        $("button").button();
    });

</script>

<!-- Page Content -->
<div class="page-content">

    <!-- Page Header -->
    <div class="page-header position-relative">
        <div class="header-title">
            <h1>
               Products By Warehouse
            </h1>
        </div>
        <!--Header Buttons-->
        <div class="header-buttons">
            <a class="sidebar-toggler" href="#">
                <i class="fa fa-arrows-h"></i>
            </a>
            <a class="refresh" id="refresh-toggler" href="">
                <i class="glyphicon glyphicon-refresh"></i>
            </a>
            <a class="fullscreen" id="fullscreen-toggler" href="#">
                <i class="glyphicon glyphicon-fullscreen"></i>
            </a>
        </div>
        <!--Header Buttons End-->
    </div>
    <!-- /Page Header -->
    <!-- Page Body -->
    <div class="page-body" id="resources">
      <div class="well with-header">
        <div class="header bordered-success">



            <div id="toolbartop" align="left">
             <span class="button-strip">
        <button class="btn btn-warning" id="bedata" name="linkproductsbywarehouse">Add</button>
              
            </span>
        </div>


    </div>
    <div class="table-scrollable">
                            <?php
                            if ($this->session->flashdata('msgt') == 'E') {
                                echo '
                <div id="message-red">
                <table border="0" width="100%" cellpadding="0" cellspacing="0">
                <tr>
                    <td class="red-left">' . $this->session->flashdata('msg') . '</td>
                    <td class="red-right"><a class="close-red"><img src="' . site_url() . 'images/table/icon_close_red.gif"   alt="" /></a></td>
                </tr>
                </table>
                </div>
                        ';
                            }
                            if ($this->session->flashdata('msgt') == 'S') {
                                echo '
                    <div id="message-green">
                    <table border="0" width="100%" cellpadding="0" cellspacing="0">
                    <tr>
                        <td class="green-left">' . $this->session->flashdata('msg') . '</a></td>
                        <td class="green-right"><a class="close-green"><img src="' . site_url() . 'images/table/icon_close_green.gif"   alt="" /></a></td>
                    </tr>
                    </table>
                    </div>
                    ';
                            }
                            ?>
     <table id="lines"></table>
                            <div id="pgtoolbar1"></div>
                           
</div>


</div>
</div>
<!-- /Page Body -->
</div>
<!-- /Page Content -->

</div>
<!-- /Page Container -->
<!-- Main Container -->

</div>
