Skip to content

Commit

Permalink
LIMS-59: Check for nulls before doing inserts
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Williams committed Sep 4, 2023
1 parent f53b4ff commit 9bd23f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion api/src/Model/Services/AssignData.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace SynchWeb\Model\Services;

use SynchWeb\Utils;

class AssignData
{
private $db;
Expand Down Expand Up @@ -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);
}
Expand Down
7 changes: 5 additions & 2 deletions api/src/Page/Shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 9bd23f5

Please sign in to comment.