diff --git a/src/data.js b/src/data.js index e1324e8e458f176ce6c793d3c40a779a220bfa23..4f3f92e10b6cdb086295bc9cf46133ce90dc9d90 100644 --- a/src/data.js +++ b/src/data.js @@ -14,6 +14,12 @@ const config = { } }; +$.fn.dataTable.ext.order['checkbox'] = function (settings, col) { + return this.api().column(col, {order: 'index'}).nodes().map(function (td, i) { + return $('input', td).attr('checked') ? '1' : '0'; + }); +}; + sql.connect(config, function(err) { if (err) console.log(err); @@ -119,13 +125,15 @@ function displayDataTable(data){ aoColumnDefs: [{ targets: 18, mRender: function (data, type, full, meta) { - return '<input type="checkbox" class="minimal" onchange="checkReferral(this)" id='+ full.patient_id +''+ (data ? ' checked' : '') +'/>'; - } + return '<input type="checkbox" class="minimal" onchange="checkReferral(this)" id="check2"'+ (data ? ' checked' : '') +'/>'; + }, + orderDataType: 'checkbox' },{ targets: 17, mRender: function(data, type, full, meta) { - return '<input type="checkbox" class="minimal" onclick="return false" id='+ full.patient_id +''+ (data ? ' checked' : '') +'/>'; - } + return '<input type="checkbox" class="minimal" onclick="return false" id="check1"'+ (data ? ' checked' : '') +'/>'; + }, + orderDataType: 'checkbox' },{ responsivePriority: 1, targets: 18 // Adds priority of 1 to referral column -> Will be last displayed due to responsiveness },{ diff --git a/src/insert_user.js b/src/insert_user.js deleted file mode 100644 index 9648fc2393ed30c5bfc13310c1e1655f0ddc8cfa..0000000000000000000000000000000000000000 --- a/src/insert_user.js +++ /dev/null @@ -1,27 +0,0 @@ -const sql = require("mssql"); -const bcrypt = require('bcrypt'); - -const plainTextPassword = '321'; - -const saltRounds = 10; -const salt = bcrypt.genSaltSync(saltRounds); - -const hashedPassword = bcrypt.hashSync(plainTextPassword, salt); -const username = 'user2@nhs.com'; - -const config = { - server: 'uwe-sdgp.database.windows.net', - database: 'feeding_inc', - user: 'fi_developer', - password: 'Eggyweggy156', - port: 1433, - options: { - encrypt: true - } -}; - -sql.connect(config).then(() => { - return sql.query(`INSERT INTO fid_users (user_name, user_password, user_permissions) VALUES ('${username}', '${hashedPassword}', '1')`); -}).catch(err => { - console.error(err); -}) \ No newline at end of file