Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- <assign var="max_days">5</assign> <!-- Maximum days to be returned -->
- <assign var="total_days_worked">0</assign> <!-- Number of days worked, to be returned -->
- <assign var="days_total"></assign> <!-- total hours per day will be saved here as associative array with the date as index-->
- <!-- build the days index array -->
- <loop var="timesheets">
- <perform>
- <assign var="sttime"><atom var="this" index="StartTime" /></assign>
- <dateprint format="Y-m-d" input="$sttime" assign="curent_date" />
- <!--<function assign="curent_date">php:function('date','Y-m-d' , number(sttime))</function>-->
- <assign var="days_total" index="$curent_date">0</assign>
- <!-- initiate the array as 0 -->
- </perform>
- </loop>
- <!-- Loop through time sheets and assign them to the days (arbitrarily total up hours) -->
- <loop var="timesheets">
- <perform>
- <assign var="tstotal"><atom var="this" index="TotalTime" /></assign>
- <assign var="sttime"><atom var="this" index="StartTime" /></assign>
- <dateprint format="Y-m-d" input="$sttime" assign="curent_date" />
- <!--<function assign="curent_date">php:function('date','Y-m-d' , number(sttime))</function>-->
- <assign var="currentDayTotal"><atom var="days_total" index="$curent_date" /></assign>
- <math op="+" arg1="$currentDayTotal" arg2="$tstotal" assign="fltTotal"/>
- <assign var="days_total" index="$curent_date" ><atom var="fltTotal"/></assign>
- <!--<function assign="days_total" index="$curent_date">(currentDayTotal + tstotal)</function>-->
- </perform>
- </loop>
- <!-- sort the days with date -->
- <sort var="days_total" with="key" assign="days_total"/>
- <!-- Now total up the days worked -->
- <loop var="days_total">
- <perform>
- <assign var="one"><atom>1</atom></assign>
- <math op="+" arg1="$total_days_worked" arg2="$one" assign="total_days_worked" />
- <!--<function assign="total_days_worked">(total_days_worked + 1)</function>-->
- </perform>
- </loop>
- <!-- Check how many days there are, if more than five days then restrict to five, otherwise return number -->
- <if>
- <condition>
- <compare function="gt">
- <atom var="total_days_worked"/>
- <atom var="max_days"/>
- </compare>
- </condition>
- <perform>
- <assign var="five"><atom>5</atom></assign>
- <assign var="total_days_worked"><atom var="five"/></assign>
- <!--<function assign="total_days_worked">5</function>-->
- </perform>
- </if>
- <!-- Return the number of days -->
- <log message="returning:" obj="$days_total"/>
- <log message="returning:" obj="$total_days_worked"/>
- <assign var="five"><atom>5</atom></assign>
- <!--<if>
- <condition>
- <compare function="gt">
- <atom var="five" />
- <atom var="total_days_worked"/>
- </compare>
- </condition>
- <perform>
- <exit var="five" />
- </perform>
- </if>-->
- <exit var="total_days_worked" />
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement