Untitled

mail@pastecode.io avatar
unknown
javascript
a month ago
5.1 kB
3
Indexable
Never
/** autogenerated **/
Ext._define('rh.ac.authorized_dayactivity.Manage', {
    extend: 'toolkit.widget.TabPanel',

    getDayActivityGrid: function(cfg) {
        
        if(!this._gridDayActivity) {
            this._gridDayActivity = Ext._create('rh.ac.authorized_dayactivity.Grid', {
                region: 'center',
                keywordFieldWidth: 150,
                configOrderToolBar: ['edit'],
                gridAutoLoad: false ,
                columnAction: false ,
                allowCreate: false ,
                allowUpdate: true ,
                allowRemove: false ,
                hideActions: ['add','edit','remove','copy']
            });
        }
        /*
        if(!this._gridDayActivity) {
            this._gridDayActivity = Ext._create('rh.ac.dayactivity.DayActivityGrid', {
                region: 'center',
                gridAutoLoad: true
            });
        }
        */
        return this._gridDayActivity;
    },

    getEmployeeGrid: function(cfg){
        if(!this._employeeGrid) {
            this._employeeGrid = Ext._create('rh.employee.Grid', {
                region:'west',
                width:450,
                minWidth: 300,
                split:true,
                gridAutoLoad:false,
                columnAction: false,
                allowCreate: false,
                allowUpdate: false,
                allowRemove: false,
                configOrderToolBar:['search', '->','download'],
                keywordFieldWidth: 150,
                hideColumns:['departure_unicode','effective_unicode','commission_unicode','elective_unicode','ativo'],

            });


            this._employeeGrid.setFilterProperty('chefe_imediato__matricula',this.boss,1000,true);

            this._employeeGrid.getSelectionModel().on({
                scope:this,
                selectionchange: function(sel){
                    var selection = sel.getSelections();
                    
                    if(selection.length > 0)
                       this.employee(selection[0].get('pk'));
                    
                    else
                        this.employee(null);   
                }

            })

        }

        return this._employeeGrid;
    },

    employee: function(value,dispatch) {
        dispatch = (dispatch === undefined ? true : dispatch);
        if(value !== undefined) {
            this._employee = value;
            if(dispatch)
                this.employeeObserver();
        }
        return this._employee;
    },

    employeeObserver: function() {
        var value = this.employee();

        if(value) {
            //console.info('servidor selecionado:'+String(valor)) ;
            this.getDayActivityGrid().enable();
            this.getDayActivityGrid().setParam('employee',value);
            var params = []
            params.push({'property': 'employee', 'value': value, 'stage': 1000});
            if(this.getDayActivityGrid().values.length == 0 ){
                params.push({'property': 'month_activity__month', 'value': new Date().getMonth()+1, 'stage': 1001});
                params.push({'property': 'month_activity__year', 'value': new Date().getFullYear(), 'stage': 1002});
            
            }else if(this.getDayActivityGrid().values[0] !=0 && this.getDayActivityGrid().values[1] ==0){
                params.push({'property': 'month_activity__month', 'value': this.getDayActivityGrid().values[0], 'stage': 1001});

            }else if(this.getDayActivityGrid().values[0] ==0 && this.getDayActivityGrid().values[1] != 0){
                params.push({'property': 'month_activity__year', 'value': this.getDayActivityGrid().values[1], 'stage': 1002});

            }else if (this.getDayActivityGrid().values[0] !=0 && this.getDayActivityGrid().values[1] != 0){
                params.push({'property': 'month_activity__month', 'value': this.getDayActivityGrid().values[0], 'stage': 1001});
                params.push({'property': 'month_activity__year', 'value': this.getDayActivityGrid().values[1], 'stage': 1002});
            }
            this.getDayActivityGrid().setFilter(params)
            
        }
        else {
            //console.info('servidor nao selecionado') ;
            this.getDayActivityGrid().disable();
            this.getDayActivityGrid().setParam('employee',value);
            this.getDayActivityGrid().setFilterProperty('employee',value,1000,false);
            this.getDayActivityGrid().getStore().removeAll();           
        }
    },


    constructor: function(cfg) {
        cfg = core.nullValue(cfg, {});
        this.boss = cfg.boss;

        Ext.applyIf(
            cfg,
            {
                title: 'Autorizar Movimento Dia'
            }
        );

        Ext.apply(
            cfg,
            {
                layout: 'border',
                items: [
                    this.getEmployeeGrid(cfg),
                    this.getDayActivityGrid(cfg)
                ]
            }
        );

        rh.ac.authorized_dayactivity.Manage.superclass.constructor.call(this, cfg);
        this.employeeObserver();
    }
});

Leave a Comment