<!--
Author      : Tagor / Last update   : 11/08/2014
Desc        : Ferry / 30/10/2014, perbaikan Filtering
-->


<?php
//---------Untuk privellege jika dia ada tombol save----------
if ($group_user->EditPrivillage == 1) {
    $cek_autority_edit = "";
} else {
    $cek_autority_edit = "disabled";
}

//-------------end----------------------------
?>

<div class="easyui-layout" data-options="fit:true,border:false">
    <!--    <div data-options="region:'north',border:false" style="height:30px">
            <div style="padding:2px">
                            <a href="#" class="easyui-linkbutton" id="edit-linkbutton" data-options="plain:true,iconCls:'icon-edit'" onclick="edit_data()" <?php echo $cek_autority_edit; ?>>Edit</a>
                            <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-reload'" onclick=" $('#grid').datagrid('reload')">Refresh</a>
                <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-print'" onclick="parent.tab_add('Print Items','<?php echo $menu_link; ?>', 'preview', 'to_preview')">Print Preview</a>
            </div>
            </div>-->

    <div data-options="region:'north',border:false" style="height:30px" id="button-top">

    </div>
    <div id="west-panel" data-options="region:'west',split:true,border:true" title="Filter" style="width:190px;background-color:#CCCCFF;">
        <div style="padding:5px">
            <form class="form-filter">
                <table width="100%" cellpadding="0" cellspacing="0">
                    <tr>
                        <td width="190" align="left" style="padding-bottom:8px;">
                            <b>Find</b>
                        </td>
                    </tr>
                    <tr>
                        <td align="left">
                            <input id="txt_asset_code" name="txt_asset_code" placeholder="< Asset Code >" style="margin:2px 0px 3px;width:172px;height:22px;border:1px solid #CCC;">
                        </td>
                    </tr>
                    <tr>
                        <td align="left">
                            <input id="txt_item_desc" name="txt_item_desc"  placeholder="< Description >" style="margin:2px 0px 3px;width:172px;height:22px;border:1px solid #CCC;">
                        </td>
                    </tr>

                    <tr>
                        <td><div class="tr-divider"></div></td></tr>
                    <tr>
                        <!-------copy company dari sini------------------------------------------------------------------------->
                    <tr>
                        <td align="left" style="padding-bottom:8px;">
                            <b>by Company</b>
                        </td>
                    </tr>
                    <tr>
                        <td align="left">
                            <select name="cmb_company" id="cmb_company" 
                                    class="easyui-combobox" 
                                    style="width:174px;"
                                    data-options="
                                    value:'<?php echo $this->session->userdata('company'); ?>',

                                    valueField:'CompanyCode',
                                    textField:'CompanyName',
                                    url:'<?php echo base_url(); ?>custom/get_data/company_find_master',
                                    onSelect: function(rec){
                                    var url = '<?php echo base_url(); ?>custom/get_data/branch_by_company_new/'+rec.CompanyCode;
                                    $('#cmb_branch').combobox('reload', url);
                                    $('#cmb_branch').combobox('setValue', '');
                                    }
                                    "editable="false"
                                    >

                            </select>


                        </td>
                    </tr>
                    <!------------end-------------------------------------------------------------------------------->

                    <!-------copy branch dari sini------------------------------------------------------------------------->
                    <tr>
                        <td align="left" style="padding-bottom:8px;">
                            <b>by Branch/Depo</b>
                        </td>
                    </tr>
                    <tr>
                        <td align="left">
                            <select name="cmb_branch" id="cmb_branch" 
                                    class="easyui-combobox" 
                                    style="width:174px;"  
                                    data-options="
                                    value :'<?php echo $this->session->userdata('branch'); ?>',
                                    valueField:'BranchCode', 
                                    textField:'BranchName', 
                                    url:'<?php echo base_url(); ?>custom/get_data/branch_by_company_new/<?php echo $this->session->userdata('company'); ?>'
                                    " editable="false" 
                                    >

                            </select>
                        </td>
                    </tr>
                    <!--end-------------------------------------------------------->

                    <!--ini separator--------------------------------------------->
                    <tr><td colspan="2"><div class="tr-divider"></div></td></tr>
                    <!--end-------------------------------------------------------->

                    <!--copy dari sini untuk button reset dan search-->
                    <tr>
                        <td height="38"><div style="float:right;"><a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload'" onClick="location.reload();" >Reset</a> <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onClick="searching_data();" >Search</a></div></td>
                    </tr>
                    <!--end-------------------------->

                </table>
            </form>
        </div>
    </div>

    <div data-options="region:'center',border:false,iconCls:'icon-ok'">
        <!-- gaya table baru di grid -->
        <table id="grid" 
               title="" iconCls="icon-edit" 
               singleSelect="true" rowNumbers="true" 
               pageSize="150" 
               fitColumns="true" remoteSort="false" 
               url="<?= base_url($menu_link . '/ajax') ?>" 
               style="width:auto;height:560px" 
               data-options = "border:false,view:scrollview,autoRowheight:false"
               >

            <thead>
                <tr>
                    <th halign="center" field="BranchName" width="150" align="left" sortable="true" hidden>Branch</th>
                    <th halign="center" field="AssetCode" width="130" align="left" sortable="true">Asset Code</th>
                    <th halign="center" field="ItemCode" width="100" align="left" sortable="true">Item Code</th>
                    <th halign="center" field="ItemDesc" width="250" align="left" sortable="true">Item Description</th>
                    <th halign="center" field="ItemAverage" width="100" align="left" sortable="true" formatter="formatRp" hidden>Asset Cost</th>
                    <th halign="center" field="ItemQty" width="75" align="center" sortable="true" formatter="formatRp">Qty</th>
                    <th halign="center" field="ItemUnit" width="75" align="left" sortable="true">Unit</th>
                    <th halign="center" field="EstimatedLife" width="150" align="center" sortable="true">Estm. Life (Month)</th>
                    <th halign="center" field="DepriciateRate" width="100" align="center" sortable="true" formatter="formatRp">Depct. Rate (%)</th>
                    <th halign="center" field="depreciate_method" width="175" align="center" sortable="true">Depct. Method</th>
                    <th halign="center" field="TransNumber" width="175" align="center" sortable="true" hidden='true'>Ivent Detail ID</th>
                                        <!--<th halign="center" field="Status" width="125" align="left" sortable="true">Status</th>-->
                </tr>
            </thead>
        </table>
    </div>
</div>
<script>
    $(document).ready(function () {
//	var status_privelage_delete = '<?php // echo $group_user->DeletePrivillage; ?>';
//	var status_privelage_edit 	= '<?php // echo $group_user->EditPrivillage; ?>';
//	
//	$('#grid').datagrid({
//		onDblClickRow:function(){
//			if(status_privelage_edit == 1){
//				parent.tab_edit('Edit Fixed Asset List', '<?php echo $menu_link; ?>', 'icon-edit', 'edit', $('#grid').datagrid('getSelected').IventDetailID);
//			}
//		},
//		onClickRow:function(index,value){
//			if(value.Status !='App. Dir & Mgr' || value.Status !='App. Limit' || value.Status != 'Active'){
//				$('#suspend-linkbutton').linkbutton('enable');
//			}
//			else{
//				if(status_privelage_delete == 1){
//					$('#suspend-linkbutton').linkbutton('enable');
//				}
//				else{
//					$('#suspend-linkbutton').linkbutton('disable');
//				}
//				
//				if(status_privelage_edit == 1){
//					$('#edit-linkbutton').linkbutton('enable');
//				}
//				else{
//					$('#edit-linkbutton').linkbutton('disable');
//				}
//			}
//		}
//	});

        var status_privelage_delete = '<?php echo $group_user->DeletePrivillage; ?>';
        var status_privelage_edit = '<?php echo $group_user->EditPrivillage; ?>';
        var status_privelage_add = '<?php echo $group_user->AddPrivillage; ?>';

        list_master_datagrid('FixedAssetList', '<?= $menu_link; ?>', 'Fixed Asset List', status_privelage_edit, status_privelage_delete, status_privelage_add, 'Need App. Mgr.');

    });

    /*
     jangan lupa ini ditaro dibawah di setaip list untuk search
     taro di luar documen ready jangan didalam doc ready
     jangan lupa hapus fungsi on key up di setiap find
     jangan lupa cek id gridnya
     created by : fachri 
     */
    function searching_data() {
        if ($('#cmb_branch').combobox('getValue') == "") {
            $.messager.alert('Info', 'Branch tidak boleh kosong, silahkan pilih');
        }
        else {
            var txt_asset_code = $('#txt_asset_code').val();
            var txt_item_desc = $('#txt_item_desc').val();

            var cmb_branch = $('#cmb_branch').combobox('getValue');
            var cmb_company = $('#cmb_company').combobox('getValue');

            $('#grid').datagrid('load', {
                AssetCode: txt_asset_code,
                ItemDesc: txt_item_desc,
                CompanyCode: cmb_company,
                BranchCode: cmb_branch
            });
        }
    }
//------------------end--------------------------------------
</script>