Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: IMCA Shipments #136

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
562393d
allow container assigment by staff from prop + beamline as well as visit
stufisher Aug 22, 2020
7489a29
allow filtering containers by shipment, and by registry
stufisher Aug 22, 2020
b644444
add diffractionplan columns to sample, get samples by shipment
stufisher Aug 22, 2020
b4f721b
add new diffraction plan columns and container view toggle
stufisher Aug 22, 2020
981736f
add csv importer
stufisher Aug 22, 2020
900f297
add barcode scan container assign page
stufisher Aug 22, 2020
55fad21
add new config.json option
stufisher Aug 23, 2020
fb625f0
count distinct rather than groupby
stufisher Aug 23, 2020
1419e69
dont fetch if val empty, debounce right function
stufisher Aug 29, 2020
c333c73
update breadcrumbs
stufisher Aug 31, 2020
b4bf602
punctuation
stufisher Aug 31, 2020
10507dc
use concat_ws incase some values are null
stufisher Sep 1, 2020
c6ec642
Merge branch 'master' into feature/imca_shipments
stufisher Sep 6, 2020
fcccc64
add collectionmode and priority
stufisher Sep 14, 2020
d154388
add other csv mime types
stufisher Sep 16, 2020
1c6f369
mime type is not sent on windows :|
stufisher Sep 17, 2020
e64e24a
increase page size for sample
stufisher Sep 22, 2020
432d7aa
validate barcode on scan assign page
stufisher Dec 23, 2020
e18a002
Merge branch 'master' into feature/imca_shipments
stufisher Apr 5, 2021
a8b99ee
wip: mailin enhancements
stufisher Apr 10, 2021
b61b1d9
Merge branch 'master' into feature/imca_shipments
stufisher Apr 20, 2021
f98928b
make possible to disable diff plan columns for containers
stufisher Apr 26, 2021
3feb552
rename csv button
stufisher Apr 26, 2021
b6cb466
add mark shipment returned button and api, add mark queue completed a…
stufisher Apr 30, 2021
813ce91
document disabling exp_plan fields
stufisher Apr 30, 2021
886aa2b
add initial queued containers view
stufisher Apr 30, 2021
092c3d7
update container review page, link from container
stufisher Apr 30, 2021
04b1f4f
separate spacegroups
stufisher Apr 30, 2021
c8a4f8e
add additional filters to queue view
stufisher May 22, 2021
b244d6d
add queue button to admin menu
stufisher May 22, 2021
19e51ba
allow customising auto collect label
stufisher May 22, 2021
6d4c5a1
remove debug
stufisher May 22, 2021
0bde4e5
add link back to container
stufisher May 22, 2021
dd5496d
allow staff to queue entire shipment
stufisher May 22, 2021
045682c
remove debug
stufisher May 22, 2021
707f0d5
stop shipment return if there are still outstanding queued containers
stufisher May 24, 2021
96c1c09
allow anyone to use queue shipment button if enabled
stufisher May 29, 2021
6d8818d
add samples to containerqueue for pucks and allow editing their statu…
stufisher May 29, 2021
cc1e13d
correct where option comes from...
stufisher May 31, 2021
8886b9f
increase number of containers when queuing a shipment
stufisher Jun 5, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ This file should be copied to create a client/src/js/config.json file and edited
| site_name | Site Name to display in footer |
| site_link | URL to site home page |
| site_image | PNG image of site logo to display in header|
| csv_profile | The csv profile for importing shipments, currently only imca, see src/js/csv/imca.js |
| enable_exp_plan | Whether to enable editing of experimental plan fields when creating samples |
| auto_collect_label | Customise the auto collect label from the default 'Automated' |
| queue_shipment | Allow entire shipment to be queued for automated / mail-in collection |

### Build front end
See package.json for the full list of commands that can be run.
Expand Down
87 changes: 70 additions & 17 deletions api/src/Page/Assign.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class Assign extends Page
{

public static $arg_list = array('visit' => '\w+\d+-\d+', 'cid' => '\d+', 'did' => '\d+', 'pos' => '\d+', 'bl' => '[\w-]+');
public static $arg_list = array('visit' => '\w+\d+-\d+', 'cid' => '\d+', 'did' => '\d+', 'pos' => '\d+', 'bl' => '[\w-]+', 'nodup' => '\d');

public static $dispatch = array(array('/visits(/:visit)', 'get', '_blsr_visits'),
array('/assign', 'get', '_assign'),
Expand All @@ -23,54 +23,107 @@ class Assign extends Page
# ------------------------------------------------------------------------
# Assign a container
function _assign() {
if (!$this->has_arg('visit')) $this->_error('No visit specified');
if (!$this->has_arg('visit') && !$this->has_arg('prop')) $this->_error('No visit or prop specified');
if (!$this->has_arg('cid')) $this->_error('No container id specified');
if (!$this->has_arg('pos')) $this->_error('No position specified');


$where = 'c.containerid=:1';
$args = array($this->arg('cid'));

if ($this->has_arg('visit')) {
$where .= " AND CONCAT(p.proposalcode, p.proposalnumber, '-', bl.visit_number) LIKE :".(sizeof($args)+1);
array_push($args, $this->arg('visit'));
} else {
$where .= " AND CONCAT(p.proposalcode, p.proposalnumber) LIKE :".(sizeof($args)+1);
array_push($args, $this->arg('prop'));
}

$cs = $this->db->pq("SELECT d.dewarid,bl.beamlinename,c.containerid,c.code FROM container c
INNER JOIN dewar d ON d.dewarid = c.dewarid
INNER JOIN shipping s ON s.shippingid = d.shippingid
INNER JOIN blsession bl ON bl.proposalid = s.proposalid
INNER JOIN proposal p ON s.proposalid = p.proposalid
WHERE CONCAT(CONCAT(CONCAT(p.proposalcode, p.proposalnumber), '-'), bl.visit_number) LIKE :1 AND c.containerid=:2", array($this->arg('visit'), $this->arg('cid')));
WHERE $where", $args);

if (sizeof($cs) > 0) {
$c = $cs[0];

$bl = $c['BEAMLINENAME'];
if ($this->staff) {
if ($this->has_arg('bl')) {
$bl = $this->arg('bl');
}
}

if ($this->has_arg(('nodup'))) {
$existing = $this->db->pq("SELECT c.containerid, c.name, CONCAT(p.proposalcode, p.proposalnumber) as prop
FROM container c
INNER JOIN dewar d ON d.dewarid = c.dewarid
INNER JOIN shipping s ON s.shippingid = d.shippingid
INNER JOIN proposal p ON s.proposalid = s.proposalid
WHERE beamlinelocation=1 AND samplechangerlocation:2", array($bl, $this->arg('pos')));

if (sizeof($existing)) {
$ex = $existing[0];
return $this->_error('A container is already a assigned that position: '+$ex[0]['NAME'] + '('+$ex['PROP']+')');
}
}


$this->db->pq("UPDATE dewar SET dewarstatus='processing' WHERE dewarid=:1", array($c['DEWARID']));

$this->db->pq("UPDATE container SET beamlinelocation=:1,samplechangerlocation=:2,containerstatus='processing' WHERE containerid=:3", array($c['BEAMLINENAME'], $this->arg('pos'), $c['CONTAINERID']));
$this->db->pq("INSERT INTO containerhistory (containerid,status,location,beamlinename) VALUES (:1,:2,:3,:4)", array($c['CONTAINERID'], 'processing', $this->arg('pos'), $c['BEAMLINENAME']));
$this->_update_history($c['DEWARID'], 'processing', $c['BEAMLINENAME'], $c['CODE'].' => '.$this->arg('pos'));
$this->db->pq("UPDATE container SET beamlinelocation=:1,samplechangerlocation=:2,containerstatus='processing' WHERE containerid=:3", array($bl, $this->arg('pos'), $c['CONTAINERID']));
$this->db->pq("INSERT INTO containerhistory (containerid,status,location,beamlinename) VALUES (:1,:2,:3,:4)", array($c['CONTAINERID'], 'processing', $this->arg('pos'), $bl));
$this->_update_history($c['DEWARID'], 'processing', $bl, $c['CODE'].' => '.$this->arg('pos'));

$this->_output(1);
} else {
$this->_error('No such container');
}

$this->_output(0);
}

# ------------------------------------------------------------------------
# Unassign a container
function _unassign() {
if (!$this->has_arg('visit')) $this->_error('No visit specified');
if (!$this->has_arg('visit') && !$this->has_arg('prop')) $this->_error('No visit or prop specified');
if (!$this->has_arg('cid')) $this->_error('No container id specified');


$where = 'c.containerid=:1';
$args = array($this->arg('cid'));

if ($this->has_arg('visit')) {
$where .= " AND CONCAT(p.proposalcode, p.proposalnumber, '-', bl.visit_number) LIKE :".(sizeof($args)+1);
array_push($args, $this->arg('visit'));
} else {
$where .= " AND CONCAT(p.proposalcode, p.proposalnumber) LIKE :".(sizeof($args)+1);
array_push($args, $this->arg('prop'));
}

$cs = $this->db->pq("SELECT d.dewarid,bl.beamlinename,c.containerid FROM container c
INNER JOIN dewar d ON d.dewarid = c.dewarid
INNER JOIN shipping s ON s.shippingid = d.shippingid
INNER JOIN blsession bl ON bl.proposalid = s.proposalid
INNER JOIN proposal p ON s.proposalid = p.proposalid
WHERE CONCAT(CONCAT(CONCAT(p.proposalcode, p.proposalnumber), '-'), bl.visit_number) LIKE :1 AND c.containerid=:2", array($this->arg('visit'), $this->arg('cid')));
WHERE $where", $args);

if (sizeof($cs) > 0) {
$c = $cs[0];

$bl = $c['BEAMLINENAME'];
if ($this->staff) {
if ($this->has_arg('bl')) {
$bl = $this->arg('bl');
}
}

$this->db->pq("UPDATE container SET samplechangerlocation='',beamlinelocation='',containerstatus='at facility' WHERE containerid=:1",array($c['CONTAINERID']));
$this->db->pq("INSERT INTO containerhistory (containerid,status,beamlinename) VALUES (:1,:2,:3)", array($c['CONTAINERID'], 'at facility', $c['BEAMLINENAME']));
$this->db->pq("INSERT INTO containerhistory (containerid,status,beamlinename) VALUES (:1,:2,:3)", array($c['CONTAINERID'], 'at facility', $bl));
//$this->_update_history($c['DEWARID'], 'unprocessing');

$this->_output(1);
} else {
$this->_error('No such container');
}
$this->_output(0);
}


Expand Down Expand Up @@ -102,10 +155,10 @@ function _deactivate() {
$this->db->pq("UPDATE container SET containerstatus='at facility', samplechangerlocation='', beamlinelocation='' WHERE containerid=:1", array($c['ID']));
$this->db->pq("INSERT INTO containerhistory (containerid,status) VALUES (:1,:2)", array($c['ID'], 'at facility'));
}
$this->_output(1);

$this->_output(1);
} else {
$this->_error('No such dewar');
}
$this->_output(0);
}


Expand Down
Loading