-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage2.html
More file actions
349 lines (308 loc) · 11.9 KB
/
page2.html
File metadata and controls
349 lines (308 loc) · 11.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css">
<title>Scan Prescription</title>
<!-- Bootstrap files -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
<link href="node_modules/cropperjs/dist/cropper.css" rel="stylesheet">
<script src="node_modules/cropperjs/dist/cropper.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body class="page2" style="color: white;">
<div class="container">
<div class="alert alert-default mt-4" style="height: 3rem;color: wheat;">
<div class="row">
<div class="col text-left">
<p><strong>Hii Youngman</strong></p>
</div>
<div class="col text-right">
<a class="btn" onclick="page1()"><strong>Back</strong></a>
</div>
</div>
</div>
<!-- <p class="center"><strong>Medicines requested from</strong></p>
--> <form><strong>
<div class="form-group">
<div class="row">
<div class="col-md-6">
<label for="name">Name of the Medical Shop</label>
<input type="text" id="name" required class="form-control mb-2">
<small id="nameHelp" class="form-text text-white mb-2">Drugstore chain with health & beauty items, plus first-aid supplies & some household products.</small>
</div>
<div class="col-md-3">
<label for="mail">Email Id</label>
<input type="mail" id="mail" required class="form-control mb-2">
</div>
<div class="col-md-3">
<label for="mail">Website</label>
<input type="text" id="web" required class="form-control mb-2">
</div>
</div>
<label for="address">Location</label>
<input type="text" id="address" class="form-control mb-2">
<div class="row">
<div class="col-md-6">
<label for="city">City</label>
<input type="text" id="city" required class="form-control mb-2">
</div>
<div class="col-md-6">
<label for="state">State</label>
<input type="text" id="state" required class="form-control mb-2">
</div>
</div>
<div class="row">
<div class="col-md-8">
<label for="hours">Pharmacy Hours</label>
<select class="form-control mb-2" readonly>
<option>Sunday 9.00 AM - 6.00 PM</option>
<option>Monday 9.00 AM -10.30 PM</option>
<option>Tuesday 9.00 AM - 10.30 PM</option>
<option>Wednesday 9.00 AM - 10.30 PM</option>
<option>Thursday 9.00 AM - 10.30 PM</option>
<option>Friday 9.00 AM - 10.30 PM</option>
<option>Saturday 9.00 AM -10.30 PM</option>
</select>
</div>
<div class="col-md-4">
<label for="phone">Mobile No</label>
<input type="numbe2" id="mobile" required class="form-control mb-2">
</div>
</div>
<div class="row mt-2">
<div class="col-md-8">
<div class="checkbox">
<label><input type="checkbox"> I understand and accept the terms and conditions.</label>
</div>
</div>
<div class="col-md-4">
<label for="files" class="btn btn-default form-control btn-dark" id="scan_btn">Scan Prescription</label>
<input id="files" style="visibility:hidden;" type="file" name="image" accept="image/*" capture="environment">
</div>
</div>
</div></strong>
</form>
</div>
<p class="container" id="picEdit" style="visibility: hidden;">
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal" id="btnCrop">Crop</button>
<button type="button" class="btn btn-info btn-lg" id="btnRestore">Reset</button>
</p>
<!-- <button type="button" class="btn btn-info" onclick="showimage()">show</button> -->
<!-- <div id="check"></div> -->
<div class="container img-fluid" alt="Responsive image" id="img_edit">
<canvas id="canvas" class="mr-5"></canvas>
</div>
<!--popup to show image -->
<div id="myModal" class="modal fade text-dark" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Cropped Image</h4>
</div>
<div class="modal-body text-info">
<p><strong>click proceed button to send the prescription</strong></p>
<div id="result" class="m-5"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-info" onclick="UploadPrescription()">Proceed</button>
<button type="button" class="btn btn-danger" data-dismiss="modal">Abort</button>
</div>
</div>
</div>
</div>
<div class="container" style="visibility: hidden;" id="status">
<p><strong>Order Status</strong></p>
<form id="orderAccept">
<div class="row">
<div class="col-md-6">
<label for="victim_name">Customer Name</label>
<input type="text" id="name1" class="form-control mb-2">
</div>
<div class="col-md-6">
<label for="mobile1">Mobile No</label>
<input type="text" id="mobile1" class="form-control mb-2">
</div>
</div>
<img src="" id="CustomerImage" />
</form>
</div>
<br><br><br>
<!-- <footer class="footer_bg">
<div class="row">
<div class="col-md-2">
<div class="text-left" style="margin-left: 2rem">© 2018 WeCareYou</div>
</div>
<div class="col-md-10">
<div class="text-right" style="margin-right: 2rem">Contact us: support@wecareyou.com</div>
</div>
</div>
</footer> -->
<!--Script-->
<script type="text/javascript">
var canvas = $("#canvas"),
context = canvas.get(0).getContext("2d"),
$result = $('#result');
var input = document.querySelector('input[type=file]');
input.onchange = function () {
if (this.files && this.files[0]) {
if ( this.files[0].type.match(/^image\//) ) {
var reader = new FileReader();
reader.onload = function(evt) {
var img = new Image();
img.onload = function() {
context.canvas.height = img.height;
context.canvas.width = img.width;
context.drawImage(img, 0, 0);
document.getElementById("picEdit").style.visibility="visible";
var image = document.getElementById('canvas');
var cropper = new Cropper(image, {
aspectRatio: 1 / 1,
setDragMode: "move"
});
// cropper.rotateTo(180);
// setDragMode("move");
$('#btnCrop').click(function() {
croppedImageDataURL = cropper.getCroppedCanvas().toDataURL();
console.log(croppedImageDataURL);
$result.append( $('<img>').attr('src', croppedImageDataURL) );
});
$('#btnRestore').click(function() {
$result.empty();
});
};
img.src = evt.target.result;
};
reader.readAsDataURL(this.files[0]);
}
else {
alert("Invalid file type! Please select an image file.");
}
}
else {
alert('No file(s) selected.');
}
};
function page1(){
location.href="home.html";
}
function takePhoto(){
}
// Api call
function UploadPrescription() {
var url = 'https://meds-api-cip.herokuapp.com/prescriptions#create';
var formData = new FormData();
// $result = $('#result');
user = JSON.parse(localStorage['user']);
formData.append('name', user['name'] );
formData.append('mobileNo', user['mobileNo'] );
formData.append('shop_mail_id', mail);
formData.append('photo', input.files[0]);
formData.append('url', croppedImageDataURL)
fetch(url, {
method: 'POST', // or 'PUT'
body: formData // data can be `string` or {object}!
// headers:{
// 'Content-Type': 'multipart/form-data'
// }
})
.then(response => response.json())
.catch(error => console.error('Error:', error))
.then(response => console.log('Success:', JSON.stringify(response)));
$('#myModal').modal('hide');
inst1 = document.getElementById('scan_btn')
inst1.parentNode.removeChild(inst1);
inst2 = document.getElementById('picEdit')
inst2.parentNode.removeChild(inst2);
inst3 = document.getElementById('img_edit')
inst3.parentNode.removeChild(inst3);
document.getElementById("name1").value = user['name'];
document.getElementById("mobile1").value = user['mobileNo'];
document.getElementById('status').style.visibility = 'visible';
document.getElementById("CustomerImage").src = croppedImageDataURL;
localStorage.setItem( 'img_url', JSON.stringify(croppedImageDataURL));
}
function showimage(){
var url = 'https://meds-api-cip.herokuapp.com/prescriptions#show';
fetch(url)
.then((res) => { return res.json() })
.then((data) => {
$('#check').append( $('<img>').attr('src', data.url))
});
}
function updateShop(mail){
var url = 'https://meds-api-cip.herokuapp.com/medical_shops/show';
var data = {mail: mail};
let query ='?'+Object.keys(data)
.map(k => encodeURIComponent(k) + '=' + encodeURIComponent(data[k]))
.join('&');
url = url + query;
fetch(url)
.then((res) => { return res.json() })
.then((data) => {
if (data.Message){
console.log(data.Message);
}
else{
document.getElementById("name").value = data[0].name;
document.getElementById("web").value = data[0].web;
document.getElementById("mail").value = data[0].mail;
document.getElementById("address").value = data[0].address;
document.getElementById("city").value = data[0].city;
document.getElementById("state").value = data[0].state;
document.getElementById("mobile").value = data[0].mobile;
}
});
}
mail = localStorage['shop_mail'].replace(/"/g,"");
if (mail != ""){
updateShop(mail)
}
if (localStorage.getItem("img_url") !== null) {
croppedImageDataURL = JSON.parse(localStorage['img_url']);
user = JSON.parse(localStorage['user']);
document.getElementById('status').style.visibility = 'visible';
inst1 = document.getElementById('scan_btn')
inst1.parentNode.removeChild(inst1);
inst2 = document.getElementById('picEdit')
inst2.parentNode.removeChild(inst2);
inst3 = document.getElementById('img_edit')
inst3.parentNode.removeChild(inst3);
document.getElementById("name1").value = user['name'];
document.getElementById("mobile1").value = user['mobileNo'];
document.getElementById("CustomerImage").src = croppedImageDataURL;
updateStatus(user['mobileNo'])
}
function updateStatus(mob){
var url = 'https://meds-api-cip.herokuapp.com/prescriptions/get_status';
var data = {mobileNo: mob};
let query ='?'+Object.keys(data)
.map(k => encodeURIComponent(k) + '=' + encodeURIComponent(data[k]))
.join('&');
url = url + query;
fetch(url)
.then((res) => { return res.json() })
.then((data) => {
if (data[0]['order_accepted'] != null){
b1 = document.createElement("input");
b1.type = "button";
b1.id = 'status0';
b1.name = "status";
if (data[0]['order_accepted'] == true) {
b1.value = "Accepted";
b1.className = "btn btn-success btn-sm btn-block";
}
else{
b1.value = "Rejected";
b1.className = "btn btn-danger btn-sm btn-block";
}
$('#status').append(b1);
}
});
}
</script>
</body>
</html>