I'm trying to do a simple thing in sugar : check if the assigned user already have a meeting when saving a new one on the same date/hours.
So, i've got a before_save logic hook which check if the assigned user already have meetings. It works well.
Now, i want to throw an alert to the user, it seems that the Confirm one is good : if confirmed, save the meeting. If cancelled, then go back to it and change the date.
I wrote this inside my logic hook, if the user is not available, then $isavailable is false.
if ($isavailable == false) { // User already has a meeting at this time => error
echo "<script type='text/javascript'>
app.alert.show('message-id', {
level: 'confirmation',
messages: 'Confirm?',
autoClose: false,
onConfirm: function(){
alert('Confirmed!');
},
onCancel: function(){
alert('Cancelled!');
}
});</script>";
}
But the alert does not show.
And how can i make the cancel => go back to the current meeting. and the confirm => save the current meeting??
Can you please help me on that?
Thanks.
Gaëlle