=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js 2013-10-02 03:09:16 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js 2013-10-03 04:32:03 +0000 @@ -109,32 +109,6 @@ urlparam: 'id' } }, - period: { - relativeperiodunits: { - reportingMonth: 1, - last3Months: 3, - last12Months: 12, - reportingQuarter: 1, - last4Quarters: 4, - lastSixMonth: 1, - last2SixMonths: 2, - thisYear: 1, - lastYear: 1, - last5Years: 5 - }, - periodtypes: [ - {id: 'Daily', name: 'Daily'}, - {id: 'Weekly', name: 'Weekly'}, - {id: 'Monthly', name: 'Monthly'}, - {id: 'BiMonthly', name: 'BiMonthly'}, - {id: 'Quarterly', name: 'Quarterly'}, - {id: 'SixMonthly', name: 'SixMonthly'}, - {id: 'Yearly', name: 'Yearly'}, - {id: 'FinancialOct', name: 'FinancialOct'}, - {id: 'FinancialJuly', name: 'FinancialJuly'}, - {id: 'FinancialApril', name: 'FinancialApril'} - ] - }, reportPosition: { POSITION_ROW_ORGUNIT_COLUMN_PERIOD: 1, POSITION_ROW_PERIOD_COLUMN_ORGUNIT: 2, @@ -266,7 +240,6 @@ relativeperiod: { checkbox: [] }, - fixedperiod: {}, dataElementGroupBy:{} }, options: {}, @@ -1269,15 +1242,10 @@ TR.store.programStage.removeAll(); TR.store.programStage.add({'id': f.programStageId, 'localid': f.programStageLocalid, 'name': f.programStageName}); - // Date period range + // Date range - TR.store.dateRange.removeAll(); - for( var i=0;i 0 ){ - var prefix = ''; - fperiod.store.each( function(r) { - period += r.data.id + ";"; - }); - } - // Relative periods var rperiod = TR.cmp.params.relativeperiod.checkbox; + var period = ''; p.relativePeriods = []; Ext.Array.each(rperiod, function(item) { if(item.getValue() && !item.hidden){ period += item.paramName + ";"; } }); - if( period.length > 0 ){ period = period.substr(0,period.length-1); p.dimension.push('pe:' + period); } + + // Sort-order + if( TR.state.sortOrder!= '' ){ + p.sortOrder = TR.state.sortOrder + } } return p; }, getURLParams: function( type ){ var params = ""; + params += '&startDate=' + TR.cmp.settings.startDate.rawValue; params += '&endDate=' + TR.cmp.settings.endDate.rawValue; if(TR.cmp.settings.ouMode.getValue()!="" ){ params += '&ouMode=' + TR.cmp.settings.ouMode.getValue(); } - // Order-by - - if(TR.state.asc!=""){ - params += '&asc=' + TR.state.asc; - } - else if(TR.state.desc!=""){ - params += '&desc=' + TR.state.desc; - } - // Paging params += '&page=' + TR.state.currentPage; - // Get searching values - - params ; - - // Organisation unit - // User orgunits if( Ext.getCmp('userOrgunit').getValue() === true ){ @@ -1998,7 +1894,48 @@ params += '&dimension=' + filter; } }); - + + var reportType = Ext.getCmp('reportTypeGroup').getValue().reportType; + if(reportType=='true') + { + // Order-by + + if(TR.state.asc!=""){ + params += '&asc=' + TR.state.asc; + } + else if(TR.state.desc!=""){ + params += '&desc=' + TR.state.desc; + } + } + else{ + if(Ext.getCmp('limitOption').getValue()!==null){ + params += '&limit=' + Ext.getCmp('limitOption').getValue(); + } + + params += '&position=' + TR.state.aggregateReport.getPosition(); + if( Ext.getCmp('dataElementGroupByCbx').getValue() != null ){ + params += '&deGroupBy=' + Ext.getCmp('dataElementGroupByCbx').getValue().split('_')[1]; + } + + // Relative periods + var rperiod = TR.cmp.params.relativeperiod.checkbox; + var period = ''; + Ext.Array.each(rperiod, function(item) { + if(item.getValue() && !item.hidden){ + period += item.paramName + ";"; + } + }); + if( period.length > 0 ){ + period = period.substr(0,period.length-1); + params += '&dimension=pe:' + period; + } + + // Sort-order + if( TR.state.sortOrder!= '' ){ + params += '&sortOrder=' + TR.state.sortOrder; + } + } + return params; }, @@ -2020,13 +1957,7 @@ if( type) { - var completedEvent=''; - if( Ext.getCmp('completedEventsOpt').getValue() == true) - { - completedEvent = "&completedEventsOpt=true"; - } - - document.location = url + programId + ".xls?stage=" + programStageId + completedEvent + TR.state.getURLParams(); + document.location = url + programId + ".xls?stage=" + programStageId + TR.state.getURLParams(); } // Show report on grid else @@ -2146,34 +2077,22 @@ aggregateReport: { generate: function( type ) { + // Validation if( !TR.state.aggregateReport.validation.objects() ) { return; } + // Get url var programId = Ext.getCmp('programCombobox').getValue(); var programStageId = TR.cmp.params.programStage.getValue(); var url = TR.conf.finals.ajax.path_api + TR.conf.finals.ajax.generateaggregatereport_get; - // Export to XLS + + // Export to XLS if( type) { - TR.state.aggregateReport.getURLParams(); - var completedEvent=''; - if( Ext.getCmp('completedEventsOpt').getValue() == true ) - { - completedEvent = "&completedEventsOpt=true"; - } - - var displayTotals='&displayTotals=false'; - if( Ext.getCmp('displayTotalsOpt').getValue() == true ) - { - displayTotals = "&displayTotals=true"; - } - - var exportForm = document.getElementById('exportForm'); - exportForm.action = url + "?type=" + type + completedEvent + "&" + displayTotals; - exportForm.submit(); + document.location = url + programId + ".xls?stage=" + programStageId + TR.state.getURLParams(); } // Show report on grid else @@ -2421,13 +2340,6 @@ TR.util.list.addOptionToList(endDateList, r.data.endDate, ''); }); - // Fixed periods - - var fixedPeriodList = document.getElementById('fixedPeriods'); - TR.util.list.clearList(fixedPeriodList); - TR.cmp.params.fixedperiod.selected.store.each( function(r) { - TR.util.list.addOptionToList(fixedPeriodList, r.data.id, ''); - }); // Relative periods @@ -2452,6 +2364,8 @@ return false; } + // Validate date + if( TR.cmp.settings.startDate.rawValue != "" && !TR.cmp.settings.startDate.isValid() ) { @@ -2467,19 +2381,12 @@ TR.util.notification.error( message, message); return false; } - - if (TR.state.orgunitIds.length == 0 - && TR.cmp.aggregateFavorite.userorganisationunit.getValue() == 'false' - && TR.cmp.aggregateFavorite.userorganisationunitchildren.getValue() == 'false' ) { - TR.util.notification.error(TR.i18n.et_no_orgunits, TR.i18n.em_no_orgunits); - return false; - } - if( TR.store.dateRange.data.length==0 - && TR.cmp.params.fixedperiod.selected.store.data.items.length == 0 ) + if( TR.cmp.settings.startDate.rawValue=="" + && TR.cmp.settings.startDate.rawValue == "" ) { - var relativePeriodList = TR.cmp.params.relativeperiod.checkbox; var flag = false; + var relativePeriodList = TR.cmp.params.relativeperiod.checkbox; Ext.Array.each(relativePeriodList, function(item) { if(item.getValue()){ flag = true; @@ -2493,6 +2400,17 @@ } } + // Validate orgunit + + if (TR.state.orgunitIds.length == 0 + && TR.cmp.aggregateFavorite.userorganisationunit.getValue() == 'false' + && TR.cmp.aggregateFavorite.userorganisationunitchildren.getValue() == 'false' ) { + TR.util.notification.error(TR.i18n.et_no_orgunits, TR.i18n.em_no_orgunits); + return false; + } + + // Validate data element + var isValid = true; TR.cmp.params.dataelement.selected.store.each( function(r) { var deId = r.data.id; @@ -2523,10 +2441,7 @@ { periodInt++; } - if( TR.cmp.params.fixedperiod.selected.store.data.items.length > 0 ) - { - periodInt++; - } + var relativePeriodList = TR.cmp.params.relativeperiod.checkbox; Ext.Array.each(relativePeriodList, function(item) { if(item.getValue()){ @@ -2571,7 +2486,11 @@ // Check filter by period if( p == 3 ) { - var noPeriod = TR.store.dateRange.data.length + TR.cmp.params.fixedperiod.selected.store.data.length; + var noPeriod = 0; + if( TR.cmp.settings.startDate.rawValue!="" && TR.cmp.settings.startDate.rawValue!="" ){ + noPeriod++; + } + var relativePeriodList = TR.cmp.params.relativeperiod.checkbox; Ext.Array.each(relativePeriodList, function(item) { if(item.getValue() && !item.hidden @@ -2662,12 +2581,18 @@ TR.datatable = { datatable: null, getDataTable: function() { - var cols = this.createColTable(); + var cols = []; + var reportType = Ext.getCmp('reportTypeGroup').getValue().reportType; + if( reportType===true ){ + cols = this.createCaseColTable(); + } + else{ + cols = this.createAggColTable(); + } // title var title = TR.cmp.settings.program.rawValue + " - " + TR.cmp.params.programStage.rawValue + " " + TR.i18n.report; - if(Ext.getCmp('reportTypeGroup').getValue().reportType=='false') - { + if(reportType===false){ title = TR.value.title; } @@ -2679,15 +2604,19 @@ items: cols, listeners: { headerclick: function(container, column, e) { - if( column.sortable ) - { - if(column.sortState=='ASC'){ - TR.state.asc = column.dataIndex; - TR.state.desc = ""; + if( column.sortable ){ + if( reportType === true ){ + if(column.sortState=='ASC'){ + TR.state.asc = column.dataIndex; + TR.state.desc = ""; + } + else{ + TR.state.asc = ""; + TR.state.desc = column.dataIndex; + } } else{ - TR.state.asc = ""; - TR.state.desc = column.dataIndex; + TR.state.sortOrder = column.sortState; } TR.exe.execute(false, true ); } @@ -2793,7 +2722,7 @@ return this.datatable; }, - createColTable: function(){ + createCaseColTable: function(){ var cols = []; for( var i =0; i ' + TR.i18n.date_period_range + '', - id: 'datePeriodRangeDiv', - hideCollapseTool: true, - autoScroll: true, - items: [ - { - xtype: 'datefield', - cls: 'tr-textfield-alt1', - id: 'startDateRange', - fieldLabel: TR.i18n.start_date, - labelWidth: 90, - editable: true, - allowBlank:true, - emptyText: TR.i18n.select_from_date, - invalidText: TR.i18n.the_date_is_not_valid, - style: 'margin-right:8px', - width: TR.conf.layout.west_fieldset_width - 20, - format: TR.i18n.format_date, - maxValue: new Date(), - listeners: { - added: function() { - TR.cmp.settings.startDateRange = this; - }, - change:function(){ - var startDate = TR.cmp.settings.startDate.getValue(); - Ext.getCmp('endDate').setMinValue(startDate); - } - } - }, - { - xtype: 'datefield', - cls: 'tr-textfield-alt1', - id: 'endDateRange', - fieldLabel: TR.i18n.end_date, - labelWidth: 90, - editable: true, - allowBlank:true, - emptyText: TR.i18n.select_to_date, - invalidText: TR.i18n.the_date_is_not_valid, - width: TR.conf.layout.west_fieldset_width - 20, - format: TR.i18n.format_date, - maxValue: new Date(), - listeners: { - added: function() { - TR.cmp.settings.startDateRange = this; - }, - change:function(){ - var endDate = TR.cmp.settings.endDate.getValue(); - Ext.getCmp('startDate').setMaxValue( endDate ); - } - } - }, - { - xtype: 'button', - text: TR.i18n.add, - style: 'margin-left:95px; margin-bottom: 10px;', - width: 130, - height: 24, - handler: function() { - var startDate = Ext.getCmp('startDateRange').rawValue; - var endDate = Ext.getCmp('endDateRange').rawValue; - if( startDate != '' && endDate != '' - && Ext.getCmp('startDateRange').isValid() - && Ext.getCmp('endDateRange').isValid() ) - { - TR.store.dateRange.add({ - 'startDate': startDate, - 'endDate': endDate - }); - } - } - }, - { - xtype: 'button', - text: TR.i18n.clear, - style: 'margin-left:4px; margin-bottom: 10px;', - width: 130, - height: 24, - handler: function() { - if( TR.store.dateRange.data.items.length > 0 ) - { - var result = window.confirm( TR.i18n.confirm_delete_date_range_list ); - if ( result ) - { - TR.store.dateRange.loadData([],false); - } - } - } - }, - Ext.create('Ext.grid.Panel', { - style: 'border: solid 1px #D0D0D0', - width: TR.conf.layout.west_fieldset_width - 18, - store: TR.store.dateRange, - height: 205, - columns: [ - { - text: TR.i18n.start_date, - dataIndex: 'startDate', - width: 150, - menuDisabled: true, - sortable: false, - draggable: false - }, - { - text: TR.i18n.end_date, - dataIndex: 'endDate', - width: 150, - menuDisabled: true, - sortable: false, - draggable: false - }, - { - menuDisabled: true, - sortable: false, - xtype: 'actioncolumn', - width: 40, - items: [{ - icon: 'images/remove.png', - tooltip: TR.i18n.remove, - handler: function(grid, rowIndex, colIndex) { - TR.store.dateRange.removeAt(rowIndex); - } - }] - } - ] - }) - ] - }, - // RELATIVE PERIODS { title: '
' + TR.i18n.relative_periods + '
', @@ -5351,182 +5094,6 @@ } }, - // FIXED PERIODS - { - title: '
' + TR.i18n.fixed_periods + '
', - id: 'fixedPeriodsDiv', - hideCollapseTool: true, - items: [ - { - xtype: 'panel', - layout: 'column', - bodyStyle: 'border-style:none', - items: [ - { - xtype: 'combobox', - cls: 'tr-combo', - style: 'margin-bottom:8px', - width: 253, - valueField: 'id', - displayField: 'name', - fieldLabel: TR.i18n.select_type, - labelStyle: 'padding-left:7px;', - labelWidth: 90, - editable: false, - queryMode: 'remote', - store: TR.store.periodtype, - periodOffset: 0, - listeners: { - select: function() { - var pt = new PeriodType(), - periodType = this.getValue(); - var periods = pt.get(periodType).generatePeriods({ - offset: this.periodOffset, - filterFuturePeriods: true, - reversePeriods: true - }); - - TR.store.fixedperiod.available.setIndex(periods); - TR.store.fixedperiod.available.loadData(periods); - TR.util.multiselect.filterAvailable(TR.cmp.params.fixedperiod.available, TR.cmp.params.fixedperiod.selected); - } - } - }, - { - xtype: 'button', - text: 'Prev year', - style: 'margin-left:4px', - height: 24, - handler: function() { - var cb = this.up('panel').down('combobox'); - if (cb.getValue()) { - cb.periodOffset--; - cb.fireEvent('select'); - } - } - }, - { - xtype: 'button', - text: 'Next year', - style: 'margin-left:3px', - height: 24, - handler: function() { - var cb = this.up('panel').down('combobox'); - if (cb.getValue() && cb.periodOffset < 0) { - cb.periodOffset++; - cb.fireEvent('select'); - } - } - } - ] - }, - { - xtype: 'panel', - layout: 'column', - bodyStyle: 'border-style:none', - items: [ - { - xtype: 'multiselect', - name: 'availableFixedPeriods', - cls: 'tr-toolbar-multiselect-left', - width: (TR.conf.layout.west_fieldset_width - TR.conf.layout.west_width_subtractor) / 2, - height: 245, - valueField: 'id', - displayField: 'name', - store: TR.store.fixedperiod.available, - tbar: [ - { - xtype: 'label', - text: TR.i18n.available, - cls: 'tr-toolbar-multiselect-left-label' - }, - '->', - { - xtype: 'button', - icon: 'images/arrowright.png', - width: 22, - handler: function() { - TR.util.multiselect.select(TR.cmp.params.fixedperiod.available, TR.cmp.params.fixedperiod.selected); - } - }, - { - xtype: 'button', - icon: 'images/arrowrightdouble.png', - width: 22, - handler: function() { - TR.util.multiselect.selectAll(TR.cmp.params.fixedperiod.available, TR.cmp.params.fixedperiod.selected); - } - }, - ' ' - ], - listeners: { - added: function() { - TR.cmp.params.fixedperiod.available = this; - }, - afterrender: function() { - this.boundList.on('itemdblclick', function() { - TR.util.multiselect.select(this, TR.cmp.params.fixedperiod.selected); - }, this); - } - } - }, - { - xtype: 'multiselect', - name: 'selectedFixedPeriods', - cls: 'tr-toolbar-multiselect-right', - width: (TR.conf.layout.west_fieldset_width - TR.conf.layout.west_width_subtractor) / 2, - height: 245, - displayField: 'name', - valueField: 'id', - ddReorder: false, - queryMode: 'local', - store: TR.store.fixedperiod.selected, - tbar: [ - ' ', - { - xtype: 'button', - icon: 'images/arrowleftdouble.png', - width: 22, - handler: function() { - TR.util.multiselect.unselectAll(TR.cmp.params.fixedperiod.available, TR.cmp.params.fixedperiod.selected); - } - }, - { - xtype: 'button', - icon: 'images/arrowleft.png', - width: 22, - handler: function() { - TR.util.multiselect.unselect(TR.cmp.params.fixedperiod.available, TR.cmp.params.fixedperiod.selected); - } - }, - '->', - { - xtype: 'label', - text: TR.i18n.selected, - cls: 'tr-toolbar-multiselect-right-label' - } - ], - listeners: { - added: function() { - TR.cmp.params.fixedperiod.selected = this; - }, - afterrender: function() { - this.boundList.on('itemdblclick', function() { - TR.util.multiselect.unselect(TR.cmp.params.fixedperiod.available, this); - }, this); - } - } - } - ] - } - ], - listeners: { - added: function() { - TR.cmp.params.fixedperiod.panel = this; - } - } - }, - // ORGANISATION UNIT { title: '
' + TR.i18n.organisation_units + '
', @@ -6428,13 +5995,8 @@ Ext.getCmp('downloadPdfIcon').setVisible(false); Ext.getCmp('downloadCvsIcon').setVisible(false); Ext.getCmp('aggregateFavoriteBtn').setVisible(false); - Ext.getCmp('datePeriodRangeDiv').setVisible(false); - Ext.getCmp('displayTotalsOpt').setVisible(false); Ext.getCmp('caseBasedFavoriteBtn').setVisible(true); - Ext.getCmp('dateRangeDiv').setVisible(true); Ext.getCmp('relativePeriodsDiv').setVisible(false); - Ext.getCmp('fixedPeriodsDiv').setVisible(false); - Ext.getCmp('dateRangeDiv').expand(); TR.state.orgunitIds = []; for( var i in TR.init.system.rootnodes){ === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js 2013-10-02 10:14:05 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js 2013-10-03 04:32:03 +0000 @@ -820,15 +820,14 @@ function removeEvent( programStageId ) { var s = "" + programStageId; - if( s.indexOf("local") != -1 ) { - if( confirm(i18n_comfirm_delete_event) ) { - DAO.store.delete('dataValues', programStageId).always(function() { + if( s.indexOf("local") != -1) { + if ( confirm( i18n_comfirm_delete_event ) ) { + DAO.store.delete( 'dataValues', programStageId ).always( function () { updateOfflineEvents(); - setTimeout(updateOfflineEvents, 200); - }); + } ); } } else { - removeItem(programStageId, '', i18n_comfirm_delete_event, 'removeCurrentEncounter.action'); + removeItem( programStageId, '', i18n_comfirm_delete_event, 'removeCurrentEncounter.action' ); } }