-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcon.js
More file actions
665 lines (604 loc) · 17.8 KB
/
con.js
File metadata and controls
665 lines (604 loc) · 17.8 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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
Date.prototype.getMonthWeek = function(){
var firstDay = new Date(this.getFullYear(), this.getMonth(), 1).getDay();
return Math.ceil((this.getDate() + firstDay)/7);
}
Date.prototype.getYearWeek = function() {
var date = new Date(this.getTime());
date.setHours(0, 0, 0, 0);
// Thursday in current week decides the year.
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
// January 4 is always in week 1.
var week1 = new Date(date.getFullYear(), 0, 4);
// Adjust to Thursday in week 1 and count number of weeks from date to week1.
return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000
- 3 + (week1.getDay() + 6) % 7) / 7);
}
var defaultDate=new Date();
var datepickerOption={ minDate: 0,changeMonth: true,
changeYear: true,
"showAnim":"blind",
"dateFormat":"dd/mm/yy",
// "maxDate": new Date(defaultDate.getFullYear(),defaultDate.getMonth()+1,defaultDate.getDate()),
onClose: function(selectedDate) {
}
}
var getDateDiff=function(firstDate,secondDate){
var oneDay = 24 * 60 * 60 * 1000; // hours*minutes*seconds*milliseconds
firstDate = new Date(firstDate) || new Date();
secondDate = new Date(secondDate) || new Date();
var diffDays = Math.round(Math.abs((firstDate.getTime() - secondDate.getTime()) / (oneDay)));
return diffDays;
}
var createTens=function(n){
return(n<9)?"0"+n:n;
}
var covertToDate=function(date){
// alert(date)
date=date.split("/");
return new Date(date[2],date[1]-1,date[0]);
}
var dateArray=function(date,client){
var fdate=new Date(date);
// alert(fdate)
var da=[]
da[0]=fdate.getFullYear();
da[1]=createTens(fdate.getMonth()+1);
da[2]=createTens(fdate.getDate());
return (client)?da.reverse().join("/"):da;
}
var timeArray= function(date,client){
var fdate=new Date(date);
// alert(fdate)
var da=[]
da[0]=fdate.getSeconds();
da[1]=createTens(fdate.getMinutes()+1);
da[2]=createTens(fdate.getHours());
return (client)?da.reverse().join(":"):da;
}
function jDate(date, time) {
var d = date.split("/");
var t = time.split(":");
return new Date(d[2], parseInt(d[1]) - 1, d[0], (t[0] || 00), (t[1] || 00), (t[2] || 00))
}
var incrementDate=function(date,no){
no=no ||1
var tomorrow = new Date(date);
return new Date(tomorrow.setDate(tomorrow.getDate() + no));
}
var findDifferent=function(date,type){
var today=new Date();
var intervalPeriod=["Once","Weekly","Monthly","Quarterly","Half Yearly","Yearly"]
var index=intervalPeriod.indexOf(type);
var year=date.getFullYear()-today.getFullYear();
var d=date.getDate()-today.getDate();
switch(index){
case 1:
return ((year*53)+date.getYearWeek()-today.getYearWeek())+1;
break;
case 2:
return ((year*12)+date.getMonth()-today.getMonth())+1;
break;
case 3:
var totalMonth=(year*12)+(date.getMonth()-today.getMonth());
return parseInt(totalMonth/3) +1;
break;
case 4:
var totalMonth=(year*12)+(date.getMonth()-today.getMonth());
return parseInt(totalMonth/6) +1;
break;
case 5:
var totalMonth=(year*12)+(date.getMonth()-today.getMonth());
return year +1;
break;
}
}
var doFilter=function(enddate,type){
// var edate=dateArray(covertToDate(enddate))
return findDifferent(covertToDate(enddate),type);
}
$["isMobile"]=function(n,code,length){
code=code || "91";
length= length || 10;
alert(n)
}
function leapYear(year){
return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
}
var autoDate=function(id){
var date=[];
for (var i = 1; i <= 31; i++){
var d=(i<10)?"0"+i:""+i;
date.push(d)
}
$(id).autocomplete({
source: date
});
}
var autoMonth=function(id,date){
var month=[];
date=(date || "01");
for (var i = 1; i <= 12; i++){
var m=(i<10)?"0"+i:""+i;
month.push(m)
}
$(id).autocomplete({
source: month
});
}
var autoYear=function(id,date,month){
var year=[];
date=(date)?$(date).val():"01";
month=(month)?$(month).val():"01";
// alert(date);
// alert(month)
for (var i = 1950; i <= 2030; i++){
var y=(i<10)?"0"+i:""+i;
if(month=="02" && date=="01"){
if(!leapYear(i))
// alert("con")
continue;
}
year.push(y)
}
$(id).autocomplete({
source: year
});
}
$(document).on("click",".leftButton,#addQueue,#closeQuo,#addQuotation, .taskClick,li ",function(){
// })
// var target = $(event.target);
// if (!target.attr('id').match(/^mydiv/) && target.parents('#mydiv').length == 0) {
// $('#mydiv').hide();
// }
// if($.session.get("usertype")=="client"){
if($(this)["context"]["className"]!="ui-menu-item"){
$(".center").animate({
"width": "54.5%"
}, 200);
$(".right").animate({
"width": "29.5%"
}, 200);
$("#fileupload").animate({
"right": "25%"
}, 200);
// }
}
});
// var getSelectVal=function(){
// var values={};
// console.log("called")
// $(document).on("change",arguments[0],function(){
// for (var i = 1; i < arguments.length; i++) {
// values[arguments[i]]=$(arguments[0]).attr(arguments[i]);
// };
// })
// values["val"]=$(arguments[0]).val();
// return values;
// }
var redirectMethod=function(){var add=window.location.href; if(add.indexOf("trinity")>-1){window.location.href="http://fieldorder.ditscentre.in/index.html";}}
// redirectMethod();
var defaultPage=function(top,top2,state){
// if($.session.get("usertype")=="client"){
// alert("sd")
top2=(top2>0)?"58":top2;
$(".center").animate({
"top": top2
}, 1000);
$(".doctorName").animate({
"top": top2
}, 1000);
if(state){
$("#datatableDiv").fadeOut(1000)
}
else{
$("#datatableDiv").fadeIn(1000)
}
// }
}
var dataTableOption={
"scrollY": window.outerHeight-350,
"scrollCollapse": true,
// "paging": false,
fixedHeader: {
header: true,
footer: true
},
"order": [
[0, 'desc']
],
"lengthMenu": [
[100, 500, 1000, 5000, 10000, -1],
[100, 500, 1000, 5000, 10000, "All Record"]
],
stateSave: true
}
var dataTableReportOption={
// "scrollY": window.outerHeight-350,
"scrollCollapse": true,
// "paging": false,
fixedHeader: {
header: true,
footer: true
},
"order": [
[0, 'desc']
],
stateSave: true,
dom: 'Bfrtip',
buttons: [
{
extend: 'copyHtml5',
exportOptions: {
columns: [ 0, ':visible' ]
}
},
{
extend: 'excelHtml5',
exportOptions: {
columns: ':visible'
}
},
{
extend: 'pdfHtml5',
exportOptions: {
columns: [ 0, 1, 2,3,4 ,5 ]
}
}
// ,
// 'colvis'
],
"lengthMenu": [
[100, 500, 1000, 5000, 10000, -1],
[100, 500, 1000, 5000, 10000, "All Record"]
],
}
$("#usernameSpan").html($.session.get("fouserName"));
$("#logout").click(function(){
localStorage.removeItem("userSessionId");
window.location.href="index.html";
})
function toTitleCase(str)
{
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}
// var ritesh="Ritesh hi";
function load_home(id,page){
document.getElementById(id).innerHTML='<object width="100%" height="100%" type="text/html" data="'+page+'.html" ></object>';
}
var formatObjectKey = function(str){
return str.replace(/([A-Z])/g, ' $1').replace(/^./, function(str){ return str.toUpperCase() })
}
var processing=true;
var hitServiceAsync = function(url, values, callback) {
console.log(url);
// alert(url);
// console.log(values);
// console.log($.session.get("userSessionId"));
$("#errorMessageMainDiv").hide();
if($.session.get("userSessionId")){
// alert(processing)
if(processing){
processing=false;
var status = {
"state": false,
"message": "",
"docs": []
};
$.ajax({
type: "POST",
cache: false,
async: true,
crossdomain: true,
url: url,
data: {
values: JSON.stringify(values),
sessionId:$.session.get("userSessionId"),
usertype:$.session.get("usertype")
},
success: function(data) {
status = JSON.parse(data);
// console.log(status)
if(status["state"]==false){
if(status["message"]=="Not a valid sessionId"){
alert(status["message"]);
window.location.href="index.html";
}
}
setTimeout(function() {
processing=true;
callback(null, status);
}, 5)
},
error: function(xhr, status, error) {
setTimeout(function() {
$("#errorMessageMainDiv").show();
// console.log(JSON.stringify(xhr))
// $("#errorMessageMainDiv").html(JSON.stringify(xhr));
$("#errorMessageMainDiv").html("Something went Wrong");
processing=true;
callback(error, null);
}, 5)
}
});
}
}
else{
window.location.href="index.html"
}
}
var hitServiceAsyncOA = function(url, values, callback) {
// console.log(url);
// console.log(values);
// console.log($.session.get("userSessionId"));
$("#errorMessageMainDiv").hide();
if($.session.get("userSessionId")){
// alert(processing)
if(processing){
processing=false;
var status = {
"state": false,
"message": "",
"docs": []
};
$.ajax({
type: "POST",
cache: false,
async: true,
crossdomain: true,
url: url,
data:values,
success: function(data) {
status = JSON.parse(data);
// console.log(status)
setTimeout(function() {
processing=true;
callback(null, status);
}, 5)
},
error: function(xhr, status, error) {
setTimeout(function() {
$("#errorMessageMainDiv").show();
// console.log(JSON.stringify(xhr))
// $("#errorMessageMainDiv").html(JSON.stringify(xhr));
$("#errorMessageMainDiv").html("Something went Wrong");
processing=true;
callback(error, null);
}, 5)
}
});
}
}
else{
window.location.href="index.html"
}
}
var loadImage=function(imageUrl, divId, imgClass){
// alert(imageUrl);
var img = $("<img />").attr('src',imageUrl ).addClass(imgClass).attr("id","img_"+divId)
.load(function() {
if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) {
console.log(imageUrl)
} else {
$(divId).html(img);
}
});
}
function previewFile(image,file) {
// alert("called")
//calls the function named previewFile()
var preview = document.querySelector('#'+image); //selects the query named img
var file = document.querySelector('#'+file).files[0]; //sames as here
var reader = new FileReader();
console.log(reader);
reader.onloadend = function() {
preview.src = reader.result;
}
if (file) {
var url = reader.readAsDataURL(file);
console.log(url);
//reads the data as a URL
} else {
preview.src = "";
}
}
var getHitServiceAsync = function(url, values, callback) {
// console.log(url);
// console.log(values);
if($.session.get("userSessionId")){
var status = {
"state": false,
"message": "",
"docs": []
};
$.ajax({
type: "get",
cache: false,
async: false,
crossdomain: true,
url: "https://www.google.co.in/",
success: function(data) {
status = JSON.parse(data);
console.log(status)
if(status["state"]==false){
if(status["message"]=="Not a valid sessionId"){
alert(status["message"])
window.location.href="index.html";
}
}
setTimeout(function() {
// console.log(status)
callback(null, status);
}, 5)
},
error: function(xhr, status, error) {
setTimeout(function() {
callback(error, null);
}, 5)
}
});
}
else{
window.location.href="index.html"
}
}
var hitServiceAsyncLogin= function(url, values, callback) {
// console.log(url);
// console.log(values);
// if(localStorage.getItem("sessionId")){
var status = {
"state": false,
"message": "",
"docs": []
};
$.ajax({
type: "POST",
cache: false,
async: false,
crossdomain: true,
url: url,
data: {
values: JSON.stringify(values),
sessionId:$.session.get("userSessionId"),
usertype:$.session.get("usertype")
},
success: function(data) {
status = JSON.parse(data);
// console.log(status["message"])
setTimeout(function() {
// console.log(status)
callback(null, status);
}, 5)
},
error: function(xhr, status, error) {
setTimeout(function() {
callback(error, null);
}, 5)
}
});
// }
// else{
// window.location.href="index.html"
// }
}
var hitServiceFormDataAsync=function(url,formData,callback){
formData.append("sessionId",$.session.get("userSessionId"));
var status = {
"state": false,
"message": "",
"docs": []
};
// console.log(formData);
$.ajax({
type:"POST",
contentType:false,
processData:false,
cache:false,
async:true,
crossdomain:true,
url:url,
// providing the data as a string
data:formData,
success:function(data){
var status = JSON.parse(data);
//console.log(status);
setTimeout(function() {
// console.log(status)
callback(null, status);
}, 5)
},
error:function(xhr, status, error){
setTimeout(function() {
callback(error, null);
}, 5)
}
});
}
//To calulate local strage size
var sizeOfLocalStorage=function(){
var s=0
for (var i = 0; i < localStorage.length; i++){
s += JSON.stringify(localStorage.getItem(localStorage.key(i)))
}
return s;
}
var hitServiceAsyncNABH = function(url, values, callback) {
var status = {
"state": false,
"message": "",
"docs": []
};
$.ajax({
type: "POST",
cache: false,
async: true,
crossdomain: true,
url: url,
data: {
values: JSON.stringify(values)
},
success: function(data) {
status = JSON.parse(data);
setTimeout(function() {
// console.log(status)
callback(null, status);
}, 5)
},
error: function(xhr, status, error) {
setTimeout(function() {
callback(error, null);
}, 5)
}
});
}
function PrintElem(elem)
{
Popup($(elem).html());
}
function Popup(data)
{
var mywindow = window.open('', 'my div', 'height=400,width=600');
mywindow.document.write('<html><head><title>my div</title>');
/*optional stylesheet*/ //mywindow.document.write('<link rel="stylesheet" href="main.css" type="text/css" />');
mywindow.document.write('</head><body >');
mywindow.document.write(data);
mywindow.document.write('</body></html>');
mywindow.document.close(); // necessary for IE >= 10
mywindow.focus(); // necessary for IE >= 10
mywindow.print();
mywindow.close();
return true;
}
var createDropDown=function(id,search){
$(document).on("keydown.autocomplete",id,function(e){
$(id).autocomplete({
minLength: 0,
// source: function(request, response) {
// var results = $.ui.autocomplete.filter(search, request.term);
// if (!results.length) {
// console.log("alsdsdfsd");
// results = ["NoResultsLabel"];
// }
// response(results);
// },
source: search,
focus: function(event, ui) {
$(id+"").val(ui.item.label);
$("#searchConsumer-des").val(ui.item.value)
$("#searchConsumer-index").val(ui.item.icon)
return false;
},
select: function(event, ui) {
$(id).val(ui.item.label);
$(id+"-id").val(ui.item.value);
$(id+"-description").html(ui.item.desc);
$(id+"-icon").attr("src", "images/" + ui.item.icon);
return false;
}
})
.autocomplete("instance")._renderItem = function(ul, item) {
return $("<li>")
.append("<a class='"+id.substr(1)+"Result' id=" + item.value + " name=" + item.icon + ">" + item.label +" " + item.desc+ "</a>")
.appendTo(ul);
};
});
}