

<xxtr >

<xxtd class="fitlabel xtext-left">
  
</xxtd>

   <div <SUB readonlyDisplay> style=" background: gray; " xxclass="float-right">      
    Add Indexes For Year
    Add Single Index
    
    <select id=milestoneIndexYear class="p-1 m-1 xbtn xbtn-light ml-1 float-right"> 
      <option value="">Choose Year</option>
      <option value="2022">2022</option>
      <option value="2023">2023</option>
      <option value="2024">2024</option>
      <option value="2025">2025</option>  
    </select>
    
    <select id=milestoneIndexMonth class="p-1 m-1 xbtn xbtn-light ml-1 float-right">
      <option value="">Choose month</option>    
      <option value="Jan">Jan</option>
      <option value="Feb">Feb</option>
      <option value="Mar">Mar</option>
      <option value="Apr">Ap</option>
      <option value="May">May</option>
      <option value="Jun">Jun</option>
      <option value="Jul">Jul</option>
      <option value="Aug">Aug</option>
      <option value="Sep">Sep</option>
      <option value="Oct">Oct</option>
      <option value="Nov">Nov</option>
      <option value="Dec">Dec</option>    
    </select>
  
  
Exception Report 

</xxtr>

function showBreakdown() {  
   fitDialogUrl(window.event, { url: "<SUB URLADD>?page=alcea.custom.noirlab.ExceptionReport&bugId=<SUB bs.mId>", big: true, title: "Exception Report" } );
}

var latestNewIds = "";

var ms1 = ["Oct", "Nov", "Dec"];
var ms2 = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep'];

function addMilestonesForYear() {
  var year = jQuery("#milestoneIndexYear").val();
  if (year.length==0) {
    alert("Choose Year First");
    return;
  }
  
  fitToast(event, "Adding Milestone Indexes");
  
  for (let i=ms2.length-1; i>=0; i--) {
    let monthYear = ms2[i] + "-" + year;
    addMilestoneIndex(monthYear);
  }
  for (let i=ms1.length-1; i>=0; i--) {
    let monthYear = ms1[i] + "-" + (parseInt(year)-1);
    addMilestoneIndex(monthYear);
  }
  
}

function addSingleMilestoneIndex(showInfo) {
	var month = jQuery("#milestoneIndexMonth").val();
	if (month.length==0) {
	  alert("Choose Month First");
	  return;
	}
	
  var year = jQuery("#milestoneIndexYear").val();
  if (year.length==0) {
    alert("Choose Year First");
    return;
  }
  
  fitToast(event, "Adding Milestone : " + monthYear);
  
	var monthYear = month + "-" + year;
	addMilestoneIndex(monthYear);
	
}

function addMilestoneIndex(monthYear) {

	var milestoneIndexContext = 5;
	var otherFieldId = 8;
	var initialParentField = 19;
	
	//var proj = jQuery("mProject").val();
	var proj = fitFieldValue("mProject");
	
	var bugParms = "&mSubject=xxx" +
	               "&field7=" + monthYear +
	               "&mProject=" + proj +
	               
	               "&field"+otherFieldId+"=<SUB bs.mId>" +
	               "&fromNewRelButton="+otherFieldId;

  var ret = true;
  jQuery.ajax({
    type: 'get',
    url: mmUrlAddNoContext + 
         '&CONTEXT=' + milestoneIndexContext +
         '&page=com.other.SubmitBug' +
         //'&checkForStaleData=1' +
         //'&mId=<SUB bs.mId>' +
         //'&staleDataCheck=<SUB staleDataCheck>' +
         bugParms +
         '&makeUniqueUrl=' +  (new Date().valueOf()),
    async: false,
    success: function(output, status, xhr) {
      var newId = xhr.getResponseHeader("FITbsId");
      if (newId!=null && newId.length>0) {
        latestNewIds+=newId+" ";
        updateRelationship = initialParentField;
        updateTrackRelationship(newId);
      } else {
        var errorMessage = xhr.getResponseHeader("FITerrorMessage");
        fitInfo(window.event, errorMessage);
      }
    },
    failure: function(t) {
      fitInfo(window.event, "Connection Failure: "+t);
    }
  });
                   
  return ret;
                   
}

	 //# MilestoneToIndexCustomUserField.js
