/*
 * 부서 정보
 */
var store_part = new Ext.data.Store({
    proxy: new Ext.data.HttpProxy({
        method: 'POST',
        url: '../lib/config_json.php'
    }),
    baseParams: {
        section: 'part'
    },
    reader: new Ext.data.JsonReader({
        root: 'data',
        fields: [{
            name: 'part_idx'
        }, {
            name: 'part_name'
        }]
    })
});

/*
 * 직급 정보
 */
var store_position = new Ext.data.Store({
    proxy: new Ext.data.HttpProxy({
        method: 'POST',
        url: '../lib/config_json.php'
    }),
    baseParams: {
        section: 'position'
    },
    reader: new Ext.data.JsonReader({
        root: 'data',
        fields: [{
            name: 'position_idx'
        }, {
            name: 'position_name'
        }]
    })
});

/*
 * 담당업무 정보
 */
var store_task = new Ext.data.Store({
    proxy: new Ext.data.HttpProxy({
        method: 'POST',
        url: '../lib/config_json.php'
    }),
    baseParams: {
        section: 'task'
    },
    reader: new Ext.data.JsonReader({
        root: 'data',
        fields: [{
            name: 'task_idx'
        }, {
            name: 'task_name'
        }]
    })
});

/*
 * 근태 정보
 */
var store_attendance = new Ext.data.Store({
    proxy: new Ext.data.HttpProxy({
        method: 'POST',
        url: '../lib/config_json.php'
    }),
    baseParams: {
        section: 'attendance'
    },
    reader: new Ext.data.JsonReader({
        root: 'data',
        fields: [{
            name: 'attendance_idx'
        }, {
            name: 'attendance_name'
        }]
    })
});

/**
 * 게시판종류
 */
var store_bbs_type = new Ext.data.Store({
    proxy: new Ext.data.HttpProxy({
        method: 'POST',
        url: '../lib/config_json.php'
    }),
    baseParams: {
        section: 'bbs_type'
    },
    reader: new Ext.data.JsonReader({
        root: 'data',
        fields: [{
            name: 'bbs_key'
        }, {
            name: 'bbs_value'
        }]
    })
});

/**
 * 사용중인 모든 문서
 */
var store_use_docs = new Ext.data.Store({
	proxy: new Ext.data.HttpProxy({
        url: '/edoc/edoc_json.php'
    }),
    baseParams: {
        section: 'use_docs'
    },
    reader: new Ext.data.JsonReader({
        root: 'informations',
        totalProperty: 'totalCount',
        fields: [{
            name: 'doc_code'
        }, {
            name: 'doc_name'
        }]
	})
});



/**
 * 거래처
 */
var store_client = new Ext.data.Store({
    proxy: new Ext.data.HttpProxy({
        method: 'POST',
        url: '../lib/config_json.php'
    }),
    baseParams: {
        section: 'client'
    },
    reader: new Ext.data.JsonReader({
        root: 'data',
        fields: [{
            name: 'client_idx'
        }, {
            name: 'client_name'
        }]
    })
});



/*
 * 사용중인 모든문서
 */
var _CYCLE_USE_DOCS = [];

/**
 * 사용중인 휴가서보고서
 */
var _GRID_RD_HOLIDAY = [];
var _GRID_HD_HOLIDAY = [];
var _CYCLE_HOLIDAY = [];
var _store_edoc_holiday = new Ext.data.Store({
    autoLoad: true,
    proxy: new Ext.data.HttpProxy({
        method: 'POST',
        url: '../lib/config_json.php'
    }),
    baseParams: {
        section: 'edoc_holiay'
    },
    reader: new Ext.data.JsonReader({
        root: 'data',
        fields: [{
            name: 'doc_idx'
        }, {
            name: 'holiday_name'
        }, {
            name: 'doc_name'
        }]
    }),
    listeners: {
        load: function(store, record, s){
        
            store.each(function(e){
                _GRID_RD_HOLIDAY.push({
                    name: "doc_" + e.get('doc_idx')
                })
                
                _GRID_HD_HOLIDAY.push({
                    header: e.get('holiday_name'),
                    align: "center",
                    dataIndex: "doc_" + e.get('doc_idx'),
                    renderer: function(v){
                        if (!v) {
                            return 0;
                        }
                        else {
                            return v + ' 일';
                        }
                    }
                })
                
                _CYCLE_HOLIDAY.push({
                    text: '<b>' + e.get('holiday_name') + '</b>',
                    value: e.get('doc_idx')
                })
				_CYCLE_USE_DOCS.push({
					text: e.get('holiday_name'),
					value: 'holiday_'+e.get('doc_idx')					
				})
            })
        }
    }
});


/**
 * 사용중인 근태보고서
 */
var _CYCLE_ATTENDANCE = [];
var _store_edoc_attendance = new Ext.data.Store({
    autoLoad: true,
    proxy: new Ext.data.HttpProxy({
        method: 'POST',
        url: '../lib/config_json.php'
    }),
    baseParams: {
        section: 'edoc_attendance'
    },
    reader: new Ext.data.JsonReader({
        root: 'data',
        fields: [{
            name: 'doc_idx'
        }, {
            name: 'attendance_name'
        }, {
            name: 'doc_name'
        }]
    }),
    listeners: {
        load: function(store, record, s){
            store.each(function(e){
                _CYCLE_ATTENDANCE.push({
                    text: '<b>' + e.get('attendance_name') + '</b>',
                    value: e.get('doc_idx')
                });
				
				_CYCLE_USE_DOCS.push({
					text: e.get('attendance_name'),
					value: 'attendance_'+e.get('doc_idx')					
				})
            })
        }
    }
});
