var tmrRunning = false; var tmr; var curTmr; function ssTime(n) { var fuid = '0'; if ($('.hidFUID').length > 0) { fuid = $('.hidFUID').val(); } if ($(n).val() == 'Start Timer') { var desc = ''; if ($('#selDescription').length > 0) { desc = $('#selDescription option:selected').text(); } else if ($('#inpDescription').length > 0) { desc = $('#inpDescription').val(); } var ttype = ''; if ($('#selTimeType').length > 0) { ttype = $('#selTimeType option:selected').text(); } $.post('../handlers/general.ashx?pageaction=starttmr', { mid: $('.hidModId').val(), sid: $('.hidSid').val(), desc: desc, fuid: fuid, ttype: ttype }, function (data) { curTmr = data; tmrRunning = true; $('#tmrLabel').html('Elapsed Time'); $('.aelTimer').html('0'); $(n).val('Stop Timer'); tmr = setInterval(tickIt, 1000); $('#ancTmrCan').closest('tr').remove(); }); } else { var desc = ''; if ($('#selDescription').length > 0) { desc = $('#selDescription option:selected').text(); } else if ($('#inpDescription').length > 0) { desc = $('#inpDescription').val(); } var ttype = ''; if ($('#selTimeType').length > 0) { ttype = $('#selTimeType option:selected').text(); } $.post('../handlers/general.ashx?pageaction=stoptmr', { tid: curTmr, mid: $('.hidModId').val(), sid: $('.hidSid').val(), tmroid: $('.dvTimerButton').attr('toid'), desc: desc, fuid: fuid, ttype: ttype }, function (data) { tmrRunning = false; $('#tmrLabel').html('Total Time'); $('.dvTimerButton').html(data.split('¦')[1]); $('.aelTimer').html('' + data.split('¦')[0] + ''); if (RefreshAllNotes != null) { RefreshAllNotes(); } }); } return false; } function ssTimeCont(t) { curTmr = t; tmrRunning = true; tmr = setInterval(tickIt, 1000); } function tickIt() { if (tmrRunning) { $('.aelTimer').html(parseInt($('.aelTimer').html()) + 1); } else { clearInterval(tmr); } } function ShowTimes() { var fuid = '0'; if ($('.hidFUID').length > 0) { fuid = $('.hidFUID').val(); } var tmrid = $('.dvTimerButton').attr('toid'); window.top.ShowDialogURL2("../tools/times.aspx?toid=" + tmrid + "&mid=" + $('.hidModId').val() + "&sid=" + $('.hidSid').val() + "&fuid=" + fuid, '800px', '400px'); } function CanTmrEntry(n) { ShowDefTimerUI(); if (RefreshAllNotes != null) { RefreshAllNotes(); } } function SubmitTmrEntry(n) { var fuid = '0'; if ($('.hidFUID').length > 0) { fuid = $('.hidFUID').val(); } var desc = ''; if ($('#selDescription').length > 0) { desc = $('#selDescription option:selected').text(); } else if ($('#inpDescription').length > 0) { desc = $('#inpDescription').val(); } var ttype = ''; if ($('#selTimeType').length > 0) { ttype = $('#selTimeType option:selected').text(); } var ttmbr = ""; if ($('#selTeamMemberTimer').length > 0) { ttmbr = $('#selTeamMemberTimer').val(); } $.post('../handlers/general.ashx?pageaction=tmrentry', { mid: $('.hidModId').val(), sid: $('.hidSid').val(), tstrt: $('#tmrStart').val(), tend: $('#tmrEnd').val(), desc: desc, fuid: fuid, ttmbr: ttmbr, ttype: ttype }, function (data) { CanTmrEntry(n); $('.aelTimer').html('' + data + ''); UpdateOnScreenTimerBasedFormulas($('.hidModId').val(), $('.hidSid').val()); if (RefreshAllNotes != null) { RefreshAllNotes(); } }); } function SubmitTmrComplete(n) { var fuid = '0'; if ($('.hidFUID').length > 0) { fuid = $('.hidFUID').val(); } var hcdate = ''; hcdate = $('#hcDate').val(); var hctime = ''; hctime = $('#hcTime').val(); var desc = ''; if ($('#selDescription').length > 0) { desc = $('#selDescription option:selected').text(); } else if ($('#inpDescription').length > 0) { desc = $('#inpDescription').val(); } var ttype = ''; if ($('#selTimeType').length > 0) { ttype = $('#selTimeType option:selected').text(); } var ttmbr = ""; if ($('#selTeamMemberTimer').length > 0) { ttmbr = $('#selTeamMemberTimer').val(); } $.post('../handlers/general.ashx?pageaction=timercompeleteentry', { mid: $('.hidModId').val(), sid: $('.hidSid').val(), hrs: $('#tmrHours').spinner("value"), mins: $('#tmrMinutes').spinner("value"), desc: desc, fuid: fuid, ttmbr: ttmbr, ttype: ttype, hcdate: hcdate, hctime: hctime }, function (data) { CanTmrEntry(n); if (data.indexOf('Error') > -1) { alert(data); } else { $('.aelTimer').html('' + data + ''); UpdateOnScreenTimerBasedFormulas($('.hidModId').val(), $('.hidSid').val()); if (RefreshAllNotes != null) { RefreshAllNotes(); } } }); } function SubmitTimerFromMassUpdate(n) { var fuid = '0'; if ($('.hidFUID').length > 0) { fuid = $('.hidFUID').val(); } var hcdate = ''; hcdate = $('#hcDate').val(); var hctime = ''; hctime = $('#hcTime').val(); var desc = ''; if ($('#selDescription').length > 0) { desc = $('#selDescription option:selected').text(); } else if ($('#inpDescription').length > 0) { desc = $('#inpDescription').val(); } var ttype = ''; if ($('#selTimeType').length > 0) { ttype = $('#selTimeType option:selected').text(); } var ttmbr = ""; if ($('#selTeamMemberTimer').length > 0) { ttmbr = $('#selTeamMemberTimer').val(); } var timerVals = { hrs: $('#tmrHours').spinner("value"), mins: $('#tmrMinutes').spinner("value"), desc: desc, fuid: fuid, ttmbr: ttmbr, ttype: ttype, hcdate: hcdate, hctime: hctime } return timerVals; } function UpdateOnScreenTimerBasedFormulas(modId, modRefId) { $.post('../handlers/general.ashx?pageaction=timerformulaupdate', { mid: modId, sid: modRefId }, function (data2) { var items = data2.split('|'); for (var i = 0; i < items.length; i++) { var fldValue = items[i].split('·'); if ($('td[fldid="fld_' + fldValue[0] + '"]').length > 0) { $('td[fldid="fld_' + fldValue[0] + '"]').next('td').find('span').first().html(fldValue[1]); } } }); } function SubmitTmrHourly(n) { var fuid = '0'; if ($('.hidFUID').length > 0) { fuid = $('.hidFUID').val(); } var hcdate = ''; if ($('#hcDate').length > 0) { hcdate = $('#hcDate').val(); } var desc = ''; if ($('#selDescription').length > 0) { desc = $('#selDescription option:selected').text(); } else if ($('#inpDescription').length > 0) { desc = $('#inpDescription').val(); } var ttype = ''; if ($('#selTimeType').length > 0) { ttype = $('#selTimeType option:selected').text(); } var ttmbr = ""; if ($('#selTeamMemberTimer').length > 0) { ttmbr = $('#selTeamMemberTimer').val(); } $.post('../handlers/general.ashx?pageaction=hrlyentry', { mid: $('.hidModId').val(), sid: $('.hidSid').val(), hrs: $('#tmrHours').val(), desc: desc, fuid: fuid, ttmbr: ttmbr, ttype: ttype, hcdate: hcdate }, function (data) { CanTmrEntry(n); $('.aelTimer').html('' + data + ''); UpdateOnScreenTimerBasedFormulas($('.hidModId').val(), $('.hidSid').val()); if (RefreshAllNotes != null) { RefreshAllNotes(); } }); } function ShowTimerUI() { var fuid = '0'; if ($('.hidFUID').length > 0) { fuid = $('.hidFUID').val(); } $.post('../handlers/general.ashx?pageaction=gettmrui', { toid: $('.dvTimerButton').attr('toid'), fuid: fuid }, function (data) { $('.dvTimerButton').html(data); }); } function ShowManUI() { var fuid = '0'; if ($('.hidFUID').length > 0) { fuid = $('.hidFUID').val(); } $.post('../handlers/general.ashx?pageaction=gettmrman', { toid: $('.dvTimerButton').attr('toid'), fuid: fuid }, function (data) { $('.dvTimerButton').html(data); $('#tmrStart').datetimepicker({}); $('#tmrEnd').datetimepicker({}); }); } function ShowHourlyUI() { var fuid = '0'; if ($('.hidFUID').length > 0) { fuid = $('.hidFUID').val(); } $.post('../handlers/general.ashx?pageaction=gethourlyui', { toid: $('.dvTimerButton').attr('toid'), fuid: fuid }, function (data) { $('.dvTimerButton').html(data); if ($('#hcDate').length > 0) { $('#hcDate').datetimepicker({ timepicker: false, closeOnDateSelect: true, scrollInput: false, format: 'm/d/Y' }); } }); } function ShowCompleteUI() { var fuid = '0'; if ($('.hidFUID').length > 0) { fuid = $('.hidFUID').val(); } $.post('../handlers/general.ashx?pageaction=gettimercompleteui', { toid: $('.dvTimerButton').attr('toid'), fuid: fuid }, function (data) { $('.dvTimerButton').html(data); $('#hcDate').datetimepicker({ timepicker: false, closeOnDateSelect: true, scrollInput: false, format: 'm/d/Y' }); $('#hcTime').datetimepicker({ datepicker: false, format: 'h:ii A' }); }); } function ShowDefTimerUI() { var fuid = '0'; if ($('.hidFUID').length > 0) { fuid = $('.hidFUID').val(); } $.post('../handlers/general.ashx?pageaction=getdeftmrui', { toid: $('.dvTimerButton').attr('toid'), fuid: fuid }, function (data) { $('.dvTimerButton').html(data); }); }