Skip to content

Commit

Permalink
Occurrence Review bug fix
Browse files Browse the repository at this point in the history
- Fixed bug that interferred with downloads of editing reports
  • Loading branch information
egbot committed Feb 6, 2020
1 parent c826b81 commit 5ed6549
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions classes/OccurrenceEditReview.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,13 @@ private function getOccurEditArr(){
return $retArr;
}

private function getEditSqlBase(){
private function getEditSqlBase($includeUserTable=false){
//Build SQL WHERE fragment
$sqlBase = '';
if($this->collid){
$sqlBase = 'FROM omoccuredits e INNER JOIN omoccurrences o ON e.occid = o.occid WHERE (o.collid = '.$this->collid.') ';
$sqlBase = 'FROM omoccuredits e INNER JOIN omoccurrences o ON e.occid = o.occid ';
if($includeUserTable) $sqlBase .= 'INNER JOIN users u ON e.uid = u.uid ';
$sqlBase .= 'WHERE (o.collid = '.$this->collid.') ';
if($this->appliedStatusFilter !== ''){
$sqlBase .= 'AND (e.appliedstatus = '.$this->appliedStatusFilter.') ';
}
Expand Down Expand Up @@ -177,10 +179,12 @@ private function getRevisionArr(){
return $retArr;
}

private function getRevisionSqlBase(){
private function getRevisionSqlBase($includeUserTable = false){
$sqlBase = '';
if($this->collid){
$sqlBase = 'FROM omoccurrevisions r INNER JOIN omoccurrences o ON r.occid = o.occid WHERE (o.collid = '.$this->collid.') ';
$sqlBase = 'FROM omoccurrevisions r INNER JOIN omoccurrences o ON r.occid = o.occid ';
if($includeUserTable) $sqlBase .= 'INNER JOIN users u ON r.uid = u.uid ';
$sqlBase .= 'WHERE (o.collid = '.$this->collid.') ';
if($this->appliedStatusFilter !== ''){
$sqlBase .= 'AND (r.appliedstatus = '.$this->appliedStatusFilter.') ';
}
Expand Down Expand Up @@ -344,7 +348,7 @@ public function exportCsvFile($idStr, $exportAll = false){
$sql = 'SELECT e.ocedid AS id, o.occid, o.catalognumber, o.dbpk, e.fieldname, e.fieldvaluenew, e.fieldvalueold, e.reviewstatus, e.appliedstatus, '.
'CONCAT_WS(", ",u.lastname,u.firstname) AS username, e.initialtimestamp ';
if($exportAll){
$sql .= $this->getEditSqlBase();
$sql .= $this->getEditSqlBase(true);
}
else{
$sql .= 'FROM omoccuredits e INNER JOIN omoccurrences o ON e.occid = o.occid '.
Expand All @@ -360,7 +364,7 @@ public function exportCsvFile($idStr, $exportAll = false){
$sql = 'SELECT r.orid AS id, o.occid, o.catalognumber, o.dbpk, r.oldvalues, r.newvalues, r.reviewstatus, r.appliedstatus, '.
'r.externaleditor, CONCAT_WS(", ",u.lastname,u.firstname) AS username, r.externaltimestamp, r.initialtimestamp ';
if($exportAll){
$sql .= $this->getRevisionSqlBase();
$sql .= $this->getRevisionSqlBase(true);
}
else{
$sql .= 'FROM omoccurrevisions r INNER JOIN omoccurrences o ON r.occid = o.occid '.
Expand Down

0 comments on commit 5ed6549

Please sign in to comment.