9 Replies Latest reply on Dec 16, 2010 9:25 AM by Roenti

    Enhancement of SampleTimesheet.pdf how to request

    Roenti

      First off, thank you GKaiseril for your May 29, 2009 10:24 AM "Sample Timesheet with Total as Decimal Hours and Hours and Minutes" thread. It was exactly what I needed.

       

      I'm working on a project that takes that sample Timesheet one step further by useing the generated total to auto fill two seperate text fields labeled RegT and OT respectively. I'm coming up short with keyword searches and thus the reason for this post.

       

      // I'm a nob to scripting/programming so please bear with me as I iron out the learning curve.

      //My thought proccess is this.

       

      //Total hours worked Reg/OT auto gen filled sections in user saveable adobe pdf file.

       

      //Regular Time output

      If a(total hours worked) >= 8

      then = 8

      else a = 1*

       

      //Over Time output

      If a(total hours worked) <= 8

      Then = 0

      else a - 8


      //End

       

       

      I confident that the code should be applied to the text field properties calculate section. I just don't know how to code it. Any and all assistance will be greatly appreciated.

       

      Thank you.

        • 1. Re: Enhancement of SampleTimesheet.pdf how to request
          Roenti Level 1

          I'm not sure if I'm understanding my reference material correctly.

           

          I keep getting this error

          "missing ; before statement 3: at line 4"

           

          Here is the script I've typed up and its generating the error message.

           

          event.value = '';
          // get the Total time
          var sThrs = this.getField('total.TT').value;
          // get the Regular Time
          var sRhrs = this.getField('RegTh').value;
          //get the Over Time
          Var sOhrs = this.getField('OverTh').value;
          if(sThrs = >=8)
          {
             Ohrs = sThrs - 8
          }
          else
          {
             sRhrs = sThrs * 1
          }
          // complete script only if we have data
          if(sStart != '') {
          // convert sTHours string to seconds
          var fTHours = Time2Num('hh:mm', sThrs);
          // convert sRHours string to seconds
          var fRHours = Time2Num('hh:mm', sRhrs);
          // convert sRHours string to seconds
          var fRHours = Time2Num('hh:mm', sOhrs);
          // compute difference in seconds
          var fDiff = fRhrs - fThrs;
          // convert to rounded minutes
          // report decimal hours
          event.value = fDiff / 60;
          fDiff = Math.round(fDiff / 60);
          // compute difference in seconds
          var fDiff = fOhrs - fThrs;
          // convert to rounded minutes
          fDiff = Math.round(fDiff / 60);
          // report decimal hours
          event.value = fDiff / 60;
          }

           

           

          I really don't know if Im correctly understanding these programmin concepts. I neeeeed just a little push in the right direction if anyone is availabe. I'm wondering if the Total.TT should be called up as an int instead of a var? Any and all assistance would be greatly appreciated. Thank you

          • 2. Re: Enhancement of SampleTimesheet.pdf how to request
            George_Johnson MVP & Adobe Community Professional

            There are at least two problems. The first is you use Var instead of var, and:

             

            if(sThrs = >=8)

             

            instead of:

             

            if (sThrs >= 8)

             

            Also, there is no int type in JavaScript.

            1 person found this helpful
            • 3. Re: Enhancement of SampleTimesheet.pdf how to request
              Roenti Level 1

              Thank you George
              I have re-analyzedr the code and it no longer generates error msges. however my Time sheet forum  Regular time and Over Tare are not being calculated and ore remaining blank. is the code correct now or have i made another noobie mistake?

               

              event.value = '';

               

              //get the Total time

               

              var sThrs = this.getField('Total.TT').value;

               

              //get the Regular Time

               

              var sRhrs = this.getField('RegTh').value;

               

              //get the Over Time

               

              var sOhrs = this.getField('OverTh').value;

               

              if (sThrs >=8)

               

              OverTh = 8 - sThrs

               

              else

               

              sRhrs = sThrs * 1

               

              //complete script only if we have data

               

              if(sStart != '') {

               

              //convert sTHours string to seconds

               

              var fTHours = Time2Num('hh:mm', sThrs);

               

              //convert sRHours string to seconds

               

              var fRHours = Time2Num('hh:mm', sRhrs);

               

              //convert sRHours string to seconds

               

              var fRHours = Time2Num('hh:mm', sOhrs);

               

              //compute difference in seconds

               

              var fDiff = fRhrs - fThrs;

               

              //convert to rounded minutes

               

              //report decimal hours

               

              event.value = fDiff / 60;

               

              fDiff = Math.round(fDiff / 60);

               

              //compute difference in seconds

               

              var fDiff = fOhrs - fThrs;

               

              //convert to rounded minutes

               

              fDiff = Math.round(fDiff / 60);

               

              //report decimal hours

               

              event.value = fDiff / 60;

               

              }

               

               

               

               


              it is finally passing

              • 4. Re: Enhancement of SampleTimesheet.pdf how to request
                George_Johnson MVP & Adobe Community Professional

                You have this line:

                 

                if(sStart != '') {

                 

                 

                but I don't see where this value is set anywhere. What is sStart supposed to come from?

                1 person found this helpful
                • 5. Re: Enhancement of SampleTimesheet.pdf how to request
                  Roenti Level 1

                  How do I add a PDF file to a reply?.

                  • 6. Re: Enhancement of SampleTimesheet.pdf how to request
                    George_Johnson MVP & Adobe Community Professional

                    You cannot, but some folks post to a web server. If you don't have access to one, try using Acrobat.com. You have to share (publish) the document and post the link here.

                    • 7. Re: Enhancement of SampleTimesheet.pdf how to request
                      Roenti Level 1

                      Ok hopefully this works. If it does work then you should see a downloadable

                      pdf file.

                       

                      I'm not a programmer. I dabbled with HTML coding about 15 years ago for a

                      class project. I have a beginners lvl text book on VB as a on hand resource.

                      I've been searching the web for script examples.

                       

                      I hope the attachment helps you help me. All assistance is appreciated.

                       

                      Thank you.

                      • 9. Re: Enhancement of SampleTimesheet.pdf how to request
                        Roenti Level 1

                        Ignore the part at the top where it says "This question is Answered" I still need help. I just finished successfully getting the pdf file available for review. George post helped resolve that issue. I'm learning as I go here. Thank you for your patience and all assitance; it is appreciated.