public function onQueryServiceAvailableEmployees(mixed &$query, mixed $search, string $date) : void

Fires before launching the query used to fetch the employees assigned to the selected service.


Description

Trigger hook to allow the plugins to manipulate the default query used to load the employees assigned to the selected service.

The query loads first the employees with the lowest count of overall reservations, so that we can have a correct balance.

It is possible to use this hook to improve this algorithm, in example by counting only the reservations of the last quarter.

NOTE: calling $search->isServiceAvailable() will result in recursion.


Parameters

&$query

(mixed)  Either a query builder or a SQL string.

$search

(VAPAvailabilityImplementor)  The instance used to check the availability.

$date

(string)  The check-in date (UTC).

Return Value

None.


Example

/**
 * Trigger hook to allow the plugins to manipulate the default query used
 * to load the employees assigned to the selected service. The query loads
 * first the employees with the lowest count of overall reservations, so
 * that we can have a correct balance.
 *
 * @param   mixed    &$query  Either a query builder or a string.
 * @param   mixed    $search  The availability search instance.
 * @param   string   $date    The check-in date (UTC).
 *
 * @return  void
 */
public function onQueryServiceAvailableEmployees(&$query, $search, $date)
{
    /**
     * @todo manipulate query here
     */
}

Changelog

VersionDescription
1.7 Introduced.
Last Update: 2021-10-05 17:12
Helpful?