<!---
    Author  : Ferry / Tanggal : 15-06-2015	
    Revisi  :
-->

	<?php
		if($group_user->SavePrivillage == 1){
			$cek_autority_save 		= "";
		}
		else{
			$cek_autority_save 		= "disabled";
		}

        if($group_user->ReversePrivillage == 1){
            $cek_autority_reverse  = "";
        }
        else{
            $cek_autority_reverse    = "disabled";
        }
		//-------------end----------------------------
	?>

<div class="easyui-layout" data-options="fit:true,border:false">
    <!-- top view-->
    <div id="form-header" data-options="region:'north',border:false" >
        <div id="form-header-wrapper">
            <table cellpadding="0" cellspacing="0" width="100%" height="100%" border="0">
                <tr>
                    <td align="left" valign="middle">
                        <!-- <a href="#" class="easyui-linkbutton" iconCls="icon-document" plain="true" onclick="location.reload();">New</a> -->
                        <a href="#" class="easyui-linkbutton" id="refresh-linkbutton" data-options="plain:true,iconCls:'icon-reload'" onclick="location.reload();">Refresh</a>
                    </td>							
    
                    <td height="25" align="right" valign="middle">								
                        <span class="form-title"><?=$menu_label?></span>
                    </td>
                </tr>
            </table>		     	
        </div>			
    </div>
    <!-- end top view -->	

    <!-- center view -->
    <div id="form-body" data-options="region:'center',border:false">
        <div id="form-wrapper" class="easyui-panel" fit="true" style="padding:5px;">
            <form id="fm_bank_reconcile" name="fm_bank_reconcile" method="post">
                <input type="hidden" name="detail" id="detail"/>
                <input type="hidden" name="detail_from_db" id="detail_from_db"/>
                <input type="hidden" name="hdn_currency_code" id="hdn_currency_code" />
                
                <input type="hidden" name="hdn_new_balance" id="hdn_new_balance"/>
                <input type="hidden" name="hdn_calculated_balance" id="hdn_calculated_balance"/>
                <input type="hidden" name="hdn_out_of_balance" id="hdn_out_of_balance"/>
                <input type="hidden" name="hdn_total_clear" id="hdn_total_clear"/>
                
                <table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0">
                    <tr>
                        <td width="43%" valign="top">
                            <table width="100%" cellpadding="0" cellspacing="1">
                                <tr height='20'>
                                    <td width='230'><b>Show Reconcille</b></td>
                                    <td width='10'><b>:</b></td>

                                    <td>
                                        <!-- <input type="text" name="txt_calculated_balance" id="txt_calculated_balance" class="easyui-numberbox" style="width:250px;text-align:right;" readonly
                                            data-options="min:1,precision:'2',groupSeparator:'.',decimalSeparator:','"                                    
                                        /> -->
                                        <input type="checkbox" name="txt_show" id="txt_show" value="0"/>
                                    </td>
                                </tr>

                                <tr height="20">
                                    <td width="230"><b>Bank Account</b></td>
                                    <td width="10"><b>:</b></td>

                                    <td>
                                        <select name="cbg_bank_account" id="cbg_bank_account" class="combo-grid" editable="true" style="width:250px;height:22px" required="true"
                                            data-options="
                                                panelWidth:400,
                                                idField:'AccountNumber',
                                                textField:'AccountName',
                                                url: '<?=base_url()?>list/bank_reconcile/ajax_bank_account',
                                                method: 'post',
                                                fitColumns: true,
                                                columns: [[
                                                    {field:'AccountName',title:'Account Bank Name',width:100,halign:'center',align:'center'},						
                                                    {field:'CurrencyCode',title:'Currency Name',width:100,halign:'center',align:'center'}						
                                                ]],
                                                onSelect:function(rowIndex, rowData){
                                                    $('.spn_currency').text(rowData.CurrencyCode);
                                                    $('#hdn_currency_code').val(rowData.CurrencyCode);


                                                    if( $('#txt_show').is(':checked') ){
                                                        var Rec_Status = 1;

                                                    }else{

                                                        var Rec_Status = 0;
                                                    }

                                                    var date_rec        = $('#txt_bren_date').datebox('getValue');
                                                    g_status            = Rec_Status;
                                                    g_bank              = rowData.AccountNumber;
                                                    g_currency          = rowData.CurrencyCode;
                                                    
                                                    $('#dtg_item').datagrid('load',{
                                                        BankAccount         : rowData.AccountNumber,
                                                        Currency            : rowData.CurrencyCode,
                                                        Rec_Status          : Rec_Status,
                                                        Date_Rec            : date_rec

                                                    });                
                                                }                                            
                                            ">
                                        </select>
                                    </td>
                                </tr>
                                
                                <!-- <tr height='20'>
                                    <td width="230"><b>Last Reconcille Date</b></td>
                                    <td width="10"><b>:</b></td>

                                    <td>
                                        <input type="text" name="txt_new_balance" id="txt_new_balance" class="easyui-numberbox" style="width:250px;text-align:right;" readonly
                                            data-options="min:1,precision:'2',groupSeparator:'.',decimalSeparator:','"                                    
                                        />
                                        <input type="text" name="txt_bren_last_date" id="txt_bren_last_date" class="easyui-datebox" value="" style="width:250px;" readonly /> 
                                    </td>
                                </tr> -->
                                
                                <tr height='20'>
                                    <td width='230'><b>Currency</b></td>
                                    <td width='10'><b>:</b></td>

                                    <td>
                                       <!--  <input name="txt_out_of_balance" id="txt_out_of_balance" type="text" class="easyui-numberbox" style="width:250px;text-align:right;" readonly
                                            data-options="min:1,precision:'2',groupSeparator:'.',decimalSeparator:','"                                    
                                        /> -->
                                        <span class="spn_currency" style="font-weight:bold"></span>
                                    </td>
                                    
                                </tr>
                                <tr height="20">
                                    <td width="230"><b>Amount Balance</b></td>
                                    <td width="10"><b>:</b></td>
                                    <td>
                                        <input name="amount_balance" id="amount_balance" type="text" class="easyui-numberbox" style="width:250px;height:20px;text-align:right" formatter="formatRp" 
                                            data-options="
                                                precision:2,decimalSeparator:',',groupSeparator:'.'
                                        ">
                                        
                                    </td>
                                </tr>
                                <tr height="20">
                                    <td width="230"><b>Calculate Balance</b></td>
                                    <td width="10"><b>:</b></td>
                                    <td>
                                        <input name="amount_calculate" id="amount_calculate" type="text" class="easyui-numberbox" style="width:250px;height:20px;text-align:right" formatter="formatRp" 
                                            data-options="
                                                precision:2,decimalSeparator:',',groupSeparator:'.'
                                        " readonly="true">
                                        
                                    </td>
                                </tr>
                                <tr height="20">
                                    <td width="230"><b>Remaining Balance</b></td>
                                    <td width="10"><b>:</b></td>
                                    <td>
                                        <input name="amount_remaining" id="amount_remaining" type="text" class="easyui-numberbox" style="width:250px;height:20px;text-align:right" formatter="formatRp" 
                                            data-options="
                                                precision:2,decimalSeparator:',',groupSeparator:'.'
                                        " readonly="true">
                                        
                                    </td>
                                </tr>
                            </table>
                        </td>

<!--                        <td width="7%" valign='top'>
                            <table width="100%" cellpadding="0" cellspacing="1">
                                <tr height="20"></tr>
                                <tr height="20"></tr>
                                <tr height="20"></tr>
                                <tr>
                                    <td valign='top' align="left"><a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-calculator',size:'small'" id="calc_validate" onClick="sum_all();"></td>
                                </tr>
                            </table>
                        </td>-->
                        
                        <td width="50%" valign="top">
                            <table width="100%" cellpadding="0" cellspacing="1">
                               

                                <tr height='20'>
                                    <td colspan='2'>&nbsp;</td>
                                    <td width="400"  align="right"><b>Reconcile Date</b></td>
                                    <td width='10'><b>:</b></td>

                                    <td align='left'>
                                        <input type="text" name="txt_bren_date" id="txt_bren_date" class="easyui-datebox validBackward" value="today" style="width:150px;height:20px" editable="false" required="required" /> 
                                    </td>
                                </tr>

                               <!--  <tr tr height='20'>
                                    <td colspan="2">&nbsp;</td>
                                    <td width="140" align="right" ><b>Last Reconcile Date</b></td>
                                    <td width="10"><b>:</b></td>

                                    <td align="left" >
                                        <input type="text" name="txt_bren_last_date" id="txt_bren_last_date" class="easyui-datebox" value="" style="width:150px;" readonly /> 
                                    </td>
                                </tr>
                                <tr height='20'>
                                    <td colspan='2'>&nbsp;</td>
                                    <td width="400"  align="right"><b>Show Reconcile</b></td>
                                    <td width='10'><b>:</b></td>

                                    <td align='left'>
                                        <input type="checkbox" name="txt_bren_date" id="txt_bren_date"  /> 
                                    </td>
                                </tr>
                                
                                <tr tr height='20'>
                                    <td colspan="2">&nbsp;</td>
                                    <td width="140" align="right" ><b>Currency</b></td>
                                    <td width="10"><b>:</b></td>

                                    <td>
                                        <span class="spn_currency" style="font-weight:bold">IDR</span>
                                    </td>
                                </tr> -->
                            </table>
                        </td>
                    </tr>
                </table>
                
                <div class="easyui-tabs" data-options="tabHeight:18" style="margin-top:5px;">		
                    <div id="tab_item" title="Item">
                        <table id="dtg_item" title="" iconCls="icon-edit" singleSelect="true" rowNumbers="true" fitColumns="true" style="height:400px"
                            url="<?=base_url()?>list/bank_reconcile/ajax_item" 
                             data-options = "border:false,autoRowheight:false"
                        >
                            <thead>
                                <tr>
                                    <th field='Trans_Date'    width='75'  data-options="align:'center',halign:'center'" formatter="formatDate">Date</th>
                                    <th field='Trans_Number'  width='195' data-options="align:'center',halign:'center'" editor="{type:'text'}">Source No</th>
                                    <!-- <th field='Account_Number' width='100' data-options="align:'left',halign:'center'"   >AccountNumber</th> -->
                                    <th field='Trans_Type'    width='60'  data-options="align:'center',halign:'center'">Trans Type</th>
                                    <th field='Trans_Desc'    width='250' data-options="align:'left',halign:'center'"  >Description</th>
                                    <th field='Deposit'       width='100' data-options="align:'right',halign:'center'"  formatter="formatRp">Deposit</th>
                                    <th field='WithDrawal'    width='100' data-options="align:'right',halign:'center'"  formatter="formatRp">Withdrawal</th>
                                    <th field='Status_Reconcile' width='60'  data-options="align:'center',halign:'center'" hidden editor="{type:'text'}">Reconcile</th>
                                    <th field="Status_Rebook"        width="90"  data-options="halign:'center',align:'center'" editor="{type:'checkbox',options:{on:'Yes',off:'No'}}">Change</th>
                                    <!-- <th field='Currency_Rate' width='60'  data-options="align:'center',halign:'center'" hidden>Currency Rate</th> -->
                                    
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>
                
                <table width="30%" cellpadding="0" cellspacing="1" style="padding-top:7px;display:none" border='0' align='right'>
                    <tr height='20'>
                        <td width="120"><b>Total Clear</b></td>
                        <td width="10"><b>:</b></td>

                        <td align="right" width='170'>
                            <input type="text" id="txt_total_clear" name="txt_total_clear" class="easyui-numberbox" value="0" style="text-align:right;" readonly
                                data-options="min:0,precision:2,decimalSeparator:',',groupSeparator:'.'"
                            />
                        </td>
                    </tr>
                    
                    <tr height='20'>
                        <td width="160"><b>Total Outstanding</b></td>
                        <td width="10"><b>:</b></td>

                        <td align="right" width='170'>
                            <input type="text" id="txt_total_outstanding" name="txt_total_outstanding" class="easyui-numberbox" value="0" style="text-align:right;" readonly
                                data-options="min:0,precision:2,decimalSeparator:',',groupSeparator:'.'"
                            />
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>

    <div id="form-footer" data-options="region:'south',border:false">
    	<table width="100%" cellpadding="0" cellspacing="0">
            <tr>
                <td align="right">
                    <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 app-button" iconCls="icon-ok" onclick="app_mgr()">App. Mgr</a>
                    <a href="javascript:void(0)" class="easyui-linkbutton form-button app-reverse" iconCls="icon-reload" onclick="app_reverse()" <?php echo $cek_autority_reverse;?>>Reverse</a>
                    <a href="javascript:void(0)" class="easyui-linkbutton form-button" iconCls="icon-save" onclick="save_data();" <?php echo $cek_autority_save;?>>Save</a>
                    <a href="javascript:void(0)" class="easyui-linkbutton form-button" iconCls="icon-cancel" onclick="parent.tab_close('tt');">Cancel</a>
                </div>
            </tr>
        </table>
    </div>
</div>

<script>

var job_status          = "<?php echo $this->session->userdata('jobtitle_status');?>";
var arr_reconcile       = [];
var cek_reverse         = "<?php echo $group_user->ReversePrivillage;?>";
var g_status            = 0;
var g_bank              = '';
var g_currency          = '';

var SavePrivillage  = '<?=$group_user->SavePrivillage;?>';

$(document).ready(function(){
    
    $('.app-button').linkbutton('disable');

    $('#txt_show').click(function () {
        if ($(this).val() == 0) {
            $(this).val(1);
            $('input[name="chk_TransStatus"]').prop('checked', true);
            var Rec_Status = 1;
        } else {
            $(this).val(0);
            $('input[name="chk_TransStatus"]').prop('checked', false);
            var Rec_Status = 0;
        }

        var date_rec        = $('#txt_bren_date').datebox('getValue');
        g_status            = Rec_Status;
        g_bank              = $('#cbg_bank_account').combogrid('getValue');
        g_currency          = $('#hdn_currency_code').val();
        
        if(g_bank != ''){
            $('#dtg_item').datagrid('load',{
                BankAccount         : g_bank,
                Currency            : g_currency,
                Rec_Status          : Rec_Status,
                Date_Rec            : date_rec

            });      
        }          
    });

    $('#txt_bren_date').datebox({
        onChange:function(){

            var date_rec    = $('#txt_bren_date').datebox('getValue');

            if(g_bank!=''){
                $('#dtg_item').datagrid('load',{
                    BankAccount         : g_bank,
                    Currency            : g_currency,
                    Rec_Status          : g_status,
                    Date_Rec            : date_rec
                });     
            }

        }
    });

    $('#amount_balance').numberbox({
        onChange:function(){
            if(g_bank!=''){
                sum_foote_note();
            }
        }
    })
      
	$('#dtg_item').edatagrid({
            onBeginEdit:function(rowIndex, rowData){

                    editors                 = $('#dtg_item').edatagrid('getEditors', rowIndex);
                    
                    trans_number_editor     = $(editors[0].target);
                    status_recon            = $(editors[1].target);
                    status_editor           = $(editors[2].target);

                    $(trans_number_editor).prop('readonly', true);

                    $(trans_number_editor).click(function(){
                        TransNo             = rowData.Trans_Number;
                        TransType           = rowData.Trans_Type;            

                        trans_number        = TransNo.split('/');
                        trans_code          = trans_number[1];            
                        InitialCharTrans    = trans_code.substring(4,6);

                        open_transaction(TransNo,TransType);

                        //load_transaction(InitialCharTrans, TransNo);
                    });

                    if(rowData.Status_Reconcile == "Yes"){
                        $(status_editor).click(function(){
                            sum_foote_note();           
                        });

                        status_editor.prop('disabled',true);
                    }else{
                        $(status_editor).click(function(){
                            sum_foote_note();           
                        });
                        status_editor.prop('disabled',false);
                    }

    
            },
            onEndEdit:function(rowIndex,row,changes){
                
            },
            onLoadSuccess:function(data){
                var statusrebook        = 0;
                var statusRC            = 0;
                arr_reconcile           = data.rows;
                
                /*============================= change checkbox sttaus reconcile =====================*/
                $.each(arr_reconcile,function(index,value){
                    if((value.Status_Rebook == "Yes") && (value.Status_Reconcile == "No")){
                        statusrebook++;
                    }

                    if(value.Status_Reconcile == "Yes"){
                        statusRC++;
                     }
                });
                /*==================================== end ============================================*/
                
                /*======================= disable or enbale app-button =========================*/
                if((job_status == 1) && (statusrebook > 0)){

                        $('.app-button').linkbutton('enable');
                      
                }else{
                      
                      $('.app-button').linkbutton('disable');
                }
                /*======================================= end ======================================*/

                /*============================== disable or enable app-reverse ===========================*/
                if((statusRC > 0) && (cek_reverse == 1 ) && (job_status == 1)){
                    $('.app-reverse').linkbutton('enable');
                }else{
                    $('.app-reverse').linkbutton('disable');
                }
                /*====================================== end =======================================*/

               /*================= Hitung amount balance, callculate dan remaining saat awal loading account ========================*/
                var amount_balance = 0;
                var amount_calculate        = 0;
                var amount_remaining        = 0;


                var data_length = data.rows.length;

                for(var i=0;i<data_length;i++){

                    if(data.rows[i].Status_Rebook == 'Yes'){
                        if(data.rows[i].Deposit == 0){
                            amount_balance      -= parseFloat(data.rows[i].WithDrawal);
                            amount_calculate    -= parseFloat(data.rows[i].WithDrawal);
                            //console.log('amount_calculate 0 :'+amount_calculate);
                        }else{
                            amount_balance      += parseFloat(data.rows[i].Deposit);
                            amount_calculate    += parseFloat(data.rows[i].Deposit);
                            //console.log('amount_calculate 1:'+amount_calculate);
                        }
                    }else{
                        if(data.rows[i].Deposit == 0){
                            amount_balance      -= parseFloat(data.rows[i].WithDrawal);
                        }else{
                            amount_balance      += parseFloat(data.rows[i].Deposit);
                        }
                    }

                    //console.log('amount_balance :'+amount_balance);
                }

                amount_remaining = amount_balance - amount_calculate;
                // console.log(amount_remaining);

                $('#amount_balance').numberbox('setValue',amount_balance);
                if(amount_calculate != 0){
                    $('#amount_calculate').numberbox('setValue',amount_calculate);
                    $('#amount_remaining').numberbox('setValue',amount_remaining);
                }

                /*=========================================== end ========================================*/
                
            },
            rowStyler:function(index,row){
                switch (row.Status_Reconcile)
                {
                    case 'Yes':
                        return 'background-color:#FA8072;color:#000000;';
                        break;
                    case 'No':
                        return 'background-color:#ffffff;color:#000000;';
                        break;
                }  
            }
        });
        
        $("#fm_bank_reconcile").click(function() {
            $('#dtg_item').edatagrid('saveRow');
	   });
});

    function sum_foote_note(){
        $('#dtg_item').edatagrid('saveRow');
        item = $('#dtg_item').datagrid('getRows');

        var amount_balance          = parseFloat($('#amount_balance').numberbox('getValue'));
        var amount_calculate        = 0;
        var amount_remaining        = 0;

        $.each(item,function(index,value){
            if(value.Status_Rebook =='Yes'){
                if(value.Deposit == 0){
                    amount_calculate    -= parseFloat(value.WithDrawal);
                }else{
                    amount_calculate    += parseFloat(value.Deposit);
                }
            }
        });

        amount_remaining    = amount_balance - amount_calculate;

        $('#amount_calculate').numberbox('setValue',amount_calculate);
        $('#amount_remaining').numberbox('setValue',amount_remaining);

        //var total_yes       = 0;

        // $.each(item, function(index, value) {
        //     if(value.Status_Rebook == 'Yes'){
        //         if(value.Deposit == 0){
        //             amount_calculate    += parseFloat(value.WithDrawal);
        //         }
        //         else{
        //             amount_calculate    += parseFloat(value.Deposit);
        //         }
        //     }
        //     else{
        //         if(value.Deposit == 0){
        //             total_outstanding   += parseFloat(value.WithDrawal);
        //         }
        //         else{
        //             total_outstanding   += parseFloat(value.Deposit);
        //         }
        //     }
        //});

       // $('.app-button').linkbutton('disable');
        //$('.app-reverse').linkbutton('disable');
        // $('#txt_total_clear').numberbox('setValue', total_clear);
        // $('#txt_total_outstanding').numberbox('setValue', total_outstanding);
    }
	
    function load_transaction(InitialCharTrans, TransNo){
        var Tbl;
        var TabTitle;
        var LinkTo;

        switch(InitialCharTrans){
            case 'PP':
                Tbl         = 'at_purchasepayment';
                TabTitle    = 'Purchase Payment';
                LinkTo      = 'list/purchases_payment';
                break;

            case 'SR':
                Tbl         = 'at_salesreceipt';
                TabTitle    = 'Sales Receipt';
                LinkTo      = 'list/sales_receipt';
                break;

            case 'EC':
                Tbl         = 'at_expensecashbon';
                TabTitle    = 'Expense Cash-Bon';
                LinkTo      = 'list/purchases_expense_cashbon';
                break;

            case 'EP':
                Tbl         = 'at_expensepayment';
                TabTitle    = 'Expense Payment';
                LinkTo      = 'list/purchases_expense_real';
                break;

            case 'CP':
                Tbl         = 'at_cashpayment';
                TabTitle    = 'Payment <= 250.000';
                LinkTo      = 'list/payment';
                break;

            case 'CD':
                Tbl         = 'at_cashdeposit';
                TabTitle    = 'Deposit';
                LinkTo      = 'list/deposit';
                break;

            case 'BS':
                Tbl         = 'at_banksweep';
                TabTitle    = 'Sweep BANK';
                LinkTo      = 'list/swift_bank';
                break;

            case 'AP':
                Tbl         = 'at_afiliasidebt';
                TabTitle    = 'Piutang Afiliasi';
                LinkTo      = 'list/piutang_afiliasi';
                break;

            case 'AI':
                Tbl         = 'at_afiliasiinstallment';
                TabTitle    = 'Payment Afiliasi';
                LinkTo      = 'list/payment_afiliasi';
                break;

            case 'AE':
                Tbl         = 'at_employeedebt';
                TabTitle    = 'Piutang Karyawan';
                LinkTo      = 'list/piutang_karyawan';
                break;

            case 'EI':
                Tbl         = 'at_employeeinstallment';
                TabTitle    = 'Payment Karyawan';
                LinkTo      = 'list/payment_karyawan';
                break;

            case 'TC':
                Tbl         = 'at_transfercash';
                TabTitle    = 'Transfer To Petty Cash';
                LinkTo      = 'list/transaksi_antar_kas';
                break;

            default:
                Tbl         = '';
                TabTitle    = '';
                LinkTo      = '';
        }
        parent.tab_edit(TabTitle, LinkTo, 'icon-edit', 'edit', TransNo);
    }

    function save_data(){
        $('#dtg_item').edatagrid('saveRow');
        var rows    = $('#dtg_item').datagrid('getSelections');
        var index   = $('#dtg_item').datagrid('getRowIndex', rows);

        if(rows == ''){
            $.messager.alert('Info','Silahkan seleksi data pada table','error',function(){
                return false;
            });
        }
        else{
            var item    = $('#dtg_item').datagrid('getRows');
            var detail  = JSON.stringify(item);
            
            $("#detail").val(detail);
            save_transaction('<?=$menu_link;?>','#fm_bank_reconcile');
        }
    }

    function app_mgr(){
        $('#dtg_item').edatagrid('saveRow');
        var item =  $('#dtg_item').datagrid('getRows');

        var total_item = item.length;

        if(total_item <= 0 ){
            $.messager.alert('Info','Silahkan Pilih Bank Account untuk di reconcile','error',function(){
                return false;
            });
        }
        else{
            var detail  = JSON.stringify(item);
            
            $("#detail").val(detail);
            //$("#detail_from_db").val(JSON.stringify(arr_reconcile));
            approved_data('<?=$menu_link?>','#fm_bank_reconcile');
        }
        
    }

    function app_reverse(){
        var item    = $('#dtg_item').datagrid('getRows');
        var detail  = JSON.stringify(item);
        
        $("#detail").val(detail);
        reversed_data('F','<?=$menu_link?>', $('#detail').val()+'='+$('#cbg_bank_account').combogrid('getValue'), 'Bank Reconcile');
    }

$.extend($.fn.datagrid.defaults.editors, {
    text: {
        init: function(container, options){
            var input = $('<input type="text" class="datagrid-editable-input">').appendTo(container);
            return input;
        },
        destroy: function(target){
            $(target).remove();
        },
        getValue: function(target){
            return $(target).val();
        },
        setValue: function(target, value){
            $(target).val(value);
        },
        resize: function(target, width){
            $(target)._outerWidth(width);
        }
    }
});
</script>