public function addDetermination($detArr, $isEditor)
 {
     $status = "Determination submitted successfully!";
     if (!$this->occid) {
         return 'ERROR: occid is null';
     }
     $isCurrent = 0;
     if (!array_key_exists('makecurrent', $detArr)) {
         $detArr['makecurrent'] = 0;
     }
     if (!array_key_exists('printqueue', $detArr)) {
         $detArr['printqueue'] = 0;
     }
     if ($detArr['makecurrent'] == 1 && $isEditor < 3) {
         $isCurrent = 1;
     }
     if ($isEditor == 3) {
         $status = "Determination has been added successfully, but is pending approval before being activated";
     }
     $sortSeq = 1;
     if (preg_match('/([1,2]{1}\\d{3})/', $detArr['dateidentified'], $matches)) {
         $sortSeq = 2100 - $matches[1];
     }
     if ($isCurrent) {
         //Set all dets for this specimen to not current
         $sqlSetCur1 = 'UPDATE omoccurdeterminations SET iscurrent = 0 WHERE appliedstatus = 1 AND occid = ' . $this->occid;
         if (!$this->conn->query($sqlSetCur1)) {
             $status = 'ERROR resetting dets to not current: ' . $this->conn->error;
             //$status .= '; '.$sqlSetCur1;
         }
     }
     //Load new determination into omoccurdeterminations
     $sciname = $this->cleanInStr($detArr['sciname']);
     $notes = $this->cleanInStr($detArr['identificationremarks']);
     if ($isEditor == 3 && is_numeric($detArr['confidenceranking'])) {
         $notes .= ($notes ? '; ' : '') . 'ConfidenceRanking: ' . $detArr['confidenceranking'];
     }
     $sql = 'INSERT INTO omoccurdeterminations(occid, identifiedBy, dateIdentified, sciname, scientificNameAuthorship, ' . 'identificationQualifier, iscurrent, printqueue, appliedStatus, identificationReferences, identificationRemarks, sortsequence) ' . 'VALUES (' . $this->occid . ',"' . $this->cleanInStr($detArr['identifiedby']) . '","' . $this->cleanInStr($detArr['dateidentified']) . '","' . $sciname . '",' . ($detArr['scientificnameauthorship'] ? '"' . $this->cleanInStr($detArr['scientificnameauthorship']) . '"' : 'NULL') . ',' . ($detArr['identificationqualifier'] ? '"' . $this->cleanInStr($detArr['identificationqualifier']) . '"' : 'NULL') . ',' . $detArr['makecurrent'] . ',' . $detArr['printqueue'] . ',' . ($isEditor == 3 ? 0 : 1) . ',' . ($detArr['identificationreferences'] ? '"' . $this->cleanInStr($detArr['identificationreferences']) . '"' : 'NULL') . ',' . ($notes ? '"' . $notes . '"' : 'NULL') . ',' . $sortSeq . ')';
     //echo "<div>".$sql."</div>";
     if ($this->conn->query($sql)) {
         //Create and insert Symbiota GUID for determination(UUID)
         $guid = UuidFactory::getUuidV4();
         $detId = $this->conn->insert_id;
         if (!$this->conn->query('INSERT INTO guidoccurdeterminations(guid,detid) VALUES("' . $guid . '",' . $detId . ')')) {
             $status .= ' (Warning: Symbiota GUID mapping #1 failed)';
         }
         //If is current, move old determination from omoccurrences to omoccurdeterminations and then load new record into omoccurrences
         if ($isCurrent) {
             //If determination is already in omoccurdeterminations, INSERT will fail move omoccurrences determination to  table
             $sqlInsert = 'INSERT INTO omoccurdeterminations(occid, identifiedBy, dateIdentified, sciname, scientificNameAuthorship, ' . 'identificationQualifier, identificationReferences, identificationRemarks, sortsequence) ' . 'SELECT occid, IFNULL(identifiedby,"unknown") AS idby, IFNULL(dateidentified,"unknown") AS di, ' . 'sciname, scientificnameauthorship, identificationqualifier, identificationreferences, identificationremarks, 10 AS sortseq ' . 'FROM omoccurrences WHERE (occid = ' . $this->occid . ')';
             //echo "<div>".$sqlInsert."</div>";
             if ($this->conn->query($sqlInsert)) {
                 //Create and insert Symbiota GUID for determination(UUID)
                 $guid = UuidFactory::getUuidV4();
                 $detId = $this->conn->insert_id;
                 if (!$this->conn->query('INSERT INTO guidoccurdeterminations(guid,detid) VALUES("' . $guid . '",' . $detId . ')')) {
                     $status .= ' (Warning: Symbiota GUID mapping #2 failed)';
                 }
             }
             $tidToAdd = $detArr['tidtoadd'];
             if ($tidToAdd && !is_numeric($tidToAdd)) {
                 $tidToAdd = 0;
             }
             //Check to see if taxon has a locality security protection (rare, threatened, or sensitive species)
             $sStatus = 0;
             if ($tidToAdd) {
                 $sqlSs = 'SELECT securitystatus FROM taxa WHERE (tid = ' . $tidToAdd . ')';
                 $rsSs = $this->conn->query($sqlSs);
                 if ($rSs = $rsSs->fetch_object()) {
                     if ($rSs->securitystatus == 1) {
                         $sStatus = 1;
                     }
                 }
                 $rsSs->free();
                 if (!$sStatus) {
                     $sql2 = 'SELECT c.clid ' . 'FROM fmchecklists c INNER JOIN fmchklsttaxalink cl ON c.clid = cl.clid ' . 'INNER JOIN taxstatus ts1 ON cl.tid = ts1.tid ' . 'INNER JOIN taxstatus ts2 ON ts1.tidaccepted = ts2.tidaccepted ' . 'INNER JOIN omoccurrences o ON c.locality = o.stateprovince ' . 'WHERE c.type = "rarespp" AND ts1.taxauthid = 1 AND ts2.taxauthid = 1 ' . 'AND (ts2.tid = ' . $tidToAdd . ') AND (o.occid = ' . $this->occid . ')';
                     //echo $sql; exit;
                     $rsSs2 = $this->conn->query($sql2);
                     if ($rsSs2->num_rows) {
                         $sStatus = 1;
                     }
                     $rsSs2->free();
                 }
             }
             //Load new determination into omoccurrences table
             $sqlNewDet = 'UPDATE omoccurrences ' . 'SET identifiedBy = "' . $this->cleanInStr($detArr['identifiedby']) . '", dateIdentified = "' . $this->cleanInStr($detArr['dateidentified']) . '",' . 'family = ' . ($detArr['family'] ? '"' . $this->cleanInStr($detArr['family']) . '"' : 'NULL') . ',' . 'sciname = "' . $sciname . '",genus = NULL, specificEpithet = NULL, taxonRank = NULL, infraspecificepithet = NULL,' . 'scientificNameAuthorship = ' . ($detArr['scientificnameauthorship'] ? '"' . $this->cleanInStr($detArr['scientificnameauthorship']) . '"' : 'NULL') . ',' . 'identificationQualifier = ' . ($detArr['identificationqualifier'] ? '"' . $this->cleanInStr($detArr['identificationqualifier']) . '"' : 'NULL') . ',' . 'identificationReferences = ' . ($detArr['identificationreferences'] ? '"' . $this->cleanInStr($detArr['identificationreferences']) . '"' : 'NULL') . ',' . 'identificationRemarks = ' . ($detArr['identificationremarks'] ? '"' . $this->cleanInStr($detArr['identificationremarks']) . '"' : 'NULL') . ', ' . 'tidinterpreted = ' . ($tidToAdd ? $tidToAdd : 'NULL') . ', localitysecurity = ' . $sStatus . ' WHERE (occid = ' . $this->occid . ')';
             //echo "<div>".$sqlNewDet."</div>";
             $this->conn->query($sqlNewDet);
             //Add identification confidence
             if (isset($detArr['confidenceranking'])) {
                 $idStatus = $this->editIdentificationRanking($detArr['confidenceranking'], '');
                 if ($idStatus) {
                     $status .= '; ' . $idStatus;
                 }
             }
             //Remap images
             $sql = 'UPDATE images SET tid = ' . ($tidToAdd ? $tidToAdd : 'NULL') . ' WHERE (occid = ' . $this->occid . ')';
             //echo $sql;
             if (!$this->conn->query($sql)) {
                 $status = 'ERROR: Annotation added but failed to remap images to new name';
                 $status .= ': ' . $this->conn->error;
             }
         }
         //FP code
         global $fpEnabled;
         if (isset($fpEnabled) && $fpEnabled && isset($detArr['fpsubmit']) && $detArr['fpsubmit']) {
             $status = "Determination added successfully and submitted to Filtered Push!";
             try {
                 // create an array that the annotation generator can understand from $detArr
                 $annotation = fpNewDetArr($detArr);
                 // generate rdf/xml
                 $generator = FPNetworkFactory::getAnnotationGenerator();
                 $rdf = $generator->generateRdfXml($annotation);
                 // inject annotation into fp
                 $network = FPNetworkFactory::getNetworkFacade();
                 $response = $network->injectIntoFP($rdf);
             } catch (Exception $e) {
                 error_log($e->getFile() . '(' . $e->getLine() . '): ' . $e->getMessage());
                 $status = "Determination added successfully but there was an error during submission to Filtered Push!";
             }
         }
     } else {
         $status = 'ERROR - failed to add determination: ' . $this->conn->error;
     }
     return $status;
 }