You are viewing limited content. For full access, please sign in.

Question

Question

Labels printing incorrectly to PDF

asked on September 11, 2017 Show version history

I have a form that I am updating the labels based on a date entered at the beginning of the form.

When the form is submitted, the date labels display correctly.

It is only when the user either downloads the form after submission or the form is saved to Laserfiche that the date labels display 2 months and 21 days off.

For instance, the date labels when the form is submitted is "09/09 Saturday". When the form is downloaded, the date label displays "11/30 Wednesday". The day of the week is incorrect as well. It should read "11/30 Thursday".

When I hard-code the parse_date (EX: parse_date = new Date (2017,8,9), the form will display in forms correctly and also download correctly displaying the correct lables.  

Please see javascript below: 

function datelabels(){
	
	//Initialize Variables
    var str_date, parse_date;
    var arr_date = new Array (), arr_labels = new Array ();
  
    //Assign str_date
    str_date = $('.payperiod div[type="text"]').text();
    if(str_date === ''){ str_date = $('.payperiod input').val(); }

    
    
    //BEGIN PROCESS - If Empty
    if(str_date !== ''){
    	//Get Year, Month, and Day
      	arr_date = str_date.split('/');

     		
        //Build Labels List for All Tables
      	for(var i = 13; i > -1; i--){
            
      		parse_date = new Date(parseInt(arr_date[2]), parseInt(arr_date[0]) - 1, parseInt(arr_date[1]));
      		parse_date.setDate(parse_date.getDate() - i);
      		str_date = addZero(parse_date.getMonth(), 'm') + '/' + addZero(parse_date.getDate(),'d') + ' ' +  getDayString(parse_date.getDay());
                                                                       
          //str_date = addZero(parse_date.getMonth(), 'm') + '/' + addZero(parse_date.getDate(), 'd') + ' ' + getDayString(parse_date.getDay());
          
            arr_labels.push(str_date);
            
    	} //END OF FOR LOOP
      	
        
        i = 0;//Counter For Retrieve Dates From Array
      	
      	//IF COLUMN NAMES CHANGE, UPDATE THIS CODE!!!!
	    $('.wlabels tr th label').each(function(){
          if($(this).html() !== 'Payroll Use'){
            if($(this).html() !== 'Total'){
              $(this).html(arr_labels[i]);
              i++;
            } else { i = 0; }
          }
      	});
    
     
    } //END OF PROCESS   
  
  }//END OF datelabels FUNCTION
  
  
  function addZero(num, type){
    if(type === 'm'){
      num = num + 1;
    }
    if(num < 10){
     num = '0' + num; 
    }
    
    return num;
  } //END OF addZero FUNCTION
  
  
  function getDayString(num){
    var day;    //Create a local variable to hold the string
    switch(num)
    {
      case 0:
        day="Sun";
        break;
      case 1:
        day="Mon";
        break;
      case 2:
        day="Tues";
        break;
      case 3:
        day="Wed";
        break;
      case 4:
        day="Thurs";
        break;
      case 5:
        day="Fri";
        break;
      case 6:
        day="Sat";
        break;
      default:
        day="Invalid day";
    }
    return day;
  }  //END OF getDayString FUNCTION

 

0 0

Answer

SELECTED ANSWER
replied on September 11, 2017 Show version history

I found the issue. I had to replace "ParseInt()" with "Number()" function.

I know this wasn't an issue when Laseriche provided me the script in the answers article below. 

Would Laserfiche know why this would cause an issue when Forms is generating a PDF?

 http://answers.laserfiche.com/questions/117391/Form-not-displaying-correct-label-for-fields#117401

1 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.