@@ -137,9 +137,10 @@ class Record_Manager {
137137 }
138138 //artificially populate the CURRENT PEN value - we want to know where the cow moved from
139139 if ( $ ( "#CURRENT_PEN" ) . val ( ) == 0 ) {
140- for ( var i = this . json_data . length ; i > 0 ; i -- ) {
140+ console . log ( "Artificially populate the CURRENT PEN" )
141+ for ( var i = 1 ; i < this . json_data . length ; i ++ ) {
141142 // populate the "CURRENT PEN" value with the previous record matching the cow id
142- for ( var j = i - 1 ; j > this . json_data . length ; j -- ) {
143+ for ( var j = i - 1 ; j > 0 ; j -- ) {
143144 if ( this . json_data [ i ] [ "ID" ] == this . json_data [ j ] [ "ID" ] ) {
144145 this . json_data [ i ] [ "CURRENT PEN" ] = this . json_data [ j ] [ "TO PEN" ]
145146 break
@@ -148,8 +149,8 @@ class Record_Manager {
148149 }
149150 }
150151 $ ( "#model_data_config" ) . hide ( )
151- record_manager . process_data ( record_manager . json_data , record_manager ) ;
152152
153+ record_manager . process_data ( record_manager . json_data , record_manager ) ;
153154
154155 }
155156
@@ -384,17 +385,19 @@ class Record_Manager {
384385 // called with event_data["sick"],"FLU","WELL",end_date)
385386 // create a sub set of the data
386387 //any record that has an EVENT labeled {_event_start} should have a record
387- //console.log("populate_days", _end_date)
388+ //console.log("populate_days", _end_date,_array )
388389 for ( var i = 0 ; i < this . json_data . length ; i ++ ) {
389390 var t = this . json_data [ i ] ;
391+
390392 var end_date = false
391393 if ( t [ "EVENT" ] . trim ( ) == _event_start ) {
392394
393395 // find the end date which should be ahead
394396 if ( _event_end && _event_end != "" ) {
395397 for ( var j = i + 1 ; j < this . json_data . length ; j ++ ) {
396398 var u = this . json_data [ j ]
397- // make sure the next event is later than the first and matched the desired end event name
399+ // make sure the next event is later than the first and matches the desired end event name
400+
398401 if ( u [ "ID" ] == t [ "ID" ] && u [ "EVENT" ] . trim ( ) == _event_end && moment ( t [ "START DATE" ] , this . date_format ) . unix ( ) < moment ( u [ "START DATE" ] , this . date_format ) . unix ( ) ) {
399402// console.log("Closing t",t, "with u",u)
400403 end_date = moment ( u [ "START DATE" ] , this . date_format ) . unix ( )
0 commit comments