From 2ff71abaaf707c0209967c7998651174cefb0be5 Mon Sep 17 00:00:00 2001 From: Hacene SI HADJ MOHAND Date: Mon, 28 Jun 2021 14:39:11 +0200 Subject: [PATCH] correcting survey dates update --- js/app/views/CatalogUI.js | 53 +++++++++++++++++++++++++++++++++++++++-------------- php/classes/TimeTableMgr.php | 21 ++++++++++++++++++++- 2 files changed, 59 insertions(+), 15 deletions(-) diff --git a/js/app/views/CatalogUI.js b/js/app/views/CatalogUI.js index 0a3cf7e..3f546df 100644 --- a/js/app/views/CatalogUI.js +++ b/js/app/views/CatalogUI.js @@ -153,25 +153,51 @@ Ext.define('amdaUI.CatalogUI', { var stops= []; if (this.TTGrid.getStore().getTotalCount() <= 0) return; - Ext.Array.each(this.TTGrid.getStore().data.first.value, function (item, index) { - starts[index] = (item.raw.start); - stops[index] = (item.raw.stop); + reqObj = { + 'typeTT': 'catalog', + } + AmdaAction.readCacheIntervals(reqObj, function(result, e) + { + if (!result) { + myDesktopApp.errorMsg(e.message); + Ext.defer(function () { + Ext.Msg.toFront() + }, 10); + + return; + } else if (!result.success) + { + if (result.message) + myDesktopApp.errorMsg(result.message); + else + myDesktopApp.errorMsg('Unknown error during catalog survey dates update'); + + Ext.defer(function () { + Ext.Msg.toFront() + }, 10); + + return; + } + Ext.Array.each(result.intervals, function (item, index) { + starts[index] = (item.start); + stops[index] = (item.stop); }); if(starts.length !== 0 || stops.length !== 0) { - starts.sort(); - stops.sort(); - s = new Date(starts[0]); - e = new Date(stops[stops.length - 1]); - if(! ttObj.get('surveyStart') ){ + starts.sort(); + stops.sort(); + s = new Date(starts[0]); + e = new Date(stops[stops.length - 1]); + if(! ttObj.get('surveyStart') ){ ttObj.set('surveyStart', s); this.status.isModified = true; - } - if(! ttObj.get('surveyStop') ){ + } + if(! ttObj.get('surveyStop') ){ ttObj.set('surveyStop', e); this.status.isModified = true; + } } - } + }); }, createTT: function (catId) { @@ -183,7 +209,7 @@ Ext.define('amdaUI.CatalogUI', { descr = 'Generated by CDPP/Amda Catalog Module \n' + 'From Catalog: ' + this.object.get('name') + '\nOn: ' + date + '\n'; ttObj.set('description', descr + this.object.get('description')); ttObj.set('contact', this.object.get('contact')); - this.updateSurveyDates(ttObj); + //this.updateSurveyDates(ttObj); timeTabNode.set('object', ttObj); var explorerTree = Ext.getCmp(amdaUI.ExplorerUI.RESRC_TAB.TREE_ID); var ttRootNode = explorerTree.getRootNode().findChild('id', 'timeTable-treeRootNode', true); @@ -619,7 +645,6 @@ Ext.define('amdaUI.CatalogUI', { loadObject: function () { // load object into form this.object.set('created', this.convertUTCDateToLocalDate(this.object.get('created'))); - this.updateSurveyDates(this.object); this.formPanel.getForm().loadRecord(this.object); this.status = null; @@ -721,7 +746,7 @@ Ext.define('amdaUI.CatalogUI', { if (this.TTGrid.getStore().getTotalCount() > 0) { // update TimeTable object which the content of form - this.updateSurveyDates(this.object); + basicForm.updateRecord(this.object); var me = this; this.checkIntervalsStatusForSave(function () { diff --git a/php/classes/TimeTableMgr.php b/php/classes/TimeTableMgr.php index c79195d..1e9a1cc 100644 --- a/php/classes/TimeTableMgr.php +++ b/php/classes/TimeTableMgr.php @@ -87,10 +87,29 @@ class TimeTableMgr extends AmdaObjectMgr if ($attribute->tagName != 'intervals') { $attributesToReturn[$attribute->tagName] = $attribute->nodeValue; } else { - $nbInt++; + + // get 'surveyStart' and + if($attributesToReturn['surveyStart'] == "" || $attributesToReturn['surveyStop'] == "" ){ + if($nbInt == 0){ + foreach ($attribute->childNodes as $ch ){ + if($ch->tagName == 'start') $start = $ch->nodeValue; + if($ch->tagName == 'stop') $stop = $ch->nodeValue; + } + }else{ + foreach ($attribute->childNodes as $ch ){ + if($ch->tagName == 'start' && $start > $ch->nodeValue) $start = $ch->nodeValue; + if($ch->tagName == 'stop' && $stop < $ch->nodeValue) $stop = $ch->nodeValue; + } + } + } + $nbInt++; } } } + if($attributesToReturn['surveyStart'] == "") + $attributesToReturn['surveyStart'] = $start; + if($attributesToReturn['surveyStop'] == "" ) + $attributesToReturn['surveyStop'] = $stop; $attributesToReturn['nbIntervals'] = $nbInt; return $attributesToReturn; -- libgit2 0.21.2