YetiForceCompany/YetiForceCRM

View on GitHub
modules/OSSEmployees/views/EmployeeHierarchy.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%
<?php

/**
 * OSSEmployees EmployeeHierarchy view class.
 *
 * @copyright YetiForce S.A.
 * @license YetiForce Public License 6.5 (licenses/LicenseEN.txt or yetiforce.com)
 */
class OSSEmployees_EmployeeHierarchy_View extends \App\Controller\View\Page
{
    use App\Controller\ClearProcess;

    /**
     * Function to check permission.
     *
     * @param \App\Request $request
     *
     * @throws \App\Exceptions\NoPermittedToRecord
     */
    public function checkPermission(App\Request $request)
    {
        $recordId = $request->getInteger('record');
        if (!$recordId) {
            throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);
        }
        if (!\App\Privilege::isPermitted($request->getModule(), 'DetailView', $recordId)) {
            throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);
        }
    }

    public function process(App\Request $request)
    {
        $viewer = $this->getViewer($request);
        $moduleName = $request->getModule();
        $recordModel = Vtiger_Record_Model::getInstanceById($request->getInteger('record'), $moduleName);
        $hierarchy = $recordModel->getEmployeeHierarchy();

        $viewer->assign('MODULE', $moduleName);
        $viewer->assign('EMPLOYEES_HIERARCHY', $hierarchy);
        $viewer->view('EmployeeHierarchy.tpl', $moduleName);
    }
}