Hello everyone,
I am struggling to find a way to control behaviour on an add form.
I have a timesheet - if an employee has an open entry, I would like to display a message and prevent them from advancing any further, forcing them to click Back To List. If the employee doesn't have any open entries, then they proceed as normal.
I have attempted many variations using Javascript onload etc. The closest I have come to is the below field event when the user scans their RFID card, however there is no messagebox displayed
this is the change field event on that cardid field:
This all works up to this point (at least, I don't get any errors - I can't get the result to echo / print on my page....)
I am just at my wits end as to how to get a simple message to appear, or, at a minimum, see how to disable the save button on the form.
Any assistance is greatly appreciated.
Best regards,
Craig
I am struggling to find a way to control behaviour on an add form.
I have a timesheet - if an employee has an open entry, I would like to display a message and prevent them from advancing any further, forcing them to click Back To List. If the employee doesn't have any open entries, then they proceed as normal.
I have attempted many variations using Javascript onload etc. The closest I have come to is the below field event when the user scans their RFID card, however there is no messagebox displayed
this is the change field event on that cardid field:
function OnClient Before(params,ctrl,pageObj,ajax) { var ctrlemployeeid = ctrl.getPeer('employee_id'); params["employee_id_in"] = ctrlemployeeid.getValue(); } // function OnClient Before
function OnServer($params, $result) {$result["employee_id_count"] = DBLookup("SELECT count(employee_id) FROM timesheet_entry WHERE employee_id = '" . $params['employee_id_in'] . "' AND finish_time is null"); } // function OnServer
This all works up to this point (at least, I don't get any errors - I can't get the result to echo / print on my page....)
function OnClient After(result,ctrl,pageObj,ajax) { var ctrlcarduida = ctrl.getPeer('card_uid'); var ctrlemployeeid = ctrl.getPeer('employee_id'); var ctrlwoseq = ctrl.getPeer('wo_seq'); var ctrlqty = ctrl.getPeer('qty_complete'); // rather than disabling all of these fields, disable the save button if ($result["employee_id_count"] > 0) {echo("How many timesheet entries has this employee got open ? ". $result['employee_id_count']) ctrlcarduida.setDisabled(); ctrlemployeeid.setDisabled(); ctrlwoseq.setDisabled(); ctrlqty.setDisabled(); ctrlcarduida.setFocus(); return false; }else{ ctrlcarduida.setEnabled(); ctrlemployeeid.setEnabled(); ctrlwoseq.setEnabled(); ctrlqty.setEnabled(); if (ctrlstartime.getValue() == '') {ctrlstartime.setValue(now()); var ctrlwo = Runner.getControl(pageid, 'work_order'); ctrlwo.setFocus();} } } // function OnClient After
I am just at my wits end as to how to get a simple message to appear, or, at a minimum, see how to disable the save button on the form.
Any assistance is greatly appreciated.
Best regards,
Craig