diff --git a/classes/DwcArchiverCore.php b/classes/DwcArchiverCore.php index 48033c6c37..4ca0d34db8 100644 --- a/classes/DwcArchiverCore.php +++ b/classes/DwcArchiverCore.php @@ -1524,6 +1524,7 @@ private function writeOccurrenceFile(){ $dwcOccurManager = new DwcArchiverOccurrence($this->conn); $dwcOccurManager->setSchemaType($this->schemaType); $dwcOccurManager->setExtended($this->extended); + $dwcOccurManager->setHarvestExsiccatae(); $dwcOccurManager->setIncludePaleo($this->hasPaleo); if(!$this->occurrenceFieldArr) $this->occurrenceFieldArr = $dwcOccurManager->getOccurrenceArr($this->schemaType, $this->extended); //Output records @@ -1662,6 +1663,10 @@ private function writeOccurrenceFile(){ elseif($this->schemaType == 'backup') unset($r['collid']); if($ocnStr = $dwcOccurManager->getAdditionalCatalogNumberStr($r['occid'])) $r['otherCatalogNumbers'] = $ocnStr; + if($exsStr = $dwcOccurManager->getExsiccateStr($r['occid'])){ + if(isset($r['occurrenceRemarks']) && $r['occurrenceRemarks']) $exsStr = $r['occurrenceRemarks'].'; '.$exsStr; + $r['occurrenceRemarks'] = $exsStr; + } if($assocOccurStr = $dwcOccurManager->getAssociationStr($r['occid'])) $r['t_associatedOccurrences'] = $assocOccurStr; if($assocTaxa = $dwcOccurManager->getAssocTaxa($r['occid'])) $r['associatedTaxa'] = $assocTaxa; //$dwcOccurManager->appendUpperTaxonomy($r); diff --git a/classes/DwcArchiverOccurrence.php b/classes/DwcArchiverOccurrence.php index aaa0f7b203..c1acbe4a0c 100644 --- a/classes/DwcArchiverOccurrence.php +++ b/classes/DwcArchiverOccurrence.php @@ -6,6 +6,7 @@ class DwcArchiverOccurrence{ private $schemaType; private $extended = false; private $includePaleo = false; + private $harvestExsiccatae = false; private $relationshipArr; private $upperTaxonomy = array(); private $taxonRankArr = array(); @@ -358,6 +359,32 @@ public function getAdditionalCatalogNumberStr($occid){ return $retStr; } + public function setHarvestExsiccatae(){ + $sql = 'SELECT occid FROM omexsiccatiocclink LIMIT 1'; + $rs = $this->conn->query($sql); + if($rs->num_rows) $this->harvestExsiccatae = true; + $rs->free(); + } + + public function getExsiccateStr($occid){ + $retStr = ''; + $sql = 'SELECT t.title, t.abbreviation, t.editor, t.exsrange, n.exsnumber, l.notes '. + 'FROM omexsiccatiocclink l INNER JOIN omexsiccatinumbers n ON l.omenid = n.omenid '. + 'INNER JOIN omexsiccatititles t ON n.ometid = t.ometid '. + 'WHERE l.occid = '.$occid; + $rs = $this->conn->query($sql); + while($r = $rs->fetch_object()){ + $retStr = $r->title; + if($r->abbreviation) $retStr .= ' ['.$r->abbreviation.']'; + if($r->exsrange) $retStr .= ', '.$r->exsrange; + if($r->editor) $retStr .= ', '.$r->editor; + $retStr .= ', exs #: '.$r->exsnumber; + if($r->notes) $retStr .= ' ('.$r->notes.')'; + } + $rs->free(); + return $retStr; + } + public function getAssociationStr($occid){ $retStr = ''; if($occid){ diff --git a/classes/KeyDataManager.php b/classes/KeyDataManager.php index 5c995bd709..f87bc7ffaa 100644 --- a/classes/KeyDataManager.php +++ b/classes/KeyDataManager.php @@ -18,7 +18,8 @@ class KeyDataManager extends Manager { private $charArr = Array(); private $taxaCount; private $lang; - private $commonDisplay = false; + private $displayMode; + private $displayCommon = false; private $pid; private $dynClid; @@ -35,16 +36,12 @@ public function __destruct(){ //$returns an Array of ("chars" => $charArray, "taxa" => $taxaArray) //In coming attrs are in the form of: (cid => array of cs) public function getData(){ - $charArray = array(); - $taxaArray = array(); + $retArr = array(); if(($this->clid && $this->taxonFilter) || $this->dynClid){ - $this->setTaxaListSQL(); - $taxaArray = $this->getTaxaList(); - $charArray = $this->getCharList(); + $retArr['taxa'] = $this->getTaxaList(); + $retArr['chars'] = $this->getCharList(); } - $returnArray["chars"] = $charArray; - $returnArray["taxa"] = $taxaArray; - return $returnArray; + return $retArr; } //returns map: HeadingId => Array( @@ -182,36 +179,51 @@ public function getCharList(){ return $returnArray; } - //return an array: family => array(TID => DisplayName) + public function getTaxaArr(){ + $this->setTaxaListSQL(); + $retArr = array(); + $rs = $this->conn->query($this->sql); + $this->taxaCount = 0; + $taxaArr = array(); + while($r = $rs->fetch_object()){ + $this->taxaCount++; + $retArr[$r->family][$r->tid] = $r->sciname; + $taxaArr[$r->tid] = $r->family; + } + $rs->free(); + if($this->displayCommon){ + $sql = 'SELECT tid, vernacularName FROM taxavernaculars WHERE langid = 1 AND SortSequence = 1 AND tid IN('.implode(',',array_keys($taxaArr)).')'; + $rs = $this->conn->query($sql); + while($r = $rs->fetch_object()){ + $retArr[$taxaArr[$r->tid]][$r->tid]['vern'] = $r->vernacularName; + } + $rs->free(); + } + return $retArr; + } + public function getTaxaList(){ - $taxaList[] = null; - unset($taxaList); - $sqlTaxa = ""; - if($this->commonDisplay){ - $sqlTaxa = "SELECT innert.tid, innert.Family, IFNULL(v.VernacularName, innert.DisplayName) AS DisplayName, innert.ParentTID ". - "FROM (".$this->sql.") innert LEFT JOIN (SELECT tid, VernacularName FROM taxavernaculars WHERE langid = 1 AND SortSequence = 1) v ON innert.tid = v.tid "; + //Delete after current modifications are approved + $this->setTaxaListSQL(); + $retArr = array(); + $rs = $this->conn->query($this->sql); + $this->taxaCount = 0; + $taxaArr = array(); + while($r = $rs->fetch_object()){ + $this->taxaCount++; + $retArr[$r->family][$r->tid] = $r->sciname; + $taxaArr[$r->tid] = $r->family; } - else{ - $sqlTaxa = $this->sql; + $rs->free(); + if($this->displayMode){ + $sql = 'SELECT tid, vernacularName FROM taxavernaculars WHERE langid = 1 AND SortSequence = 1 AND tid IN('.implode(',',array_keys($taxaArr)).')'; + $rs = $this->conn->query($sql); + while($r = $rs->fetch_object()){ + $retArr[$taxaArr[$r->tid]][$r->tid] = $r->vernacularName; + } + $rs->free(); } - //echo $sqlTaxa.'
'; - $result = $this->conn->query($sqlTaxa); - $returnArray = array(); - $sppArr = array(); - $count = 0; - while ($row = $result->fetch_object()){ - $count++; - $family = $row->Family; - $tid = $row->tid; - $displayName = $row->DisplayName; - unset($sppArr); - if(array_key_exists($family, $returnArray)) $sppArr = $returnArray[$family]; - $sppArr[$tid] = $displayName; - $returnArray[$family] = $sppArr; - } - $this->taxaCount = $count; - $result->close(); - return $returnArray; + return $retArr; } public function setTaxaListSQL(){ @@ -262,7 +274,7 @@ public function setTaxaListSQL(){ $sqlWhere.=' AND (D'.$count.'.CID='.$cid.') AND ('.$stateStr.')'; } } - $this->sql = 'SELECT DISTINCT t.tid, ts.Family, t.SciName AS DisplayName, ts.ParentTID '.$sqlFromBase.$sqlWhere; + $this->sql = 'SELECT DISTINCT t.tid, ts.family, t.sciname '.$sqlFromBase.$sqlWhere; //echo $this->sql; } } @@ -293,29 +305,28 @@ public function getTaxaFilterList(){ if($this->childClidArr){ $clidStr .= ','.implode(',',array_keys($this->childClidArr)); } - $sql .= 'FROM (taxstatus ts INNER JOIN taxa nt ON ts.tid = nt.tid) INNER JOIN fmchklsttaxalink cltl ON nt.TID = cltl.TID WHERE (cltl.CLID IN('.$clidStr.')) '; + $sql .= 'FROM (taxstatus ts INNER JOIN taxa nt ON ts.tid = nt.tid) INNER JOIN fmchklsttaxalink cltl ON nt.TID = cltl.TID WHERE (ts.taxauthid = 1) AND (cltl.CLID IN('.$clidStr.')) '; } else if($this->dynClid){ - $sql .= 'FROM (taxstatus ts INNER JOIN taxa nt ON ts.tid = nt.tid) INNER JOIN fmdyncltaxalink dcltl ON nt.TID = dcltl.TID WHERE (dcltl.dynclid = '.$this->dynClid.') '; + $sql .= 'FROM (taxstatus ts INNER JOIN taxa nt ON ts.tid = nt.tid) INNER JOIN fmdyncltaxalink dcltl ON nt.TID = dcltl.TID WHERE (ts.taxauthid = 1) AND (dcltl.dynclid = '.$this->dynClid.') '; } else{ - $sql .= "FROM (((taxstatus ts INNER JOIN taxa nt ON ts.tid = nt.tid) ". - "INNER JOIN fmchklsttaxalink cltl ON nt.TID = cltl.TID) ". - "INNER JOIN fmchecklists cl ON cltl.CLID = cl.CLID) ". - "INNER JOIN fmchklstprojlink clpl ON cl.CLID = clpl.clid ". - "WHERE (clpl.pid = ".$this->pid.") "; + $sql .= 'FROM (((taxstatus ts INNER JOIN taxa nt ON ts.tid = nt.tid) '. + 'INNER JOIN fmchklsttaxalink cltl ON nt.TID = cltl.TID) '. + 'INNER JOIN fmchecklists cl ON cltl.CLID = cl.CLID) '. + 'INNER JOIN fmchklstprojlink clpl ON cl.CLID = clpl.clid '. + 'WHERE (ts.taxauthid = 1) '; + if($this->pid) $sql .= 'AND (clpl.pid = '.$this->pid.') '; } - $sql .= 'AND (ts.taxauthid = 1)'; - //echo $sql.'
'; exit; - $result = $this->conn->query($sql); - while($row = $result->fetch_object()){ + $rs = $this->conn->query($sql); + while($row = $rs->fetch_object()){ $genus = $row->UnitName1; $family = $row->Family; if($genus) $returnArr[] = $genus; if($family) $returnArr[] = $family; } - $result->free(); + $rs->free(); $returnArr = array_unique($returnArr); natcasesort($returnArr); array_unshift($returnArr,"--------------------------"); @@ -390,8 +401,14 @@ public function setLanguage($l){ $this->lang = $l; } - public function setCommonDisplay($bool){ - if($bool) $this->commonDisplay = true; + public function setDisplayMode($bool){ + if($bool) $this->displayMode = 1; + else $this->displayMode = 0; + } + + public function setDisplayCommon($bool){ + if($bool) $this->displayCommon = true; + else $this->displayCommon = false; } public function setTaxonFilter($t){ diff --git a/classes/OccurrenceAttributeSearch.php b/classes/OccurrenceAttributeSearch.php new file mode 100644 index 0000000000..02d75158c0 --- /dev/null +++ b/classes/OccurrenceAttributeSearch.php @@ -0,0 +1,130 @@ +getTraitArr, if reverting to using OccurrenceAttributes class + + //private $traitSearchArr = array(); + public function __construct(){ + parent::__construct('readonly'); + } + + public function __destruct(){ + parent::__destruct(); + } + + public function getTraitSearchArr($traitID = null){ + if($traitID) { + $traitIDArr = array_map('trim', explode(',', $traitID)); + if (($key = array_search('0', $traitIDArr)) !== false) { + unset($traitIDArr[$key]); + } // this purges potential zeros from the array + $traitID = implode(',', $traitIDArr); + foreach($traitIDArr as $tid) { + if(!is_numeric($tid)) return null; // reject non-numeric IDs + } + } + unset($this->traitArr); + $this->traitArr = array(); + $this->setTraitSearchArr($traitID); + $this->setTraitStates(); + return $this->traitArr; + } + + private function setTraitSearchArr($traitID){ + $sql = 'SELECT traitid, traitname, traittype, units, description, refurl, notes, dynamicproperties FROM tmtraits WHERE traittype IN("UM","OM","TF","NU") '; + if($traitID) $sql .= 'AND (traitid IN('.$traitID.'))'; + $rs = $this->conn->query($sql); + while($r = $rs->fetch_object()){ + if(!isset($this->traitArr[$r->traitid])){ + $this->traitArr[$r->traitid]['name'] = $r->traitname; + $this->traitArr[$r->traitid]['type'] = $r->traittype; + $this->traitArr[$r->traitid]['props'] = $r->dynamicproperties; + //Get dependent traits and append to return array + $this->setDependentTraits($r->traitid); + } + } + $rs->free(); + return $this->traitArr; + } + + public function echoTraitSearchForm($traitID){ + echo $this->getTraitSearchHTML($traitID,true); + } + + private function getTraitSearchHTML($traitID,$display,$classStr=''){ + $controlType = ''; + if($this->traitArr[$traitID]['props']){ + $propArr = json_decode($this->traitArr[$traitID]['props'],true); + if(isset($propArr[0]['controlType'])) $controlType = $propArr[0]['controlType']; + } + $innerStr = '
'; + if(isset($this->traitArr[$traitID]['states'])){ + if($this->traitArr[$traitID]['type']=='TF'){ + $innerStr .= '
'.$this->traitArr[$traitID]['name'].':
'; + $innerStr .= '
'; + } + else $innerStr .= '
'; + $attrStateArr = $this->traitArr[$traitID]['states']; + foreach($attrStateArr as $sid => $sArr){ + $isCoded = false; + if(array_key_exists('coded',$sArr)){ + if(is_numeric($sArr['coded'])) $isCoded = $sArr['coded']; + else $isCoded = true; + $this->stateCodedArr[$sid] = $sid; + } + $depTraitIdArr = array(); + if(isset($sArr['dependTraitID']) && $sArr['dependTraitID']) $depTraitIdArr = $sArr['dependTraitID']; + if($this->traitArr[$traitID]['type']=='NU'){ + $innerStr .= '
'; + $innerStr .= $sArr['name']. + $innerStr .= ': '; + if($depTraitIdArr){ + foreach($depTraitIdArr as $depTraitId){ + $innerStr .= $this->getTraitSearchHTML($depTraitId,$isCoded,trim($classStr.' child-'.$sid)); + } + } + } + else{ + if($controlType == 'checkbox' || $controlType == 'radio'){ + $innerStr .= '
'; + $innerStr .= ' '; + $innerStr .= $sArr['name']; + } + elseif($controlType == 'select'){ + $innerStr .= ''; + } + if($depTraitIdArr){ + foreach($depTraitIdArr as $depTraitId){ + $innerStr .= $this->getTraitSearchHTML($depTraitId,$isCoded,trim($classStr.' child-'.$sid)); + } + } + if($controlType != 'select') $innerStr .= '
'; + } + } + $innerStr .= '
'; + } + $innerStr .= '
'; + //Display if trait has been coded or is the first/base trait (e.g. $indend == 0) + $divClass = ''; + if($classStr){ + $classArr = explode(' ',$classStr); + $divClass = array_pop($classArr); + } + $outStr = '
'; + if($controlType == 'select'){ + $outStr .= ''; + } + else{ + $outStr .= $innerStr; + } + $outStr .= '
'; + return $outStr; + } + +} diff --git a/classes/OccurrenceAttributes.php b/classes/OccurrenceAttributes.php index 2bf3235a03..59a6f9bc30 100644 --- a/classes/OccurrenceAttributes.php +++ b/classes/OccurrenceAttributes.php @@ -4,7 +4,7 @@ class OccurrenceAttributes extends Manager { private $collidStr = 0; - private $traitArr = array(); + protected $traitArr = array(); private $stateCodedArr = array(); private $reviewSqlBase; private $occid = 0; @@ -297,7 +297,7 @@ private function setTraitArr($traitID){ return $this->traitArr; } - private function setDependentTraits($traitid){ + protected function setDependentTraits($traitid){ $sql = 'SELECT DISTINCT s.traitid AS parenttraitid, d.parentstateid, d.traitid AS depTraitID '. 'FROM tmstates s INNER JOIN tmtraitdependencies d ON s.stateid = d.parentstateid '. 'WHERE (s.traitid = '.$traitid.')'; @@ -311,7 +311,7 @@ private function setDependentTraits($traitid){ $rs->free(); } - private function setTraitStates(){ + protected function setTraitStates(){ $sql = 'SELECT traitid, stateid, statename, description, notes, refurl FROM tmstates '; if($this->traitArr) $sql .= 'WHERE traitid IN('.implode(',',array_keys($this->traitArr)).') '; $sql .= 'ORDER BY traitid, sortseq, statecode '; @@ -711,4 +711,4 @@ public function getSourceControlledArr($currentSetStr=''){ return $sourceControlArr; } } -?> \ No newline at end of file +?> diff --git a/classes/OccurrenceEditorManager.php b/classes/OccurrenceEditorManager.php index 5b3ea381cb..bbe1daaf29 100644 --- a/classes/OccurrenceEditorManager.php +++ b/classes/OccurrenceEditorManager.php @@ -734,11 +734,11 @@ private function addTableJoins(&$sql){ } //Edit functions - public function editOccurrence($occArr, $editorStatus){ + public function editOccurrence($postArr, $editorStatus){ global $USER_RIGHTS; $status = ''; - $occid = $occArr['occid']; + $occid = $postArr['occid']; if(is_numeric($occid) && $editorStatus){ $quickHostEntered = false; $autoCommit = false; @@ -761,7 +761,7 @@ public function editOccurrence($occArr, $editorStatus){ } } //Processing edit - $editedFields = trim($occArr['editedfields']); + $editedFields = trim($postArr['editedfields']); $editArr = array_unique(explode(';',$editedFields)); foreach($editArr as $k => $fName){ if(trim($fName) == 'host' || trim($fName) == 'hostassocid'){ @@ -779,15 +779,15 @@ public function editOccurrence($occArr, $editorStatus){ if($editArr || $quickHostEntered){ if($editArr){ //Deal with scientific name changes if the AJAX code fails - if(in_array('sciname',$editArr) && $occArr['sciname'] && !$occArr['tidinterpreted']){ + if(in_array('sciname',$editArr) && $postArr['sciname'] && !$postArr['tidinterpreted']){ $sql2 = 'SELECT t.tid, t.author, ts.family '. 'FROM taxa t INNER JOIN taxstatus ts ON t.tid = ts.tid '. - 'WHERE ts.taxauthid = 1 AND sciname = "'.$this->cleanInStr($occArr['sciname']).'"'; + 'WHERE ts.taxauthid = 1 AND sciname = "'.$this->cleanInStr($postArr['sciname']).'"'; $rs2 = $this->conn->query($sql2); if($r2 = $rs2->fetch_object()){ - $occArr['tidinterpreted'] = $r2->tid; - if(!$occArr['scientificnameauthorship']) $occArr['scientificnameauthorship'] = $r2->author; - if(!$occArr['family']) $occArr['family'] = $r2->family; + $postArr['tidinterpreted'] = $r2->tid; + if(!$postArr['scientificnameauthorship']) $postArr['scientificnameauthorship'] = $r2->author; + if(!$postArr['family']) $postArr['family'] = $r2->family; } $rs2->free(); } @@ -818,7 +818,7 @@ public function editOccurrence($occArr, $editorStatus){ //If processing status was "unprocessed" and recordEnteredBy is null, populate with user login if($oldValues['recordenteredby'] == 'preprocessed' || (!$oldValues['recordenteredby'] && ($oldValues['processingstatus'] == 'unprocessed' || $oldValues['processingstatus'] == 'stage 1'))){ - $occArr['recordenteredby'] = $GLOBALS['USERNAME']; + $postArr['recordenteredby'] = $GLOBALS['USERNAME']; $editArr[] = 'recordenteredby'; } @@ -826,11 +826,11 @@ public function editOccurrence($occArr, $editorStatus){ $sqlEditsBase = 'INSERT INTO omoccuredits(occid,reviewstatus,appliedstatus,uid,fieldname,fieldvaluenew,fieldvalueold) '. 'VALUES ('.$occid.',1,'.($autoCommit?'1':'0').','.$GLOBALS['SYMB_UID'].','; foreach($editArr as $fieldName){ - if(!array_key_exists($fieldName,$occArr)){ + if(!array_key_exists($fieldName,$postArr)){ //Field is a checkbox that is unchecked: cultivationstatus, localitysecurity - $occArr[$fieldName] = 0; + $postArr[$fieldName] = 0; } - $newValue = $this->cleanInStr($occArr[$fieldName]); + $newValue = $this->cleanInStr($postArr[$fieldName]); $oldValue = $this->cleanInStr($oldValues[$fieldName]); //Version edits only if value has changed if($oldValue != $newValue){ @@ -838,14 +838,14 @@ public function editOccurrence($occArr, $editorStatus){ if($fieldName == 'ometid'){ //Exsiccati title has been changed, thus grab title string $exsTitleStr = ''; - $sql = 'SELECT title FROM omexsiccatititles WHERE ometid = '.$occArr['ometid']; + $sql = 'SELECT title FROM omexsiccatititles WHERE ometid = '.$postArr['ometid']; $rs = $this->conn->query($sql); if($r = $rs->fetch_object()){ $exsTitleStr = $r->title; } $rs->free(); //Setup old and new strings - if($newValue) $newValue = $exsTitleStr.' (ometid: '.$occArr['ometid'].')'; + if($newValue) $newValue = $exsTitleStr.' (ometid: '.$postArr['ometid'].')'; if($oldValue) $oldValue = $oldValues['title'].' (ometid: '.$oldValues['ometid'].')'; } $sqlEdit = $sqlEditsBase.'"'.$fieldName.'","'.$newValue.'","'.$oldValue.'")'; @@ -860,13 +860,13 @@ public function editOccurrence($occArr, $editorStatus){ $status = 'SUCCESS: edits submitted and activated '; $sql = ''; //Apply autoprocessing status if set - if(array_key_exists('autoprocessingstatus',$occArr) && $occArr['autoprocessingstatus']){ - $occArr['processingstatus'] = $occArr['autoprocessingstatus']; + if(array_key_exists('autoprocessingstatus',$postArr) && $postArr['autoprocessingstatus']){ + $postArr['processingstatus'] = $postArr['autoprocessingstatus']; } - if(isset($occArr['institutioncode']) && $occArr['institutioncode'] == $this->collMap['institutioncode']) $occArr['institutioncode'] = ''; - if(isset($occArr['collectioncode']) && $occArr['collectioncode'] == $this->collMap['collectioncode']) $occArr['collectioncode'] = ''; - if(isset($occArr['ownerinstitutioncode']) && $occArr['ownerinstitutioncode'] == $this->collMap['institutioncode']) $occArr['ownerinstitutioncode'] = ''; - foreach($occArr as $oField => $ov){ + if(isset($postArr['institutioncode']) && $postArr['institutioncode'] == $this->collMap['institutioncode']) $postArr['institutioncode'] = ''; + if(isset($postArr['collectioncode']) && $postArr['collectioncode'] == $this->collMap['collectioncode']) $postArr['collectioncode'] = ''; + if(isset($postArr['ownerinstitutioncode']) && $postArr['ownerinstitutioncode'] == $this->collMap['institutioncode']) $postArr['ownerinstitutioncode'] = ''; + foreach($postArr as $oField => $ov){ if(in_array($oField,$this->occFieldArr) && $oField != 'observeruid'){ $vStr = $this->cleanInStr($ov); $sql .= ','.$oField.' = '.($vStr!==''?'"'.$vStr.'"':'NULL'); @@ -879,28 +879,28 @@ public function editOccurrence($occArr, $editorStatus){ //If sciname was changed, update image tid link if(in_array('tidinterpreted',$editArr)){ //Remap images - $sqlImgTid = 'UPDATE images SET tid = '.(is_numeric($occArr['tidinterpreted'])?$occArr['tidinterpreted']:'NULL').' WHERE occid = ('.$occid.')'; + $sqlImgTid = 'UPDATE images SET tid = '.(is_numeric($postArr['tidinterpreted'])?$postArr['tidinterpreted']:'NULL').' WHERE occid = ('.$occid.')'; $this->conn->query($sqlImgTid); } //If host was entered in quickhost field, update record if($quickHostEntered){ - if($occArr['hostassocid']){ - if($occArr['host']){ - $sqlHost = 'UPDATE omoccurassociations SET verbatimsciname = "'.$occArr['host'].'" WHERE associd = '.$occArr['hostassocid'].' '; + if($postArr['hostassocid']){ + if($postArr['host']){ + $sqlHost = 'UPDATE omoccurassociations SET verbatimsciname = "'.$postArr['host'].'" WHERE associd = '.$postArr['hostassocid'].' '; } else{ - $sqlHost = 'DELETE FROM omoccurassociations WHERE associd = '.$occArr['hostassocid'].' '; + $sqlHost = 'DELETE FROM omoccurassociations WHERE associd = '.$postArr['hostassocid'].' '; } } else{ - $sqlHost = 'INSERT INTO omoccurassociations(occid,relationship,verbatimsciname) VALUES('.$occid.',"host","'.$occArr['host'].'")'; + $sqlHost = 'INSERT INTO omoccurassociations(occid,relationship,verbatimsciname) VALUES('.$occid.',"host","'.$postArr['host'].'")'; } $this->conn->query($sqlHost); } //Update occurrence record $sql = 'UPDATE omoccurrences SET '.substr($sql,1).' WHERE (occid = '.$occid.')'; if($this->conn->query($sql)){ - if(strtolower($occArr['processingstatus']) != 'unprocessed'){ + if(strtolower($postArr['processingstatus']) != 'unprocessed'){ //UPDATE uid within omcrowdsourcequeue, only if not yet processed $isVolunteer = true; if(array_key_exists('CollAdmin',$USER_RIGHTS) && in_array($this->collId, $USER_RIGHTS['CollAdmin'])){ @@ -918,7 +918,7 @@ public function editOccurrence($occArr, $editorStatus){ } } //Deal with paleo fields - if($this->paleoActivated && array_key_exists('eon',$occArr)){ + if($this->paleoActivated && array_key_exists('eon',$postArr)){ //Check to see if paleo record already exists $paleoRecordExist = false; $paleoSql = 'SELECT paleoid FROM omoccurpaleo WHERE occid = '.$occid; @@ -932,9 +932,9 @@ public function editOccurrence($occArr, $editorStatus){ $paleoHasValue = false; $paleoFrag = ''; foreach($this->paleoFieldArr as $paleoField){ - if(array_key_exists($paleoField,$occArr)){ - $paleoFrag .= ','.$paleoField.' = '.($occArr[$paleoField]?'"'.$this->cleanInStr($occArr[$paleoField]).'"':'NULL'); - if($occArr[$paleoField]) $paleoHasValue = true; + if(array_key_exists($paleoField,$postArr)){ + $paleoFrag .= ','.$paleoField.' = '.($postArr[$paleoField]?'"'.$this->cleanInStr($postArr[$paleoField]).'"':'NULL'); + if($postArr[$paleoField]) $paleoHasValue = true; } } $paleoSql = ''; @@ -956,9 +956,9 @@ public function editOccurrence($occArr, $editorStatus){ $paleoFrag1 = ''; $paleoFrag2 = ''; foreach($this->paleoFieldArr as $paleoField){ - if(array_key_exists($paleoField,$occArr) && $occArr[$paleoField]){ + if(array_key_exists($paleoField,$postArr) && $postArr[$paleoField]){ $paleoFrag1 .= ','.$paleoField; - $paleoFrag2 .= ',"'.$this->cleanInStr($occArr[$paleoField]).'" '; + $paleoFrag2 .= ',"'.$this->cleanInStr($postArr[$paleoField]).'" '; } } if($paleoFrag1){ @@ -972,8 +972,8 @@ public function editOccurrence($occArr, $editorStatus){ //Deal with exsiccati if(in_array('ometid',$editArr) || in_array('exsnumber',$editArr)){ - $ometid = $this->cleanInStr($occArr['ometid']); - $exsNumber = $this->cleanInStr($occArr['exsnumber']); + $ometid = $this->cleanInStr($postArr['ometid']); + $exsNumber = $this->cleanInStr($postArr['exsnumber']); if($ometid && $exsNumber){ //Values have been submitted, thus try to add ometid and omenid //Get exsiccati number id @@ -1011,9 +1011,9 @@ public function editOccurrence($occArr, $editorStatus){ } } //Deal with duplicate clusters - if(isset($occArr['linkdupe']) && $occArr['linkdupe']){ - $dupTitle = $occArr['recordedby'].' '.$occArr['recordnumber'].' '.$occArr['eventdate']; - $status .= $this->linkDuplicates($occArr['linkdupe'],$dupTitle); + if(isset($postArr['linkdupe']) && $postArr['linkdupe']){ + $dupTitle = $postArr['recordedby'].' '.$postArr['recordnumber'].' '.$postArr['eventdate']; + $status .= $this->linkDuplicates($postArr['linkdupe'],$dupTitle); } } else{ @@ -1031,9 +1031,9 @@ public function editOccurrence($occArr, $editorStatus){ return $status; } - public function addOccurrence($occArr){ - $status = "SUCCESS: new occurrence record submitted successfully "; - if($occArr){ + public function addOccurrence($postArr){ + $status = 'SUCCESS: new occurrence record submitted successfully '; + if($postArr){ $fieldArr = array('basisOfRecord' => 's', 'catalogNumber' => 's', 'otherCatalogNumbers' => 's', 'occurrenceid' => 's', 'ownerInstitutionCode' => 's', 'institutionCode' => 's', 'collectionCode' => 's', 'family' => 's', 'sciname' => 's', 'tidinterpreted' => 'n', 'scientificNameAuthorship' => 's', 'identifiedBy' => 's', 'dateIdentified' => 's', @@ -1047,36 +1047,27 @@ public function addOccurrence($occArr){ 'footprintwkt' => 's', 'georeferencedBy' => 's', 'georeferenceProtocol' => 's', 'georeferenceSources' => 's', 'georeferenceVerificationStatus' => 's', 'georeferenceRemarks' => 's', 'minimumElevationInMeters' => 'n', 'maximumElevationInMeters' => 'n','verbatimElevation' => 's', 'minimumDepthInMeters' => 'n', 'maximumDepthInMeters' => 'n', 'verbatimDepth' => 's','disposition' => 's', 'language' => 's', 'duplicateQuantity' => 'n', - 'labelProject' => 's','processingstatus' => 's', 'recordEnteredBy' => 's', 'observeruid' => 'n', 'dateentered' => 'd', 'genericcolumn2' => 's'); - $sql = 'INSERT INTO omoccurrences(collid, '.implode(array_keys($fieldArr),',').') VALUES ('.$occArr["collid"]; + 'labelProject' => 's','processingStatus' => 's', 'recordEnteredBy' => 's', 'observeruid' => 'n', 'dateentered' => 'd', 'genericcolumn2' => 's'); + $sql = 'INSERT INTO omoccurrences(collid, '.implode(array_keys($fieldArr),',').') VALUES ('.$postArr['collid']; $fieldArr = array_change_key_case($fieldArr); - //if(array_key_exists('cultivationstatus',$occArr) && $occArr['cultivationstatus']) $occArr['cultivationstatus'] = $occArr['cultivationstatus']; - //if(array_key_exists('localitysecurity',$occArr) && $occArr['localitysecurity']) $occArr['localitysecurity'] = $occArr['localitysecurity']; - if(!isset($occArr['dateentered']) || !$occArr['dateentered']) $occArr['dateentered'] = date('Y-m-d H:i:s'); - if(!isset($occArr['basisofrecord']) || !$occArr['basisofrecord']) $occArr['basisofrecord'] = (strpos($this->collMap['colltype'],'Observations') !== false?'HumanObservation':'PreservedSpecimen'); - if(isset($occArr['institutionCode']) && $occArr['institutionCode'] == $this->collMap['institutioncode']) $occArr['institutionCode'] = ''; - if(isset($occArr['collectionCode']) && $occArr['collectionCode'] == $this->collMap['collectioncode']) $occArr['collectionCode'] = ''; + //if(array_key_exists('cultivationstatus',$postArr) && $postArr['cultivationstatus']) $postArr['cultivationstatus'] = $postArr['cultivationstatus']; + //if(array_key_exists('localitysecurity',$postArr) && $postArr['localitysecurity']) $postArr['localitysecurity'] = $postArr['localitysecurity']; + if(!isset($postArr['dateentered']) || !$postArr['dateentered']) $postArr['dateentered'] = date('Y-m-d H:i:s'); + if(!isset($postArr['basisofrecord']) || !$postArr['basisofrecord']) $postArr['basisofrecord'] = (strpos($this->collMap['colltype'],'Observations') !== false?'HumanObservation':'PreservedSpecimen'); + if(isset($postArr['institutioncode']) && $postArr['institutioncode'] == $this->collMap['institutioncode']) $postArr['institutionCode'] = ''; + if(isset($postArr['collectioncode']) && $postArr['collectioncode'] == $this->collMap['collectioncode']) $postArr['collectionCode'] = ''; foreach($fieldArr as $fieldStr => $fieldType){ $fieldValue = ''; - if(array_key_exists($fieldStr,$occArr)) $fieldValue = $occArr[$fieldStr]; + if(array_key_exists($fieldStr,$postArr)) $fieldValue = $postArr[$fieldStr]; if($fieldValue){ if($fieldType == 'n'){ - if(is_numeric($fieldValue)){ - $sql .= ', '.$fieldValue; - } - else{ - $sql .= ', NULL'; - } + if(is_numeric($fieldValue)) $sql .= ', '.$fieldValue; + else $sql .= ', NULL'; } - else{ - //Is string or date - $sql .= ', "'.$this->cleanInStr($fieldValue).'"'; - } - } - else{ - $sql .= ', NULL'; + else $sql .= ', "'.$this->cleanInStr($fieldValue).'"'; //Is string or date } + else $sql .= ', NULL'; } $sql .= ')'; if($this->conn->query($sql)){ @@ -1090,14 +1081,14 @@ public function addOccurrence($occArr){ $status .= '(WARNING: Symbiota GUID mapping failed) '; } //Deal with paleo - if($this->paleoActivated && array_key_exists('eon',$occArr)){ + if($this->paleoActivated && array_key_exists('eon',$postArr)){ //Add new record $paleoFrag1 = ''; $paleoFrag2 = ''; foreach($this->paleoFieldArr as $paleoField){ - if(array_key_exists($paleoField,$occArr)){ + if(array_key_exists($paleoField,$postArr)){ $paleoFrag1 .= ','.$paleoField; - $paleoFrag2 .= ','.($occArr[$paleoField]?'"'.$this->cleanInStr($occArr[$paleoField]).'"':'NULL'); + $paleoFrag2 .= ','.($postArr[$paleoField]?'"'.$this->cleanInStr($postArr[$paleoField]).'"':'NULL'); } } if($paleoFrag1){ @@ -1106,10 +1097,10 @@ public function addOccurrence($occArr){ } } //Deal with Exsiccati - if(isset($occArr['ometid']) && isset($occArr['exsnumber'])){ + if(isset($postArr['ometid']) && isset($postArr['exsnumber'])){ //If exsiccati titie is submitted, trim off first character that was used to force Google Chrom to sort correctly - $ometid = $this->cleanInStr($occArr['ometid']); - $exsNumber = $this->cleanInStr($occArr['exsnumber']); + $ometid = $this->cleanInStr($postArr['ometid']); + $exsNumber = $this->cleanInStr($postArr['exsnumber']); if($ometid && $exsNumber){ $exsNumberId = ''; $sql = 'SELECT omenid FROM omexsiccatinumbers WHERE ometid = '.$ometid.' AND exsnumber = "'.$exsNumber.'"'; @@ -1140,24 +1131,24 @@ public function addOccurrence($occArr){ } } //Deal with host data - if(array_key_exists('host',$occArr)){ - $sql = 'INSERT INTO omoccurassociations(occid,relationship,verbatimsciname) VALUES('.$this->occid.',"host","'.$this->cleanInStr($occArr['host']).'")'; + if(array_key_exists('host',$postArr)){ + $sql = 'INSERT INTO omoccurassociations(occid,relationship,verbatimsciname) VALUES('.$this->occid.',"host","'.$this->cleanInStr($postArr['host']).'")'; if(!$this->conn->query($sql)){ $status .= '(WARNING adding host: '.$this->conn->error.') '; } } - if(isset($occArr['confidenceranking']) && $occArr['confidenceranking']){ - $this->editIdentificationRanking($occArr['confidenceranking'],''); + if(isset($postArr['confidenceranking']) && $postArr['confidenceranking']){ + $this->editIdentificationRanking($postArr['confidenceranking'],''); } //Deal with checklist voucher - if(isset($occArr['clidvoucher']) && isset($occArr['tidinterpreted'])){ - $status .= $this->linkChecklistVoucher($occArr['clidvoucher'],$occArr['tidinterpreted']); + if(isset($postArr['clidvoucher']) && isset($postArr['tidinterpreted'])){ + $status .= $this->linkChecklistVoucher($postArr['clidvoucher'],$postArr['tidinterpreted']); } //Deal with duplicate clustering - if(isset($occArr['linkdupe']) && $occArr['linkdupe']){ - $dupTitle = $occArr['recordedby'].' '.$occArr['recordnumber'].' '.$occArr['eventdate']; - $status .= $this->linkDuplicates($occArr['linkdupe'],$dupTitle); + if(isset($postArr['linkdupe']) && $postArr['linkdupe']){ + $dupTitle = $postArr['recordedby'].' '.$postArr['recordnumber'].' '.$postArr['eventdate']; + $status .= $this->linkDuplicates($postArr['linkdupe'],$dupTitle); } } else{ @@ -1294,8 +1285,45 @@ public function deleteOccurrence($delOccid){ return $status; } + public function cloneOccurrence($postArr){ + $retArr = array(); + if(isset($postArr['clonecount']) && $postArr['clonecount']){ + $postArr['recordenteredby'] = $GLOBALS['USERNAME']; + $sourceOccid = $this->occid; + $clearAllArr = array('catalognumber','othercatalognumbers','occurrenceid','individualcount','duplicatequantity','processingstatus','dateentered'); + $postArr = array_diff_key($postArr,array_flip($clearAllArr)); + if($postArr['targetcollid'] && $postArr['targetcollid'] != $this->collId){ + $clearCollArr = array('basisofrecord','ownerinstitutioncode','institutioncode','collectioncode'); + $postArr = array_diff_key($postArr,array_flip($clearCollArr)); + $postArr['collid'] = $postArr['targetcollid']; + } + if(isset($postArr['carryover']) && $postArr['carryover'] == 1){ + $clearEventArr = array('family','sciname','tidinterpreted','scientificnameauthorship','identifiedby','dateidentified','identificationreferences','identificationremarks', + 'taxonremarks','identificationqualifier','recordnumber','occurrenceremarks','verbatimattributes','dynamicproperties','lifestage','sex'); + $postArr = array_diff_key($postArr,array_flip($clearEventArr)); + } + $cloneCatNum = array(); + if(isset($postArr['clonecatnum'])) $cloneCatNum = $postArr['clonecatnum']; + for($i=0; $i < $postArr['clonecount']; $i++){ + if(isset($cloneCatNum[$i]) && $cloneCatNum[$i]) $postArr['catalognumber'] = $cloneCatNum[$i]; + $this->addOccurrence($postArr); + if($sourceOccid != $this->occid && !in_array($this->occid,$retArr)){ + $retArr[$this->occid] = $this->occid; + if(isset($postArr['assocrelation']) && $postArr['assocrelation']){ + $sql = 'INSERT INTO omoccurassociations(occid, occidAssociate, relationship,createdUid) '. + 'values('.$this->occid.','.$sourceOccid.',"'.$postArr['assocrelation'].'",'.$GLOBALS['SYMB_UID'].') '; + if(!$this->conn->query($sql)){ + $this->errorArr[] = 'ERROR adding relationship for cloned specimens: '.$this->conn->error; + } + } + } + } + $this->occid = $sourceOccid; + } + return $retArr; + } + public function mergeRecords($targetOccid,$sourceOccid){ - global $QUICK_HOST_ENTRY_IS_ACTIVE; $status = true; if(!$targetOccid || !$sourceOccid){ $this->errorArr[] = 'ERROR: target or source is null'; @@ -2182,6 +2210,19 @@ public function getQuickHost(){ return $retArr; } + public function getAssociationControlVocab(){ + $retArr = array(); + $sql = 'SELECT t.cvTermID, t.term '. + 'FROM ctcontrolvocabterm t INNER JOIN ctcontrolvocab v ON t.cvID = v.cvID '. + 'WHERE v.tablename = "omoccurassociations" AND v.fieldName = "relationship" ORDER BY term'; + $rs = $this->conn->query($sql); + while($r = $rs->fetch_object()){ + $retArr[$r->cvTermID] = $r->term; + } + $rs->free(); + return $retArr; + } + public function isCrowdsourceEditor(){ $isEditor = false; $sql = 'SELECT reviewstatus, uidprocessor FROM omcrowdsourcequeue WHERE occid = '.$this->occid; diff --git a/classes/OccurrenceExsiccatae.php b/classes/OccurrenceExsiccatae.php index 3b0aa6b3e3..604ec8f6a5 100644 --- a/classes/OccurrenceExsiccatae.php +++ b/classes/OccurrenceExsiccatae.php @@ -77,16 +77,10 @@ public function getTitleArr($searchTerm, $specimenOnly, $imagesOnly, $collId, $s //echo $sql; if($rs = $this->conn->query($sql)){ while($r = $rs->fetch_object()){ - if($sortBy == 1) { - if($r->abbreviation) $titleStr = (strlen($r->abbreviation)>100?substr($r->abbreviation,0,100).'...':$r->abbreviation); - else { - $titleStr = (strlen($r->title)>100?substr($r->title,0,100).'...':$r->title); - $titleStr .= ', '.(strlen($r->editor)>50?substr($r->editor,0,50).'...':$r->editor); - } - } else { - $titleStr = (strlen($r->title)>100?substr($r->title,0,100).'...':$r->title); - if($r->editor) $titleStr .= ', '.(strlen($r->editor)>50?substr($r->editor,0,50).'...':$r->editor); - } + $titleStr = $r->title; + if($sortBy == 1 && $r->abbreviation) $titleStr = $r->abbreviation; + if(strlen($titleStr)>100) $titleStr = substr($titleStr,0,100).'...'; + $retArr[$r->ometid]['editor'] = $this->cleanOutStr($r->editor); $retArr[$r->ometid]['exsrange'] = $this->cleanOutStr($r->exsrange); $retArr[$r->ometid]['title'] = $this->cleanOutStr($titleStr); } diff --git a/classes/OccurrenceIndividual.php b/classes/OccurrenceIndividual.php index 3e28e90a6a..26bcde9444 100644 --- a/classes/OccurrenceIndividual.php +++ b/classes/OccurrenceIndividual.php @@ -363,6 +363,65 @@ public function getDuplicateArr(){ return $retArr; } + //Occurrence trait and attribute functions + public function getTraitArr(){ + $retArr = array(); + if($this->occid){ + $sql = 'SELECT t.traitid, t.traitName, t.description AS t_desc, t.refUrl AS t_url, s.stateid, s.stateName, s.description AS s_desc, s.refUrl AS s_url, d.parentstateid '. + 'FROM tmattributes a INNER JOIN tmstates s ON a.stateid = s.stateid '. + 'INNER JOIN tmtraits t ON s.traitid = t.traitid '. + 'LEFT JOIN tmtraitdependencies d ON t.traitid = d.traitid '. + 'WHERE t.isPublic = 1 AND a.occid = '.$this->occid.' ORDER BY t.traitName, s.sortSeq'; + $rs = $this->conn->query($sql); + if($rs){ + while($r = $rs->fetch_object()){ + $retArr[$r->traitid]['name'] = $r->traitName; + $retArr[$r->traitid]['desc'] = $r->t_desc; + $retArr[$r->traitid]['url'] = $r->t_url; + $retArr[$r->traitid]['depStateID'] = $r->parentstateid; + $retArr[$r->traitid]['state'][$r->stateid]['name'] = $r->stateName; + $retArr[$r->traitid]['state'][$r->stateid]['desc'] = $r->s_desc; + $retArr[$r->traitid]['state'][$r->stateid]['url'] = $r->s_url; + } + $rs->free(); + } + if($retArr){ + //Set dependent traits + $sql = 'SELECT DISTINCT s.traitid AS parentTraitID, d.parentStateID, d.traitid AS depTraitID '. + 'FROM tmstates s INNER JOIN tmtraitdependencies d ON s.stateid = d.parentstateid '. + 'WHERE s.traitid IN('.implode(',',array_keys($retArr)).')'; + //echo $sql.'
'; + $rs = $this->conn->query($sql); + while($r = $rs->fetch_object()){ + $retArr[$r->parentTraitID]['state'][$r->parentStateID]['depTraitID'][] = $r->depTraitID; + } + $rs->free(); + } + } + return $retArr; + } + + public function echoTraitDiv($traitArr, $targetID, $ident = 15){ + $tArr = $traitArr[$targetID]; + foreach($tArr['state'] as $stateID => $sArr){ + $this->echoTraitUnit($sArr,$ident); + if(array_key_exists('depTraitID',$sArr)){ + foreach($sArr['depTraitID'] as $depTraitID){ + $this->echoTraitDiv($traitArr, $depTraitID, $ident+15); + } + } + } + } + + public function echoTraitUnit($outArr, $indent=0){ + echo '
'; + if($outArr['url']) echo ''; + echo ''.$outArr['name'].' '; + if($outArr['url']) echo ''; + if($outArr['desc']) echo ': '.$outArr['desc']; + echo '
'; + } + //Occurrence comment functions public function getCommentArr($isEditor){ $retArr = array(); diff --git a/classes/OccurrenceLoans.php b/classes/OccurrenceLoans.php index 54bb2e1985..9d42b04fe8 100644 --- a/classes/OccurrenceLoans.php +++ b/classes/OccurrenceLoans.php @@ -488,6 +488,31 @@ public function getSpecimenTotal($loanid){ return $retStr; } + public function exportSpecimenList($loanid){ + $fileName = 'loanSpecList_'.date('Ymd').'.csv'; + header ('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header ('Content-Type: text/csv'); + header ('Content-Disposition: attachment; filename="'.$fileName.'"'); + $sql = 'SELECT o.catalogNumber, o.otherCatalogNumbers, o.occurrenceID, o.family, o.sciname, o.recordedBy, o.recordNumber, o.eventDate, '. + 'o.country, o.stateProvince, o.county, o.locality, o.decimalLatitude, o.decimalLongitude, o.minimumElevationInMeters, o.dateEntered, o.dateLastModified '. + 'FROM omoccurrences o INNER JOIN omoccurloanslink l ON o.occid = l.occid '. + 'WHERE loanid = '.$loanid; + $rs = $this->conn->query($sql); + if($rs->num_rows){ + $headerArr = array(); + $fields = mysqli_fetch_fields($rs); + foreach($fields as $val) $headerArr[] = $val->name; + $out = fopen('php://output', 'w'); + fputcsv($out, $headerArr); + while($r = $rs->fetch_assoc()){ + fputcsv($out, $r); + } + $rs->free(); + fclose($out); + } + else echo "Specimen recordset is empty.\n"; + } + public function linkSpecimen($loanid, $catNum){ //This method is used by the ajax script insertLoanSpecimen.php if(is_numeric($loanid)){ diff --git a/classes/OccurrenceManager.php b/classes/OccurrenceManager.php index 8cae3c0ae7..3544573d1c 100644 --- a/classes/OccurrenceManager.php +++ b/classes/OccurrenceManager.php @@ -427,6 +427,27 @@ protected function setSqlWhere(){ $this->displaySearchArr[] = 'includes cultivated/captive occurrences'; } } + $anyTraitsHere = false; + $stateids = array(); + foreach($this->searchTermArr as $stkey => $stval){ + if("traitid-" == substr($stkey, 0, 8) && is_numeric($stval)) { + $stateids[] = $stval; + $anyTraitsHere = true; + } + } + if($anyTraitsHere == true) { + $traitSql = implode(',', $stateids); + $traitNameSql = 'SELECT CONCAT_WS(": ", t.traitname, s.statename) AS traitName FROM tmtraits t JOIN tmstates s ON s.traitid = t.traitid WHERE s.stateid IN(' . $traitSql . ')'; + $rs = $this->conn->query($traitNameSql); + if($rs){ + while($r = $rs->fetch_object()) { + $this->displaySearchArr[] = $r->traitName; + } + $rs->free(); + } + $sqlWhere .= 'AND (o.occid IN(SELECT occid FROM tmattributes WHERE stateid IN(' . $traitSql . ')))'; + } + if($sqlWhere){ $this->sqlWhere = 'WHERE '.substr($sqlWhere,4); } @@ -844,6 +865,16 @@ protected function readRequestVariables(){ unset($this->searchTermArr["includecult"]); } } + // Traits search: loop over all "traitid-" fields + foreach ($_REQUEST as $reqkey => $reqval){ + if("traitid-" == substr($reqkey, 0, 8)){ + if($reqval){ + $this->searchTermArr[$reqkey] = $reqval[0]; + } else { + unset($this->searchTermArr[$reqkey]); + } + } + } $llPattern = '-?\d+\.{0,1}\d*'; if(array_key_exists("upperlat",$_REQUEST)){ $upperLat = ''; $bottomlat = ''; $leftLong = ''; $rightlong = ''; diff --git a/classes/SpecUploadBase.php b/classes/SpecUploadBase.php index d72c80e5fc..abfc2df56d 100644 --- a/classes/SpecUploadBase.php +++ b/classes/SpecUploadBase.php @@ -286,7 +286,8 @@ public function echoFieldMapTable($autoMap, $mode){ 'elevationmeters'=>'minimumelevationinmeters','minelevationm'=>'minimumelevationinmeters','maxelevationm'=>'maximumelevationinmeters','verbatimelev'=>'verbatimelevation', 'field:associatedspecies'=>'associatedtaxa','associatedspecies'=>'associatedtaxa','assoctaxa'=>'associatedtaxa','specimennotes'=>'occurrenceremarks','notes'=>'occurrenceremarks', 'generalnotes'=>'occurrenceremarks','plantdescription'=>'verbatimattributes','description'=>'verbatimattributes','specimendescription'=>'verbatimattributes', - 'phenology'=>'reproductivecondition','field:habitat'=>'habitat','habitatdescription'=>'habitat','sitedeschabitat'=>'habitat','ometid'=>'exsiccatiidentifier','exsnumber'=>'exsiccatinumber', + 'phenology'=>'reproductivecondition','field:habitat'=>'habitat','habitatdescription'=>'habitat','sitedeschabitat'=>'habitat', + 'ometid'=>'exsiccatiidentifier','exsiccataeidentifier'=>'exsiccatiidentifier','exsnumber'=>'exsiccatinumber','exsiccataenumber'=>'exsiccatinumber', 'group'=>'paleo-lithogroup','lithostratigraphicterms'=>'paleo-lithology','imageurl'=>'associatedmedia','subject_references'=>'tempfield01','subject_recordid'=>'tempfield02' ); diff --git a/collections/editor/includes/queryform.php b/collections/editor/includes/queryform.php index 90584f362a..41ae8294b6 100644 --- a/collections/editor/includes/queryform.php +++ b/collections/editor/includes/queryform.php @@ -36,7 +36,7 @@ else{ $processingStatusArr = array('unprocessed','unprocessed/NLP','stage 1','stage 2','stage 3','pending review-nfn','pending review','expert required','reviewed','closed'); } -if(!isset($_REQUEST['q_catalognumber'])) $displayQuery = true; +//if(!isset($_REQUEST['q_catalognumber'])) $displayQuery = true; ?>
@@ -93,6 +93,7 @@
Entered by: +
Date entered: @@ -138,9 +139,8 @@
Exsiccati Title: - - $exsTitle){ echo ''; @@ -175,7 +175,7 @@ 'georeferenceVerificationStatus'=>'Georeference Verification Status','georeferencedBy'=>'Georeferenced By','habitat'=>'Habitat', 'identificationQualifier'=>'Identification Qualifier','identificationReferences'=>'Identification References', 'identificationRemarks'=>'Identification Remarks','identifiedBy'=>'Identified By','individualCount'=>'Individual Count', - 'informationWithheld'=>'Information Withheld','institutionCode'=>'Institution Code (override)','labelProject'=>'Label Project', + 'informationWithheld'=>'Information Withheld','institutionCode'=>'Institution Code (override)','labelProject'=>'Project', 'language'=>'Language','lifeStage'=>'Life Stage','locationid'=>'Location ID','locality'=>'Locality', 'localitySecurity'=>'Locality Security','localitySecurityReason'=>'Locality Security Reason','locationRemarks'=>'Location Remarks', 'username'=>'Modified By','municipality'=>'Municipality','occurrenceRemarks'=>'Notes (Occurrence Remarks)','ocrFragment'=>'OCR Fragment', @@ -342,4 +342,45 @@
-
\ No newline at end of file +
+ \ No newline at end of file diff --git a/collections/editor/occurrenceeditor.php b/collections/editor/occurrenceeditor.php index f408cb3c8f..b548b4ed2b 100644 --- a/collections/editor/occurrenceeditor.php +++ b/collections/editor/occurrenceeditor.php @@ -10,7 +10,7 @@ $occIndex = array_key_exists('occindex',$_REQUEST)?$_REQUEST['occindex']:false; $crowdSourceMode = array_key_exists('csmode',$_REQUEST)?$_REQUEST['csmode']:0; $action = array_key_exists('submitaction',$_REQUEST)?$_REQUEST['submitaction']:''; -if(!$action && array_key_exists('carryloc',$_REQUEST)) $goToMode = 2; +if(!$action && array_key_exists('carryover',$_REQUEST)) $goToMode = 2; //Sanitation if(!is_numeric($occId)) $occId = ''; @@ -104,12 +104,12 @@ //0 = not editor, 1 = admin, 2 = editor, 3 = taxon editor, 4 = crowdsource editor or collection allows public edits //If not editor, edits will be submitted to omoccuredits table but not applied to omoccurrences - if($IS_ADMIN || ($collId && array_key_exists("CollAdmin",$USER_RIGHTS) && in_array($collId,$USER_RIGHTS["CollAdmin"]))){ + if($IS_ADMIN || ($collId && array_key_exists('CollAdmin',$USER_RIGHTS) && in_array($collId,$USER_RIGHTS['CollAdmin']))){ $isEditor = 1; } else{ if($isGenObs){ - if(!$occId && array_key_exists("CollEditor",$USER_RIGHTS) && in_array($collId,$USER_RIGHTS["CollEditor"])){ + if(!$occId && array_key_exists('CollEditor',$USER_RIGHTS) && in_array($collId,$USER_RIGHTS['CollEditor'])){ //Approved General Observation editors can add records $isEditor = 2; } @@ -122,7 +122,7 @@ $isEditor = 2; } } - elseif(array_key_exists("CollEditor",$USER_RIGHTS) && in_array($collId,$USER_RIGHTS["CollEditor"])){ + elseif(array_key_exists('CollEditor',$USER_RIGHTS) && in_array($collId,$USER_RIGHTS['CollEditor'])){ //Is an assigned editor for this collection $isEditor = 2; } @@ -134,14 +134,25 @@ //Collection is set as allowing public edits $isEditor = 4; } - elseif(array_key_exists("CollTaxon",$USER_RIGHTS) && $occId){ + elseif(array_key_exists('CollTaxon',$USER_RIGHTS) && $occId){ //Check to see if this user is authorized to edit this occurrence given their taxonomic editing authority $isEditor = $occManager->isTaxonomicEditor(); } } - if($action == "Save Edits"){ + if($action == 'saveOccurEdits'){ $statusStr = $occManager->editOccurrence($_POST,$isEditor); } + elseif($action == 'cloneRecord'){ + $cloneArr = $occManager->cloneOccurrence($_POST); + if($cloneArr){ + $statusStr = 'Success! The following '.count($cloneArr).' cloned record(s) have been created:'; + $statusStr .= '
'; + foreach($cloneArr as $cloneOccid){ + $statusStr .= '
#'.$cloneOccid.'
'; + } + $statusStr .= '
'; + } + } if($isEditor && $isEditor != 3){ if($action == 'Save OCR'){ $statusStr = $occManager->insertTextFragment($_POST['imgid'],$_POST['rawtext'],$_POST['rawnotes'],$_POST['rawsource']); @@ -159,16 +170,16 @@ } if($isEditor){ //Available to full editors and taxon editors - if($action == "Submit Determination"){ + if($action == 'Submit Determination'){ //Adding a new determination $statusStr = $occManager->addDetermination($_POST,$isEditor); $tabTarget = 1; } - elseif($action == "Submit Determination Edits"){ + elseif($action == 'Submit Determination Edits'){ $statusStr = $occManager->editDetermination($_POST); $tabTarget = 1; } - elseif($action == "Delete Determination"){ + elseif($action == 'Delete Determination'){ $statusStr = $occManager->deleteDetermination($_POST['detid']); $tabTarget = 1; } @@ -179,27 +190,17 @@ $occManager->setQueryVariables(); $qryCnt = $occManager->getQueryRecordCount(); $qryCnt++; - if($goToMode){ - //Go to new record - $occIndex = $qryCnt; - } - else{ - //Stay on record and get $occId - $occId = $occManager->getOccId(); - } - } - else{ - $statusStr = $occManager->getErrorStr(); + if($goToMode) $occIndex = $qryCnt; //Go to new record + else $occId = $occManager->getOccId(); //Stay on record and get $occId } + else $statusStr = $occManager->getErrorStr(); } elseif($action == 'Delete Occurrence'){ if($occManager->deleteOccurrence($occId)){ $occId = 0; $occManager->setOccId(0); } - else{ - $statusStr = $occManager->getErrorStr(); - } + else $statusStr = $occManager->getErrorStr(); } elseif($action == 'Transfer Record'){ $transferCollid = $_POST['transfercollid']; @@ -216,11 +217,11 @@ } } } - elseif($action == "Submit Image Edits"){ + elseif($action == 'Submit Image Edits'){ $statusStr = $occManager->editImage($_POST); $tabTarget = 2; } - elseif($action == "Submit New Image"){ + elseif($action == 'Submit New Image'){ if($occManager->addImage($_POST)){ $statusStr = 'Image added successfully'; $tabTarget = 2; @@ -229,7 +230,7 @@ $statusStr .= $occManager->getErrorStr(); } } - elseif($action == "Delete Image"){ + elseif($action == 'Delete Image'){ $removeImg = (array_key_exists("removeimg",$_POST)?$_POST["removeimg"]:0); if($occManager->deleteImage($_POST["imgid"], $removeImg)){ $statusStr = 'Image deleted successfully'; @@ -300,7 +301,7 @@ if($goToMode){ //Adding new record, override query form and prime for current user's dataentry for the day $occId = 0; - $occManager->setQueryVariables(array('eb'=>$PARAMS_ARR['un'],'dm'=>date('Y-m-d'))); + $occManager->setQueryVariables(array('eb'=>$PARAMS_ARR['un'],'de'=>date('Y-m-d'))); if(!$qryCnt){ $qryCnt = $occManager->getQueryRecordCount(); $occIndex = $qryCnt; @@ -321,7 +322,7 @@ $occIndex = false; } } - elseif($action == 'Save Edits'){ + elseif($action == 'saveOccurEdits'){ //Get query count and then reset; don't use new count for this display $qryCnt = $occManager->getQueryRecordCount(); $occManager->getQueryRecordCount(1); @@ -428,7 +429,7 @@ } else{ ?> - + - + @@ -486,7 +487,7 @@ function requestImage(){ @@ -584,7 +585,7 @@ function requestImage(){
Search returned 0 records
'."\n"; + if($qryCnt == 0 && !$occId) echo '
Search returned 0 records
'."\n"; if($occArr || $goToMode == 1 || $goToMode == 2){ //$action == 'gotonew' if($occId && $isLocked){ ?> @@ -763,7 +764,7 @@ function requestImage(){ ?>
Out On Loan - To: + To:
Due date:
@@ -1259,13 +1260,8 @@ function requestImage(){ '; ?> - - -
@@ -1290,7 +1286,7 @@ function requestImage(){

- +
@@ -1438,56 +1434,104 @@ function requestImage(){ - Status Auto-Set: - +
+ Status Auto-Set: + +
+ + + +
+
+
- Additional Options -
- - Carry over locality values + Record Cloning +
+
Carry over:
+
+ Collection event fields
+ All fields
+
+
+
+ Relationship: + +
+ getCollectionList(true); + unset($targetArr[$collId]); + if(count($targetArr) > 1){ + ?> +
+ Target collection: + +
+ +
+ Number of records: +
+ + +
+ +
-
- - - -
-
- - - - + + +
Follow-up Action:
- /> Go to New Record
- /> Go to New Record and Carryover Locality Information
- /> Remain on Editing Page (add images, determinations, etc) + /> Go to New Record
+ /> Go to New Record and Carryover Locality Information
+ /> Remain on Editing Page (add images, determinations, etc)
'Description','lifestage' => 'Life Stage', 'sex' => 'Sex', 'individualcount' => 'Individual Count', 'samplingprotocol' => 'Sampling Protocol', 'preparations' => 'Preparations', 'reproductivecondition' => 'Reproductive Condition', 'typestatus' => 'Type Status','cultivationstatus' => 'Cultivation Status','establishmentmeans' => 'Establishment Means', - 'disposition' => 'Disposition','duplicatequantity' => 'Duplicate Qty','datelastmodified' => 'Date Last Modified', + 'disposition' => 'Disposition','duplicatequantity' => 'Duplicate Qty','datelastmodified' => 'Date Last Modified', 'labelproject' => 'Project', 'processingstatus' => 'Processing Status','recordenteredby' => 'Entered By','dbpk' => 'dbpk','basisofrecord' => 'Basis Of Record','language' => 'Language'); $headMap = array(); diff --git a/collections/exsiccati/index.php b/collections/exsiccati/index.php index 1a7d30a0ea..de84ff49a7 100644 --- a/collections/exsiccati/index.php +++ b/collections/exsiccati/index.php @@ -407,15 +407,14 @@ function buildExsSelect(selectObj){ echo ''; echo $tArr['title']; echo ''; + if($tArr['editor']) echo ', '.$tArr['editor']; if($tArr['exsrange']) echo ' ['.$tArr['exsrange'].']'; ?> There are no exsiccatae matching your request
'; - } + else echo '
There are no exsiccatae matching your request
'; ?> getTitleObj($ometid); ?> -
+
@@ -437,11 +436,14 @@ function buildExsSelect(selectObj){
'.$exsArr['title'].'
'; if(isset($exsArr['sourceidentifier'])){ if(preg_match('/^http.+IndExs.+={1}(\d+)$/', $exsArr['sourceidentifier'], $m)) echo ' (IndExs #'.$m[1].')'; } - if($exsArr['notes']) echo '
'.$exsArr['notes'].'
'; + if($exsArr['abbreviation']) echo '
Abbreviation: '.$exsArr['abbreviation'].'
'; + if($exsArr['editor']) echo '
Editor(s): '.$exsArr['editor'].'
'; + if($exsArr['exsrange']) echo '
Range: '.$exsArr['exsrange'].'
'; + if($exsArr['notes']) echo '
Notes: '.$exsArr['notes'].'
'; ?>