<div id="dialog-item" class="easyui-dialog" closed="true" data-options="modal:true, iconCls:'icon-save'" buttons="#dialog-buttons" style="width:860px;height:532px;top:27px;background-color:#F8F8F8;padding:5px;">


    <form id="form_account" method="post" novalidate>
        <input type="hidden" id="status_tab" name="status_tab" />

        <div id="tab_purchase_req" class="easyui-tabs" style="width:835px;height:485px; background-color:#F8F8F8;" data-options="fit:true,plain:true">
            <div title="Item" style="padding:10px" >
                <table width="100%">
                    <tr>
                        <td width="310"><b>Item Category</b></td>
                        <td><b>:</b></td>

                        <td>
                            <select name="cmb_ItemCategoryID" id="cmb_ItemCategoryID" class="easyui-combobox" style="width:512px;" editable="true" 
                                    data-options="
                                    valueField:'ItemCategoryID',
                                    textField:'ItemCategoryName',
                                    url:'<?php echo base_url(); ?>custom/get_data/itemcategory',
                                    onSelect: function(rec){
                                    var id = rec.ItemCategoryID;
                                    search_choose_item_new();
                                    }
                                    ">
                            </select>
                        </td>
                    </tr>

                    <tr>
                        <td><b><span class="header_code">Item Code</span></b></td>
                        <td><b>:</b></td>

                        <td>
                            <input type="text" style="width:510px;height:20px" name="txt_ItemCode" id="txt_ItemCode" class="easyui-validatebox" onkeyup="search_choose_item_new();" />
                        </td>
                    </tr>

                    <tr>
                        <td><b><span class="header_name">Item Name</span></b></td>
                        <td><b>:</b></td>

                        <td>
                            <input type="text" style="width:510px;height:20px" name="txt_ItemDesc" id="txt_ItemDesc" class="easyui-validatebox" onkeyup="search_choose_item_new();" />
                        </td>
                    </tr>
                </table>
                <table id="tt_choose_item" class="easyui-datagrid" singleSelect="true" remoteSort="false" pagesize="150" fitColumns="true" style="width:812px;height:313px" 
                       data-options = "border:true,view:scrollview,autoRowheight:false"
                       url="<?= base_url() ?>custom/get_data/search_item"                    
                       >                        
                    <thead>
                        <tr>
                            <th field="ItemCode"        		width="293" sortable="true" halign='center'><span class="header_code">Item Code</span></th>
                            <th field="ItemDesc"        		width="430" sortable="true" halign='center'><span class="header_name">Item Name</span></th>
                            <th field="ItemCategoryCode"        width="430" sortable="true" halign='center'><span class="header_name">Item Category Name</span></th>
                            <th field="ItemCategoryID"  		width="200" sortable="true" halign='center' hidden><span class="header_name">Item Category</span></th>
                            
                            <th field="ItemUnit"          width="100" sortable="true" halign='center'><span class="header_name">Item Unit</span></th>
                        </tr>
                    </thead>
                </table>
                <!-- Dialog Button for Dialog Item-->
                <div style="border:none; margin-top:10px; float:right;">
                    <a href="javascript:void(0)" class="easyui-linkbutton  <?php echo $lables['button']['ok']['classKey'];?>0" iconCls="icon-ok" onClick="choose_item();">&nbsp; <?php echo $lables['button']['ok']['lable'];?> &nbsp; &nbsp;</a>
                    <a href="javascript:void(0)" class="easyui-linkbutton  <?php echo $lables['button']['cancel']['classKey'];?>0" id="btnCancel" iconCls="icon-cancel" onClick="modal_close('dialog-item');
                        setArrayPageStart();"><?php echo $lables['button']['cancel']['lable'];?></a>
                </div>
                <!-- End of Dialog Button for Dialog Item-->
            </div>
            <div title="Services / Expenses" style="padding:10px">
                <table width="100%">
                    <tr>
                        <td width="310"><b>Item Category</b></td>
                        <td><b>:</b></td>

                        <td>
                            <select name="cmb_ItemCategoryID" id="cmb_ItemCategoryID" class="easyui-combobox" style="width:512px;" editable="false" disabled="disabled"
                                    data-options="
                                    valueField:'ItemCategoryID',
                                    textField:'ItemCategoryName',

                                    onSelect: function(rec){
                                    var id = rec.ItemCategoryID;
                                    search_servis_item();
                                    }
                                    ">
                            </select>
                        </td>
                    </tr>

                    <tr>
                        <td><b><span class="header_code">Item Code</span></b></td>
                        <td><b>:</b></td>

                        <td>
                            <input type="text" style="width:510px;height:20px" name="txt_ItemCode_Servis" id="txt_ItemCode_Servis" class="easyui-validatebox" onkeyup="search_servis_item();" />
                        </td>
                    </tr>

                    <tr>
                        <td><b><span class="header_name">Item Name</span></b></td>
                        <td><b>:</b></td>

                        <td>
                            <input type="text" style="width:510px;height:20px" name="txt_ItemDesc_Servis" id="txt_ItemDesc_Servis" class="easyui-validatebox" onkeyup="search_servis_item();" />
                        </td>
                    </tr>
                </table>
                <table id="tt_choose_servis" class="easyui-datagrid" singleSelect="true" remoteSort="false" pagesize="150" fitColumns="true" style="width:812px;height:313px" 
                       data-options = "border:true,view:scrollview,autoRowheight:false"
                       url="<?= base_url() ?>custom/get_data/search_service"                   
                       >                        
                    <thead>
                        <tr>
                            <th field="ItemCode"        width="293" sortable="true" halign='center'><span class="header_code">Service / Expense Name</span></th>
                            <th field="ItemDesc"        width="430" sortable="true" halign='center'><span class="header_name">Description</span></th>
                            <th field="ItemCategoryID"  width="200" sortable="true" halign='center' hidden><span class="header_name">Item Category</span></th>
                        </tr>
                    </thead>
                </table>
                <!-- Dialog Button for Dialog servis-->
                <div style="border:none; margin-top:10px; float:right;">
                    <a href="javascript:void(0)" class="easyui-linkbutton  <?php echo $lables['button']['ok']['classKey'];?>1" iconCls="icon-ok" onClick="choose_servis();">&nbsp; <?php echo $lables['button']['ok']['lable'];?> &nbsp; &nbsp;</a>
                    <a href="javascript:void(0)" class="easyui-linkbutton  <?php echo $lables['button']['cancel']['classKey'];?>1" id="btnCancel" iconCls="icon-cancel" onClick="modal_close('dialog-item');
                        setArrayPageStart();"><?php echo $lables['button']['cancel']['lable'];?></a>
                </div>
                <!-- End of Dialog Button for Dialog Item-->
            </div>
            <div title="Adv. Payment" style="padding:10px">
                <table width="100%">
                    <tr>
                        <td width="310"><b>Item Category</b></td>
                        <td><b>:</b></td>

                        <td>
                            <select name="cmb_item_category" id="cmb_item_category" class="easyui-combobox" style="width:512px;" editable="false" disabled="disabled"
                                    data-options="
                                    valueField:'ItemCategoryID',
                                    textField:'ItemCategoryName',

                                    onSelect: function(rec){
                                    var id = rec.ItemCategoryID;
                                    search_choose_item4();
                                    }
                                    ">
                            </select>
                        </td>
                    </tr>

                    <tr>
                        <td><b><span class="header_code">Item Code</span></b></td>
                        <td><b>:</b></td>

                        <td>
                            <input type="text" style="width:510px;height:20px" name="txt_ItemCode_Adv" id="txt_ItemCode_Adv" class="easyui-validatebox" onkeyup="search_adv();" />
                        </td>
                    </tr>

                    <tr>
                        <td><b><span class="header_name">Item Name</span></b></td>
                        <td><b>:</b></td>

                        <td>
                            <input type="text" style="width:510px;height:20px" name="txt_ItemDesc_Adv" id="txt_ItemDesc_Adv" class="easyui-validatebox" onkeyup="search_adv();" />
                        </td>
                    </tr>
                </table>
                <table id="tt_choose_advance" class="easyui-datagrid" singleSelect="true" remoteSort="false" pagesize="150" fitColumns="true" style="width:812px;height:313px" 
                       data-options = "border:true,view:scrollview,autoRowheight:false"
                       url="<?= base_url() ?>custom/get_data/search_advance"                   
                       >                        
                    <thead>
                        <tr>
                            <th field="ItemCode"        width="293" sortable="true" halign='center'><span class="header_code">Adv. Payment Name</span></th>
                            <th field="ItemDesc"        width="430" sortable="true" halign='center'><span class="header_name">Description</span></th>
                            <th field="ItemCategoryID"  width="200" sortable="true" halign='center' hidden><span class="header_name">Item Category</span></th>
                        </tr>
                    </thead>
                </table>
                <!-- Dialog Button for Dialog servis-->
                <div style="border:none; margin-top:10px; float:right;">
                    <a href="javascript:void(0)" class="easyui-linkbutton  <?php echo $lables['button']['ok']['classKey'];?>2" iconCls="icon-ok" onClick="choose_advance();">&nbsp; <?php echo $lables['button']['ok']['lable'];?> &nbsp; &nbsp;</a>
                    <a href="javascript:void(0)" class="easyui-linkbutton  <?php echo $lables['button']['cancel']['classKey'];?>2" id="btnCancel" iconCls="icon-cancel" onClick="modal_close('dialog-item');
                        setArrayPageStart();"><?php echo $lables['button']['cancel']['lable'];?></a>
                </div>
                <!-- End of Dialog Button for Dialog Item-->
            </div>
        </div>

    </form>
</div>

<script>
    $('#tab_purchase_req').tabs({
        border: true,
        onSelect: function (title) {
            if (title == 'Item') {
                $('#status_tab').val(0);
                $('#cmb_item_category').combobox('enable');
                setArrayTabModalTab1();
            }
            else if (title == 'Services / Expenses') {
                $('#status_tab').val(1);
                $('#cmb_item_category').combobox('disable');
                setArrayTabModalTab2();
            }
            else {
                $('#status_tab').val(2);
                $('#cmb_item_category').combobox('disable');
                setArrayTabModalTab3();
            }
        }
    });
    function setArrayTabModalTab1(){   
        //====== reset keytab ================//
        isArrayTabIndex = -1;
        isFormIdDatagrid = "";
        isIdNameDatagrid = "tt_choose_item";
        isFirstFieldName = null;
        //isArrayTab      = [[{"type":"combogrid", idname:"cmb_ItemCategoryID"}],"txt_ItemCode","txt_ItemDesc",[{type:"datagrid",idname:"tt_choose_item"}],"icon-ok","icon-cancel"];
        isArrayTab      = [[{"type":"combobox", idname:"cmb_ItemCategoryID"}],"btnCancel" ];
        //======END reset keytab ==============//
        //console.log("tab 1 johnnnnn");
    }
    function setArrayTabModalTab2(){   
        //====== reset keytab ================//
        isArrayTabIndex = -1;
        isFormIdDatagrid = "";
        isIdNameDatagrid = "tt_choose_servis";
        isFirstFieldName = null;
        //isArrayTab      = [[{"type":"combogrid", idname:"cmb_ItemCategoryID"}],"txt_ItemCode","txt_ItemDesc",[{type:"datagrid",idname:"tt_choose_item"}],"icon-ok","icon-cancel"];
        isArrayTab      = [[{"type":"combobox", idname:"cmb_ItemCategoryID"}],"btnCancel" ];
        //======END reset keytab ==============//
        //console.log("tab 2 ooooeeyyy");
    }
    function setArrayTabModalTab3(){
        //====== reset keytab ================//
        isArrayTabIndex = -1;
        isFormIdDatagrid = "";
        isIdNameDatagrid = "tt_choose_advance";
        isFirstFieldName = null;
        //isArrayTab      = [[{"type":"combogrid", idname:"cmb_ItemCategoryID"}],"txt_ItemCode","txt_ItemDesc",[{type:"datagrid",idname:"tt_choose_item"}],"icon-ok","icon-cancel"];
        isArrayTab      = [[{"type":"combobox", idname:"cmb_ItemCategoryID"}],"btnCancel" ];
        //======END reset keytab ==============//
        //console.log("tab 3 cuuuuyyy");
    }
</script>