<section class="panel">

<header class="panel-heading clearfix panel-theame">

<i class="fa fa-list"></i> Warehouse

<div class="pull-right">

<a class="ad-btn"
onclick="loadPopupModal('MasWarehouse/create','Add Warehouse','lg')">

<svg width="30" height="30" viewBox="0 0 24 24">
<circle cx="12" cy="12" r="11" stroke="white" stroke-width="2"></circle>
<line x1="12" y1="7" x2="12" y2="17" stroke="#5db5a4" stroke-width="2"></line>
<line x1="7" y1="12" x2="17" y2="12" stroke="#5db5a4" stroke-width="2"></line>
</svg>

</a>

</div>

</header>

<div class="panel-body">

<table class="table table-hover table-bordered" id="tbl_Warehouse">

<thead>
<tr>
<th>SI No</th>
<th>Warehouse Name</th>
<th>Base Warehouse</th>
</tr>
</thead>

</table>

</div>

</section>


<script>

$(document).ready(function(){

var table = $("#tbl_Warehouse").DataTable({

processing:true,
serverSide:true,

ajax:{
url:"<?php echo Yii::app()->createUrl('MasWarehouse/getList')?>",
type:"POST"
},

fnCreatedRow:function(nRow,aData){

$(nRow).addClass("context-menu");
AddContextMenu(nRow,aData);

}

});

});

function AddContextMenu(row,data){

$(row).contextMenu({

selector:'td',

items:{

edit:{
name:"Edit",
icon:"edit",
callback:function(){

loadPopupModal(
"MasWarehouse/create&id="+data[3].id,
"Edit Warehouse",
"lg"
);

}
},

disable:{
name:(data[3].status=="Y")?"Disable":"Enable",
icon:"edit",
callback:function(){

Disable(data[3].id);

}
}

}

});

}

function Disable(id){

$.ajax({

type:'POST',
url:"<?php echo Yii::app()->createUrl('MasWarehouse/disable')?>",
data:{id:id},

success:function(){
reloadTable("#tbl_Warehouse");
}

});

}

</script>