getJoining ();
foreach ( $reg as $i ) {
$ncd = DBInterface::getNCD ( $i ['fk_ncd_collectionID'] );
$addressncd [$i ['institutionFullName']] = [ ];
$visitoraddress [$i ['institutionFullName']] = [ ];
$contactdetails [$i ['institutionFullName']] = [ ];
$descriptions [$i ['institutionFullName']] = [ ];
Yii::info ( "registry " . $i ['fk_ncd_collectionID'] . " " . sizeof ( $ncd ) );
if (empty ( $ncd )) {
$ncd = DBInterface::getNCDInstitution ( $i ['fk_ncd_institutionID'] );
}
if (! empty ( $ncd ) && sizeof ( $ncd ) > 0) {
$a = [ ];
$v = [ ];
$c = [ ];
$d = [ ];
$id = $ncd [0] ["ID_Institution"];
if (! empty ( $ncd [0] ["Name"] ) or ! empty ( $ncd [0] ["SubUnitName"] ))
if (! empty ( $ncd [0] ["SubUnitName"] ))
$a [] = "" . $ncd [0] ["Name"].", ".$ncd [0] ["SubUnitName"] ."";
else $a [] = "" . $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] ["CountryID"] ))
$a [] = "Country code: " . $ncd [0] ["CountryID"];
$addressncd [$i ['institutionFullName']] = implode ( "
", array_filter ( $a ) );
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] ["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] ["Description"] ))
$d [] = "Description: " . $ncd [0] ["Description"];
$descriptions [$i ['institutionFullName']] = implode ( "
", array_filter ( $d ) );
if (($i ['fk_ncd_collectionID']) != "") {
$collections = DBInterface::getNCDCollections ( $i ['fk_ncd_collectionID'] );
if (sizeof ( $collections ) == 0)
$collectionncd [$i ['fk_ncd_collectionID']] = [ ];
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 {
/* $collections = DBInterface::getNCDChildren ( $i ['fk_ncd_institutionID'] );
if (sizeof ( $collections ) == 0)
$collectionncd [$i ['fk_ncd_institutionID']] = [ ];
else
foreach ( $collections as $collection ) {
$c = [ ];
if (! empty ( $collection ["logoURL"] ))
$c [] = $collection ["logoURL"];
}
$collectionncd [$i ['fk_ncd_institutionID']] = $c ;*/
}
} else {
$addressncd [$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"]
] );
}
public function actionTable()
{
$searchModel = new InstitutionForm();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$dataProvider->query->andFilterWhere(['!=', 'parentInstitutionID', '38']);
$sort = $dataProvider->getSort();
$sort->defaultOrder = ['dateOfJoining' => SORT_DESC];
$dataProvider->pagination->pageSize=25;
return $this->render('table', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
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;
}
}