2020-06-21 23:53:38 +02:00
< ? php
echo $this -> element ( 'genericElements/IndexTable/index_table' , [
'data' => [
'data' => $data ,
'top_bar' => [
'children' => [
[
'type' => 'simple' ,
'children' => [
'data' => [
'type' => 'simple' ,
'text' => __ ( 'Add organisation' ),
'class' => 'btn btn-primary' ,
2023-09-12 14:11:15 +02:00
'popover_url' => '/organisations/add' ,
'requirement' => ! empty ( $loggedUser [ 'role' ][ 'perm_admin' ]),
2020-06-21 23:53:38 +02:00
]
]
],
2021-02-26 10:36:06 +01:00
[
'type' => 'context_filters' ,
'context_filters' => $filteringContexts
],
2020-06-21 23:53:38 +02:00
[
'type' => 'search' ,
2021-03-10 09:43:36 +01:00
'button' => __ ( 'Search' ),
2020-06-21 23:53:38 +02:00
'placeholder' => __ ( 'Enter value to search' ),
'data' => '' ,
2021-03-10 09:43:36 +01:00
'searchKey' => 'value' ,
'allowFilering' => true
2021-10-20 09:39:12 +02:00
],
[
'type' => 'table_action' ,
'table_setting_id' => 'organisation_index' ,
2020-06-21 23:53:38 +02:00
]
]
],
'fields' => [
[
'name' => '#' ,
'sort' => 'id' ,
'class' => 'short' ,
'data_path' => 'id' ,
],
[
'name' => __ ( 'Name' ),
'class' => 'short' ,
'data_path' => 'name' ,
2021-11-11 14:50:25 +01:00
'sort' => 'name' ,
2020-06-21 23:53:38 +02:00
],
[
'name' => __ ( 'UUID' ),
'sort' => 'uuid' ,
'class' => 'short' ,
'data_path' => 'uuid' ,
],
[
'name' => __ ( 'Members' ),
'data_path' => 'alignments' ,
'element' => 'count_summary' ,
'url' => '/individuals/index/?Organisations.id={{url_data}}' ,
'url_data_path' => 'id'
],
2023-09-12 09:26:07 +02:00
[
'name' => __ ( 'Group memberships' ),
'data_path' => 'org_groups' ,
'data_id_sub_path' => 'id' ,
'data_value_sub_path' => 'name' ,
'element' => 'link_list' ,
'url_pattern' => '/orgGroups/view/{{data_id}}'
],
2020-06-21 23:53:38 +02:00
[
'name' => __ ( 'URL' ),
'sort' => 'url' ,
'class' => 'short' ,
'data_path' => 'url' ,
],
[
2023-02-22 00:37:34 +01:00
'name' => __ ( 'Country' ),
2020-06-21 23:53:38 +02:00
'data_path' => 'nationality' ,
2021-11-11 14:50:25 +01:00
'sort' => 'nationality' ,
2020-06-21 23:53:38 +02:00
],
[
'name' => __ ( 'Sector' ),
'data_path' => 'sector' ,
2021-11-11 14:50:25 +01:00
'sort' => 'sector' ,
2020-06-21 23:53:38 +02:00
],
[
'name' => __ ( 'Type' ),
'data_path' => 'type' ,
2021-11-11 14:50:25 +01:00
'sort' => 'type' ,
2021-09-02 11:52:47 +02:00
],
[
'name' => __ ( 'Tags' ),
'data_path' => 'tags' ,
'element' => 'tags' ,
],
2020-06-21 23:53:38 +02:00
],
'title' => __ ( 'ContactDB Organisation Index' ),
'description' => __ ( 'A list of organisations known by your Cerebrate instance. This list can get populated either directly, by adding new organisations or by fetching them from trusted remote sources.' ),
2023-09-27 12:05:48 +02:00
'includeAllPagination' => true ,
2020-06-21 23:53:38 +02:00
'actions' => [
[
'url' => '/organisations/view' ,
'url_params_data_paths' => [ 'id' ],
'icon' => 'eye'
],
[
2021-01-11 16:28:07 +01:00
'open_modal' => '/organisations/edit/[onclick_params_data_path]' ,
'modal_params_data_path' => 'id' ,
2021-11-24 01:28:01 +01:00
'icon' => 'edit' ,
2023-09-12 11:08:46 +02:00
'complex_requirement' => [
2024-05-15 11:22:35 +02:00
'function' => function ( $row , $options ) use ( $loggedUser , $validOrgs ) {
2023-09-12 11:08:46 +02:00
if ( $loggedUser [ 'role' ][ 'perm_admin' ] || ( $loggedUser [ 'role' ][ 'perm_org_admin' ] && $row [ 'id' ] == $loggedUser [ 'organisation' ][ 'id' ])) {
return true ;
}
2024-05-15 11:22:35 +02:00
if ( $loggedUser [ 'role' ][ 'perm_group_admin' ] && in_array ( $row [ 'id' ], $validOrgs )) {
return true ;
}
2023-09-12 11:08:46 +02:00
return false ;
}
]
2020-06-21 23:53:38 +02:00
],
[
2021-01-11 16:28:07 +01:00
'open_modal' => '/organisations/delete/[onclick_params_data_path]' ,
'modal_params_data_path' => 'id' ,
2021-11-24 01:28:01 +01:00
'icon' => 'trash' ,
'requirement' => $loggedUser [ 'role' ][ 'perm_admin' ]
2021-01-11 16:28:07 +01:00
],
2020-06-21 23:53:38 +02:00
]
]
]);
echo '</div>' ;
?>