1d70512abSGreg Roach<?php 2d70512abSGreg Roach 3*10e06497SGreg Roachdeclare(strict_types=1); 4*10e06497SGreg Roach 5d70512abSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel; 64b3ef6caSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\FixLevel0MediaAction; 74b3ef6caSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\FixLevel0MediaData; 8d70512abSGreg Roachuse Fisharebest\Webtrees\I18N; 9d70512abSGreg Roach 107c2c99faSGreg Roach/** 117c2c99faSGreg Roach * @var string $title 127c2c99faSGreg Roach */ 137c2c99faSGreg Roach 14d70512abSGreg Roach?> 15dd6b2bfcSGreg Roach<?php use Fisharebest\Webtrees\View; ?> 16dd6b2bfcSGreg Roach 170c0910bfSGreg Roach<?= view('components/breadcrumbs', ['links' => [route(ControlPanel::class) => I18N::translate('Control panel'), $title]]) ?> 18dd6b2bfcSGreg Roach 19dd6b2bfcSGreg Roach<h1><?= $title ?></h1> 20dd6b2bfcSGreg Roach 21dd6b2bfcSGreg Roach<p> 22dd6b2bfcSGreg Roach <?= I18N::translate('If a media object is linked to an individual, when it should be linked to a fact or event, then you can move it to the correct location.') ?> 23dd6b2bfcSGreg Roach</p> 24dd6b2bfcSGreg Roach 2571d313c5SGreg Roach<table 26b4139381SGreg Roach class="table table-bordered table-sm table-hover wt-fix-table datatables d-none" 2771d313c5SGreg Roach <?= view('lists/datatables-attributes') ?> 28728c8c27SGreg Roach data-ajax="<?= e(json_encode(['url' => route(FixLevel0MediaData::class)], JSON_THROW_ON_ERROR)) ?>" 2971d313c5SGreg Roach data-server-side="true" 3071d313c5SGreg Roach> 31315eb316SGreg Roach <caption class="visually-hidden"> 32dd6b2bfcSGreg Roach <?= I18N::translate('Media objects') ?> 33dd6b2bfcSGreg Roach </caption> 34dd6b2bfcSGreg Roach <thead class="thead-dark"> 35dd6b2bfcSGreg Roach <tr> 36dd6b2bfcSGreg Roach <th data-sortable="false"><?= I18N::translate('Family tree') ?></th> 37dd6b2bfcSGreg Roach <th data-sortable="false"><?= I18N::translate('Media object') ?></th> 38dd6b2bfcSGreg Roach <th data-sortable="false"><?= I18N::translate('Title') ?></th> 39dd6b2bfcSGreg Roach <th data-sortable="false"><?= I18N::translate('Individual') ?></th> 40dd6b2bfcSGreg Roach <th data-sortable="false"><?= I18N::translate('Facts and events') ?></th> 41dd6b2bfcSGreg Roach </tr> 42dd6b2bfcSGreg Roach </thead> 43dd6b2bfcSGreg Roach</table> 44dd6b2bfcSGreg Roach 45dd6b2bfcSGreg Roach<?php View::push('javascript') ?> 46dd6b2bfcSGreg Roach<script> 47dd6b2bfcSGreg Roach 'use strict'; 48dd6b2bfcSGreg Roach 49dd6b2bfcSGreg Roach // If we click on a button, post the request and reload the table 50dd6b2bfcSGreg Roach document.querySelector(".wt-fix-table").onclick = function (event) { 51dd6b2bfcSGreg Roach let element = event.target; 52dd6b2bfcSGreg Roach if (element.classList.contains("wt-fix-button")) { 53dd6b2bfcSGreg Roach event.stopPropagation(); 54dd6b2bfcSGreg Roach if (confirm(element.dataset.confirm)) { 55dd6b2bfcSGreg Roach $.ajax({ 56dd6b2bfcSGreg Roach data: { 57dd6b2bfcSGreg Roach "fact_id": element.dataset.factId, 58dd6b2bfcSGreg Roach "indi_xref": element.dataset.individualXref, 59dd6b2bfcSGreg Roach "obje_xref": element.dataset.mediaXref, 60dd6b2bfcSGreg Roach "tree_id": element.dataset.treeId 61dd6b2bfcSGreg Roach }, 62dd6b2bfcSGreg Roach method: "POST", 63728c8c27SGreg Roach url: <?= json_encode(route(FixLevel0MediaAction::class), JSON_THROW_ON_ERROR) ?> 64dd6b2bfcSGreg Roach }).done(function () { 65dd6b2bfcSGreg Roach $(".wt-fix-table").DataTable().ajax.reload(null, false); 66dd6b2bfcSGreg Roach }); 67dd6b2bfcSGreg Roach } 68dd6b2bfcSGreg Roach } 69dd6b2bfcSGreg Roach }; 70dd6b2bfcSGreg Roach</script> 71dd6b2bfcSGreg Roach<?php View::endpush() ?> 72