<?php
/*      Author 	: 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><b>P/L Account</b></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>Item Account</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-color:#eee;">
        <div id="form-wrapper" class="easyui-layout" border="false" style="width:1100px;height:520px;background:#FFF;">
            <div data-options="region:'west',split:true,collapsible:false" style="width:954px;">
                <table id="dtg_pl_account" class="easyui-edatagrid" title="List Of G/L Account" rownumbers="true" fitColumns="true"
                    url="<?php echo base_url(); ?>setup/preference_account/ajax_pl_account">
                    <thead>
                        <tr>
                            <th field='PLStatus' width="40" editor="{options:{on:'Yes',off:'No'}}" data-options="align:'center'">P/L</th>
                            <th field='AccountNumber' width="150" halign="center">Account Number</th>
                            <th field='AccountName' width="320" halign="center">Account Name</th>
                            <th field='AccountTypeName' width="240" halign="center">Account Type</th>
                            <th field='Status' width="82" align="center" halign="center">Status</th>
                            <th field='AccountChild' width="50" halign="center" hidden="true">Account Child</th>
                            <th field='ModusCode' width="50" halign="center" editor="{type:'numberbox'}" hidden>Modus Code</th>
                        </tr>
                     </thead>
                </table>					
            </div>
        </div>
        
        <div style="padding:20px;text-align:right;width:925px;">
            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-help" onclick="" plain="true">Help</a>
            <a href="javascript:void(0)" class="easyui-linkbutton form-button" iconCls="icon-save" onclick="save_pl_account('setup/preference_account');">Save</a>					  
            <a href="javascript:void(0)" class="easyui-linkbutton  form-button" iconCls="icon-cancel" onclick="">Cancel</a>						
        </div>	
    </div>
</div>

<script>
    //Fungsi untuk tampilan menjorok
    function format_acc(val,row){
        return '<span style="padding-left:'+row.AccountLevel+'em;">'+val+'</span>';	
    }

    function save_pl_account(url) {        
        $('#dtg_pl_account').edatagrid('saveRow');

        url = base_url + url + '/update_pl_account';
	var selected_pl_account = JSON.stringify($('#dtg_pl_account').datagrid('getRows'));
	
	$.messager.confirm('Warning :','Pastikan P/L Account yang dipilih sudah benar...?',  
            function(r){
                if (r){
                    $.post(url, {selected_pl_account:selected_pl_account}, function(result){
                        if (result.status==true){
                            $.messager.alert('Success',result.message,'info',function(){
                                location.reload();
                            });
                        } 
                        else {
                            $.messager.alert('Error',result.message,'error',function(){
                                location.reload();                                
                            });
                        }
                    },'json');
                }
            }
	);
    }

    function load_branch_pl_coa(url) {        
	url = base_url + url + '/branch_pl_account';

	$.messager.confirm('Warning :','Anda Yakin, akan membatalkan semua transaksi...?',  
            function(r){
                if (r){
                    $.post(url);
                }
            }
	);
    }
    
    $(document).ready(function(){
	$('#dtg_pl_account').datagrid({
            onBeginEdit:function(rowIndex){
                editors = $('#dtg_pl_account').datagrid('getEditors', rowIndex);

                pl_status   = $(editors[0].target);
                modus_code  = $(editors[1].target);
 
                $(pl_status).click(function(){
                    modus_code.numberbox('setValue', 2);
                });
            }  
         });
    });
</script>