Skip to content

Commit 5fc0e78

Browse files
ndg63276Mark Williams
andauthored
LIMS-1590: Dont allow name editing for lab contacts when login is set (#887)
Co-authored-by: Mark Williams <mark.williams@diamond.ac.uk>
1 parent 4a10c81 commit 5fc0e78

File tree

3 files changed

+38
-33
lines changed

3 files changed

+38
-33
lines changed

api/src/Page/Contact.php

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ class Contact extends Page
3939
# Get List of Lab Contacts
4040
function _get_contacts() {
4141
if (!$this->has_arg('prop')) $this->_error('No proposal specified');
42-
42+
4343
$args = array($this->proposalid);
4444
$where = 'WHERE c.proposalid = :1';
45-
45+
4646
if ($this->has_arg('cid')) {
4747
$where .= ' AND c.labcontactid=:'.(sizeof($args)+1);
4848
array_push($args, $this->arg('cid'));
@@ -63,37 +63,36 @@ function _get_contacts() {
6363
$pp = $this->has_arg('per_page') ? $this->arg('per_page') : 15;
6464
$start = 0;
6565
$end = $pp;
66-
66+
6767
if ($this->has_arg('page')) {
6868
$pg = $this->arg('page') - 1;
6969
$start = $pg*$pp;
7070
$end = $pg*$pp+$pp;
7171
}
72-
72+
7373
$st = sizeof($args)+1;
7474
$en = $st + 1;
7575
array_push($args, $start);
7676
array_push($args, $end);
77-
77+
7878
$order = 'c.labcontactid DESC';
79-
80-
$rows = $this->db->paginate("SELECT c.labcontactid, c.cardname, pe.givenname, pe.familyname, pe.phonenumber, l.name as labname, l.address, l.city, l.country, c.courieraccount, c.billingreference, c.defaultcourriercompany, c.dewaravgcustomsvalue, c.dewaravgtransportvalue, pe.emailaddress, l.postcode, l.country
79+
80+
$rows = $this->db->paginate("SELECT c.labcontactid, c.cardname, pe.givenname, pe.familyname, pe.phonenumber, IF(pe.login IS NOT NULL, pe.login, IF(pe.externalid IS NOT NULL, 'External', NULL)) AS login, l.name as labname, l.address, l.city, l.country, c.courieraccount, c.billingreference, c.defaultcourriercompany, c.dewaravgcustomsvalue, c.dewaravgtransportvalue, pe.emailaddress, l.postcode, l.country
8181
FROM labcontact c
8282
INNER JOIN person pe ON c.personid = pe.personid
8383
INNER JOIN laboratory l ON l.laboratoryid = pe.laboratoryid
8484
INNER JOIN proposal p ON p.proposalid = c.proposalid
8585
$where ORDER BY $order", $args);
86-
86+
8787
if ($this->has_arg('cid')) {
8888
if (sizeof($rows))$this->_output($rows[0]);
8989
else $this->_error('No such contact');
90-
91-
} else $this->_output(array('total' => $tot,
92-
'data' => $rows,
93-
));
90+
} else {
91+
$this->_output(array('total' => $tot, 'data' => $rows));
92+
}
9493
}
95-
96-
94+
95+
9796
# ------------------------------------------------------------------------
9897
# Update field for lab contact
9998
function _update_contact() {

client/src/js/modules/contact/views/viewcontact.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ define(['marionette',
2727
doOnRender: function() {
2828
var edit = new Editable({ model: this.model, el: this.$el })
2929
edit.create('CARDNAME', 'text');
30-
edit.create('FAMILYNAME', 'text');
31-
edit.create('GIVENNAME', 'text');
30+
if (!this.model.get('LOGIN')) {
31+
edit.create('FAMILYNAME', 'text');
32+
edit.create('GIVENNAME', 'text');
33+
}
3234
edit.create('PHONENUMBER', 'text');
3335
edit.create('EMAILADDRESS', 'text');
3436
edit.create('LABNAME', 'text');
@@ -46,4 +48,4 @@ define(['marionette',
4648

4749
})
4850

49-
})
51+
})

client/src/js/templates/contact/contactview.html

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,52 @@ <h1>View Home Lab Contact</h1>
44

55
<div class="form">
66
<ul>
7-
7+
88
<li>
99
<span class="label">Card Name</span>
1010
<span class="CARDNAME"><%-CARDNAME%></span>
1111
</li>
12-
12+
1313

1414
<li class="head">Contact Details</li>
1515

16+
<li>
17+
<span class="label">Login</span>
18+
<span class="LOGIN"><%-LOGIN%></span>
19+
</li>
20+
1621
<li>
1722
<span class="label">Family Name</span>
1823
<span class="FAMILYNAME"><%-FAMILYNAME%></span>
1924
</li>
20-
21-
25+
2226
<li>
2327
<span class="label">First Name</span>
2428
<span class="GIVENNAME"><%-GIVENNAME%></span>
2529
</li>
26-
30+
2731
<li>
2832
<span class="label">Phone Number</span>
2933
<span class="PHONENUMBER"><%-PHONENUMBER%></span>
3034
</li>
31-
35+
3236
<li>
3337
<span class="label">Email Address</span>
3438
<span class="EMAILADDRESS"><%-EMAILADDRESS%></span>
3539
</li>
36-
40+
3741
<li class="head">University / Institution / Company Details</li>
38-
42+
3943
<li>
4044
<span class="label">Name</span>
4145
<span class="LABNAME"><%-LABNAME%></span>
4246
</li>
43-
47+
4448
<li class="clearfix">
4549
<span class="label">Street Address <br />(Max 3 lines, excluding post code, city)</span>
4650
<div class="ADDRESS text editable tw-block"><%-ADDRESS%></div>
4751
</li>
48-
52+
4953
<li>
5054
<span class="label">City</span>
5155
<span class="CITY"><%-CITY%></span>
@@ -62,31 +66,31 @@ <h1>View Home Lab Contact</h1>
6266
</li>
6367

6468
<li class="head">Dewar Return Details</li>
65-
69+
6670
<li>
6771
<span class="label">Courier Company</span>
6872
<span class="DEFAULTCOURRIERCOMPANY"><%-DEFAULTCOURRIERCOMPANY%></span>
6973
</li>
70-
74+
7175
<li>
7276
<span class="label">Courier Account No.</span>
7377
<span class="COURIERACCOUNT"><%-COURIERACCOUNT%></span>
7478
</li>
75-
79+
7680
<li>
7781
<span class="label">Billing Reference</span>
7882
<span class="BILLINGREFERENCE"><%-BILLINGREFERENCE%></span>
7983
</li>
80-
84+
8185
<li>
8286
<span class="label">Dewar Customs Value</span>
8387
<span class="DEWARAVGCUSTOMSVALUE"><%-DEWARAVGCUSTOMSVALUE%></span>
8488
</li>
85-
89+
8690
<li>
8791
<span class="label">Dewar Transport Value</span>
8892
<span class="DEWARAVGTRANSPORTVALUE"><%-DEWARAVGTRANSPORTVALUE%></span>
8993
</li>
90-
94+
9195
</ul>
9296
</div>

0 commit comments

Comments
 (0)