mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-24 23:49:19 +00:00
Start the timer on the basis of time diff between now_time and timestamp
This commit is contained in:
@@ -78,6 +78,7 @@ frappe.ui.form.on("Timesheet", {
|
|||||||
if (row.timer_timestamp) {
|
if (row.timer_timestamp) {
|
||||||
let timestamp = moment(frappe.datetime.now_datetime()).diff(moment(row.timer_timestamp),"seconds");
|
let timestamp = moment(frappe.datetime.now_datetime()).diff(moment(row.timer_timestamp),"seconds");
|
||||||
timer(frm, disabled, row, timestamp);
|
timer(frm, disabled, row, timestamp);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
row.timer_timestamp = frappe.datetime.now_datetime();
|
row.timer_timestamp = frappe.datetime.now_datetime();
|
||||||
@@ -261,7 +262,25 @@ var control_timer = function(frm, dialog, row, timestamp=0) {
|
|||||||
|
|
||||||
$(".playpause").click(function(e) {
|
$(".playpause").click(function(e) {
|
||||||
if (!initialised) {
|
if (!initialised) {
|
||||||
|
var args = dialog.get_values();
|
||||||
|
if(!args) return;
|
||||||
|
if (!frm.doc.time_logs[0].activity_type) {
|
||||||
|
frm.doc.time_logs = [];
|
||||||
|
}
|
||||||
|
row = frappe.model.add_child(frm.doc, "Timesheet Detail", "time_logs");
|
||||||
|
row.activity_type = args.activity_type;
|
||||||
|
row.from_time = frappe.datetime.get_datetime_as_string();
|
||||||
|
row.hours = args.hours;
|
||||||
|
row.project = args.project;
|
||||||
|
row.timer_timestamp = frappe.datetime.now_datetime();
|
||||||
|
let d = moment(row.from_time)
|
||||||
|
if(row.hours) {
|
||||||
|
d.add(row.hours, "hours");
|
||||||
|
row.to_time = d.format(moment.defaultDatetimeFormat);
|
||||||
|
}
|
||||||
|
row.status = 'Pending';
|
||||||
|
frm.refresh_field("time_logs");
|
||||||
|
}
|
||||||
if (clicked) {
|
if (clicked) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user