diff --git a/api/src/Model/Services/AssignData.php b/api/src/Model/Services/AssignData.php index b52c9a3d7..116e98c18 100644 --- a/api/src/Model/Services/AssignData.php +++ b/api/src/Model/Services/AssignData.php @@ -2,6 +2,8 @@ namespace SynchWeb\Model\Services; +use SynchWeb\Utils; + class AssignData { private $db; @@ -100,9 +102,10 @@ function updateDewarHistory($did, $status, $beamline = null, $additionalStatusDe $st = $status; if ($additionalStatusDetail) $st .= ' (' . $additionalStatusDetail . ')'; + $loc = Utils::getValueOrDefault($beamline, ''); $this->db->pq("INSERT INTO dewartransporthistory (dewarid, dewarstatus, storagelocation, arrivaldate) - VALUES (:1, :2, :3, CURRENT_TIMESTAMP)", array($did, $st, $beamline)); + VALUES (:1, :2, :3, CURRENT_TIMESTAMP)", array($did, $st, $loc)); $this->updateDewar($did, $status); } diff --git a/api/src/Page/Shipment.php b/api/src/Page/Shipment.php index 85573b6f4..1b26401d9 100644 --- a/api/src/Page/Shipment.php +++ b/api/src/Page/Shipment.php @@ -864,6 +864,8 @@ function _transfer_dewar() global $transfer_email; if (!$this->has_arg('DEWARID')) $this->_error('No dewar specified'); + if (!$this->has_arg('LOCATION')) + $this->_error('No location specified'); $dew = $this->db->pq("SELECT d.dewarid,s.shippingid FROM dewar d @@ -1049,7 +1051,7 @@ function _dispatch_dewar() $dewar_location = $last_history['STORAGELOCATION']; } else { // Use the current location of the dewar instead if no history - $dewar_location = $dew['STORAGELOCATION']; + $dewar_location = Utils::getValueOrDefault($dew['STORAGELOCATION'], ''); } } // Check if the last history storage location is an EBIC prefix or not @@ -3111,10 +3113,11 @@ function _cancel_pickup() foreach ($dewars as $i => $d) { $this->db->pq("UPDATE dewar SET dewarstatus='pickup cancelled' WHERE dewarid=:1", array($d['DEWARID'])); + $loc = Utils::getValueOrDefault($d['STORAGELOCATION'], ''); $this->db->pq( "INSERT INTO dewartransporthistory (dewarid,dewarstatus,storagelocation,arrivaldate) VALUES (:1,'pickup cancelled',:2,CURRENT_TIMESTAMP)", - array($d['DEWARID'], $d['STORAGELOCATION']) + array($d['DEWARID'], $loc) ); } } catch (\Exception $e) {