1<?php 2 3use Fisharebest\Webtrees\I18N; 4use Fisharebest\Webtrees\Submitter; 5use Illuminate\Database\Capsule\Manager as DB; 6use Illuminate\Database\Query\Expression; 7use Illuminate\Database\Query\JoinClause; 8 9?> 10 11<?php 12// Count the number of linked records. These numbers include private records. 13// It is not good to bypass privacy, but many servers do not have the resources 14// to process privacy for every record in the tree 15// Count the number of linked records. These numbers include private records. 16// It is not good to bypass privacy, but many servers do not have the resources 17// to process privacy for every record in the tree 18$count_individuals = DB::table('individuals') 19 ->join('link', static function (JoinClause $join): void { 20 $join->on('l_from', '=', 'i_id'); 21 $join->on('l_file', '=', 'i_file'); 22 }) 23 ->where('l_type', '=', Submitter::RECORD_TYPE) 24 ->where('l_file', '=', $tree->id()) 25 ->groupBy(['l_to']) 26 ->select(['l_to', new Expression('COUNT(*) AS total')]) 27 ->pluck('total', 'l_to') 28 ->all(); 29 30$count_families = DB::table('families') 31 ->join('link', static function (JoinClause $join): void { 32 $join->on('l_from', '=', 'f_id'); 33 $join->on('l_file', '=', 'f_file'); 34 }) 35 ->where('l_type', '=', Submitter::RECORD_TYPE) 36 ->where('l_file', '=', $tree->id()) 37 ->groupBy(['l_to']) 38 ->select(['l_to', new Expression('COUNT(*) AS total')]) 39 ->pluck('total', 'l_to') 40 ->all(); 41?> 42 43<table 44 class="table table-bordered table-sm wt-table-submitter datatables d-none" 45 <?= view('lists/datatables-attributes') ?> 46 data-auto-width="false" 47 data-columns="<?= e(json_encode([ 48 null, 49 ['visible' => array_sum($count_individuals) > 0], 50 ['visible' => array_sum($count_families) > 0], 51 ['visible' => (bool) $tree->getPreference('SHOW_LAST_CHANGE'), 'searchable' => false], 52 ])) ?>" 53 data-searchable="true" 54> 55 <caption class="sr-only"> 56 <?= $caption ?? I18N::translate('Submitters') ?> 57 </caption> 58 59 <thead> 60 <tr> 61 <th><?= I18N::translate('Submitter name') ?></th> 62 <th><?= I18N::translate('Individuals') ?></th> 63 <th><?= I18N::translate('Families') ?></th> 64 <th><?= I18N::translate('Last change') ?></th> 65 </tr> 66 </thead> 67 68 <tbody> 69 <?php foreach ($submitters as $submitter) : ?> 70 <tr class="<?= $submitter->isPendingDeletion() ? 'wt-old' : ($submitter->isPendingAddition() ? 'wt-new' : '') ?>"> 71 <td data-sort="<?= e($submitter->sortName()) ?>"> 72 <a href="<?= e($submitter->url()) ?>"> 73 <?= $submitter->fullName() ?> 74 </a> 75 </td> 76 77 <td class="text-center" data-sort="<?= $count_individuals[$submitter->xref()] ?? 0 ?>"> 78 <?= I18N::number($count_individuals[$submitter->xref()] ?? 0) ?> 79 </td> 80 81 <td class="text-center" data-sort="<?= $count_families[$submitter->xref()] ?? 0 ?>"> 82 <?= I18N::number($count_families[$submitter->xref()] ?? 0) ?> 83 </td> 84 85 <td data-sort="<?= $submitter->lastChangeTimestamp()->unix() ?>"> 86 <?= view('components/datetime', ['timestamp' => $submitter->lastChangeTimestamp()]) ?> 87 </td> 88 </tr> 89 <?php endforeach ?> 90 </tbody> 91</table> 92