diff --git a/classes/ExsiccatiManager.php b/classes/ExsiccatiManager.php index 261696a370..f25808a760 100644 --- a/classes/ExsiccatiManager.php +++ b/classes/ExsiccatiManager.php @@ -208,36 +208,41 @@ public function getExsOccArr($id, $target = 'omenid'){ return $retArr; } - public function exportExsiccatiAsCsv($searchTerm, $specimenOnly, $imagesOnly, $collId){ - $fieldArr = array('titleID'=>'et.ometid', 'exsiccatiTitle'=>'et.title', 'abbreviation'=>'et.abbreviation', 'editors'=>'et.editor', 'range'=>'et.exsrange', - 'startDate'=>'et.startdate', 'endDate'=>'et.enddate', 'source'=>'et.source', 'sourceIdentifier'=>'et.sourceIdentifier', 'titleNotes'=>'et.notes AS titleNotes', 'exsiccatiNumber'=>'en.exsnumber'); + public function exportExsiccatiAsCsv($searchTerm, $specimenOnly, $imagesOnly, $collId, $titleOnly){ $fileName = 'exsiccatiOutput_'.time().'.csv'; header ('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header ('Content-Type: text/csv'); header ('Content-Disposition: attachment; filename="'.$fileName.'"'); $sqlInsert = ''; - if($collId || $specimenOnly){ - $sqlInsert .= 'INNER JOIN omexsiccatiocclink ol ON en.omenid = ol.omenid INNER JOIN omoccurrences o ON ol.occid = o.occid '; - if($imagesOnly) $sqlInsert .= 'INNER JOIN images i ON o.occid = i.occid '; - if($collId) $sqlInsert .= 'WHERE o.collid = '.$collId.' '; - $fieldArr['occid'] = 'o.occid'; - $fieldArr['catalogNumber'] = 'o.catalognumber'; - $fieldArr['otherCatalogNumbers'] = 'o.othercatalognumbers'; - $fieldArr['occurrenceSourceId_dbpk'] = 'o.dbpk'; - $fieldArr['collector'] = 'o.recordedby'; - $fieldArr['collectorNumber'] = 'o.recordnumber'; - $fieldArr['occurrenceNotes'] = 'ol.notes AS occurrenceNotes'; - $refUrl = "http://"; - if((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443) $refUrl = "https://"; - $refUrl .= $_SERVER["SERVER_NAME"]; - if($_SERVER["SERVER_PORT"] && $_SERVER["SERVER_PORT"] != 80 && $_SERVER['SERVER_PORT'] != 443) $refUrl .= ':'.$_SERVER["SERVER_PORT"]; - $refUrl .= $GLOBALS['CLIENT_ROOT'].'/collections/individual/index.php?occid='; - $fieldArr['referenceUrl'] = 'CONCAT("'.$refUrl.'",o.occid) as referenceUrl'; + $fieldArr = array('titleID'=>'et.ometid', 'exsiccatiTitle'=>'et.title', 'abbreviation'=>'et.abbreviation', 'editors'=>'et.editor', 'range'=>'et.exsrange', + 'startDate'=>'et.startdate', 'endDate'=>'et.enddate', 'source'=>'et.source', 'sourceIdentifier'=>'et.sourceIdentifier', 'titleNotes'=>'et.notes AS titleNotes'); + if(!$titleOnly){ + $sqlInsert = 'INNER JOIN omexsiccatinumbers en ON et.ometid = en.ometid '; + $fieldArr['exsiccatiNumber'] = 'en.exsnumber'; + if($collId || $specimenOnly){ + $sqlInsert .= 'INNER JOIN omexsiccatiocclink ol ON en.omenid = ol.omenid INNER JOIN omoccurrences o ON ol.occid = o.occid '; + if($imagesOnly) $sqlInsert .= 'INNER JOIN images i ON o.occid = i.occid '; + if($collId) $sqlInsert .= 'WHERE o.collid = '.$collId.' '; + $fieldArr['occid'] = 'o.occid'; + $fieldArr['catalogNumber'] = 'o.catalognumber'; + $fieldArr['otherCatalogNumbers'] = 'o.othercatalognumbers'; + $fieldArr['occurrenceSourceId_dbpk'] = 'o.dbpk'; + $fieldArr['collector'] = 'o.recordedby'; + $fieldArr['collectorNumber'] = 'o.recordnumber'; + $fieldArr['occurrenceNotes'] = 'ol.notes AS occurrenceNotes'; + $refUrl = "http://"; + if((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443) $refUrl = "https://"; + $refUrl .= $_SERVER["SERVER_NAME"]; + if($_SERVER["SERVER_PORT"] && $_SERVER["SERVER_PORT"] != 80 && $_SERVER['SERVER_PORT'] != 443) $refUrl .= ':'.$_SERVER["SERVER_PORT"]; + $refUrl .= $GLOBALS['CLIENT_ROOT'].'/collections/individual/index.php?occid='; + $fieldArr['referenceUrl'] = 'CONCAT("'.$refUrl.'",o.occid) as referenceUrl'; + } } if($searchTerm){ $sqlInsert .= ($sqlInsert?'AND ':'WHERE ').'et.title LIKE "%'.$searchTerm.'%" OR et.abbreviation LIKE "%'.$searchTerm.'%" OR et.editor LIKE "%'.$searchTerm.'%" '; } - $sql = 'SELECT '.implode(',',$fieldArr).' FROM omexsiccatititles et INNER JOIN omexsiccatinumbers en ON et.ometid = en.ometid '.$sqlInsert.'ORDER BY et.title, en.exsnumber+0'; + $sql = 'SELECT '.implode(',',$fieldArr).' FROM omexsiccatititles et '.$sqlInsert.'ORDER BY et.title'; + if(!$titleOnly) $sql .= ', en.exsnumber+0'; $rs = $this->conn->query($sql); if($rs->num_rows){ $out = fopen('php://output', 'w'); diff --git a/collections/exsiccati/index.php b/collections/exsiccati/index.php index 6b3907cc2d..9e0edf546f 100644 --- a/collections/exsiccati/index.php +++ b/collections/exsiccati/index.php @@ -76,8 +76,10 @@ $statusStr = $exsManager->transferOccurrence($omenId,$_POST['occid'],trim($_POST['targetometid'],'k'),$_POST['targetexsnumber']); } } -if($formSubmit == 'dlexsiccati'){ - $exsManager->exportExsiccatiAsCsv($searchTerm, $specimenOnly, $imagesOnly, $collId); +if($formSubmit == 'dlexs' || $formSubmit == 'dlexs_titleOnly'){ + $titleOnly = false; + if($formSubmit == 'dlexs_titleOnly') $titleOnly = true; + $exsManager->exportExsiccatiAsCsv($searchTerm, $specimenOnly, $imagesOnly, $collId, $titleOnly); exit; } ?> @@ -329,8 +331,9 @@ function buildExsSelect(selectObj){ onchange="this.form.submit()">Abbreviation