<?php
/*	
 *	Author 	: Wahyu / Tanggal : 22-07-2014	
 *	Revisi 	: Ferry / Tanggal : 15-12-2014 
 */
?>

<div id="cc" class="easyui-layout" data-options="fit:true, border:false">
    <div data-options="region:'west',split:true, border:true" title="" style="width:230px; background-color:#F8F8F8;">
        <div title="" style="padding:10px;overflow:auto;" data-options="selected:true" >				
            <div class="preference_menu">
                <ul>
                    <!--<li><a href="<?php echo site_url('setup/preference_account'); ?>" style="border-top:none;"><img src="<?php echo base_url(); ?>assets/custom/icons/clipboard-invoice.png" alt=""/><span>P/L Account</span></a></li>-->	
                    <li><a href="<?php echo site_url('setup/preference_item'); ?>"><img src="<?php echo base_url(); ?>assets/custom/icons/clipboard-invoice.png" alt=""/><span><b>Item Account</b></span></a></li>	
                    <li><a href="<?php echo site_url('setup/preference_sales'); ?>"><img src="<?php echo base_url(); ?>assets/custom/icons/moneys.png" alt=""/><span>Sales Account</span></a></li>                   				   
                    <li><a href="<?php echo site_url('setup/preference_purchases'); ?>"><img src="<?php echo base_url(); ?>assets/custom/icons/sticky-notes.png" alt=""/><span>Purchases Account</span></a></li>	
                    <li><a href="<?php echo site_url('setup/preference_services'); ?>"><img src="<?php echo base_url(); ?>assets/custom/icons/calculator.png" alt=""/><span>Expense Account</span></a></li>
                    <li><a href="<?php echo site_url('setup/preference_advances'); ?>"><img src="<?php echo base_url(); ?>assets/custom/icons/calculator.png" alt=""/><span>Adv. Payment Account</span></a></li>
                    <li><a href="<?php echo site_url('setup/preference_expense'); ?>"><img src="<?php echo base_url(); ?>assets/custom/icons/calculator.png" alt=""/><span>Cash-Bon Account</span></a></li>
                    <li><a href="<?php echo site_url('setup/preference_others'); ?>"><img src="<?php echo base_url(); ?>assets/custom/icons/money-coin.png" alt=""/><span>Others Account</span></a></li> 
                    <li><a href="<?php echo site_url('setup/preference_approval'); ?>"><img src="<?php echo base_url(); ?>assets/custom/icons/property.png" alt=""/><span>Sales Approval Limit</span></a></li>
                    <li><a href="<?php echo site_url('setup/preference_miscellaneous'); ?>"><img src="<?php echo base_url(); ?>assets/custom/icons/folder-stand.png" alt=""/><span>Miscellaneous</span></a></li>
                </ul>
            </div>	
        </div>
    </div>
	
    <div data-options="region:'center',fit:true,plain:true,border:false" style="background:#eee;">
        <div id="form-wrapper" class="easyui-panel" border="false" style="width:1125px;height:520px;background:#FFF;border:#95B8E7 1px solid;">
            <div style="background:linear-gradient(to bottom,#EFF5FF 0,#E0ECFF 100%);height:27px;border-bottom:#95B8E7 1px solid;">
            	<a href="#" class="easyui-linkbutton" id="refresh-linkbutton" data-options="plain:true,iconCls:'icon-reload'" onclick="location.reload();">Refresh</a>
            </div>
                <div style="overflow:hidden;padding:1px;">				                
                    <form id="preference_item_default" name="preference_item_default" method="post" class="preference_form">
                        <input type="hidden" name="jobtitle" value="<?php echo $this->session->userdata('jobtitle'); ?>" />				

                        <table width="100%" cellspacing="1" cellpadding="1">
                            <tr>
                                <td valign="middle"><b>Item Category</b></td>
                                
                                <td width="650" align="left" valign="middle">
                                    <select id="select_item_category" name="select_item_category" class="easyui-combobox" style="width:651px;" required="true"
                                        data-options = "
                                            valueField:'ItemCategoryID',
                                            textField:'ItemCategoryName',
                                            url:'<?php echo base_url(); ?>setup/preference_item/item_category'
                                        ">
                                    </select>
                                </td>
                            </tr>
                    
                            <tr>
                                <td colspan="2"><hr /></td>
                            </tr>

                            <tr>
                                <td valign="middle"><b>Sales Account</b></td>
                                
                                <td width="650" align="left" valign="middle">
                                    <select id="select_item_sales_account" name="select_item_sales_account" class="easyui-combobox" style="width:651px;" required="true"
                                        data-options = "
                                            valueField:'AccountNumber',
                                            textField:'AccountName',
                                            url:'<?php echo base_url(); ?>setup/preference_item/akun_sales'
                                        ">
                                    </select>
                                </td>
                            </tr>
                    
                            <tr>
                                <td valign="middle"><b>COGS  Account</b></td>
                            
                                <td width="650" align="left" valign="middle">
                                    <select id="select_item_cogs_account" name="select_item_cogs_account" class="easyui-combobox" style="width:651px;" required="true"
                                        data-options = "
                                            valueField:'AccountNumber',
                                            textField:'AccountName',
                                            url:'<?php echo base_url(); ?>setup/preference_item/akun_cogs'
                                        ">
                                    </select>
                                </td>
                            </tr>

                            <tr>
                                <td valign="middle"><b>Inventory  Account</b></td>

                                <td width="650" align="left" valign="middle">
                                    <select id="select_item_inventory_account" name="select_item_inventory_account" class="easyui-combobox" style="width:651px;" required="true"
                                        data-options = "
                                            valueField:'AccountNumber',
                                            textField:'AccountName',
                                            url:'<?php echo base_url(); ?>setup/preference_item/akun_inventory'
                                        ">
                                    </select>
                                </td>
                            </tr>
                    
                    <tr>
                        <td valign="middle"><b>Taxable PPh 22</b></td>
                        <td width="650" align="left" valign="middle">
                            <select id="select_item_taxable22" name="select_item_taxable22" class="easyui-combobox" style="width:651px;" required="true"
                                data-options = "
                                    valueField:'AccountNumber',
                                    textField:'AccountName',
                                    url:'<?php echo base_url(); ?>setup/preference_item/akun_taxable_pph22'
                                ">
                            </select>
                        </td>
                    </tr>
                    
                    <tr>
                        <td valign="middle"><b>Sales Return Account</b></td>
                        <td width="650" align="left" valign="middle">
                            <select id="select_item_account_sr" name="select_item_account_sr" class="easyui-combobox" style="width:651px;" required="true"
                                data-options = "
                                    valueField:'AccountNumber',
                                    textField:'AccountName',
                                    url:'<?php echo base_url(); ?>setup/preference_item/akun_sr'
                                ">
                            </select>
                        </td>
                    </tr>
                    
                    <tr>
                        <td valign="middle"><b>Purchase Return Account</b></td>
                        <td width="650" align="left" valign="middle">
                            <select id="select_item_account_pr" name="select_item_account_pr" class="easyui-combobox" style="width:651px;" required="true"
                                data-options = "
                                    valueField:'AccountNumber',
                                    textField:'AccountName',
                                    url:'<?php echo base_url(); ?>setup/preference_item/akun_pr'
                                ">
                            </select>
                        </td>
                    </tr>
                    
                    <tr>
                        <td valign="middle"><b>Unbilled Account (Owing)</b></td>
                        <td width="650" align="left" valign="middle">
                            <select id="select_account_unbilled" name="select_account_unbilled" class="easyui-combobox" style="width:651px;" required="true"
                                data-options = "
                                    valueField:'AccountNumber',
                                    textField:'AccountName',
                                    url:'<?php echo base_url(); ?>setup/preference_item/akun_unbilled'
                                ">
                            </select>
                        </td>
                    </tr>                    
                </table>
            </form>
        </div>
    </div>
		
        <div style="padding:5px;text-align:right;width:1110px;">
            <a id="save_button" href="javascript:void(0)" class="easyui-linkbutton form-button" iconCls="icon-save" onclick="submit_form()">Save</a> 								
            <a href="javascript:void(0)" class="easyui-linkbutton  form-button" iconCls="icon-cancel" onclick="parent.tab_close('tt')">Cancel</a>						
        </div>	
    </div>
</div>

<script type="text/javascript">	
    function submit_form(){
        var categori = $('#select_item_category').combobox('getValues');
	 
        if(categori == 0) {
            $.messager.alert('Unseccessfull','Kategori Belum Dipilih','error');
            return false;
        }
        else {
            custom_data('<?php echo"setup/preference_item"; ?>/proses_post_data_prefernce_item_account','#preference_item_default');
			//$("#preference_item_default").submit();
        }
    }
	
    function approval(){
        $("#preference_item_default").submit();
    }
	
    $('#select_item_category').combobox({
        //valueField: 'id', 
	
        onSelect: function(rec){
            var item_id = rec.ItemCategoryID;
			
            $.ajax({
                type: "POST",
                url: "<?=base_url()?>setup/preference_item/combo_list_sales_item_account",
                data: "item_id="+item_id,
                cache: false,
                success: function(msg){
                    $("#select_item_sales_account").combobox('select', msg);
                }
            });

            $.ajax({
                type: "POST",
                url: "<?php echo base_url(); ?>setup/preference_item/combo_list_cogs_item_account",
                data: "item_id="+item_id,
                cache: false,
                success: function(msg){
                    $("#select_item_cogs_account").combobox('select', msg);
                }
            });
			
            $.ajax({
                type: "POST",
                url: "<?php echo base_url(); ?>setup/preference_item/combo_list_inventory_item_account",
                data: "item_id="+item_id,
                cache: false,
                success: function(msg){
                    $("#select_item_inventory_account").combobox('select', msg);
                }
            });

            $.ajax({
                type: "POST",
                url: "<?php echo base_url(); ?>setup/preference_item/combo_list_taxable22_item_account",
                data: "item_id="+item_id,
                cache: false,
                success: function(msg){
                    $("#select_item_taxable22").combobox('select', msg);
                }
            });
			
            $.ajax({
                type: "POST",
                url: "<?php echo base_url(); ?>setup/preference_item/combo_list_sr_item_account",
                data: "item_id="+item_id,
                cache: false,
                success: function(msg){
                    $("#select_item_account_sr").combobox('select', msg);
                }
            });

            $.ajax({
                type: "POST",
                url: "<?php echo base_url(); ?>setup/preference_item/combo_list_pr_item_account",
                data: "item_id="+item_id,
                cache: false,
                success: function(msg){
                    $("#select_item_account_pr").combobox('select', msg);
                }
            });

            $.ajax({
                type: "POST",
                url: "<?php echo base_url(); ?>setup/preference_item/combo_list_unbilled_item_account",
                data: "item_id="+item_id,
                cache: false,
                success: function(msg){
                    $("#select_account_unbilled").combobox('select', msg);
                }
            });			
        }
    });
</script>