getJoining ();
foreach ( $reg as $i ) {
$ncd = DBInterface::getNCD ( $i ['institutionFullName'] );
$addressncd [$i ['institutionFullName']] = [ ];
$visitoraddress [$i ['institutionFullName']] = [ ];
$contactdetails [$i ['institutionFullName']] = [ ];
$descriptions [$i ['institutionFullName']] = [ ];
Yii::info ( "registry " . $i ['institutionFullName'] . " " . sizeof ( $ncd ) );
if (! empty ( $ncd ) && sizeof ( $ncd ) > 0) {
$a = [ ];
$v = [ ];
$c = [ ];
$d = [ ];
$id = $ncd [0] ["ID"];
if (! empty ( $ncd [0] ["Name"] ))
$a [] = "Name:" . $ncd [0] ["Name"];
if (! empty ( $ncd [0] ["Street"] ))
$a [] = "Street: " . $ncd [0] ["Street"];
if (! empty ( $ncd [0] ["Pobox"] ))
$a [] = "Pobox: " . $ncd [0] ["Pobox"];
if (! empty ( $ncd [0] ["Extadd"] ))
$a [] = "Extadd: " . $ncd [0] ["Extadd"];
if (! empty ( $ncd [0] ["Pcode"] ))
$a [] = "Postal code: " . $ncd [0] ["Pcode"];
if (! empty ( $ncd [0] ["Locality"] ))
$a [] = "Locality: " . $ncd [0] ["Locality"];
if (! empty ( $ncd [0] ["Region"] ))
$a [] = "Region: " . $ncd [0] ["Region"];
if (! empty ( $ncd [0] ["CountryID"] ))
$a [] = "Country code: " . $ncd [0] ["CountryID"];
$addressncd [$i ['institutionFullName']] = implode ( "
", array_filter ( $a ) );
if (! empty ( $ncd [0] ["VisitorStreet"] ))
$v [] = "Street: " . $ncd [0] ["VisitorStreet"];
if (! empty ( $ncd [0] ["VisitorExtadd"] ))
$v [] = "Extadd: " . $ncd [0] ["VisitorExtadd"];
if (! empty ( $ncd [0] ["VisitorPcode"] ))
$v [] = "Postal code: " . $ncd [0] ["VisitorPcode"];
if (! empty ( $ncd [0] ["VisitorLocality"] ))
$v [] = "Locality: " . $ncd [0] ["VisitorLocality"];
if (! empty ( $ncd [0] ["VisitorRegion"] ))
$v [] = "Region: " . $ncd [0] ["VisitorRegion"];
$visitoraddress [$i ['institutionFullName']] = implode ( "
", array_filter ( $v ) );
if (! empty ( $ncd [0] ["Telephone"] ))
$c [] = "Phone: " . $ncd [0] ["Telephone"];
if (! empty ( $ncd [0] ["Fax"] ))
$c [] = "Fax: " . $ncd [0] ["Fax"];
if (! empty ( $ncd [0] ["Email"] ))
$c [] = "EMail: " . $ncd [0] ["Email"];
if (! empty ( $ncd [0] ["LogoURL"] ))
$c [] = "Logo: " . $ncd [0] ["LogoURL"];
if (! empty ( $ncd [0] ["WebsiteURL"] ))
$c [] = "Website: " . $ncd [0] ["WebsiteURL"];
$contactdetails [$i ['institutionFullName']] = implode ( "
", array_filter ( $c ) );
if (! empty ( $ncd [0] ["AccessRights"] ))
$d [] = "Access rights: " . $ncd [0] ["AccessRights"];
if (! empty ( $ncd [0] ["Rights"] ))
$d [] = "Rights: " . $ncd [0] ["Rights"];
if (! empty ( $ncd [0] ["UsageRestrictions"] ))
$d [] = "Usage restrictions: " . $ncd [0] ["UsageRestrictions"];
if (! empty ( $ncd [0] ["SubUnitName"] ))
$d [] = "Sub-unit: " . $ncd [0] ["SubUnitName"];
// if (! empty ( $ncd [0] ["Name"] ))
// $d [] = "Name:" . $ncd [0] ["Name"];
if (! empty ( $ncd [0] ["Description"] ))
$d [] = "Description: " . $ncd [0] ["Description"];
if (! empty ( $ncd [0] ["SubUnitName"] ))
$d [] = "SubUnitName: " . $ncd [0] ["SubUnitName"];
$descriptions [$i ['institutionFullName']] = implode ( "
", array_filter ( $d ) );
$collections = DBInterface::getNCDCollections ( $id );
if (sizeof ( $collections ) == 0)
$collectionncd [$i ['institutionFullName']] = [ ];
else
foreach ( $collections as $collection ) {
$c = [ ];
if (! empty ( $collection ["Title"] ))
$c [] = "Title: " . $collection ["Title"];
if (! empty ( $collection ["AlternativeTitle"] ))
$c [] = "AlternativeTitle: " . $collection ["AlternativeTitle"];
if (! empty ( $collection ["Description"] ))
$c [] = "Description: " . $collection ["Description"];
if (! empty ( $collection ["DescriptionForSpecialists"] ))
$c [] = "DescriptionForSpecialists: " . $collection ["DescriptionForSpecialists"];
if (! empty ( $collection ["CiteAs"] ))
$c [] = "Cite as: " . $collection ["CiteAs"];
if (! empty ( $collection ["AccessPoints"] ))
$c [] = "Access points: " . $collection ["AccessPoints"];
if (! empty ( $collection ["AccessPointsNotes"] ))
$c [] = "Access points notes: " . $collection ["AccessPointsNotes"];
if (! empty ( $collection ["Provenance"] ))
$c [] = "Provenance: " . $collection ["Provenance"];
if (! empty ( $collection ["Notes"] ))
$c [] = "Notes: " . $collection ["Notes"];
// if (! empty ( $collection ["DevelopmentStatusID"] ))
// $c [] = "Notes" .$collection ["DevelopmentStatusID"];
if (! empty ( $collection ["KnownToContainTypes"] ) && $collection ["KnownToContainTypes"] == "1")
$c [] = "Known to contain types ";
// if (! empty ( $collection ["Notes"] ))
// $c [] = "Notes: " . $collection ["PrimaryGroupingPrincipleID"];
// if (! empty ( $collection ["Notes"] ))
// $c [] = "Notes: " . $collection ["PrimaryPurposeID"];
// if (! empty ( $collection ["Notes"] ))
// $c [] = "Notes: " . $collection ["IsPartOfCollectionID"];
if (! empty ( $collection ["RelatedCollections"] ))
$c [] = "Related collections: " . $collection ["RelatedCollections"];
if (! empty ( $collection ["Rights"] ))
$c [] = "Rights: " . $collection ["Rights"];
if (! empty ( $collection ["Notes"] ))
$c [] = "Access rights: " . $collection ["AccessRights"];
if (! empty ( $collection ["UsageRestrictions"] ))
$c [] = "Usage restrictions: " . $collection ["UsageRestrictions"];
if (! empty ( $collection ["Explanation"] ))
$c [] = "Conservation status: " . $collection ["Explanation"];
if (! empty ( $collection ["ConservationStatusDate"] ))
$c [] = "Conservation status date: " . $collection ["ConservationStatusDate"];
$collectionncd [$i ['institutionFullName']] = [
implode ( "
", $c )
];
}
} else {
$addressncd [$i ['institutionFullName']] = "";
$visitoraddress [$i ['institutionFullName']] = "";
$contactdetails [$i ['institutionFullName']] = "";
$descriptions [$i ['institutionFullName']] = "";
$collectionncd [$i ['institutionFullName']] = [ ];
}
$institution [$i ['institutionFullName']] = [
$i ['Latitude'],
$i ['Longitude']
];
$latitudes [] = $i ['Latitude'];
$longitudes [] = $i ['Longitude'];
$names [] = $i ['institutionFullName'];
$tmp = DBInterface::getNbUnits ( $i ['parentInstitutionID'] );
if (sizeof ( $tmp ) > 0) {
foreach ( $tmp as $t )
$counts [$i ['institutionFullName']] = $t ['nb'];
} else
$counts [$i ['institutionFullName']] = 0;
$contact = [ ];
$tmp = DBInterface::getContacts ( $i ['parentInstitutionID'] );
if (sizeof ( $tmp ) > 0) {
foreach ( $tmp as $t )
$contact [] = [
$t ['name'],
$t ['email']
];
} else
$contact [] = [ ];
$contacts [$i ['institutionFullName']] = $contact;
}
foreach ( $collectionncd as $k => $v )
Yii::info ( "COLLECTION NCD KEY " . $k );
return $this->render ( 'index', [
'latitude' => $latitudes,
'longitude' => $longitudes,
'names' => $names,
'partners' => $reg,
'counts' => $counts,
'contacts' => $contacts,
'addressncd' => $addressncd,
'visitoraddressncd' => $visitoraddress,
'contactdetailsncd' => $contactdetails,
'descriptionsncd' => $descriptions,
'collectionsncd' => $collectionncd,
'joiningAll' => $datesOfJoining ["all"],
'joiningCore' => $datesOfJoining ["Core"],
'joiningAssociate' => $datesOfJoining ["Associate"],
'joiningObserver' => $datesOfJoining ["Observer"]
] );
}
private function getJoining() {
$statistics_core = [ ];
$statistics_asso = [ ];
$statistics_observ = [ ];
$statisticsAll = [ ];
$years = DBInterface::getJoining ("");
$allYears=[];
foreach ($years as $year){
$day = DateTime::createFromFormat ( 'Y-m-d', $year ['dateOfJoining'] );
$allYears[]=$day->format ( 'Y' );
}
$institutions = DBInterface::getJoining ( "Core" );
$totalMonth = 0;
$allMonths = [ ];
foreach ( $institutions as $i ) {
$day = DateTime::createFromFormat ( 'Y-m-d', $i ['dateOfJoining'] );
$month = $day->format ( 'Y' );
if (in_array ( $month, $statistics_core ))
$tMonth = $statistics_core [$month];
else
$tMonth = $totalMonth;
$tMonth += 1;
$totalMonth = $tMonth;
$statistics_core [$month] = $tMonth;
$allMonths [] = $month;
}
array_reverse($allYears);
foreach ($allYears as $year){
if(!array_key_exists($year, $statistics_core)){
$prev=0;
$startYear=$year-1;
while ( ($startYear) >= min($allYears)){
if (array_key_exists($startYear, $statistics_core)){
$prev=$statistics_core[$startYear];
break;
}
else $startYear-=1;
}
$statistics_core[$year]=$prev;
}
}
$institutions = DBInterface::getJoining ( "Associate" );
$totalMonth = 0;
foreach ( $institutions as $i ) {
$day = DateTime::createFromFormat ( 'Y-m-d', $i ['dateOfJoining'] );
$month = $day->format ( 'Y' );
if (in_array ( $month, $statistics_asso ))
$tMonth = $statistics_asso [$month];
else
$tMonth = $totalMonth;
$tMonth += 1;
$totalMonth = $tMonth;
$statistics_asso [$month] = $tMonth;
$allMonths [] = $month;
}
foreach ($allYears as $year){
if(!array_key_exists($year, $statistics_asso)){
$prev=0;
$startYear=$year-1;
while ( ($startYear) >= min($allYears)){
if (array_key_exists($startYear, $statistics_asso)){
$prev=$statistics_asso[$startYear];
break;
}
else $startYear-=1;
}
$statistics_asso[$year]=$prev;
}
}
$institutions = DBInterface::getJoining ( "Observer" );
$totalMonth = 0;
foreach ( $institutions as $i ) {
$day = DateTime::createFromFormat ( 'Y-m-d', $i ['dateOfJoining'] );
$month = $day->format ( 'Y' );
if (in_array ( $month, $statistics_observ ))
$tMonth = $statistics_observ [$month];
else
$tMonth = $totalMonth;
$tMonth += 1;
$totalMonth = $tMonth;
$statistics_observ [$month] = $tMonth;
$allMonths [] = $month;
}
foreach ($allYears as $year){
if(!array_key_exists($year, $statistics_observ)){
$prev=0;
$startYear=$year-1;
while ( ($startYear) >= min($allYears)){
if (array_key_exists($startYear, $statistics_observ)){
$prev=$statistics_observ[$startYear];
break;
}
else $startYear-=1;
}
$statistics_observ[$year]=$prev;
}
}
foreach ( array_unique ( $allMonths ) as $m ) {
$total = 0;
if (array_key_exists ( $m, $statistics_asso ))
$total += $statistics_asso [$m];
if (array_key_exists ( $m, $statistics_core ))
$total += $statistics_core [$m];
if (array_key_exists ( $m, $statistics_observ ))
$total += $statistics_observ [$m];
$statisticsAll [$m] = $total;
}
$statistics_retCore = [ ];
foreach ( $statistics_core as $k => $v ) {
$statistics_retCore [] = "['" . $k . "', " . $v . "]";
}
$statistics_retAsso = [ ];
foreach ( $statistics_asso as $k => $v ) {
$statistics_retAsso [] = "['" . $k . "', " . $v . "]";
}
$statistics_retObs = [ ];
foreach ( $statistics_observ as $k => $v ) {
$statistics_retObs [] = "['" . $k . "', " . $v . "]";
}
$statistics_retAll = [ ];
foreach ( $statisticsAll as $k => $v ) {
$statistics_retAll [] = "['" . $k . "', " . $v . "]";
}
$toRet = [ ];
$toRet ["all"] = "[" . implode ( ", ", $statistics_retAll ) . "]";
$toRet ["Core"] = "[" . implode ( ", ", $statistics_retCore ) . "]";
$toRet ["Associate"] = "[" . implode ( ", ", $statistics_retAsso ) . "]";
$toRet ["Observer"] = "[" . implode ( ", ", $statistics_retObs ) . "]";
return $toRet;
}
}