Add button to reset start time

This commit is contained in:
phl0 2023-10-27 10:12:30 +02:00
parent f56e031946
commit ad2d7e756c
No known key found for this signature in database
GPG Key ID: 48EA1E640798CA9A
2 changed files with 7 additions and 2 deletions

View File

@ -995,6 +995,12 @@ $(document).on('keypress',function(e) {
} }
); );
}); });
$('#reset_time').click(function() {
var now = new Date();
var localTime = now.getTime();
var utc = localTime + (now.getTimezoneOffset() * 60000);
$('#start_time').val(("0" + now.getUTCHours()).slice(-2)+':'+("0" + now.getUTCMinutes()).slice(-2)+':'+("0" + now.getUTCSeconds()).slice(-2));
});
}); });
</script> </script>
@ -1124,7 +1130,6 @@ $(document).on('keypress',function(e) {
$('#start_time').focusout(function() { $('#start_time').focusout(function() {
if (manual && $('#start_time').val() != '') { if (manual && $('#start_time').val() != '') {
$('#end_time').val($('#start_time').val()); $('#end_time').val($('#start_time').val());
console.log("HERE!");
} }
}); });

View File

@ -58,7 +58,7 @@
</div> </div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="start_time"><?php echo lang('general_word_time_on'); ?></label> <label for="start_time"><?php echo lang('general_word_time_on'); ?></label> <?php if ($_GET['manual'] != 1) { ?><i id="reset_time" data-toggle="tooltip" data-original-title="Reset start time" class="fas fa-stopwatch"></i><?php } ?>
<input type="text" class="form-control form-control-sm input_start_time" name="start_time" id="start_time" value="<?php if (($this->session->userdata('start_time') != NULL && ((time() - $this->session->userdata('time_stamp')) < 24 * 60 * 60))) { echo substr($this->session->userdata('start_time'),0,5); } else {echo date('H:i'); } ?>" size="7" <?php echo ($_GET['manual'] == 0 ? "disabled" : ""); ?> required pattern="[0-2][0-9]:[0-5][0-9]"> <input type="text" class="form-control form-control-sm input_start_time" name="start_time" id="start_time" value="<?php if (($this->session->userdata('start_time') != NULL && ((time() - $this->session->userdata('time_stamp')) < 24 * 60 * 60))) { echo substr($this->session->userdata('start_time'),0,5); } else {echo date('H:i'); } ?>" size="7" <?php echo ($_GET['manual'] == 0 ? "disabled" : ""); ?> required pattern="[0-2][0-9]:[0-5][0-9]">
</div> </div>