<?php
$toolbarFilterSchema = is_array($toolbarFilterSchema ?? null) ? $toolbarFilterSchema : [];
$searchToolbarFilterSchema = is_array($searchToolbarFilterSchema ?? null) ? $searchToolbarFilterSchema : [];
$drawerToolbarFilterSchema = is_array($drawerToolbarFilterSchema ?? null) ? $drawerToolbarFilterSchema : [];
$toolbarFilterState = is_array($toolbarFilterState ?? null) ? $toolbarFilterState : [];
$toolbarOptionSets = is_array($toolbarOptionSets ?? null) ? $toolbarOptionSets : [];
$clientFilterSchema = is_array($clientFilterSchema ?? null) ? $clientFilterSchema : [];
$searchConfig = is_array($searchConfig ?? null) ? $searchConfig : null;
$filterChipMeta = is_array($filterChipMeta ?? null) ? $filterChipMeta : [];
$isConfigured = $isConfigured ?? false;
?>
<?php if (!$isConfigured): ?>
  <div class="notice" data-variant="warning" role="alert">
    <p><?php e(t('BC connection is not configured. Please configure the connection in the settings.')); ?></p>
    <a href="<?php e(lurl('helpdesk/settings')); ?>" role="button" class="secondary outline small">
      <?php e(t('Open settings')); ?>
    </a>
  </div>
<?php endif; ?>

<?php
$listTitle = t('Software products');
require templatePath('partials/app-list-titlebar.phtml');
?>
<?php
$filterUiNamespace = 'helpdesk-software-products';
require templatePath('partials/app-list-filters.phtml');
?>
<div class="app-list-table">
  <div id="helpdesk-software-products-grid"></div>
</div>

<script src="<?php e(assetVersion('vendor/gridjs/gridjs.umd.js')); ?>"></script>
<script type="application/json" id="page-config-helpdesk-software-products"><?php gridJsonForJs([
    'dataUrl' => lurl('helpdesk/software-products-data'),
    'gridLang' => gridLang(),
    'gridSearch' => $searchConfig,
    'filterSchema' => $clientFilterSchema,
    'filterChipMeta' => $filterChipMeta,
    'editBaseUrl' => lurl('helpdesk/software-products/edit/'),
    'labels' => [
        'code' => t('Code'),
        'bcDescription' => t('BC description'),
        'name' => t('Product name'),
        'status' => t('Status'),
    ],
]); ?></script>
<script type="module" src="<?php e(assetVersion('modules/helpdesk/js/pages/helpdesk-software-products-index.js')); ?>"></script>
