public function getMaxPriority($materialId, $structureId)
    {
        // Get all table materials identifiers from current form material
        $tableMaterialIds = dbQuery('material')
            ->cond('parent_id', $materialId)
            ->cond('type', 3)
            ->cond('Active', 1)
            ->cond('Draft', 0)
            ->join('structurematerial')
            ->cond('structurematerial.StructureID', $structureId)
            ->fields('MaterialID');

        $material = null;
        if (
            dbQuery('material')
                ->cond('MaterialID', $tableMaterialIds)
                ->cond('Active', 1)
                ->order_by('priority', 'DESC')
                ->join('materialfield')
                ->first($material)
        ) {
            return $material->priority;
        }
        return 0;

    }