@jd-data-limited/easy-fm 1.2.2-alpha6 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/prop1.toml +58 -0
- package/prop2.toml +58 -0
- package/src/index.ts +36 -4
- package/test.js +11 -8
- package/test2.js +413 -0
package/dist/index.js
CHANGED
package/package.json
CHANGED
package/prop1.toml
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#Minecraft server properties
|
|
2
|
+
#Wed May 03 20:32:16 AEST 2023
|
|
3
|
+
allow-flight=false
|
|
4
|
+
allow-nether=true
|
|
5
|
+
broadcast-console-to-ops=true
|
|
6
|
+
broadcast-rcon-to-ops=true
|
|
7
|
+
difficulty=easy
|
|
8
|
+
enable-command-block=false
|
|
9
|
+
enable-jmx-monitoring=false
|
|
10
|
+
enable-query=false
|
|
11
|
+
enable-rcon=false
|
|
12
|
+
enable-status=true
|
|
13
|
+
enforce-secure-profile=true
|
|
14
|
+
enforce-whitelist=false
|
|
15
|
+
entity-broadcast-range-percentage=100
|
|
16
|
+
force-gamemode=false
|
|
17
|
+
function-permission-level=2
|
|
18
|
+
gamemode=survival
|
|
19
|
+
generate-structures=true
|
|
20
|
+
generator-settings={}
|
|
21
|
+
hardcore=false
|
|
22
|
+
hide-online-players=false
|
|
23
|
+
level-name=world
|
|
24
|
+
level-seed=
|
|
25
|
+
level-type=minecraft\:normal
|
|
26
|
+
max-chained-neighbor-updates=1000000
|
|
27
|
+
max-players=20
|
|
28
|
+
max-threads=6
|
|
29
|
+
max-tick-time=-1
|
|
30
|
+
max-world-size=29999984
|
|
31
|
+
motd=A Minecraft Server
|
|
32
|
+
network-compression-threshold=256
|
|
33
|
+
online-mode=false
|
|
34
|
+
op-permission-level=4
|
|
35
|
+
player-idle-timeout=0
|
|
36
|
+
prevent-proxy-connections=false
|
|
37
|
+
previews-chat=false
|
|
38
|
+
pvp=true
|
|
39
|
+
query.port=25565
|
|
40
|
+
rate-limit=0
|
|
41
|
+
rcon.password=
|
|
42
|
+
rcon.port=25575
|
|
43
|
+
require-resource-pack=false
|
|
44
|
+
resource-pack=
|
|
45
|
+
resource-pack-prompt=
|
|
46
|
+
resource-pack-sha1=
|
|
47
|
+
server-ip=119.252.189.11
|
|
48
|
+
server-port=27002
|
|
49
|
+
simulation-distance=10
|
|
50
|
+
spawn-animals=true
|
|
51
|
+
spawn-monsters=true
|
|
52
|
+
spawn-npcs=true
|
|
53
|
+
spawn-protection=16
|
|
54
|
+
sync-chunk-writes=false
|
|
55
|
+
text-filtering-config=
|
|
56
|
+
use-native-transport=true
|
|
57
|
+
view-distance=10
|
|
58
|
+
white-list=false
|
package/prop2.toml
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#Minecraft server properties
|
|
2
|
+
#Wed May 03 12:46:20 CEST 2023
|
|
3
|
+
allow-flight=false
|
|
4
|
+
allow-nether=true
|
|
5
|
+
broadcast-console-to-ops=true
|
|
6
|
+
broadcast-rcon-to-ops=true
|
|
7
|
+
difficulty=easy
|
|
8
|
+
enable-command-block=true
|
|
9
|
+
enable-jmx-monitoring=false
|
|
10
|
+
enable-query=true
|
|
11
|
+
enable-rcon=false
|
|
12
|
+
enable-status=true
|
|
13
|
+
enforce-secure-profile=true
|
|
14
|
+
enforce-whitelist=false
|
|
15
|
+
entity-broadcast-range-percentage=100
|
|
16
|
+
force-gamemode=false
|
|
17
|
+
function-permission-level=2
|
|
18
|
+
gamemode=survival
|
|
19
|
+
generate-structures=true
|
|
20
|
+
generator-settings={}
|
|
21
|
+
hardcore=false
|
|
22
|
+
hide-online-players=false
|
|
23
|
+
level-name=world
|
|
24
|
+
level-seed=
|
|
25
|
+
level-type=minecraft\:normal
|
|
26
|
+
max-chained-neighbor-updates=1000000
|
|
27
|
+
max-players=100
|
|
28
|
+
max-tick-time=60000
|
|
29
|
+
max-world-size=29999984
|
|
30
|
+
motd=4vNBdJ
|
|
31
|
+
network-compression-threshold=256
|
|
32
|
+
online-mode=true
|
|
33
|
+
op-permission-level=4
|
|
34
|
+
player-idle-timeout=0
|
|
35
|
+
prevent-proxy-connections=false
|
|
36
|
+
previews-chat=false
|
|
37
|
+
pvp=true
|
|
38
|
+
query.port=41305
|
|
39
|
+
rate-limit=0
|
|
40
|
+
rcon.password=
|
|
41
|
+
rcon.port=25575
|
|
42
|
+
require-resource-pack=false
|
|
43
|
+
resource-pack=
|
|
44
|
+
resource-pack-prompt=
|
|
45
|
+
resource-pack-sha1=
|
|
46
|
+
server-ip=
|
|
47
|
+
server-port=41305
|
|
48
|
+
simulation-distance=10
|
|
49
|
+
snooper-enabled=false
|
|
50
|
+
spawn-animals=true
|
|
51
|
+
spawn-monsters=true
|
|
52
|
+
spawn-npcs=true
|
|
53
|
+
spawn-protection=16
|
|
54
|
+
sync-chunk-writes=true
|
|
55
|
+
text-filtering-config=
|
|
56
|
+
use-native-transport=true
|
|
57
|
+
view-distance=10
|
|
58
|
+
white-list=false
|
package/src/index.ts
CHANGED
|
@@ -63,6 +63,23 @@ interface limitPortalsInterface {
|
|
|
63
63
|
limit: number
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
interface extraBodyOptions {
|
|
67
|
+
scripts?: {
|
|
68
|
+
prerequest?: {
|
|
69
|
+
name: string,
|
|
70
|
+
param?: string
|
|
71
|
+
},
|
|
72
|
+
presort?: {
|
|
73
|
+
name: string,
|
|
74
|
+
param?: string
|
|
75
|
+
},
|
|
76
|
+
after?: {
|
|
77
|
+
name: string,
|
|
78
|
+
param?: string
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
66
83
|
// @ts-ignore
|
|
67
84
|
const errs = [
|
|
68
85
|
{
|
|
@@ -1305,7 +1322,8 @@ export class Database extends EventEmitter {
|
|
|
1305
1322
|
if (res.messages[0].code === "0") {
|
|
1306
1323
|
resolve()
|
|
1307
1324
|
} else {
|
|
1308
|
-
reject(
|
|
1325
|
+
reject(
|
|
1326
|
+
(res.messages[0].code, res.status, res))
|
|
1309
1327
|
}
|
|
1310
1328
|
})
|
|
1311
1329
|
.catch(e => {
|
|
@@ -1934,7 +1952,7 @@ class recordGetRange extends recordGetOperation {
|
|
|
1934
1952
|
super(layout)
|
|
1935
1953
|
}
|
|
1936
1954
|
|
|
1937
|
-
private generateQueryParams() {
|
|
1955
|
+
private generateQueryParams(extraBody: extraBodyOptions = {}) {
|
|
1938
1956
|
let params = []
|
|
1939
1957
|
if (this.limit !== 100) params.push("_limit=" + this.limit)
|
|
1940
1958
|
if (this.offset !== 0) params.push("_offset=" + this.offset)
|
|
@@ -1946,16 +1964,30 @@ class recordGetRange extends recordGetOperation {
|
|
|
1946
1964
|
if (item.limit !== 100) params.push("_limit." + item.portal.name.replace(/[^0-9A-z]/g, "") + "=" + item.limit)
|
|
1947
1965
|
}
|
|
1948
1966
|
}
|
|
1967
|
+
if (extraBody.scripts) {
|
|
1968
|
+
if (extraBody.scripts.prerequest) {
|
|
1969
|
+
params.push("script.prerequest=" + extraBody.scripts.prerequest.name)
|
|
1970
|
+
if (extraBody.scripts.prerequest.param) params.push("script.prerequest.param=" + extraBody.scripts.prerequest.param)
|
|
1971
|
+
}
|
|
1972
|
+
if (extraBody.scripts.presort) {
|
|
1973
|
+
params.push("script.presort=" + extraBody.scripts.presort.name)
|
|
1974
|
+
if (extraBody.scripts.presort.param) params.push("script.presort.param=" + extraBody.scripts.presort.param)
|
|
1975
|
+
}
|
|
1976
|
+
if (extraBody.scripts.after) {
|
|
1977
|
+
params.push("script=" + extraBody.scripts.after.name)
|
|
1978
|
+
if (extraBody.scripts.after.param) params.push("script.param=" + extraBody.scripts.after.param)
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1949
1981
|
|
|
1950
1982
|
if (params.length === 0) return ""
|
|
1951
1983
|
return "?" + params.join("&")
|
|
1952
1984
|
}
|
|
1953
1985
|
|
|
1954
|
-
run(): Promise<RecordBase[]> {
|
|
1986
|
+
run(extraBody: extraBodyOptions = {}): Promise<RecordBase[]> {
|
|
1955
1987
|
return new Promise((resolve, reject) => {
|
|
1956
1988
|
// console.log(this.#toObject())
|
|
1957
1989
|
this.layout.getLayoutMeta().then(() => {
|
|
1958
|
-
return this.layout.database.apiRequest(`${this.layout.endpoint}/records${this.generateQueryParams()}`, {
|
|
1990
|
+
return this.layout.database.apiRequest(`${this.layout.endpoint}/records${this.generateQueryParams(extraBody)}`, {
|
|
1959
1991
|
method: "GET"
|
|
1960
1992
|
})
|
|
1961
1993
|
})
|
package/test.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Copyright (c) 2023. See LICENSE file for more information
|
|
3
3
|
*/
|
|
4
|
+
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
|
|
4
5
|
|
|
5
|
-
import FileMakerHost from "./
|
|
6
|
+
import FileMakerHost from "./dist/index.js";
|
|
6
7
|
|
|
7
8
|
let host = new FileMakerHost("https://lab.farmmedix.com", 0, false)
|
|
8
9
|
let database = host.database({
|
|
9
10
|
database: "Snapshot_2",
|
|
10
11
|
credentials: {
|
|
11
12
|
method: "filemaker",
|
|
12
|
-
username: "
|
|
13
|
-
password: "
|
|
13
|
+
username: "Developer",
|
|
14
|
+
password: "1df e53 0tx"
|
|
14
15
|
},
|
|
15
16
|
externalSources: []
|
|
16
17
|
})
|
|
@@ -19,11 +20,13 @@ async function setup() {
|
|
|
19
20
|
// console.log(await host.getMetadata())
|
|
20
21
|
// console.log(host.timezoneOffset)
|
|
21
22
|
await database.login()
|
|
22
|
-
let layout = database.getLayout("
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
let layout = database.getLayout("Archive")
|
|
24
|
+
layout.records.find()
|
|
25
|
+
.addRequests({"__PrimaryKey": "=BAB9264A-38A5-4C6F-8CEE-3788931EC269"})
|
|
26
|
+
.run()
|
|
27
|
+
.then(records => {
|
|
28
|
+
console.log(records[0].getField("Container").value)
|
|
29
|
+
})
|
|
27
30
|
// await layout.getLayoutMeta()
|
|
28
31
|
// console.log(layout.metadata)
|
|
29
32
|
|
package/test2.js
ADDED
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
const date = new Date();
|
|
2
|
+
let [month, day, year] = [
|
|
3
|
+
date.getMonth() + 1,
|
|
4
|
+
date.getDate(),
|
|
5
|
+
date.getFullYear(),
|
|
6
|
+
];
|
|
7
|
+
|
|
8
|
+
if (day < 10) day = '0' + day;
|
|
9
|
+
if (month < 10) month = '0' + month;
|
|
10
|
+
|
|
11
|
+
console.log(window.location.href);
|
|
12
|
+
var currloc = window.location.href.split('&fname=');
|
|
13
|
+
var location_split = currloc[0].split('&location=');
|
|
14
|
+
console.log(decodeURIComponent(location_split[1]).replace('&', '& '));
|
|
15
|
+
|
|
16
|
+
var loc = location_split[0].replace('https://www.farmmedix.com/milk-sampling-consent/?location=', '');
|
|
17
|
+
console.log(decodeURIComponent(loc));
|
|
18
|
+
|
|
19
|
+
$('#date-today').html(day + '/' + month + '/' + year);
|
|
20
|
+
$('#owner_name').html(decodeURIComponent(urlParam("fname")) + ' ' + decodeURI(urlParam("lname")));
|
|
21
|
+
$('#farm-business-name').html('');
|
|
22
|
+
$('#owner-phone').html('');
|
|
23
|
+
$('#owner-email').html(decodeURIComponent(urlParam("email")))
|
|
24
|
+
|
|
25
|
+
$("input[name=hidden_2]").val(day + '/' + month + '/' + year);
|
|
26
|
+
$("input[name=hidden]").val(decodeURIComponent(urlParam("fname")));
|
|
27
|
+
$("input[name=hidden_11]").val(decodeURIComponent(urlParam("lname")));
|
|
28
|
+
$("input[name=hidden_1]").val(decodeURIComponent(urlParam("business_name")));
|
|
29
|
+
$("input[name=hidden_4]").val(decodeURIComponent(urlParam("email")));
|
|
30
|
+
$("input[name=hidden_3]").val(decodeURIComponent(urlParam("phone")));
|
|
31
|
+
$("input[name=hidden_10]").val(decodeURIComponent(loc));
|
|
32
|
+
$("input[name=hidden_12]").val(decodeURIComponent(urlParam("role")));
|
|
33
|
+
$("input[name=show_staph]").val(decodeURIComponent(urlParam("show_staph")));
|
|
34
|
+
|
|
35
|
+
$("input[name=show_staph]").trigger("change");
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
var html = '<strong>Farm/Business Name</strong>: ' + decodeURI(urlParam("business_name"));
|
|
39
|
+
html += '<br><strong>Location</strong>: ' + decodeURIComponent(loc);
|
|
40
|
+
html += '<br><strong>First Name</strong>: ' + decodeURI(urlParam("fname"));
|
|
41
|
+
html += '<br><strong>Last Name</strong>: ' + decodeURI(urlParam("lname"));
|
|
42
|
+
html += '<br><strong>Email</strong>: ' + decodeURI(urlParam("email"));
|
|
43
|
+
html += '<br><strong>Phone</strong>: ' + decodeURI(urlParam("phone"));
|
|
44
|
+
html += '<br><strong>Role</strong>: ' + decodeURI(urlParam("role"));
|
|
45
|
+
|
|
46
|
+
var allsuppliers = decodeURIComponent(urlParam("suppliers")).replace(' ', '').split(',');
|
|
47
|
+
//console.log(decodeURIComponent(allsuppliers));
|
|
48
|
+
|
|
49
|
+
var lis = '';
|
|
50
|
+
var list_num = 13;
|
|
51
|
+
var extralistnum = 1;
|
|
52
|
+
var suppliers_all = '';
|
|
53
|
+
var output = [];
|
|
54
|
+
var newsupp = [];
|
|
55
|
+
var suppliers_obj = {};
|
|
56
|
+
|
|
57
|
+
var extra_html = '';
|
|
58
|
+
|
|
59
|
+
$.each(allsuppliers, function( k, v ) {
|
|
60
|
+
//newsupp.push(v.split('-'));
|
|
61
|
+
var o = v.split('-');
|
|
62
|
+
suppliers_obj[o[0]] += decodeURIComponent(o[1]) + ', ';
|
|
63
|
+
|
|
64
|
+
extra_html += '<div style="width: 100%; display: inline-block; color: #000"><strong>'+v.replace('-', ' ')+'</strong></div><div style="width: 100%">';
|
|
65
|
+
extra_html += '<div><div style="float: left; margin-right: 10px;"><div class="ff-el-input--label ff-el-is-required asterisk-right"><label>Number of animals</label></div><input id="extra-list-animal" class="ff-el-form-control" required="" type="number" data-animal="'+extralistnum+'" aria-required="true" /></div>';
|
|
66
|
+
extra_html += '<div style="float: left; margin-right: 10px;"><div class="ff-el-input--label ff-el-is-required asterisk-right"><label>Number of Clinical Mastitis Cases</label></div><input id="extra-list-mastitis" class="ff-el-form-control" required="" type="number" data-mastitis="'+extralistnum+'" aria-required="true" /></div>';
|
|
67
|
+
extra_html += '<div style="float: left; margin-right: 10px;"><div class="ff-el-input--label ff-el-is-required asterisk-right"><label>Bulk tank SCC level</label></div><input id="extra-list-scc" class="ff-el-form-control" required="" type="number" data-scc="'+extralistnum+'" aria-required="true" /></div>';
|
|
68
|
+
extra_html += '<div style="float: left; margin-right: 10px;"><div class="ff-el-input--label"><label>Comment on SCC and Mastitis Cases</label></div><textarea id="extra-list-comment" class="ff-el-form-control" data-comment="'+extralistnum+'"></textarea></div>';
|
|
69
|
+
extra_html += '</div></div>';
|
|
70
|
+
|
|
71
|
+
extralistnum++;
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
$('#extra-fields').html(extra_html);
|
|
75
|
+
|
|
76
|
+
$.each(suppliers_obj, function( i, v ) {
|
|
77
|
+
//console.log(i, v)
|
|
78
|
+
//html += '<br><strong>Supplier '+(i+1)+'</strong>: ' + v.replace("-", " - ");
|
|
79
|
+
suppliers_all += '<span style="color: #000000;">- <b>'+ i + ' ' + v.replace('undefined', '').slice(0, -2) +'</b></span><br>';
|
|
80
|
+
$('input[name=hidden_'+list_num+']').val('- ' + i + ' ' + v.replace('undefined', '').slice(0, -2));
|
|
81
|
+
if(i != 'Fonterra'){
|
|
82
|
+
$('input[name="has_nonfonterra"').val('yes');
|
|
83
|
+
}
|
|
84
|
+
list_num++;
|
|
85
|
+
//extralistnum++;
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
$('#loc').html(decodeURIComponent(loc))
|
|
89
|
+
$('#suppliers-all').html('');
|
|
90
|
+
$('#total-samples').html('');
|
|
91
|
+
$('#role').html($("input[name=hidden_4]").val());
|
|
92
|
+
$('#user-full-name').html(decodeURIComponent(urlParam("fname")) + ' ' + decodeURIComponent(urlParam("lname")));
|
|
93
|
+
|
|
94
|
+
$(document).on('change', '#extra-list-animal', function(){
|
|
95
|
+
var data_id = $(this).data('animal');
|
|
96
|
+
$('[name="num_animals_'+data_id+'"]').val($(this).val());
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
$(document).on('change', '#extra-list-mastitis', function(){
|
|
100
|
+
var data_id = $(this).data('mastitis');
|
|
101
|
+
$('[name="num_clinical_mastisis_'+data_id+'"]').val($(this).val());
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
$(document).on('change', '#extra-list-scc', function(){
|
|
105
|
+
var data_id = $(this).data('scc');
|
|
106
|
+
$('[name="bulk_tank_scc_'+data_id+'"]').val($(this).val());
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
$(document).on('change', '#extra-list-comment', function(){
|
|
110
|
+
var data_id = $(this).data('rolomment');
|
|
111
|
+
$('[name="comment_scc_'+data_id+'"]').val($(this).val());
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
//$("input[name=hidden_6]").val(allsuppliers.length);
|
|
115
|
+
|
|
116
|
+
$('#preview').html(html)
|
|
117
|
+
|
|
118
|
+
function urlParam(name) {
|
|
119
|
+
var results = (new RegExp("[\\?&]" + name + "=([^&#]*)")).exec(window.location.href);
|
|
120
|
+
if (results == null) return null;
|
|
121
|
+
else return results[1] || 0;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/*** added ***/
|
|
125
|
+
|
|
126
|
+
var settings = {
|
|
127
|
+
"url": "https://snapshot-2-testenv-snpgtklz4a-ts.a.run.app/api/v2/farms/simple",
|
|
128
|
+
"method": "GET",
|
|
129
|
+
"timeout": 0,
|
|
130
|
+
"headers": {
|
|
131
|
+
"Authorization": "Bot L9lrcc3z+MqZFq2QWfiAuvNkbWyjisIA2BehMuLcw9Q=",
|
|
132
|
+
"Content-Type": "application/json",
|
|
133
|
+
"Cookie": "GAESA=CoQBMDAxMjE3ODliM2MyNzI0MDMzZTE1Yjk2OTFmOWRiNWNlODliMjhmMWU3YTI2ZjFmYTJiNGE5OGE0ZDBlMjQ1NDhkY2U5MWI5NGM2NzgxOTFmZjBjMTk5NDU4MTgwMTBjYjMwMzNiOWFlYTdkMjk5Zjc3ZDUyYjI4M2UzNjE3OWRmYzYyEMS59cD3MA"
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
var allSuppliers = [];
|
|
138
|
+
var suppliersName = [];
|
|
139
|
+
|
|
140
|
+
$.ajax(settings).done(function (response) {
|
|
141
|
+
//console.log(response);
|
|
142
|
+
var ff_11_dropdown_2_val = '';
|
|
143
|
+
//allSuppliers.push(response);
|
|
144
|
+
var voidSuppliers = ["TEST SUPPLIER", "UNKNOWN SUPPLIER", ""];
|
|
145
|
+
$.map(response, function(val) {
|
|
146
|
+
allSuppliers.push({supplier_name: val.supplierName, id: val.supplierNumber, name: val.bussinessName});
|
|
147
|
+
if($.inArray(val.supplierName, suppliersName) === -1) {
|
|
148
|
+
if($.inArray(val.supplierName, voidSuppliers) === -1){
|
|
149
|
+
suppliersName.push(val.supplierName);
|
|
150
|
+
ff_11_dropdown_2_val += '<option value="'+val.supplierName+'">'+val.supplierName+'</option>';
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
$('#ff_11_dropdown_2').html(ff_11_dropdown_2_val);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
//console.log(allSuppliers);
|
|
159
|
+
|
|
160
|
+
function urlParam(name) {
|
|
161
|
+
var results = (new RegExp("[\\?&]" + name + "=([^&#]*)")).exec(window.location.href);
|
|
162
|
+
if (results == null) return null;
|
|
163
|
+
else return results[1] || 0;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
let location = decodeURI(urlParam("location"));
|
|
167
|
+
let formnum = 1;
|
|
168
|
+
|
|
169
|
+
$('.ff-el-form-check').eq(0).find('input').click();
|
|
170
|
+
$('#ff_11_input_text').val(decodeURI(urlParam("farm_name")) === 'null' ? '' : decodeURI(urlParam("farm_name")));
|
|
171
|
+
$('#ff_11_dropdown option[value="'+location+'"]').attr("selected","selected");
|
|
172
|
+
$('#ff_11_names_first_name_').val(decodeURI(urlParam("fname")) === 'null' ? '' : decodeURI(urlParam("fname")));
|
|
173
|
+
$('#ff_11_names_last_name_').val(decodeURI(urlParam("lname")) === 'null' ? '' : decodeURI(urlParam("lname")));
|
|
174
|
+
$('#ff_11_email').val(decodeURI(urlParam("email")) === 'null' ? '' : decodeURI(urlParam("email")));
|
|
175
|
+
|
|
176
|
+
$('#add-supplier').click(function(e){
|
|
177
|
+
e.preventDefault();
|
|
178
|
+
console.log('new supplier click');
|
|
179
|
+
formnum++;
|
|
180
|
+
var newfrm = '<div data-name="ff_cn_id_7" class="ff-t-container ff-column-container ff_columns_total_2 supplier_container"><div class="ff-t-cell ff-t-column-1" style="flex-basis: 50%;"><div class="ff-el-group"><div class="ff-el-input--label ff-el-is-required asterisk-right"><label for="ff_11_dropdown_2" aria-label="Supplier Name 1">Supplier Name '+formnum+'</label> </div><div class="ff-el-input--content"><select name="dropdown_2" id="ff_11_dropdown_2" class="ff-el-form-control" data-name="dropdown_2" data-calc_value="0" aria-invalid="false" aria-required="true"><option value="">– Select Supplier '+ formnum +' –</option><option value="Fonterra">Fonterra</option><option value="Arrabawn">Arrabawn</option><option value="Aurivo">Aurivo</option><option value="Carbery">Carbery</option><option value="Dairy Goat Coop">Dairy Goat Coop</option><option value="Dairygold">Dairygold</option><option value="Green Valley Dairies">Green Valley Dairies</option><option value="Mataura Valley Milk">Mataura Valley Milk</option><option value="Maui">Maui</option><option value="Miraka">Miraka</option><option value="Open Country">Open Country</option><option value="Organic Dairy Hub">Organic Dairy Hub</option><option value="Synlait">Synlait</option><option value="Tatua">Tatua</option><option value="Waiau">Waiau</option><option value="Westland">Westland</option></select></div></div></div><div class="ff-t-cell ff-t-column-2" style="flex-basis: 50%;"><div class="ff-el-group"><div class="ff-el-input--label ff-el-is-required asterisk-right"><label for="ff_11_numeric-field" aria-label="Supplier Number 1">Supplier Number '+formnum+'</label> <span id="remove-supplier">x remove</span></div><div class="ff-el-input--content"><input type="number" name="numeric-field" id="ff_11_numeric-field" class="ff-el-form-control" data-name="numeric-field" inputmode="numeric" step="any" aria-invalid="false" aria-required="true"><div id="res_dropdown"></div></div></div></div></div>';
|
|
181
|
+
if (decodeURIComponent(urlParam("show_staph")) !== "true") newfrm += "<div style='display:none;'>"
|
|
182
|
+
newfrm += '<div data-name="ff_cn_id_6" class="ff-t-container ff-column-container ff_columns_total_4 div4 "><div class="ff-t-cell ff-t-column-1" style="flex-basis: 25%;"><div class="ff-el-group"><div class="ff-el-input--label ff-el-is-required asterisk-right"><label for="number_of_animals_'+formnum+'" aria-label="Number of Animals">Number of Animals</label> </div><div class="ff-el-input--content"><input data-name="num_animals_'+formnum+'" type="number" name="number_of_animals_'+formnum+'" id="extra" class="ff-el-form-control" inputmode="numeric" step="any" aria-invalid="false" aria-required="true"><div id="res_dropdown2"></div></div></div></div><div class="ff-t-cell ff-t-column-2" style="flex-basis: 25%;"><div class="ff-el-group"><div class="ff-el-input--label ff-el-is-required asterisk-right"><label for="number_of_clinicalmastisis_'+formnum+'" aria-label="Number of Clinical Mastitis Cases">Number of Clinical Mastitis Cases</label> </div><div class="ff-el-input--content"><input type="number" name="number_of_clinicalmastisis_'+formnum+'" id="extra" class="ff-el-form-control" data-name="num_clinical_mastisis_'+formnum+'" inputmode="numeric" step="any" aria-invalid="false" aria-required="true"></div></div></div><div class="ff-t-cell ff-t-column-3" style="flex-basis: 25%;"><div class="ff-el-group"><div class="ff-el-input--label ff-el-is-required asterisk-right"><label for="bulk_tank_level'+formnum+'" aria-label="Bulk tank SCC level">Bulk tank SCC level</label> </div><div class="ff-el-input--content"><input type="number" name="bulk_tank_level'+formnum+'" id="extra" class="ff-el-form-control" data-name="bulk_tank_scc_'+formnum+'" inputmode="numeric" step="any" aria-invalid="false" aria-required="true"></div></div></div><div class="ff-t-cell ff-t-column-4" style="flex-basis: 25%;"><div class="ff-el-group"><div class="ff-el-input--label asterisk-right"><label for="comment_scc_mastisis'+formnum+'" aria-label="Comment on SCC and Mastitis Cases">Comment on SCC and Mastitis Cases</label> </div><div class="ff-el-input--content"><textarea aria-invalid="false" aria-required="false" name="comment_scc_mastisis'+formnum+'" id="extra" class="ff-el-form-control" rows="3" cols="2" data-name="comment_scc_'+formnum+'"></textarea></div></div></div></div>';
|
|
183
|
+
if (decodeURIComponent(urlParam("show_staph")) !== "true") newfrm += "</div>"
|
|
184
|
+
|
|
185
|
+
$('.div4:last').after('<div class="newdiv" id="form-container-'+formnum+'"></div>');
|
|
186
|
+
|
|
187
|
+
//$(this).prepend(newfrm)
|
|
188
|
+
$(document).find("#form-container-"+formnum).html(newfrm);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
$(document).on('click', '#remove-supplier', function(){
|
|
192
|
+
var p = $(this).parent().parent().parent().parent().parent();
|
|
193
|
+
formnum -= 1;
|
|
194
|
+
p.remove();
|
|
195
|
+
console.log(p);
|
|
196
|
+
fill_suppliers();
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
//disabled
|
|
200
|
+
$(document).on('click', '#ff_11_numeric-field_disabled', function(){
|
|
201
|
+
var supplier_name = $(this).parent().parent().parent().parent().find('#ff_11_dropdown_2').val();
|
|
202
|
+
var result = [];
|
|
203
|
+
var res = '';
|
|
204
|
+
var el = $(this);
|
|
205
|
+
if(supplier_name !== ''){
|
|
206
|
+
console.log('here' + supplier_name);
|
|
207
|
+
|
|
208
|
+
$.map(allSuppliers, function(val) {
|
|
209
|
+
console.log(val.supplier_name);
|
|
210
|
+
if(supplier_name == val.supplier_name){
|
|
211
|
+
result.push({id: val.id, milk_supplier: val.name});
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
$.map(result, function(value) {
|
|
217
|
+
console.log(value)
|
|
218
|
+
res += '<div id="milk-supplier" data-id="'+value.id+'">'+value.id+'-'+value.milk_supplier+'</div>';
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
console.log(result);
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
el.next('#res_dropdown').html(res).css('display', 'block');
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
});
|
|
230
|
+
$('#ff_11_numeric-field').after('<div id="res_dropdown"></div>');
|
|
231
|
+
|
|
232
|
+
var result = {};
|
|
233
|
+
var result2 = {};
|
|
234
|
+
var allsuppliers = [];
|
|
235
|
+
|
|
236
|
+
function fill_suppliers(){
|
|
237
|
+
let suppliers_arr = [];
|
|
238
|
+
let supplier_arr2 = [{}];
|
|
239
|
+
$(".supplier_container").each(function() {
|
|
240
|
+
var supplier = $(this).find('#ff_11_dropdown_2').val();
|
|
241
|
+
var supplier_id = $(this).find('#ff_11_numeric-field').val();
|
|
242
|
+
suppliers_arr.push(supplier+'-'+supplier_id);
|
|
243
|
+
supplier_arr2.push({supplier: supplier, supplier_id: supplier_id});
|
|
244
|
+
});
|
|
245
|
+
allsuppliers = [];
|
|
246
|
+
allsuppliers.push([suppliers_arr]);
|
|
247
|
+
$('#total-samples').html(suppliers_arr.length);
|
|
248
|
+
$('[name="hidden_6"]').val(suppliers_arr.length);
|
|
249
|
+
|
|
250
|
+
//console.log(supplier_arr2)
|
|
251
|
+
grouped = [];
|
|
252
|
+
|
|
253
|
+
supplier_arr2.forEach(function (hash) {
|
|
254
|
+
return function (o) {
|
|
255
|
+
if (!hash[o.supplier]) {
|
|
256
|
+
hash[o.supplier] = { supplier: o.supplier, supplier_id: '' };
|
|
257
|
+
grouped.push(hash[o.supplier]);
|
|
258
|
+
}
|
|
259
|
+
if(o.supplier !== undefined){
|
|
260
|
+
hash[o.supplier].supplier_id += o.supplier_id + '|';
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
};
|
|
264
|
+
}(Object.create(null)));
|
|
265
|
+
|
|
266
|
+
var grouped_suppliers = '';
|
|
267
|
+
$('#suppliers-all').html('');
|
|
268
|
+
//console.log('grouped')
|
|
269
|
+
let groupnum = 13;
|
|
270
|
+
grouped.forEach(function (item, index) {
|
|
271
|
+
//console.log(item.supplier);
|
|
272
|
+
if(item.supplier !== undefined){
|
|
273
|
+
grouped_suppliers += '- ' + item.supplier + ' ' + item.supplier_id.substring(0, item.supplier_id.length-1).replace('|', ', ') + '\r\n<br>';
|
|
274
|
+
$('[name="hidden_'+groupnum+'"]').val(' - ' + item.supplier + ' ' + item.supplier_id.substring(0, item.supplier_id.length-1).replace('|', ', '));
|
|
275
|
+
groupnum++;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
//console.log(grouped_suppliers);
|
|
281
|
+
$('#suppliers-all').html(grouped_suppliers);
|
|
282
|
+
//$('[name="hidden_suppliers"]').val(allsuppliers);
|
|
283
|
+
//$('[name="suppliers_field"]').val(grouped_suppliers);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
$(document).on('blur', '#ff_11_numeric-field', function(){
|
|
287
|
+
fill_suppliers();
|
|
288
|
+
//console.log(allsuppliers)
|
|
289
|
+
$('[id=res_dropdown]').slideUp();
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
$(document).on('keyup', '#ff_11_numeric-field_disabled', function(){
|
|
293
|
+
res = '';
|
|
294
|
+
var i = $(this).val();
|
|
295
|
+
var supplier_name = $(this).parent().parent().parent().parent().find('#ff_11_dropdown_2').val();
|
|
296
|
+
result = [];
|
|
297
|
+
$.map(suppliers_json[supplier_name], function(val) {
|
|
298
|
+
result.push(val);
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
$.map(result, function(value) {
|
|
302
|
+
|
|
303
|
+
if(i != ''){
|
|
304
|
+
var varid = value.id;
|
|
305
|
+
var regex = new RegExp(this.value);
|
|
306
|
+
res += varid.includes(i) ? '<div id="milk-supplier" data-id="'+value.id+'">'+value.id+'-'+value.milk_supplier+'</div>' : "";
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
if(i !== ''){
|
|
311
|
+
$(this).next('#res_dropdown').show();
|
|
312
|
+
$(this).next('#res_dropdown').html(res);
|
|
313
|
+
}else{
|
|
314
|
+
$(this).next('#res_dropdown').hide();
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
res = '';
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
$(document).on('click', '#milk-supplier', function(){
|
|
321
|
+
console.log('supplier' + $(this).data('id'));
|
|
322
|
+
$(this).parent().parent().find('#ff_11_numeric-field').val($(this).data('id'));
|
|
323
|
+
$(this).parent().parent().find('#ff_11_numeric-field').focus();
|
|
324
|
+
$('[id=res_dropdown]').slideUp();
|
|
325
|
+
})
|
|
326
|
+
|
|
327
|
+
$('#ff_11_numeric-field_1').after('<div id="res_dropdown2"></div>');
|
|
328
|
+
|
|
329
|
+
$("#ff_11_dropdown_3").change(function(){
|
|
330
|
+
result2 = [];
|
|
331
|
+
$.map(suppliers_json[this.value], function(val) {
|
|
332
|
+
result2.push(val);
|
|
333
|
+
});
|
|
334
|
+
console.log(result2);
|
|
335
|
+
console.log(result2);
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
var all_suppliers = {};
|
|
339
|
+
|
|
340
|
+
$('#ff_11_numeric-field_1').on('keyup', function(){
|
|
341
|
+
res2 = '';
|
|
342
|
+
var i = $(this).val();
|
|
343
|
+
$.map(result2, function(value) {
|
|
344
|
+
//res += val.id +'-'+ val.milk_supplier + '\r\n';
|
|
345
|
+
//console.log(1);
|
|
346
|
+
if(i !== ''){
|
|
347
|
+
var varid = value.id;
|
|
348
|
+
var regex = new RegExp(this.value);
|
|
349
|
+
//console.log(varid);
|
|
350
|
+
//console.log(this.value);
|
|
351
|
+
|
|
352
|
+
res2 += varid.includes(i) ? '<div>'+value.id+'-'+value.milk_supplier+'</div>' : "";
|
|
353
|
+
$('#res_dropdown2').css('display', 'block');
|
|
354
|
+
|
|
355
|
+
var last_supplier = $(this).prev('#ff_11_dropdown_2').val();
|
|
356
|
+
//console.log(last_supplier);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
});
|
|
361
|
+
if(i !== ''){
|
|
362
|
+
$('#res_dropdown2').html(res2);
|
|
363
|
+
}else{
|
|
364
|
+
$('#res_dropdown2').css('display', 'none');
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
res = ''
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
$('#ff_11_dropdown_2').change(function(){
|
|
371
|
+
$('#ff_11_numeric-field').val('');
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
$('#ff_11_phone_1').on('keyup', function(){
|
|
375
|
+
$('#owner-phone').html($(this).val());
|
|
376
|
+
$("input[name=hidden_3]").val($(this).val());
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
$('#ff_11_input_text').on('keyup', function(){
|
|
380
|
+
$('#farm-business-name').html($(this).val());
|
|
381
|
+
$("input[name=hidden_1]").val($(this).val());
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
// $('#ff_11_dropdown_1').change(function(){
|
|
385
|
+
// $('#role').html($(this).val());
|
|
386
|
+
// $("input[name=hidden_12]").val($(this).val());
|
|
387
|
+
// });
|
|
388
|
+
|
|
389
|
+
$(document).on('change', '#extra', function(){
|
|
390
|
+
var name = $(this).data('name');
|
|
391
|
+
var value = $(this).val();
|
|
392
|
+
console.log(name, value);
|
|
393
|
+
$('input[name="'+name+'"]').val(value);
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
$('#ff_11_number_of_animals_1').change(function(){
|
|
397
|
+
var value = $(this).val();
|
|
398
|
+
$('input[name="num_animals_1"]').val(value);
|
|
399
|
+
});
|
|
400
|
+
$('#ff_11_number_of_clinicalmastisis_1').change(function(){
|
|
401
|
+
var value = $(this).val();
|
|
402
|
+
$('input[name="num_clinical_mastisis_1"]').val(value);
|
|
403
|
+
});
|
|
404
|
+
$('#ff_11_bulk_tank_level2').change(function(){
|
|
405
|
+
var value = $(this).val();
|
|
406
|
+
$('input[name="bulk_tank_scc_1"]').val(value);
|
|
407
|
+
});
|
|
408
|
+
$('#ff_11_comment_scc_mastisis2').change(function(){
|
|
409
|
+
var value = $(this).val();
|
|
410
|
+
$('input[name="comment_scc_1"]').val(value);
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
|