Announcement

Collapse
No announcement yet.

best way to return number of hours

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • best way to return number of hours

    hello i try to create a pdf with an hour information
    1 i have 3 fields to day participation in my entity (day1, day2, day3)
    2 user can subscribe each day
    3 in my pdf template i need to display a sum of hours regarding days selected (1 day = 7h, 2 days = 14h, 3 days = 21h)
    thanks for helping

  • #2
    Hi yberges,

    At the moment, I see one solution as follows: create a field of the Varchar type (for example, sumOfHours) and in the entity formula, add the following lines:
    Code:
    ifThen(
        array\includes(days, 'day1'),
        sumOfHours = '7h'
        );
    
    ifThen(
        array\includes(days, 'day2'),
        sumOfHours = '14h'
        );
    
    ifThen(
        array\includes(days, 'day3'),
        sumOfHours = '21h'
        );
    
    ifThen(
        array\includes(days, 'day1') && array\includes(days, 'day2'),
        sumOfHours = '21h'
        );
    
    ifThen(
        array\includes(days, 'day1') && array\includes(days, 'day3'),
        sumOfHours = '28h'
        );
    
    ifThen(
        array\includes(days, 'day2') && array\includes(days, 'day3'),
        sumOfHours = '35h'
        );
    
    ifThen(
        array\includes(days, 'day1') && array\includes(days, 'day2') && array\includes(days, 'day3'),
        sumOfHours = '42h'
        );
    
    ifThen(
        array\length(days) == 0,
        sumOfHours = '0h'
        );​
    Just don't forget to change the word days to the name of the field that stores day1, day2, day3 values. Also, it is very important that they are called that way in the field settings, otherwise they will need to be changed to the appropriate ones.​ Then just paste the placeholder for this field into the PDF Template.​

    If you have any difficulties or problems with this solution, or if you need to explain something, I will be happy to help you.

    Comment


    • #3
      Many thanks ! i will try

      Comment


      • #4
        hello
        a question because all return 0h
        Code:
        ifThen(
            array\includes(inscMardiEnum, 'day1'),
            nombreDheureDeFormation = '7h'
            );​
        taht say :
        if inscMardiEnum have value 'day1' nombreDheureDeFormation is equal to 7h
        or
        inscMardiEnum have a value ?
        inscMardiEnum is a dropdown with Yes or No value
        regards

        Comment


        • #5
          lazovic some return ?

          Comment


          • #6
            yberges,

            Please show me the settings of your inscMardiEnum and nombreDheureDeFormation fields so that I can analyze in detail what could be wrong.

            Comment


            • #7
              hello here the screenshot
              Click image for larger version

Name:	2023-02-01_11h10_08.png
Views:	139
Size:	43.3 KB
ID:	87697
              Click image for larger version

Name:	2023-02-01_11h10_24.png
Views:	106
Size:	47.2 KB
ID:	87698
              Thanks for your help

              Comment


              • #8
                yberges,

                Thank you for additional information.

                The following formula will work if:
                • Fields for days have the same option settings (meaning that each field has the same Non and Oui options);
                • The field for the Wednesday is (presumably) named inscMercrediEnum, otherwise, just replace this field in formula with the name of your field.
                Please try this formula and let me know if everything went well.​

                Code:
                ifThen(
                inscMardiEnum = 'Non' && inscMercrediEnum = 'Non' && inscrJeudiEnum​ = 'Non',
                nombreDheureDeFormation = '0h'
                );
                
                ifThen(
                inscMardiEnum = 'Non' && inscMercrediEnum = 'Non' && inscrJeudiEnum​ = 'Oui',
                nombreDheureDeFormation = '7h'
                );
                
                ifThen(
                inscMardiEnum = 'Non' && inscMercrediEnum = 'Oui' && inscrJeudiEnum​ = 'Non',
                nombreDheureDeFormation = '7h'
                );​
                
                ifThen(
                inscMardiEnum = 'Oui' && inscMercrediEnum = 'Non' && inscrJeudiEnum​ = 'Non',
                nombreDheureDeFormation = '7h'
                );​
                
                ifThen(
                inscMardiEnum = 'Oui' && inscMercrediEnum = 'Oui' && inscrJeudiEnum​ = 'Non',
                nombreDheureDeFormation = '14h'
                );​
                
                ifThen(
                inscMardiEnum = 'Oui' && inscMercrediEnum = 'Non' && inscrJeudiEnum​ = 'Oui',
                nombreDheureDeFormation = '14h'
                );​
                
                ifThen(
                inscMardiEnum = 'Non' && inscMercrediEnum = 'Oui' && inscrJeudiEnum​ = 'Oui',
                nombreDheureDeFormation = '14h'
                );​
                
                ifThen(
                inscMardiEnum = 'Oui' && inscMercrediEnum = 'Oui' && inscrJeudiEnum​ = 'Oui',
                nombreDheureDeFormation = '21h'
                );​

                Comment


                • #9
                  that works 100000 thanks !

                  Comment

                  Working...
                  X