Automatically authorise certain leave types

58 views
Skip to first unread message

Chris Henderson

unread,
Mar 13, 2018, 10:22:37 AM3/13/18
to jorani
Hi,

I know that the system doesn't currently work this way but we would like to develop it so that we can have selected leave types not require the authorisation of a manager.

Could anyone point us the right direction to get us started?

Thanks,

Chris

Benjamin BALET

unread,
Mar 13, 2018, 11:21:37 PM3/13/18
to jor...@googlegroups.com
Hi,

In local\triggers\leave.php you can put a custom code that will be triggered after the leave request is inserted into the database and before the email is sent to the manager.
This is the cleanest way to deal with your use case without altering the base code.
I'm opened to discussion if you want to change the behavior of the code calling the trigger (application\controllers\Leaves.php:234) as far as the changes are reasonable and don't impact the default behavior. Acceptable changes would be - for example - adding a property to the controller that prevent sending the email after the trigger or similar small changes (adding an object or default id, type,etc. as a property of the controller).

--
You received this message because you are subscribed to the Google Groups "jorani" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jorani+unsubscribe@googlegroups.com.
To post to this group, send email to jor...@googlegroups.com.
Visit this group at https://groups.google.com/group/jorani.
To view this discussion on the web visit https://groups.google.com/d/msgid/jorani/1a96a0f2-9448-49b5-8852-1fbb53d48b0c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Chris Henderson

unread,
Mar 14, 2018, 6:49:13 AM3/14/18
to jorani
Hi,

Thanks for the pointer, we now have it working as required using the local trigger as below - 

function triggerCreateLeaveRequest(CI_Controller $controller)
{
    //ids of types to auto approve when requested
$auto_approve = array(11);
if (isset($_POST['type']) && isset($_POST['status']))
{
if ( in_array($controller->input->post('type'),$auto_approve) && $controller->input->post('status') == 2)
{
$_POST['status'] = 3;
}
}
}


Benjamin BALET

unread,
Mar 14, 2018, 6:52:25 AM3/14/18
to jor...@googlegroups.com
Cool :)

Next time you upgrade Jorani, remember to backup and restore this file.

--
You received this message because you are subscribed to the Google Groups "jorani" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jorani+unsubscribe@googlegroups.com.
To post to this group, send email to jor...@googlegroups.com.
Visit this group at https://groups.google.com/group/jorani.
Reply all
Reply to author
Forward
0 new messages