Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. <script>
  2. <assign var="max_days">5</assign> <!-- Maximum days to be returned -->
  3. <assign var="total_days_worked">0</assign> <!-- Number of days worked, to be returned -->
  4. <assign var="days_total"></assign> <!-- total hours per day will be saved here as associative array with the date as index-->
  5.  
  6. <!-- build the days index array -->
  7. <loop var="timesheets">
  8. <perform>
  9. <assign var="sttime"><atom var="this" index="StartTime" /></assign>
  10. <dateprint format="Y-m-d" input="$sttime" assign="curent_date" />
  11. <!--<function assign="curent_date">php:function('date','Y-m-d' , number(sttime))</function>-->
  12. <assign var="days_total" index="$curent_date">0</assign>
  13. <!-- initiate the array as 0 -->
  14. </perform>
  15. </loop>
  16.  
  17. <!-- Loop through time sheets and assign them to the days (arbitrarily total up hours) -->
  18. <loop var="timesheets">
  19. <perform>
  20. <assign var="tstotal"><atom var="this" index="TotalTime" /></assign>
  21. <assign var="sttime"><atom var="this" index="StartTime" /></assign>
  22. <dateprint format="Y-m-d" input="$sttime" assign="curent_date" />
  23. <!--<function assign="curent_date">php:function('date','Y-m-d' , number(sttime))</function>-->
  24. <assign var="currentDayTotal"><atom var="days_total" index="$curent_date" /></assign>
  25. <math op="+" arg1="$currentDayTotal" arg2="$tstotal" assign="fltTotal"/>
  26. <assign var="days_total" index="$curent_date" ><atom var="fltTotal"/></assign>
  27. <!--<function assign="days_total" index="$curent_date">(currentDayTotal + tstotal)</function>-->
  28. </perform>
  29. </loop>
  30.  
  31. <!-- sort the days with date -->
  32. <sort var="days_total" with="key" assign="days_total"/>
  33.  
  34. <!-- Now total up the days worked -->
  35. <loop var="days_total">
  36. <perform>
  37. <assign var="one"><atom>1</atom></assign>
  38. <math op="+" arg1="$total_days_worked" arg2="$one" assign="total_days_worked" />
  39. <!--<function assign="total_days_worked">(total_days_worked + 1)</function>-->
  40. </perform>
  41. </loop>
  42. <!-- Check how many days there are, if more than five days then restrict to five, otherwise return number -->
  43. <if>
  44. <condition>
  45. <compare function="gt">
  46. <atom var="total_days_worked"/>
  47. <atom var="max_days"/>
  48. </compare>
  49. </condition>
  50. <perform>
  51. <assign var="five"><atom>5</atom></assign>
  52. <assign var="total_days_worked"><atom var="five"/></assign>
  53. <!--<function assign="total_days_worked">5</function>-->
  54. </perform>
  55. </if>
  56.  
  57. <!-- Return the number of days -->
  58. <log message="returning:" obj="$days_total"/>
  59. <log message="returning:" obj="$total_days_worked"/>
  60. <assign var="five"><atom>5</atom></assign>
  61. <!--<if>
  62. <condition>
  63. <compare function="gt">
  64. <atom var="five" />
  65. <atom var="total_days_worked"/>
  66. </compare>
  67. </condition>
  68. <perform>
  69. <exit var="five" />
  70. </perform>
  71. </if>-->
  72. <exit var="total_days_worked" />
  73. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement