<?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('Customers');
require templatePath('partials/app-list-titlebar.phtml');
?>
<?php
$filterUiNamespace = 'helpdesk-search';
require templatePath('partials/app-list-filters.phtml');
?>
<div class="app-list-table">
  <div id="helpdesk-search-grid"></div>
</div>

<script src="<?php e(assetVersion('vendor/gridjs/gridjs.umd.js')); ?>"></script>
<script type="application/json" id="page-config-helpdesk-search"><?php gridJsonForJs([
    'dataUrl' => lurl('helpdesk/search-data'),
    'gridLang' => gridLang(),
    'gridSearch' => $searchConfig,
    'filterSchema' => $clientFilterSchema,
    'filterChipMeta' => $filterChipMeta,
    'labels' => [
        'debtorNo' => t('Debtor No.'),
        'name' => t('Name'),
        'city' => t('City'),
        'phone' => t('Phone'),
        'email' => t('E-Mail'),
    ],
]); ?></script>
<script type="module" src="<?php e(assetVersion('modules/helpdesk/js/pages/helpdesk-search-index.js')); ?>"></script>
