Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re-added timetracker time buttons #82

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
47 changes: 41 additions & 6 deletions include/js/timetracker_widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,48 @@ function zeroFill( number, width )

function populateEndtime()
{
var startVal = parseInt($('started').value,10);
var hrsVal = parseInt($('workhours').value,10);
var startTime=$('started').value;
var parts=startTime.split(':');
var startHour=parseInt(parts[0]);
var startMin=parseInt(parts[1]);

// get the start date. used to calculate the end date later
var startDateString=$('ttstartday').value;
var startDateParts=startDateString.split('.');
var startDate=new Date(startDateParts[2],startDateParts[1],startDateParts[0]);

// get the start time seconds
var startVal = 60*startHour+startMin;

var finVal = startVal + hrsVal;
// calculate the 'workminutes' from the work hours
var minDiff = 60*parseInt($('workhours').value,10);

finVal = zeroFill(finVal,2);
$('ended').value = finVal + ":00";
// calculate the end time
var endVal = startVal + minDiff;
var endMin = zeroFill(endVal % 60,2);
var endHour = zeroFill((endVal-endMin) / 60,2);

// initialize the end date
var endDateStamp=Date.parse(startDate);

// if our timesheet exceeds the 11:59pm barrier, add a day
if (endHour>23){
var oneday=24*60*60*1000;
while (endHour > 23){
endHour-=24;
endDateStamp+=oneday;
}
}

// create the end date
var endDate=new Date(endDateStamp);
var endDay = zeroFill(endDate.getDate(),2);
var endMonth= zeroFill(endDate.getMonth(),2);
var endYear = endDate.getFullYear();

// set end date and end time
$('ttendday').value = endDay + "." + endMonth+"."+endYear;
$('ended').value = endHour + ":" + endMin;
}
function populateHours()
{
Expand All @@ -29,4 +64,4 @@ function populateHours()
{
$('workhours').value = finVal;
}
}
}
159 changes: 88 additions & 71 deletions templates/standard/addtimetracker.tpl
Original file line number Diff line number Diff line change
@@ -1,76 +1,93 @@
<script type="text/javascript" src="include/js/timetracker_widget.js"></script>
<div class="block_in_wrapper">

<form novalidate class="main" id="trackeradd" method="post" action="managetimetracker.php?action=add" {literal} onsubmit="return validateCompleteForm(this,'input_error'); {/literal} ">
<fieldset>

<input type="hidden" name="project" value="{$project.ID}" />

<div class="row">
<label for="ttday">{#startday#}:</label>
<input type="text" class="text" style="width:80px;margin:0 6px 0 0;" id="ttday" name="ttday" realname="{#date#}" />
</div>

<div class="datepick">
<div id="datepicker_addtt" class="picker" style="display:none;"></div>
</div>

<script type="text/javascript">
theCal = new calendar({$theM},{$theY});
theCal.dayNames = ["{#monday#}","{#tuesday#}","{#wednesday#}","{#thursday#}","{#friday#}","{#saturday#}","{#sunday#}"];
theCal.monthNames = ["{#january#}","{#february#}","{#march#}","{#april#}","{#may#}","{#june#}","{#july#}","{#august#}","{#september#}","{#october#}","{#november#}","{#december#}"];
theCal.relateTo = "ttday";
theCal.keepEmpty = false;
theCal.dateFormat = "{$settings.dateformat}";
theCal.getDatepicker("datepicker_addtt");
</script>

<div class="row">
<label for="started">{#started#}:</label>
<input type="text" class="text" style="width:80px;margin:0 6px 0 0;" id="started" name="started" onkeyup=" populateHours();" required="1" regexp="^([01]?\d|2[0123]):[012345]\d$" realname="{#started#} ({#timeformat#}: hh:mm)" value="08:00" />
</div>
<div class="row">
<label for = "ended">{#ended#}:</label>
<input type="text" class="text" style="width:80px;margin:0 6px 0 0;" id="ended" name="ended" onkeyup = " populateHours();" required="1" regexp="^([01]?\d|2[0123]):[012345]\d$" realname="{#started#} ({#timeformat#}: hh:mm)" value="09:00" />
</div>


<div class = "row">
<label for = "workhours" >Hours:</label>
<input type = "number" id = "workhours" name = "workhours" value = "1" min = "1" max = "10" step = "1" onkeyup = "populateEndtime();" onchange = "populateEndtime();" style="width:40px;"/>
</div>

<input type="hidden" name="project" value="{$project.ID}" />

<div class="row">
<label for="trackcomm">{#comment#}:</label>
<textarea name="comment" id="trackcomm"></textarea>
</div>

<div class="clear_both_b"></div>

<div class="row">
<label for="ttask">{#task#}:</label>
<select name="ttask" id="ttask">
<option value="0">{#chooseone#}</option>
{section name=task loop=$ptasks}

{if $ptasks[task].title != ""}
<option value="{$ptasks[task].ID}">{$ptasks[task].title}</option>
{else}
<option value="{$ptasks[task].ID}">{$ptasks[task].text|truncate:30:"...":true}</option>
{/if}

{/section}
</select>
</div>

<div class="row-butn-bottom">
<label>&nbsp;</label>
<button type="submit" onfocus="this.blur();">{#addbutton#}</button>
</div>

</fieldset>
</form>
<form novalidate class="main" id="trackeradd" method="post" action="managetimetracker.php?action=add" {literal} onsubmit="return validateCompleteForm(this,'input_error'); {/literal} ">
<fieldset>

<input type="hidden" name="project" value="{$project.ID}" />

<div class="row">
<label for="ttstartday">{#startday#}:</label>
<input type="text" class="text" style="width:80px;margin:0 67px 0 0;" id="ttstartday" name="ttstartday" realname="{#date#}" />

<label for="ttendday">{#endday#}:</label>
<input type="text" class="text" style="width:80px;margin:0 6px 0 0;" id="ttendday" name="ttendday" realname="{#date#}" />
</div>

<div class="datepick">
<div id="datepicker_addstarttt" class="picker" style="display:none;"></div>
<div id="datepicker_addendtt" class="picker" style="display:none;"></div>
</div>

<script type="text/javascript">
startCal = new calendar({$theM},{$theY});
startCal.dayNames = ["{#monday#}","{#tuesday#}","{#wednesday#}","{#thursday#}","{#friday#}","{#saturday#}","{#sunday#}"];
startCal.monthNames = ["{#january#}","{#february#}","{#march#}","{#april#}","{#may#}","{#june#}","{#july#}","{#august#}","{#september#}","{#october#}","{#november#}","{#december#}"];
startCal.relateTo = "ttstartday";
startCal.keepEmpty = false;
startCal.dateFormat = "{$settings.dateformat}";
startCal.getDatepicker("datepicker_addstarttt");
</script>

<script type="text/javascript">

endCal = new calendar({$theM},{$theY});
endCal.dayNames = ["{#monday#}","{#tuesday#}","{#wednesday#}","{#thursday#}","{#friday#}","{#saturday#}","{#sunday#}"];
endCal.monthNames = ["{#january#}","{#february#}","{#march#}","{#april#}","{#may#}","{#june#}","{#july#}","{#august#}","{#september#}","{#october#}","{#november#}","{#december#}"];
endCal.relateTo = "ttendday";
endCal.keepEmpty = false;
endCal.dateFormat = "{$settings.dateformat}";
endCal.getDatepicker("datepicker_addendtt");

</script>

<div class="row">
<label for="started">{#started#}:</label>
<input type="text" class="text" style="width:80px;margin:0 6px 0 0;" id="started" name="started" onkeyup=" populateHours();" required="1" regexp="^([01]?\d|2[0123]):[012345]\d$" realname="{#started#} ({#timeformat#}: hh:mm)" value="08:00" />
<button class="settimebtn" onclick="getnow('started');return false;" onfocus="this.blur();" title="{#inserttime#}">hh:mm</button>

<label for = "ended">{#ended#}:</label>
<input type="text" class="text" style="width:80px;margin:0 6px 0 0;" id="ended" name="ended" onkeyup = " populateHours();" required="1" regexp="^([01]?\d|2[0123]):[012345]\d$" realname="{#started#} ({#timeformat#}: hh:mm)" value="09:00" />
<button class="settimebtn" onclick="getnow('ended');return false;" onfocus="this.blur();" title="{#inserttime#}">hh:mm</button>
</div>


<div class="row">
<label for = "workhours" >Hours:</label>
<input type = "number" id = "workhours" name = "workhours" value = "1" min = "1" max = "10" step = "1" onkeyup = "populateEndtime();" onchange = "populateEndtime();" style="width:40px;"/>
</div>

<input type="hidden" name="project" value="{$project.ID}" />

<div class="row">
<label for="trackcomm">{#comment#}:</label>
<textarea name="comment" id="trackcomm"></textarea>
</div>

<div class="clear_both_b"></div>

<div class="row">
<label for="ttask">{#task#}:</label>
<select name="ttask" id="ttask">
<option value="0">{#chooseone#}</option>
{section name=task loop=$ptasks}

{if $ptasks[task].title != ""}
<option value="{$ptasks[task].ID}">{$ptasks[task].title}</option>
{else}
<option value="{$ptasks[task].ID}">{$ptasks[task].text|truncate:30:"...":true}</option>
{/if}

{/section}
</select>
</div>

<div class="row-butn-bottom">
<label>&nbsp;</label>
<button type="submit" onfocus="this.blur();">{#addbutton#}</button>
</div>

</fieldset>
</form>

</div> {*block_in_wrapper end*}
15 changes: 15 additions & 0 deletions templates/standard/theme/standard/css/style_main.css
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,10 @@ td.message ul {
background: url(../images/color-c-cyan.png) repeat 0 0;
}

.datepick #datepicker_addendtt{
left: 440px;
}

/* ## BIG CALENDAR ###################################### */

.block .bigcal table.thecal {
Expand Down Expand Up @@ -1228,6 +1232,17 @@ td.message ul {
background-image: url(../images/back-side-neutral.png);
}

.starttimebtn{
width: 60px;
}

#workhours{
width: 60px;
margin-right: 109px;
}



/* ## ONLINELISTE ######################################## */

#onlinelist ul {
Expand Down