Skip to content

Commit 2e183a5

Browse files
committed
Fixed New Customer Bug & Updated README
1 parent e7faf09 commit 2e183a5

File tree

9 files changed

+26
-20
lines changed

9 files changed

+26
-20
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
## Fully Interactive Customer Table
3333

34-
![Customer Menu](docs/images/demo_1.png)
34+
![Customer Menu](docs/images/demo_customers.gif)
3535

3636
*Note: Data privacy is important to me, which is why the above data is fake data.*
3737

@@ -58,11 +58,11 @@
5858
* Check the **Send Email** box to send an email to the Customer.
5959
* Mobile capabilities with Bootstrap:
6060

61-
![Customer Menu Mobile](docs/images/demo_5.png)
61+
![Customer Menu Mobile](docs/images/demo_mobile.png)
6262

6363
## Custom Email Template
6464

65-
![Email Menu](docs/images/demo_2.png)
65+
![Email Menu](docs/images/demo_email.png)
6666

6767
* Configure your Email Server to send Business emails using your own plain-text or HTML email template (Gmail Supported).
6868
* Use variables from a predefined list to send curated emails to your Customers in the **Subject** and **Body**:
@@ -79,7 +79,7 @@
7979

8080
## Configure Your Business
8181

82-
![Configure Menu](docs/images/demo_3.png)
82+
![Configure Menu](docs/images/demo_configure.png)
8383

8484
* Upload and display your Company Logo.
8585
* Display your Company Title.
@@ -96,7 +96,7 @@
9696

9797
## Send Emails to Your Customers
9898

99-
![Email Example](docs/images/demo_4.png)
99+
![Email Example](docs/images/demo_send_email.png)
100100

101101
## Built Using
102102
* PHP v8.1.6
File renamed without changes.
File renamed without changes.

docs/images/demo_customers.gif

5.34 MB
Loading
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

js/main.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ var counter; // Counter for New Customer
1010
var isButtonSubmit = false; // Submit Button from Customer Notes
1111
var cust_notes; // Customer Notes
1212
var cust_id; // Customer ID
13+
var originalData; // Original Table Data Array
1314

14-
// Copy Variables to Clipboard Functi don
15+
// Copy Variables to Clipboard Function
1516
function copy_to_clipboard(event, element) {
1617
event.preventDefault();
1718
var $temp = $("<input>");
@@ -22,11 +23,13 @@ function copy_to_clipboard(event, element) {
2223
window.alert("Text copied to clipboard");
2324
}
2425

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() {
2629
originalData = $("#data_table tbody tr").get();
2730
}
2831

29-
//Search for Customers
32+
// Search for Customers
3033
const searchCustomers = () => {
3134
// Check if Counter is NOT Null
3235
if (counter != null) {
@@ -171,7 +174,7 @@ function send_single_email(box) {
171174
// Set the hidden field values
172175
$(box).closest("tr").find(".hiddenFlag").text("Not Sent");
173176
}
174-
resetOriginalData();
177+
setOriginalData();
175178

176179
console.log(data);
177180
},
@@ -223,7 +226,7 @@ function send_mass_email(box) {
223226
dataType: "HTML",
224227
success: function (data) {
225228
alert("Successfully Sent Mass Emails!");
226-
resetOriginalData();
229+
setOriginalData();
227230

228231
console.log(data);
229232
},
@@ -263,7 +266,7 @@ function update_email_flags(box) {
263266
success: function (data) {
264267
alert("Successfully Removed Send Flags!");
265268
console.log(data);
266-
resetOriginalData();
269+
setOriginalData();
267270
},
268271
error: function (error) {
269272
// Handle Error
@@ -281,11 +284,13 @@ function update_email_flags(box) {
281284
// jQuery Load Document
282285
$(document).ready(function () {
283286
// Declare Variables
284-
var originalData = $("#data_table tbody tr").get(); // Store Original Table Data
285287
const scrollable = $(".scrollable"); // Scrollable Div Tag
286288
const scrollUpButton = $("#scrollUp"); // Scroll Up Button
287289
const scrollDownButton = $("#scrollDown"); // Scroll Down Button
288290

291+
// Set Original Data Array
292+
setOriginalData();
293+
289294
// Set Customer Date/Time Created to Read Only
290295
$("#cust_created").prop("readonly", true);
291296

@@ -417,7 +422,7 @@ $(document).ready(function () {
417422
"&command=updateCustomerNotes",
418423
dataType: "HTML",
419424
success: function (data) {
420-
resetOriginalData();
425+
setOriginalData();
421426
console.log(data);
422427
},
423428
error: function (error) {
@@ -522,22 +527,22 @@ $(document).ready(function () {
522527
'</span><input class="tabledit-input tabledit-identifier" type="hidden" name="cust_id" value="' +
523528
json.cust_id.toString() +
524529
'" 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">' +
526531
json.cust_first_name +
527532
'</span><input class="tabledit-input form-control input-sm" type="text" name="cust_first_name" value="' +
528533
json.cust_first_name +
529534
'" 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">' +
531536
json.cust_last_name +
532537
'</span><input class="tabledit-input form-control input-sm" type="text" name="cust_last_name" value="' +
533538
json.cust_last_name +
534539
'" 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">' +
536541
json.cust_email +
537542
'</span><input class="tabledit-input form-control input-sm" type="text" name="cust_email" value="' +
538543
json.cust_email +
539544
'" 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">' +
541546
json.cust_phone +
542547
'</span><input class="tabledit-input form-control input-sm" type="text" name="cust_phone" value="' +
543548
json.cust_phone +
@@ -572,10 +577,11 @@ $(document).ready(function () {
572577

573578
$("#data_table").append(newRow);
574579

580+
alert("Successfully Created Customer!");
581+
575582
//Update the originalData variable with the most current table information.
576-
resetOriginalData();
583+
setOriginalData();
577584

578-
alert("Successfully Created Customer!");
579585
},
580586
error: function (jqXHR, textStatus, errorThrown) {
581587
// Handle Error
@@ -696,7 +702,7 @@ $(document).ready(function () {
696702
dataType: "HTML",
697703
success: function (data) {
698704
alert("Successfully Deleted Customer!");
699-
resetOriginalData();
705+
setOriginalData();
700706
},
701707
error: function (xhr, ajaxOptions, thrownError) {
702708
var error = JSON.parse(jqXHR.responseText);

0 commit comments

Comments
 (0)