<?php

declare(strict_types=1);

class AdminSlipController extends AdminSlipControllerCore
{
    public function __construct()
    {
        parent::__construct();

        $cookieContent = Context::getContext()->cookie->getAll();
        if (isset($cookieContent['profile']) && 5 == $cookieContent['profile']) {
            $idGroup = Db::getInstance()->getRow(
                'SELECT id_group
                FROM `' . _DB_PREFIX_ . Clinique::TABLE . '`
                WHERE id_employee = ' . (int) $cookieContent['id_employee']
            );

            if (is_array($idGroup) && isset($idGroup['id_group'])) {
                $idGroup = $idGroup['id_group'];
            } else {
                $idGroup = 0;
            }

            // Traitement spécifique pour les cliniques vétérinaires
            $this->_join .= ' INNER JOIN `' . _DB_PREFIX_ . 'customer_group` cg ON (cg.`id_customer` = o.`id_customer` AND cg.`id_group` = ' . (int) $idGroup . ')';
        }
    }
}
