Skip to content

Commit

Permalink
Merge pull request #10 from bryo-lichen/master
Browse files Browse the repository at this point in the history
Exsiccati Index Developments
  • Loading branch information
egbot authored Feb 9, 2021
2 parents fab50a5 + 8015b35 commit 85221fa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
6 changes: 3 additions & 3 deletions classes/ExsiccatiManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public function getExsOccArr($id, $target = 'omenid'){

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', 'titleNotes'=>'et.notes AS titleNotes', 'exsiccatiNumber'=>'en.exsnumber');
'startDate'=>'et.startdate', 'endDate'=>'et.enddate', 'source'=>'et.source', 'sourceIdentifier'=>'et.sourceIdentifier', 'titleNotes'=>'et.notes AS titleNotes', 'exsiccatiNumber'=>'en.exsnumber');
$fileName = 'exsiccatiOutput_'.time().'.csv';
header ('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header ('Content-Type: text/csv');
Expand All @@ -223,7 +223,7 @@ public function exportExsiccatiAsCsv($searchTerm, $specimenOnly, $imagesOnly, $c
$fieldArr['occid'] = 'o.occid';
$fieldArr['catalogNumber'] = 'o.catalognumber';
$fieldArr['otherCatalogNumbers'] = 'o.othercatalognumbers';
$fieldArr['sourceIdentifier_dbpk'] = 'o.dbpk';
$fieldArr['occurrenceSourceId_dbpk'] = 'o.dbpk';
$fieldArr['collector'] = 'o.recordedby';
$fieldArr['collectorNumber'] = 'o.recordnumber';
$fieldArr['occurrenceNotes'] = 'ol.notes AS occurrenceNotes';
Expand All @@ -237,7 +237,7 @@ public function exportExsiccatiAsCsv($searchTerm, $specimenOnly, $imagesOnly, $c
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, et.startdate';
$sql = 'SELECT '.implode(',',$fieldArr).' FROM omexsiccatititles et INNER JOIN omexsiccatinumbers en ON et.ometid = en.ometid '.$sqlInsert.'ORDER BY et.title, en.exsnumber+0';
$rs = $this->conn->query($sql);
if($rs->num_rows){
$out = fopen('php://output', 'w');
Expand Down
25 changes: 17 additions & 8 deletions collections/exsiccati/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
$sortBy = array_key_exists('sortby',$_REQUEST)?$_REQUEST['sortby']:0;
$formSubmit = array_key_exists('formsubmit',$_REQUEST)?$_REQUEST['formsubmit']:'';

//Sanitation
if(!is_numeric($ometId)) $ometId = 0;
if(!is_numeric($omenId)) $omenId = 0;
if(!is_numeric($occidToAdd)) $occidToAdd = 0;
$searchTerm = filter_var($searchTerm,FILTER_SANITIZE_STRING);
if(!is_numeric($specimenOnly)) $specimenOnly = 0;
if(!is_numeric($collId)) $collId = 0;
if(!is_numeric($imagesOnly)) $imagesOnly = 0;
if(!is_numeric($sortBy)) $sortBy = 0;

if(!$specimenOnly && !array_key_exists('searchterm', $_POST)){
//Make specimen only the default action
$specimenOnly = 1;
Expand Down Expand Up @@ -318,14 +328,13 @@ function buildExsSelect(selectObj){
<input type="radio" name="sortby" value="0" <?php echo ($sortBy == 0?"CHECKED":""); ?> onchange="this.form.submit()">Title
<input type="radio" name="sortby" value="1" <?php echo ($sortBy == 1?"CHECKED":""); ?> onchange="this.form.submit()">Abbreviation
</div>
<div style="float:right;" title="Download Exsiccati Records">
<?php
$dlUrl = 'index.php?formsubmit=dlexsiccati&searchterm='.$searchTerm.'&specimenonly='.$specimenOnly.'&imagesonly='.$imagesOnly.'&collid='.$collId;
?>
<a href="<?php echo $dlUrl; ?>" target="_blank"><img src="../../images/dl.png" style="width:15px" /></a>
</div>
<div style="margin:5px 0px 0px 5px;">
<input name="formsubmit" type="submit" value="Rebuild List" />
<div style="margin-top:5px">
<div style="float:right;" title="Download Exsiccati Records">
<button name="formsubmit" type="submit" value="dlexsiccati"><img src="../../images/dl.png" style="width:15px" /></button>
</div>
<div>
<button name="formsubmit" type="submit" value="rebuildList">Rebuild List</button>
</div>
</div>
</fieldset>
</form>
Expand Down

0 comments on commit 85221fa

Please sign in to comment.