@@ -10,8 +10,9 @@ var counter; // Counter for New Customer
10
10
var isButtonSubmit = false ; // Submit Button from Customer Notes
11
11
var cust_notes ; // Customer Notes
12
12
var cust_id ; // Customer ID
13
+ var originalData ; // Original Table Data Array
13
14
14
- // Copy Variables to Clipboard Functi don
15
+ // Copy Variables to Clipboard Function
15
16
function copy_to_clipboard ( event , element ) {
16
17
event . preventDefault ( ) ;
17
18
var $temp = $ ( "<input>" ) ;
@@ -22,11 +23,13 @@ function copy_to_clipboard(event, element) {
22
23
window . alert ( "Text copied to clipboard" ) ;
23
24
}
24
25
25
- function resetOriginalData ( ) {
26
+ // Set Tables Original Data
27
+ // This will reset to the original sorting when adding a new customer after a sort
28
+ function setOriginalData ( ) {
26
29
originalData = $ ( "#data_table tbody tr" ) . get ( ) ;
27
30
}
28
31
29
- //Search for Customers
32
+ // Search for Customers
30
33
const searchCustomers = ( ) => {
31
34
// Check if Counter is NOT Null
32
35
if ( counter != null ) {
@@ -171,7 +174,7 @@ function send_single_email(box) {
171
174
// Set the hidden field values
172
175
$ ( box ) . closest ( "tr" ) . find ( ".hiddenFlag" ) . text ( "Not Sent" ) ;
173
176
}
174
- resetOriginalData ( ) ;
177
+ setOriginalData ( ) ;
175
178
176
179
console . log ( data ) ;
177
180
} ,
@@ -223,7 +226,7 @@ function send_mass_email(box) {
223
226
dataType : "HTML" ,
224
227
success : function ( data ) {
225
228
alert ( "Successfully Sent Mass Emails!" ) ;
226
- resetOriginalData ( ) ;
229
+ setOriginalData ( ) ;
227
230
228
231
console . log ( data ) ;
229
232
} ,
@@ -263,7 +266,7 @@ function update_email_flags(box) {
263
266
success : function ( data ) {
264
267
alert ( "Successfully Removed Send Flags!" ) ;
265
268
console . log ( data ) ;
266
- resetOriginalData ( ) ;
269
+ setOriginalData ( ) ;
267
270
} ,
268
271
error : function ( error ) {
269
272
// Handle Error
@@ -281,11 +284,13 @@ function update_email_flags(box) {
281
284
// jQuery Load Document
282
285
$ ( document ) . ready ( function ( ) {
283
286
// Declare Variables
284
- var originalData = $ ( "#data_table tbody tr" ) . get ( ) ; // Store Original Table Data
285
287
const scrollable = $ ( ".scrollable" ) ; // Scrollable Div Tag
286
288
const scrollUpButton = $ ( "#scrollUp" ) ; // Scroll Up Button
287
289
const scrollDownButton = $ ( "#scrollDown" ) ; // Scroll Down Button
288
290
291
+ // Set Original Data Array
292
+ setOriginalData ( ) ;
293
+
289
294
// Set Customer Date/Time Created to Read Only
290
295
$ ( "#cust_created" ) . prop ( "readonly" , true ) ;
291
296
@@ -417,7 +422,7 @@ $(document).ready(function () {
417
422
"&command=updateCustomerNotes" ,
418
423
dataType : "HTML" ,
419
424
success : function ( data ) {
420
- resetOriginalData ( ) ;
425
+ setOriginalData ( ) ;
421
426
console . log ( data ) ;
422
427
} ,
423
428
error : function ( error ) {
@@ -522,22 +527,22 @@ $(document).ready(function () {
522
527
'</span><input class="tabledit-input tabledit-identifier" type="hidden" name="cust_id" value="' +
523
528
json . cust_id . toString ( ) +
524
529
'" disabled=""></td>' +
525
- '<td class="tabledit-view-mode" style="cursor: pointer;"><span class="tabledit-span" style="display: inline;" >' +
530
+ '<td class="tabledit-view-mode" style="cursor: pointer;"><span class="tabledit-span">' +
526
531
json . cust_first_name +
527
532
'</span><input class="tabledit-input form-control input-sm" type="text" name="cust_first_name" value="' +
528
533
json . cust_first_name +
529
534
'" style="display: none;" disabled=""></td>' +
530
- '<td class="tabledit-view-mode" style="cursor: pointer;"><span class="tabledit-span" style="display: inline;" >' +
535
+ '<td class="tabledit-view-mode" style="cursor: pointer;"><span class="tabledit-span">' +
531
536
json . cust_last_name +
532
537
'</span><input class="tabledit-input form-control input-sm" type="text" name="cust_last_name" value="' +
533
538
json . cust_last_name +
534
539
'" style="display: none;" disabled=""></td>' +
535
- '<td class="tabledit-view-mode" style="cursor: pointer;"><span class="tabledit-span" style="display: inline;" >' +
540
+ '<td class="tabledit-view-mode" style="cursor: pointer;"><span class="tabledit-span">' +
536
541
json . cust_email +
537
542
'</span><input class="tabledit-input form-control input-sm" type="text" name="cust_email" value="' +
538
543
json . cust_email +
539
544
'" style="display: none;" disabled=""></td>' +
540
- '<td class="tabledit-view-mode" style="cursor: pointer;"><span class="tabledit-span" style="display: inline;" >' +
545
+ '<td class="tabledit-view-mode" style="cursor: pointer;"><span class="tabledit-span">' +
541
546
json . cust_phone +
542
547
'</span><input class="tabledit-input form-control input-sm" type="text" name="cust_phone" value="' +
543
548
json . cust_phone +
@@ -572,10 +577,11 @@ $(document).ready(function () {
572
577
573
578
$ ( "#data_table" ) . append ( newRow ) ;
574
579
580
+ alert ( "Successfully Created Customer!" ) ;
581
+
575
582
//Update the originalData variable with the most current table information.
576
- resetOriginalData ( ) ;
583
+ setOriginalData ( ) ;
577
584
578
- alert ( "Successfully Created Customer!" ) ;
579
585
} ,
580
586
error : function ( jqXHR , textStatus , errorThrown ) {
581
587
// Handle Error
@@ -696,7 +702,7 @@ $(document).ready(function () {
696
702
dataType : "HTML" ,
697
703
success : function ( data ) {
698
704
alert ( "Successfully Deleted Customer!" ) ;
699
- resetOriginalData ( ) ;
705
+ setOriginalData ( ) ;
700
706
} ,
701
707
error : function ( xhr , ajaxOptions , thrownError ) {
702
708
var error = JSON . parse ( jqXHR . responseText ) ;
0 commit comments