18c2e8227SGreg Roach<?php 20e62c4b8SGreg Roachnamespace Fisharebest\Webtrees\Module; 38c2e8227SGreg Roach 48c2e8227SGreg Roach/** 58c2e8227SGreg Roach * webtrees: online genealogy 68c2e8227SGreg Roach * Copyright (C) 2015 webtrees development team 78c2e8227SGreg Roach * This program is free software: you can redistribute it and/or modify 88c2e8227SGreg Roach * it under the terms of the GNU General Public License as published by 98c2e8227SGreg Roach * the Free Software Foundation, either version 3 of the License, or 108c2e8227SGreg Roach * (at your option) any later version. 118c2e8227SGreg Roach * This program is distributed in the hope that it will be useful, 128c2e8227SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 138c2e8227SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 148c2e8227SGreg Roach * GNU General Public License for more details. 158c2e8227SGreg Roach * You should have received a copy of the GNU General Public License 168c2e8227SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 178c2e8227SGreg Roach */ 180e62c4b8SGreg Roachuse Fisharebest\Webtrees\Controller\SimpleController; 190e62c4b8SGreg Roachuse Fisharebest\Webtrees\Family; 200e62c4b8SGreg Roachuse Fisharebest\Webtrees\Filter; 21*3d7a8a4cSGreg Roachuse Fisharebest\Webtrees\Functions\FunctionsDb; 220e62c4b8SGreg Roachuse Fisharebest\Webtrees\GedcomRecord; 230e62c4b8SGreg Roachuse Fisharebest\Webtrees\GedcomTag; 240e62c4b8SGreg Roachuse Fisharebest\Webtrees\I18N; 250e62c4b8SGreg Roachuse Fisharebest\Webtrees\Individual; 260e62c4b8SGreg Roachuse Fisharebest\Webtrees\Note; 278c2e8227SGreg Roach 288c2e8227SGreg Roach/** 298c2e8227SGreg Roach * Class CensusAssistantModule 308c2e8227SGreg Roach */ 3115834aaeSGreg Roachclass CensusAssistantModule extends AbstractModule { 328c2e8227SGreg Roach /** {@inheritdoc} */ 338c2e8227SGreg Roach public function getTitle() { 348c2e8227SGreg Roach return /* I18N: Name of a module */ I18N::translate('Census assistant'); 358c2e8227SGreg Roach } 368c2e8227SGreg Roach 378c2e8227SGreg Roach /** {@inheritdoc} */ 388c2e8227SGreg Roach public function getDescription() { 398c2e8227SGreg Roach return /* I18N: Description of the “Census assistant” module */ I18N::translate('An alternative way to enter census transcripts and link them to individuals.'); 408c2e8227SGreg Roach } 418c2e8227SGreg Roach 428c2e8227SGreg Roach /** {@inheritdoc} */ 438c2e8227SGreg Roach public function modAction($mod_action) { 448c2e8227SGreg Roach switch ($mod_action) { 4540990b78SGreg Roach case 'census_find': 4640990b78SGreg Roach self::censusFind(); 478c2e8227SGreg Roach break; 4840990b78SGreg Roach case 'media_find': 49764a01d9SGreg Roach self::mediaFind(); 508c2e8227SGreg Roach break; 518c2e8227SGreg Roach case 'media_query_3a': 52764a01d9SGreg Roach self::mediaQuery(); 538c2e8227SGreg Roach break; 548c2e8227SGreg Roach default: 558c2e8227SGreg Roach http_response_code(404); 568c2e8227SGreg Roach } 578c2e8227SGreg Roach } 588c2e8227SGreg Roach 598c2e8227SGreg Roach /** 608c2e8227SGreg Roach * ... 618c2e8227SGreg Roach */ 6240990b78SGreg Roach private static function censusFind() { 6340990b78SGreg Roach global $WT_TREE; 6440990b78SGreg Roach 6540990b78SGreg Roach $controller = new SimpleController; 6640990b78SGreg Roach 6740990b78SGreg Roach $filter = Filter::get('filter'); 6840990b78SGreg Roach $action = Filter::get('action'); 6940990b78SGreg Roach $callback = Filter::get('callback'); 7040990b78SGreg Roach $multiple = Filter::getBool('multiple'); 7140990b78SGreg Roach 7240990b78SGreg Roach $controller 7340990b78SGreg Roach ->setPageTitle(I18N::translate('Find an individual')) 7440990b78SGreg Roach ->pageHeader(); 7540990b78SGreg Roach 7640990b78SGreg Roach ?> 7740990b78SGreg Roach <script> 7840990b78SGreg Roach function pasterow(id, nam, mnam, label, gend, cond, dom, dob, dod, occu, age, birthpl, fbirthpl, mbirthpl, chilBLD) { 7940990b78SGreg Roach window.opener.insertRowToTable(id, nam, mnam, label, gend, cond, dom, dob, dod, occu, age, birthpl, fbirthpl, mbirthpl, chilBLD); 8040990b78SGreg Roach <?php if (!$multiple) echo "window.close();"; ?> 8140990b78SGreg Roach } 8240990b78SGreg Roach 8340990b78SGreg Roach function pasteid(id, name, thumb) { 8440990b78SGreg Roach if (thumb) { 8540990b78SGreg Roach window.opener.<?php echo $callback; ?>(id, name, thumb); 8640990b78SGreg Roach <?php if (!$multiple) echo "window.close();"; ?> 8740990b78SGreg Roach } else { 8840990b78SGreg Roach // GEDFact_assistant ======================== 8940990b78SGreg Roach if (window.opener.document.getElementById('addlinkQueue')) { 9040990b78SGreg Roach window.opener.insertRowToTable(id, name); 9140990b78SGreg Roach } 9240990b78SGreg Roach window.opener.<?php echo $callback; ?>(id); 9340990b78SGreg Roach if (window.opener.pastename) { 9440990b78SGreg Roach window.opener.pastename(name); 9540990b78SGreg Roach } 9640990b78SGreg Roach <?php if (!$multiple) echo "window.close();"; ?> 9740990b78SGreg Roach } 9840990b78SGreg Roach } 9940990b78SGreg Roach </script> 10040990b78SGreg Roach <?php 10140990b78SGreg Roach 10240990b78SGreg Roach echo "<div align=\"center\">"; 10340990b78SGreg Roach echo "<table class=\"list_table width90\" border=\"0\">"; 10440990b78SGreg Roach echo "<tr><td style=\"padding: 10px;\" valign=\"top\" class=\"facts_label03 width90\">"; 10540990b78SGreg Roach echo I18N::translate('Find an individual'); 10640990b78SGreg Roach echo "</td>"; 10740990b78SGreg Roach echo "</table>"; 10840990b78SGreg Roach echo "<br>"; 10940990b78SGreg Roach 11040990b78SGreg Roach if ($action == "filter") { 11140990b78SGreg Roach $filter = trim($filter); 11240990b78SGreg Roach $filter_array = explode(' ', preg_replace('/ {2,}/', ' ', $filter)); 11340990b78SGreg Roach 11440990b78SGreg Roach // Output Individual for GEDFact Assistant ====================== 11540990b78SGreg Roach echo "<table class=\"tabs_table width90\">"; 116*3d7a8a4cSGreg Roach $myindilist = FunctionsDb::searchIndividualNames($filter_array, array($WT_TREE)); 11740990b78SGreg Roach if ($myindilist) { 11840990b78SGreg Roach echo "<tr><td class=\"list_value_wrap\"><ul>"; 11940990b78SGreg Roach usort($myindilist, '\Fisharebest\Webtrees\GedcomRecord::compare'); 12040990b78SGreg Roach foreach ($myindilist as $indi) { 12140990b78SGreg Roach $nam = $indi->getAllNames(); 12240990b78SGreg Roach $wholename = rtrim($nam[0]['givn'], '*') . " " . $nam[0]['surname']; 12340990b78SGreg Roach $fulln = rtrim($nam[0]['givn'], '*') . " " . $nam[0]['surname']; 12440990b78SGreg Roach $fulln = str_replace('"', '\'', $fulln); // Replace double quotes 12540990b78SGreg Roach $fulln = str_replace("@N.N.", "(" . I18N::translate('unknown') . ")", $fulln); 12640990b78SGreg Roach $fulln = str_replace("@P.N.", "(" . I18N::translate('unknown') . ")", $fulln); 12740990b78SGreg Roach $givn = rtrim($nam[0]['givn'], '*'); 12840990b78SGreg Roach $surn = $nam[0]['surname']; 12940990b78SGreg Roach if (isset($nam[1])) { 13040990b78SGreg Roach $fulmn = rtrim($nam[1]['givn'], '*') . " " . $nam[1]['surname']; 13140990b78SGreg Roach $fulmn = str_replace('"', '\'', $fulmn); // Replace double quotes 13240990b78SGreg Roach $fulmn = str_replace("@N.N.", "(" . I18N::translate('unknown') . ")", $fulmn); 13340990b78SGreg Roach $fulmn = str_replace("@P.N.", "(" . I18N::translate('unknown') . ")", $fulmn); 13440990b78SGreg Roach $marn = $nam[1]['surname']; 13540990b78SGreg Roach } else { 13640990b78SGreg Roach $fulmn = $fulln; 13740990b78SGreg Roach } 13840990b78SGreg Roach 13940990b78SGreg Roach //-- Build Indi Parents Family to get FBP and MBP ----------- 14040990b78SGreg Roach foreach ($indi->getChildFamilies() as $family) { 14140990b78SGreg Roach $father = $family->getHusband(); 14240990b78SGreg Roach $mother = $family->getWife(); 14340990b78SGreg Roach if (!is_null($father)) { 14440990b78SGreg Roach $FBP = $father->getBirthPlace(); 14540990b78SGreg Roach } 14640990b78SGreg Roach if (!is_null($mother)) { 14740990b78SGreg Roach $MBP = $mother->getBirthPlace(); 14840990b78SGreg Roach } 14940990b78SGreg Roach } 15040990b78SGreg Roach if (!isset($FBP)) { $FBP = "UNK, UNK, UNK, UNK"; } 15140990b78SGreg Roach if (!isset($MBP)) { $MBP = "UNK, UNK, UNK, UNK"; } 15240990b78SGreg Roach 15340990b78SGreg Roach //-- Build Indi Spouse Family to get marriage Date ---------- 15440990b78SGreg Roach foreach ($indi->getSpouseFamilies() as $family) { 15540990b78SGreg Roach $marrdate = $family->getMarriageDate(); 15640990b78SGreg Roach $marrdate = ($marrdate->minimumJulianDay() + $marrdate->maximumJulianDay()) / 2; // Julian 15740990b78SGreg Roach $children = $family->getChildren(); 15840990b78SGreg Roach } 15940990b78SGreg Roach if (!isset($marrdate)) { $marrdate = ""; } 16040990b78SGreg Roach 16140990b78SGreg Roach //-- Get Children’s Name, DOB, DOD -------------------------- 16240990b78SGreg Roach $chBLDarray = array(); 16340990b78SGreg Roach if (isset($children)) { 16440990b78SGreg Roach foreach ($children as $key => $child) { 16540990b78SGreg Roach $chnam = $child->getAllNames(); 16640990b78SGreg Roach $chfulln = rtrim($chnam[0]['givn'], '*') . " " . $chnam[0]['surname']; 16740990b78SGreg Roach $chfulln = str_replace('"', "", $chfulln); // Must remove quotes completely here 16840990b78SGreg Roach $chfulln = str_replace("@N.N.", "(" . I18N::translate('unknown') . ")", $chfulln); 16940990b78SGreg Roach $chfulln = str_replace("@P.N.", "(" . I18N::translate('unknown') . ")", $chfulln); // Child’s Full Name 17040990b78SGreg Roach $chdob = ($child->getBirthDate()->minimumJulianDay() + $child->getBirthDate()->maximumJulianDay()) / 2; // Child’s Date of Birth (Julian) 17140990b78SGreg Roach if (!isset($chdob)) { $chdob = ""; } 17240990b78SGreg Roach $chdod = ($child->getDeathDate()->minimumJulianDay() + $child->getDeathDate()->maximumJulianDay()) / 2; // Child’s Date of Death (Julian) 17340990b78SGreg Roach if (!isset($chdod)) { $chdod = ""; } 17440990b78SGreg Roach $chBLD = ($chfulln . ", " . $chdob . ", " . $chdod); 17540990b78SGreg Roach array_push($chBLDarray, $chBLD); 17640990b78SGreg Roach } 17740990b78SGreg Roach } 17840990b78SGreg Roach if ($chBLDarray && $indi->getSex() == "F") { 17940990b78SGreg Roach $chBLDarray = implode("::", $chBLDarray); 18040990b78SGreg Roach } else { 18140990b78SGreg Roach $chBLDarray = ''; 18240990b78SGreg Roach } 18340990b78SGreg Roach 18440990b78SGreg Roach echo "<li>"; 18540990b78SGreg Roach // ============================================================================================================================== 18640990b78SGreg Roach // NOTES = is equivalent to= function pasterow(id, nam, mnam, label, gend, cond, dom, dob, age, dod, occu, birthpl, fbirthpl, mbirthpl, chilBLD) { 18740990b78SGreg Roach // ============================================================================================================================== 18840990b78SGreg Roach echo "<a href=\"#\" onclick=\"window.opener.insertRowToTable("; 18940990b78SGreg Roach echo "'" . $indi->getXref() . "', "; // id - Indi Id 19040990b78SGreg Roach echo "'" . addslashes(strip_tags($fulln)) . "', "; // nam - Name 19140990b78SGreg Roach echo "'" . addslashes(strip_tags($fulmn)) . "', "; // mnam - Married Name 19240990b78SGreg Roach echo "'-', "; // label - Relation to Head of Household 19340990b78SGreg Roach echo "'" . $indi->getSex() . "', "; // gend - Sex 19440990b78SGreg Roach echo "'S', "; // cond - Marital Condition 19540990b78SGreg Roach echo "'" . $marrdate . "', "; // dom - Date of Marriage 19640990b78SGreg Roach echo "'" . (($indi->getBirthDate()->minimumJulianDay() + $indi->getBirthDate()->maximumJulianDay()) / 2) . "' ,"; // dob - Date of Birth 19740990b78SGreg Roach echo "'" . (1901 - $indi->getbirthyear()) . "' ,"; // ~age~ - Census Date minus YOB (Preliminary) 19840990b78SGreg Roach echo "'" . (($indi->getDeathDate()->minimumJulianDay() + $indi->getDeathDate()->maximumJulianDay()) / 2) . "' ,"; // dod - Date of Death 19940990b78SGreg Roach echo "'', "; // occu - Occupation 20040990b78SGreg Roach echo "'" . Filter::escapeHtml($indi->getbirthplace()) . "', "; // birthpl - Birthplace 20140990b78SGreg Roach echo "'" . $FBP . "', "; // fbirthpl - Father’s Birthplace 20240990b78SGreg Roach echo "'" . $MBP . "', "; // mbirthpl - Mother’s Birthplace 20340990b78SGreg Roach echo "'" . $chBLDarray . "'"; // chilBLD - Array of Children (name, birthdate, deathdate) 20440990b78SGreg Roach echo ");"; 20540990b78SGreg Roach echo "return false;\">"; 20640990b78SGreg Roach echo "<b>" . $indi->getFullName() . "</b> "; // Name Link 20740990b78SGreg Roach echo "</span><br><span class=\"list_item\">", GedcomTag::getLabel('BIRT', $indi), " ", $indi->getbirthyear(), " ", $indi->getbirthplace(), "</span>"; 20840990b78SGreg Roach echo "</a>"; 20940990b78SGreg Roach echo "</li>"; 21040990b78SGreg Roach echo "<hr>"; 21140990b78SGreg Roach } 21240990b78SGreg Roach echo '</ul></td></tr>'; 21340990b78SGreg Roach } else { 21440990b78SGreg Roach echo "<tr><td class=\"list_value_wrap\">"; 21540990b78SGreg Roach echo I18N::translate('No results found.'); 21640990b78SGreg Roach echo "</td></tr>"; 21740990b78SGreg Roach } 21840990b78SGreg Roach echo "</table>"; 21940990b78SGreg Roach } 22040990b78SGreg Roach echo '<button onclick="window.close();">', I18N::translate('close'), '</button>'; 22140990b78SGreg Roach echo "</div>"; // Close div that centers table 22240990b78SGreg Roach } 22340990b78SGreg Roach 22440990b78SGreg Roach /** 22540990b78SGreg Roach * ... 22640990b78SGreg Roach */ 227764a01d9SGreg Roach private static function mediaFind() { 2288c2e8227SGreg Roach global $WT_TREE; 2298c2e8227SGreg Roach 2308c2e8227SGreg Roach $controller = new SimpleController; 2318c2e8227SGreg Roach $filter = Filter::get('filter'); 2328c2e8227SGreg Roach $multiple = Filter::getBool('multiple'); 2338c2e8227SGreg Roach 2348c2e8227SGreg Roach $controller 2358c2e8227SGreg Roach ->setPageTitle(I18N::translate('Find an individual')) 2368c2e8227SGreg Roach ->pageHeader(); 2378c2e8227SGreg Roach 2388c2e8227SGreg Roach echo '<script>'; 2398c2e8227SGreg Roach ?> 2408c2e8227SGreg Roach 2418c2e8227SGreg Roach function pasterow(id, name, gend, yob, age, bpl) { 2428c2e8227SGreg Roach window.opener.opener.insertRowToTable(id, name, '', gend, '', yob, age, 'Y', '', bpl); 2438c2e8227SGreg Roach } 2448c2e8227SGreg Roach 2458c2e8227SGreg Roach function pasteid(id, name, thumb) { 2468c2e8227SGreg Roach if (thumb) { 2478c2e8227SGreg Roach window.opener.paste_id(id, name, thumb); 2488c2e8227SGreg Roach <?php if (!$multiple) echo "window.close();"; ?> 2498c2e8227SGreg Roach } else { 2508c2e8227SGreg Roach // GEDFact_assistant ======================== 2518c2e8227SGreg Roach if (window.opener.document.getElementById('addlinkQueue')) { 2528c2e8227SGreg Roach window.opener.insertRowToTable(id, name); 2538c2e8227SGreg Roach } 2548c2e8227SGreg Roach window.opener.paste_id(id); 2558c2e8227SGreg Roach if (window.opener.pastename) { 2568c2e8227SGreg Roach window.opener.pastename(name); 2578c2e8227SGreg Roach } 2588c2e8227SGreg Roach <?php if (!$multiple) echo "window.close();"; ?> 2598c2e8227SGreg Roach } 2608c2e8227SGreg Roach } 2618c2e8227SGreg Roach function checknames(frm) { 2628c2e8227SGreg Roach if (document.forms[0].subclick) { 2638c2e8227SGreg Roach button = document.forms[0].subclick.value; 2648c2e8227SGreg Roach } else { 2658c2e8227SGreg Roach button = ""; 2668c2e8227SGreg Roach } 2678c2e8227SGreg Roach if (frm.filter.value.length<2&button!="all") { 26877e70a22SGreg Roach alert("<?php echo I18N::translate('Please enter more than one character.'); ?>"); 2698c2e8227SGreg Roach frm.filter.focus(); 2708c2e8227SGreg Roach return false; 2718c2e8227SGreg Roach } 2728c2e8227SGreg Roach if (button=="all") { 2738c2e8227SGreg Roach frm.filter.value = ""; 2748c2e8227SGreg Roach } 2758c2e8227SGreg Roach return true; 2768c2e8227SGreg Roach } 2778c2e8227SGreg Roach <?php 2788c2e8227SGreg Roach echo '</script>'; 2798c2e8227SGreg Roach 2808c2e8227SGreg Roach echo "<div align=\"center\">"; 2818c2e8227SGreg Roach echo "<table class=\"list_table width90\" border=\"0\">"; 2828c2e8227SGreg Roach echo "<tr><td style=\"padding: 10px;\" valign=\"top\" class=\"facts_label03 width90\">"; // start column for find text header 2838c2e8227SGreg Roach echo $controller->getPageTitle(); 2848c2e8227SGreg Roach echo "</td>"; 2858c2e8227SGreg Roach echo "</tr>"; 2868c2e8227SGreg Roach echo "</table>"; 2878c2e8227SGreg Roach echo "<br>"; 2888c2e8227SGreg Roach echo '<button onclick="window.close();">', I18N::translate('close'), '</button>'; 2898c2e8227SGreg Roach echo "<br>"; 2908c2e8227SGreg Roach 2918c2e8227SGreg Roach $filter = trim($filter); 2928c2e8227SGreg Roach $filter_array = explode(' ', preg_replace('/ {2,}/', ' ', $filter)); 2938c2e8227SGreg Roach echo "<table class=\"tabs_table width90\"><tr>"; 294*3d7a8a4cSGreg Roach $myindilist = FunctionsDb::searchIndividualNames($filter_array, array($WT_TREE)); 2958c2e8227SGreg Roach if ($myindilist) { 2968c2e8227SGreg Roach echo "<td class=\"list_value_wrap\"><ul>"; 2970e62c4b8SGreg Roach usort($myindilist, '\Fisharebest\Webtrees\GedcomRecord::compare'); 2988c2e8227SGreg Roach foreach ($myindilist as $indi) { 2998c2e8227SGreg Roach $nam = Filter::escapeHtml($indi->getFullName()); 3008c2e8227SGreg Roach echo "<li><a href=\"#\" onclick=\"pasterow( 3018c2e8227SGreg Roach '" . $indi->getXref() . "' , 3028c2e8227SGreg Roach '" . $nam . "' , 3038c2e8227SGreg Roach '" . $indi->getSex() . "' , 3048c2e8227SGreg Roach '" . $indi->getbirthyear() . "' , 3058c2e8227SGreg Roach '" . (1901 - $indi->getbirthyear()) . "' , 3068c2e8227SGreg Roach '" . $indi->getbirthplace() . "'); return false;\"> 3078c2e8227SGreg Roach <b>" . $indi->getFullName() . "</b> "; 3088c2e8227SGreg Roach 309764a01d9SGreg Roach $born = GedcomTag::getLabel('BIRT'); 3108c2e8227SGreg Roach echo "</span><br><span class=\"list_item\">", $born, " ", $indi->getbirthyear(), " ", $indi->getbirthplace(), "</span></a></li>"; 3118c2e8227SGreg Roach echo "<hr>"; 3128c2e8227SGreg Roach } 3138c2e8227SGreg Roach echo '</ul></td></tr><tr><td class="list_label">', I18N::translate('Total individuals: %s', count($myindilist)), '</tr></td>'; 3148c2e8227SGreg Roach } else { 3158c2e8227SGreg Roach echo "<td class=\"list_value_wrap\">"; 3168c2e8227SGreg Roach echo I18N::translate('No results found.'); 3178c2e8227SGreg Roach echo "</td></tr>"; 3188c2e8227SGreg Roach } 3198c2e8227SGreg Roach echo "</table>"; 3208c2e8227SGreg Roach echo '</div>'; 3218c2e8227SGreg Roach } 3228c2e8227SGreg Roach 3238c2e8227SGreg Roach /** 3248c2e8227SGreg Roach * ... 3258c2e8227SGreg Roach */ 326764a01d9SGreg Roach private static function mediaQuery() { 32724ec66ceSGreg Roach global $WT_TREE; 32824ec66ceSGreg Roach 3298c2e8227SGreg Roach $iid2 = Filter::get('iid', WT_REGEX_XREF); 3308c2e8227SGreg Roach 3318c2e8227SGreg Roach $controller = new SimpleController; 3328c2e8227SGreg Roach $controller 3338c2e8227SGreg Roach ->setPageTitle(I18N::translate('Link to an existing media object')) 3348c2e8227SGreg Roach ->pageHeader(); 3358c2e8227SGreg Roach 33624ec66ceSGreg Roach $record = GedcomRecord::getInstance($iid2, $WT_TREE); 3378c2e8227SGreg Roach if ($record) { 3388c2e8227SGreg Roach $headjs = ''; 3398c2e8227SGreg Roach if ($record instanceof Family) { 3408c2e8227SGreg Roach if ($record->getHusband()) { 3418c2e8227SGreg Roach $headjs = $record->getHusband()->getXref(); 3428c2e8227SGreg Roach } elseif ($record->getWife()) { 3438c2e8227SGreg Roach $headjs = $record->getWife()->getXref(); 3448c2e8227SGreg Roach } 3458c2e8227SGreg Roach } 3468c2e8227SGreg Roach ?> 3478c2e8227SGreg Roach <script> 3488c2e8227SGreg Roach function insertId() { 3498c2e8227SGreg Roach if (window.opener.document.getElementById('addlinkQueue')) { 3508c2e8227SGreg Roach // alert('Please move this alert window and examine the contents of the pop-up window, then click OK') 3518c2e8227SGreg Roach window.opener.insertRowToTable('<?php echo $record->getXref(); ?>', '<?php echo htmlSpecialChars($record->getFullName()); ?>', '<?php echo $headjs; ?>'); 3528c2e8227SGreg Roach window.close(); 3538c2e8227SGreg Roach } 3548c2e8227SGreg Roach } 3558c2e8227SGreg Roach </script> 3568c2e8227SGreg Roach <?php 3578c2e8227SGreg Roach 3588c2e8227SGreg Roach } else { 3598c2e8227SGreg Roach ?> 3608c2e8227SGreg Roach <script> 3618c2e8227SGreg Roach function insertId() { 36277e70a22SGreg Roach window.opener.alert('<?php echo $iid2; ?> - <?php echo I18N::translate('Not a valid individual, family, or source ID'); ?>'); 3638c2e8227SGreg Roach window.close(); 3648c2e8227SGreg Roach } 3658c2e8227SGreg Roach </script> 3668c2e8227SGreg Roach <?php 3678c2e8227SGreg Roach } 3688c2e8227SGreg Roach ?> 3698c2e8227SGreg Roach <script>window.onLoad = insertId();</script> 3708c2e8227SGreg Roach <?php 3718c2e8227SGreg Roach } 3728c2e8227SGreg Roach 3738c2e8227SGreg Roach /** 3748c2e8227SGreg Roach * Convert custom markup into HTML 3758c2e8227SGreg Roach * 3768c2e8227SGreg Roach * @param Note $note 3778c2e8227SGreg Roach * 3788c2e8227SGreg Roach * @return string 3798c2e8227SGreg Roach */ 3808c2e8227SGreg Roach public static function formatCensusNote(Note $note) { 3818c2e8227SGreg Roach global $WT_TREE; 3828c2e8227SGreg Roach 3838c2e8227SGreg Roach $headers = array( 3848c2e8227SGreg Roach 'AgM' => 'Age at first marriage', 3858c2e8227SGreg Roach 'Age' => 'Age at last birthday', 3868c2e8227SGreg Roach 'Assets' => 'Assets = Owned,Rented - Value,Rent - Radio - Farm', 3878c2e8227SGreg Roach 'BIC' => 'Born in County', 3888c2e8227SGreg Roach 'BOE' => 'Born outside England', 3898c2e8227SGreg Roach 'BP' => 'Birthplace - (Chapman format)', 3908c2e8227SGreg Roach 'Birthplace' => 'Birthplace (Full format)', 3918c2e8227SGreg Roach 'Bmth' => 'Month of birth - If born within Census year', 3928c2e8227SGreg Roach 'ChB' => 'Children born alive', 3938c2e8227SGreg Roach 'ChD' => 'Children who have died', 3948c2e8227SGreg Roach 'ChL' => 'Children still living', 3958c2e8227SGreg Roach 'DOB' => 'Date of birth', 3968c2e8227SGreg Roach 'Edu' => 'Education - At School, Can Read, Can Write', // or "Cannot Read, Cannot Write" ?? 3978c2e8227SGreg Roach 'EmD' => 'Employed?', 3988c2e8227SGreg Roach 'EmN' => 'Unemployed?', 3998c2e8227SGreg Roach 'EmR' => 'Employer?', 4008c2e8227SGreg Roach 'Employ' => 'Employment', 4018c2e8227SGreg Roach 'Eng?' => 'English spoken?', 4028c2e8227SGreg Roach 'EngL' => 'English spoken?, if not, Native Language', 4038c2e8227SGreg Roach 'FBP' => 'Father’s Birthplace - (Chapman format)', 4048c2e8227SGreg Roach 'Health' => 'Health - 1.Blind, 2.Deaf & Dumb, 3.Idiotic, 4.Insane, 5.Disabled etc', 4058c2e8227SGreg Roach 'Home' => 'Home Ownership - Owned/Rented-Free/Mortgaged-Farm/House-Farm Schedule number', 4068c2e8227SGreg Roach 'Industry' => 'Industry', 4078c2e8227SGreg Roach 'Infirm' => 'Infirmities - 1. Deaf & Dumb, 2. Blind, 3. Lunatic, 4. Imbecile/feeble-minded', 4088c2e8227SGreg Roach 'Lang' => 'If Foreign Born - Native Language', 4098c2e8227SGreg Roach 'MBP' => 'Mother’s Birthplace - (Chapman format)', 4108c2e8227SGreg Roach 'MC' => 'Marital Condition - Married, Single, Unmarried, Widowed or Divorced', 4118c2e8227SGreg Roach 'Mmth' => 'Month of marriage - If married during Census Year', 4128c2e8227SGreg Roach 'MnsE' => 'Months employed during Census Year', 4138c2e8227SGreg Roach 'MnsU' => 'Months unemployed during Census Year', 4148c2e8227SGreg Roach 'N/A' => 'If Foreign Born - Naturalized, Alien', 4158c2e8227SGreg Roach 'NL' => 'If Foreign Born - Native Language', 4168c2e8227SGreg Roach 'Name' => 'Full Name or Married name if married', 4178c2e8227SGreg Roach 'Occupation' => 'Occupation', 4188c2e8227SGreg Roach 'Par' => 'Parentage - Father if foreign born, Mother if foreign born', 4198c2e8227SGreg Roach 'Race' => 'Race or Color - Black, White, Mulatto, Asian, Indian, Chinese etc', 4208c2e8227SGreg Roach 'Relation' => 'Relationship to Head of Household', 4218c2e8227SGreg Roach 'Sex' => 'Male or Female', 4228c2e8227SGreg Roach 'Situ' => 'Situation - Disease, Infirmity, Convict, Pauper etc', 4238c2e8227SGreg Roach 'Ten' => 'Tenure - Owned/Rented, (if owned)Free/Morgaged', 4248c2e8227SGreg Roach 'Vet' => 'War Veteran?', 4258c2e8227SGreg Roach 'WH' => 'Working at Home?', 4268c2e8227SGreg Roach 'War' => 'War or Expedition', 4278c2e8227SGreg Roach 'WksU' => 'Weeks unemployed during Census Year', 4288c2e8227SGreg Roach 'YOI' => 'If Foreign Born - Year of immigration', 4298c2e8227SGreg Roach 'YON' => 'If Foreign Born - Year of naturalization', 4308c2e8227SGreg Roach 'YUS' => 'If Foreign Born - Years in the USA', 4318c2e8227SGreg Roach 'YrsM' => 'Years Married, or Y if married in Census Year', 4328c2e8227SGreg Roach ); 4338c2e8227SGreg Roach 4348c2e8227SGreg Roach if (preg_match('/(.*)((?:\n.*)*)\n\.start_formatted_area\.\n(.*)((?:\n.*)*)\n.end_formatted_area\.((?:\n.*)*)/', $note->getNote(), $match)) { 4358c2e8227SGreg Roach // This looks like a census-assistant shared note 4368c2e8227SGreg Roach $title = Filter::escapeHtml($match[1]); 4378c2e8227SGreg Roach $preamble = Filter::escapeHtml($match[2]); 4388c2e8227SGreg Roach $header = Filter::escapeHtml($match[3]); 4398c2e8227SGreg Roach $data = Filter::escapeHtml($match[4]); 4408c2e8227SGreg Roach $postamble = Filter::escapeHtml($match[5]); 4418c2e8227SGreg Roach 4428c2e8227SGreg Roach $fmt_headers = array(); 4438c2e8227SGreg Roach foreach ($headers as $key => $value) { 4448c2e8227SGreg Roach $fmt_headers['.b.' . $key] = '<span title="' . Filter::escapeHtml($value) . '">' . $key . '</span>'; 4458c2e8227SGreg Roach } 4468c2e8227SGreg Roach 4478c2e8227SGreg Roach // Substitue header labels and format as HTML 4488c2e8227SGreg Roach $thead = '<tr><th>' . strtr(str_replace('|', '</th><th>', $header), $fmt_headers) . '</th></tr>'; 4498c2e8227SGreg Roach 4508c2e8227SGreg Roach // Format data as HTML 4518c2e8227SGreg Roach $tbody = ''; 4528c2e8227SGreg Roach foreach (explode("\n", $data) as $row) { 4538c2e8227SGreg Roach $tbody .= '<tr>'; 4548c2e8227SGreg Roach foreach (explode('|', $row) as $column) { 4558c2e8227SGreg Roach $tbody .= '<td>' . $column . '</td>'; 4568c2e8227SGreg Roach } 4578c2e8227SGreg Roach $tbody .= '</tr>'; 4588c2e8227SGreg Roach } 4598c2e8227SGreg Roach 4608c2e8227SGreg Roach return 4618c2e8227SGreg Roach $title . "\n" . // The newline allows the framework to expand the details and turn the first line into a link 4628c2e8227SGreg Roach '<p>' . $preamble . '</p>' . 4638c2e8227SGreg Roach '<table class="table-census-assistant">' . 4648c2e8227SGreg Roach '<thead>' . $thead . '</thead>' . 4658c2e8227SGreg Roach '<tbody>' . $tbody . '</tbody>' . 4668c2e8227SGreg Roach '</table>' . 4678c2e8227SGreg Roach '<p>' . $postamble . '</p>'; 4688c2e8227SGreg Roach } else { 4698c2e8227SGreg Roach // Not a census-assistant shared note - apply default formatting 4708c2e8227SGreg Roach return Filter::formatText($note->getNote(), $WT_TREE); 4718c2e8227SGreg Roach } 4728c2e8227SGreg Roach } 4738c2e8227SGreg Roach 4748c2e8227SGreg Roach /** 4758c2e8227SGreg Roach * Modify the “add shared note” field, to create a note using the assistant 4768c2e8227SGreg Roach * 4778c2e8227SGreg Roach * @param string $element_id 4788c2e8227SGreg Roach * @param string $xref 4798c2e8227SGreg Roach * @param string $action 4808c2e8227SGreg Roach * 4818c2e8227SGreg Roach * @return string 4828c2e8227SGreg Roach */ 483ffd703eaSGreg Roach public static function addNoteWithAssistantLink($element_id, $xref, $action) { 48424ec66ceSGreg Roach global $controller, $WT_TREE; 4858c2e8227SGreg Roach 4868c2e8227SGreg Roach // We do not yet support family records 48724ec66ceSGreg Roach if (!GedcomRecord::getInstance($xref, $WT_TREE) instanceof Individual) { 4888c2e8227SGreg Roach return ''; 4898c2e8227SGreg Roach } 4908c2e8227SGreg Roach 4918c2e8227SGreg Roach // Only modify “add shared note” links on the add/edit actions. 4928c2e8227SGreg Roach // TODO: does the “edit” action work? 4938c2e8227SGreg Roach if ($action != 'add' && $action != 'edit') { 4948c2e8227SGreg Roach return ''; 4958c2e8227SGreg Roach } 4968c2e8227SGreg Roach 4978c2e8227SGreg Roach $controller->addInlineJavascript(' 4988c2e8227SGreg Roach var pid_array=jQuery("#pid_array"); 4998c2e8227SGreg Roach function set_pid_array(pa) { 5008c2e8227SGreg Roach pid_array.val(pa); 5018c2e8227SGreg Roach } 5028c2e8227SGreg Roach '); 5038c2e8227SGreg Roach 5048c2e8227SGreg Roach return 5058c2e8227SGreg Roach '<br>' . 5068c2e8227SGreg Roach '<input type="hidden" name="pid_array" id="pid_array" value="">' . 5078c2e8227SGreg Roach '<a href="#" onclick="return addnewnote_assisted(document.getElementById(\'' . $element_id . '\'), \'' . $xref . '\');">' . 5088c2e8227SGreg Roach I18N::translate('Create a new shared note using assistant') . 5098c2e8227SGreg Roach '</a>'; 5108c2e8227SGreg Roach } 5118c2e8227SGreg Roach 5128c2e8227SGreg Roach /** 5138c2e8227SGreg Roach * Add a selector containing UK/US/FR census dates 5148c2e8227SGreg Roach * 5158c2e8227SGreg Roach * @param string $action 5168c2e8227SGreg Roach * @param string $tag 5178c2e8227SGreg Roach * @param string $element_id 5188c2e8227SGreg Roach * 5198c2e8227SGreg Roach * @return string 5208c2e8227SGreg Roach */ 5218c2e8227SGreg Roach public static function censusDateSelector($action, $tag, $element_id) { 5228c2e8227SGreg Roach global $controller; 5238c2e8227SGreg Roach 5248c2e8227SGreg Roach if ($action == 'add' && $tag == 'CENS') { 5258c2e8227SGreg Roach $controller->addInlineJavascript(' 5268c2e8227SGreg Roach function addDate(theCensDate) { 5278c2e8227SGreg Roach var ddate = theCensDate.split(", "); 5288c2e8227SGreg Roach document.getElementById("setctry").value = ddate[3]; 5298c2e8227SGreg Roach document.getElementById("setyear").value = ddate[0]; 5308c2e8227SGreg Roach cal_setDateField("' . $element_id . '", parseInt(ddate[0]), parseInt(ddate[1]), parseInt(ddate[2])); 5318c2e8227SGreg Roach return false; 5328c2e8227SGreg Roach } 5338c2e8227SGreg Roach function pasteAsstDate(setcy, setyr) { 5348c2e8227SGreg Roach document.getElementById(setcy+setyr).selected = true; 5358c2e8227SGreg Roach addDate(document.getElementById("selcensdate").options[document.getElementById(\'selcensdate\').selectedIndex].value); 5368c2e8227SGreg Roach return false; 5378c2e8227SGreg Roach } 5388c2e8227SGreg Roach '); 5398c2e8227SGreg Roach 5408c2e8227SGreg Roach return ' 5418c2e8227SGreg Roach <select id="selcensdate" name="selcensdate" onchange = "if (this.options[this.selectedIndex].value!=\'\') { 5428c2e8227SGreg Roach addDate(this.options[this.selectedIndex].value); 5438c2e8227SGreg Roach }"> 5448c2e8227SGreg Roach <option id="defdate" value="" selected>' . I18N::translate('Census date') . '</option> 5458c2e8227SGreg Roach <option value=""></option> 5468c2e8227SGreg Roach <option id="UK1911" class="UK" value="1911, 3, 02, UK">UK 1911</option> 5478c2e8227SGreg Roach <option id="UK1901" class="UK" value="1901, 2, 31, UK">UK 1901</option> 5488c2e8227SGreg Roach <option id="UK1891" class="UK" value="1891, 3, 05, UK">UK 1891</option> 5498c2e8227SGreg Roach <option id="UK1881" class="UK" value="1881, 3, 03, UK">UK 1881</option> 5508c2e8227SGreg Roach <option id="UK1871" class="UK" value="1871, 3, 02, UK">UK 1871</option> 5518c2e8227SGreg Roach <option id="UK1861" class="UK" value="1861, 3, 07, UK">UK 1861</option> 5528c2e8227SGreg Roach <option id="UK1851" class="UK" value="1851, 2, 30, UK">UK 1851</option> 5538c2e8227SGreg Roach <option id="UK1841" class="UK" value="1841, 5, 06, UK">UK 1841</option> 5548c2e8227SGreg Roach <option value=""></option> 5558c2e8227SGreg Roach <option id="USA1940" class="USA" value="1940, 3, 01, USA">US 1940</option> 5568c2e8227SGreg Roach <option id="USA1930" class="USA" value="1930, 3, 01, USA">US 1930</option> 5578c2e8227SGreg Roach <option id="USA1920" class="USA" value="1920, 0, 01, USA">US 1920</option> 5588c2e8227SGreg Roach <option id="USA1910" class="USA" value="1910, 3, 15, USA">US 1910</option> 5598c2e8227SGreg Roach <option id="USA1900" class="USA" value="1900, 5, 01, USA">US 1900</option> 5608c2e8227SGreg Roach <option id="USA1890" class="USA" value="1890, 5, 01, USA">US 1890</option> 5618c2e8227SGreg Roach <option id="USA1880" class="USA" value="1880, 5, 01, USA">US 1880</option> 5628c2e8227SGreg Roach <option id="USA1870" class="USA" value="1870, 5, 01, USA">US 1870</option> 5638c2e8227SGreg Roach <option id="USA1860" class="USA" value="1860, 5, 01, USA">US 1860</option> 5648c2e8227SGreg Roach <option id="USA1850" class="USA" value="1850, 5, 01, USA">US 1850</option> 5658c2e8227SGreg Roach <option id="USA1840" class="USA" value="1840, 5, 01, USA">US 1840</option> 5668c2e8227SGreg Roach <option id="USA1830" class="USA" value="1830, 5, 01, USA">US 1830</option> 5678c2e8227SGreg Roach <option id="USA1820" class="USA" value="1820, 7, 07, USA">US 1820</option> 5688c2e8227SGreg Roach <option id="USA1810" class="USA" value="1810, 7, 06, USA">US 1810</option> 5698c2e8227SGreg Roach <option id="USA1800" class="USA" value="1800, 7, 04, USA">US 1800</option> 5708c2e8227SGreg Roach <option id="USA1790" class="USA" value="1790, 7, 02, USA">US 1790</option> 5718c2e8227SGreg Roach <option value=""></option> 5728c2e8227SGreg Roach <option id="FR1951" class="FR" value="1951, 0, 01, FR">FR 1951</option> 5738c2e8227SGreg Roach <option id="FR1946" class="FR" value="1946, 0, 01, FR">FR 1946</option> 5748c2e8227SGreg Roach <option id="FR1941" class="FR" value="1941, 0, 01, FR">FR 1941</option> 5758c2e8227SGreg Roach <option id="FR1936" class="FR" value="1936, 0, 01, FR">FR 1936</option> 5768c2e8227SGreg Roach <option id="FR1931" class="FR" value="1931, 0, 01, FR">FR 1931</option> 5778c2e8227SGreg Roach <option id="FR1926" class="FR" value="1926, 0, 01, FR">FR 1926</option> 5788c2e8227SGreg Roach <option id="FR1921" class="FR" value="1921, 0, 01, FR">FR 1921</option> 5798c2e8227SGreg Roach <option id="FR1916" class="FR" value="1916, 0, 01, FR">FR 1916</option> 5808c2e8227SGreg Roach <option id="FR1911" class="FR" value="1911, 0, 01, FR">FR 1911</option> 5818c2e8227SGreg Roach <option id="FR1906" class="FR" value="1906, 0, 01, FR">FR 1906</option> 5828c2e8227SGreg Roach <option id="FR1901" class="FR" value="1901, 0, 01, FR">FR 1901</option> 5838c2e8227SGreg Roach <option id="FR1896" class="FR" value="1896, 0, 01, FR">FR 1896</option> 5848c2e8227SGreg Roach <option id="FR1891" class="FR" value="1891, 0, 01, FR">FR 1891</option> 5858c2e8227SGreg Roach <option id="FR1886" class="FR" value="1886, 0, 01, FR">FR 1886</option> 5868c2e8227SGreg Roach <option id="FR1881" class="FR" value="1881, 0, 01, FR">FR 1881</option> 5878c2e8227SGreg Roach <option id="FR1876" class="FR" value="1876, 0, 01, FR">FR 1876</option> 5888c2e8227SGreg Roach <option value=""></option> 5898c2e8227SGreg Roach </select> 5908c2e8227SGreg Roach 5918c2e8227SGreg Roach <input type="hidden" id="setctry" name="setctry" value=""> 5928c2e8227SGreg Roach <input type="hidden" id="setyear" name="setyear" value=""> 5938c2e8227SGreg Roach '; 5948c2e8227SGreg Roach } else { 5958c2e8227SGreg Roach return ''; 5968c2e8227SGreg Roach } 5978c2e8227SGreg Roach } 5988c2e8227SGreg Roach} 599