Newbe: adjust sql record before inserting into table

Hallo I am testing the schedule application if I can integrate into an existing table.
My table “arbeitszeit” has the following coloumn (Mysql)

arbzid(INT 11) PK
arbzuser(INT 11)
arbzstart (Datetime)
arbzend (Datetime)
start(Time)
end(Time)
task(Varchar) -> From another table “Tasks” as Dropdoen)
taskdetail(Varchar) -> Frorm Table “Tasks” conditional to task
currenttime(now())

Now: I want to store the only time part from arbzstart into start and only time from arbzend into end. I want to manually enter arbzuser such “2” or “11” for each entry.
The input for task are comming from another lookup table…

Is there are some example to test this?
Where should I start?
thanks
mpol_ch

Hi you can manually alter the data in your loadEvents file (the file that you’re using in scheduler.load():wink:
You can than use:

$scheduler->event->attach("beforeProcessing","delete_related"); //Before saving
$scheduler->event->attach("afterProcessing","insert_related"); //After saving

In conjunction with the appropriate PHP function.
If you’re already using start and end values in the scheduler:

function delete_related($action){
        //Set the value, this should then insert naturally along with the rest of the data.
        $newValue = date("H:i:s", strtotime($action->get_value("start_date")));
        $action->set_value("start", $newValue);
        $newValue = date("H:i:s", strtotime($action->get_value("end_date")));
        $action->set_value("end", $newValue);
}

If you’re NOT already using start and end values in the scheduler, you will need to manually update the columns after the data has been inserted:

function insert_related($action){
        global $scheduler;
        //UPDATE the value
        $newValue = date("H:i:s", strtotime($action->get_value("start_date")));
        $scheduler->sql->query("UPDATE arbeitszeit SET start = ''$newValue'' WHERE id='".$action->get_new_id()."'");
        $newValue = date("H:i:s", strtotime($action->get_value("end_date")));
        $scheduler->sql->query("UPDATE arbeitszeit SET end = ''$newValue'' WHERE id='".$action->get_new_id()."'");
}

Regards,
Dean