From 724540da337c64820e7a70c1b85c2dfe157ee01e Mon Sep 17 00:00:00 2001 From: o-psi Date: Thu, 15 Feb 2024 15:51:11 +0000 Subject: [PATCH 1/8] Make same changes to client pages as main recuring invoices and tickets --- client_invoices.php | 98 +++++++++++++++++++---------------- client_recurring_invoices.php | 3 ++ client_side_nav.php | 29 +---------- client_tickets.php | 10 ++++ tickets.php | 2 +- 5 files changed, 70 insertions(+), 72 deletions(-) diff --git a/client_invoices.php b/client_invoices.php index 0ebf2e8f..0fd91ab6 100644 --- a/client_invoices.php +++ b/client_invoices.php @@ -21,51 +21,61 @@ $sql = mysqli_query( $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); +$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('recurring_id') AS num FROM recurring WHERE recurring_archived_at IS NULL AND recurring_client_id = $client_id")); +$recurring_invoice_count = $row['num']; + ?> -
-
-

Invoices

-
-
- - - +
+
+

Invoices

+
+
+ + +
-
-
- -
+
+
+ + +
-
-
- -
- -
+
+
+ +
+
+
-
-
- 0) { ?> - +
+
+
+ Recurring | + 0) { ?> +
-
- -
-
- - "> + + + +
+
+
+ "> @@ -76,8 +86,8 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); - - + + + ?> - + - - -
Number ScopeStatus Action
+
+
@@ -162,23 +174,22 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
-
- + +
+
+
diff --git a/client_side_nav.php b/client_side_nav.php index 054d8ec3..898465d2 100644 --- a/client_side_nav.php +++ b/client_side_nav.php @@ -51,7 +51,7 @@ - @@ -237,7 +224,7 @@ -
+ + diff --git a/tickets.php b/tickets.php index f3bb48d0..d53667db 100644 --- a/tickets.php +++ b/tickets.php @@ -77,7 +77,7 @@ $sql_total_tickets_closed = mysqli_query($mysqli, "SELECT COUNT(ticket_id) AS to $row = mysqli_fetch_array($sql_total_tickets_closed); $total_tickets_closed = intval($row['total_tickets_closed']); -//Get Total Scheduled tickets +//Get Total Recurring (scheduled) tickets $sql_total_scheduled_tickets = mysqli_query($mysqli, "SELECT COUNT(scheduled_ticket_id) AS total_scheduled_tickets FROM scheduled_tickets"); $row = mysqli_fetch_array($sql_total_scheduled_tickets); $total_scheduled_tickets = intval($row['total_scheduled_tickets']); From 277e91b07ebf87f5c81b29f2b75d0176f4038971 Mon Sep 17 00:00:00 2001 From: o-psi Date: Thu, 15 Feb 2024 21:35:21 +0000 Subject: [PATCH 2/8] Update Password Gen Function --- functions.php | 53 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/functions.php b/functions.php index 31c7e575..bf46ea31 100644 --- a/functions.php +++ b/functions.php @@ -956,7 +956,12 @@ function calculateAccountBalance($mysqli, $account_id) function generateReadablePassword($security_level) { + // Cap security level at 5 + $security_level = intval($security_level); + $security_level = min($security_level, 5); + // Arrays of words + $articles = ['The', 'A']; $adjectives = ['Smart', 'Swift', 'Secure', 'Stable', 'Digital', 'Virtual', 'Active', 'Dynamic', 'Innovative', 'Efficient', 'Portable', 'Wireless', 'Rapid', 'Intuitive', 'Automated', 'Robust', 'Reliable', 'Sleek', 'Modern', 'Happy', 'Funny', 'Quick', 'Bright', 'Clever', 'Gentle', 'Brave', 'Calm', 'Eager', 'Fierce', 'Kind', 'Lucky', 'Proud', 'Silly', 'Witty', 'Bold', 'Curious', 'Elated', 'Gracious', 'Honest', 'Jolly', 'Merry', 'Noble', 'Optimistic', 'Playful', 'Quirky', 'Rustic', 'Steady', 'Tranquil', 'Upbeat']; $nouns = ['Computer', 'Laptop', 'Tablet', 'Server', 'Router', 'Software', 'Hardware', 'Pixel', 'Byte', 'App', 'Network', 'Cloud', 'Firewall', 'Email', 'Database', 'Folder', 'Document', 'Interface', 'Program', 'Gadget', 'Dinosaur', 'Tiger', 'Elephant', 'Kangaroo', 'Monkey', 'Unicorn', 'Dragon', 'Puppy', 'Kitten', 'Parrot', 'Lion', 'Bear', 'Fox', 'Wolf', 'Rabbit', 'Deer', 'Owl', 'Hedgehog', 'Turtle', 'Frog', 'Butterfly', 'Panda', 'Giraffe', 'Zebra', 'Peacock', 'Koala', 'Raccoon', 'Squirrel', 'Hippo', 'Rhino', 'Book', "Monitor"]; $verbs = ['Connects', 'Runs', 'Processes', 'Secures', 'Encrypts', 'Saves', 'Updates', 'Boots', 'Scans', 'Compiles', 'Executes', 'Restores', 'Installs', 'Configures', 'Downloads', 'Streams', 'BacksUp', 'Syncs', 'Browses', 'Navigates', 'Runs', 'Jumps', 'Flies', 'Swims', 'Dances', 'Sings', 'Hops', 'Skips', 'Races', 'Climbs', 'Crawls', 'Glides', 'Twirls', 'Swings', 'Sprints', 'Gallops', 'Trots', 'Wanders', 'Strolls', 'Marches']; @@ -968,40 +973,48 @@ function generateReadablePassword($security_level) $verb = $verbs[array_rand($verbs)]; $adv = $adverbs[array_rand($adverbs)]; - - // Combine to create a base password - if ($security_level > 2) { - $password = "The" . $adj . $noun . $adv . $verb; - } else { - $password = $adj . $noun . $verb; + $password = $adj . $noun . $verb . $adv; + + // Select an article randomly + $article = $articles[array_rand($articles)]; + + // Determine if we should use 'An' instead of 'A' + if ($article == 'A' && preg_match('/^[aeiouAEIOU]/', $adj)) { + $article = 'An'; } + // Add the article to the password + $password = $article . $password; + // Mapping of letters to special characters and numbers $mappings = [ 'A' => '@', 'a' => '@', 'E' => '3', 'e' => '3', 'I' => '!', 'i' => '!', 'O' => '0', 'o' => '0', - 'S' => '$', 's' => '$' + 'S' => '$', 's' => '$', + 'T' => '+', 't' => '+', + 'B' => '8', 'b' => '8' ]; - // Replace characters based on mappings - if ($security_level > 4) { - $password = strtr($password, $mappings); - } else { - // Randomly replace characters based on mappings - for ($i = 0; $i < strlen($password); $i++) { - if (array_key_exists($password[$i], $mappings) && rand(0, 1)) { - $password[$i] = $mappings[$password[$i]]; - } + // Generate an array of indices based on the password length + $indices = range(0, strlen($password) - 1); + // Randomly shuffle the indices + shuffle($indices); + + // Iterate through the shuffled indices and replace characters based on the security level + for ($i = 0; $i < min($security_level, strlen($password)); $i++) { + $index = $indices[$i]; // Get a random index + $currentChar = $password[$index]; // Get the character at this index + // Check if the current character has a mapping and replace it + if (array_key_exists($currentChar, $mappings)) { + $password[$index] = $mappings[$currentChar]; } } - if ($security_level > 3) { - // Add a random number at the end - $password .= rand(0, 99); - } + // Add as many random numbers as the security level + $password .= rand(pow(10, $security_level - 1), pow(10, $security_level) - 1); return $password; } From 9e2f92a92f5ddb4df9f777e928e3bfba041df927 Mon Sep 17 00:00:00 2001 From: o-psi Date: Thu, 15 Feb 2024 15:41:34 -0600 Subject: [PATCH 3/8] Fix client statement payments --- client_statement.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client_statement.php b/client_statement.php index c58eabdb..94c4ef91 100644 --- a/client_statement.php +++ b/client_statement.php @@ -137,13 +137,14 @@ if (isset($_GET['client_id'])) { payments.payment_amount, payments.payment_reference, invoices.invoice_number, - invoices.invoice_prefix + invoices.invoice_prefix, + invoices.invoice_client_id FROM payments LEFT JOIN invoices ON payments.payment_invoice_id = invoices.invoice_id WHERE - payment_account_id = $client_id + invoice_client_id = $client_id AND payment_archived_at IS NULL ORDER BY payment_date DESC"; From 633c2f785cfb2dffe9d1f390bd7f9a1f4998fe56 Mon Sep 17 00:00:00 2001 From: o-psi Date: Thu, 15 Feb 2024 22:04:54 +0000 Subject: [PATCH 4/8] Add mass bulk mail --- admin_bulk_mail.php | 148 ++++++++++++++++++++++++ admin_side_nav.php | 262 ++++++++++++++++++++++++------------------- client_bulk_mail.php | 70 +++++++----- 3 files changed, 339 insertions(+), 141 deletions(-) create mode 100644 admin_bulk_mail.php diff --git a/admin_bulk_mail.php b/admin_bulk_mail.php new file mode 100644 index 00000000..9b13959c --- /dev/null +++ b/admin_bulk_mail.php @@ -0,0 +1,148 @@ + + +
+ +
+
+

Bulk Mail

+
+ +
+
+
+ +
+ +
+ +
Email Message
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
Select Contacts
+
+
+
+ + + + + + + + + + + + + + + + + + + + +
+
+ +
+
NameTitleEmail
+
+ +
+
+ + + +
+
+ +
+ +
+ +
+
+
+ +
+ + + + +
+ + \ No newline at end of file diff --git a/client_bulk_mail.php b/client_bulk_mail.php index c7f43fb8..a6ddf359 100644 --- a/client_bulk_mail.php +++ b/client_bulk_mail.php @@ -10,8 +10,8 @@ $sql = mysqli_query($mysqli, "SELECT * FROM contacts ); ?> - -
+ +
@@ -25,19 +25,29 @@ $sql = mysqli_query($mysqli, "SELECT * FROM contacts
- +
Email Message

- +
- +
- +
@@ -45,7 +55,8 @@ $sql = mysqli_query($mysqli, "SELECT * FROM contacts
- +
@@ -70,7 +81,8 @@ $sql = mysqli_query($mysqli, "SELECT * FROM contacts
- +
Name @@ -80,7 +92,7 @@ $sql = mysqli_query($mysqli, "SELECT * FROM contacts - - - -
- -
- - - - - - - - - - + + +
+ +
+ + + + + + + + + +
- +
- +
@@ -129,7 +143,7 @@ $sql = mysqli_query($mysqli, "SELECT * FROM contacts function toggleCheckboxes() { // Get the state of the 'selectAllCheckbox' var selectAllChecked = document.getElementById('selectAllCheckbox').checked; - + // Find all checkboxes with the name 'contact[]' and set their state var checkboxes = document.querySelectorAll('input[type="checkbox"][name="contact[]"]'); checkboxes.forEach(function(checkbox) { @@ -140,4 +154,4 @@ function toggleCheckboxes() { Date: Thu, 15 Feb 2024 22:08:40 +0000 Subject: [PATCH 5/8] Only Special Contacts --- client_bulk_mail.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client_bulk_mail.php b/client_bulk_mail.php index a6ddf359..8ecb8fc0 100644 --- a/client_bulk_mail.php +++ b/client_bulk_mail.php @@ -5,6 +5,10 @@ $sql = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_client_id = $client_id AND contact_archived_at IS NULL AND contact_email != '' + AND ( contact_primary = 1 OR + contact_important = 1 OR + contact_billing = 1 OR + contact_technical = 1 ) ORDER BY contact_primary DESC, contact_important DESC" ); @@ -15,7 +19,7 @@ $sql = mysqli_query($mysqli, "SELECT * FROM contacts
-

Bulk Mail

+

Bulk Mail to Special Contacts

- + diff --git a/client_bulk_mail.php b/client_bulk_mail.php index 8ecb8fc0..41d68cb2 100644 --- a/client_bulk_mail.php +++ b/client_bulk_mail.php @@ -5,10 +5,10 @@ $sql = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_client_id = $client_id AND contact_archived_at IS NULL AND contact_email != '' - AND ( contact_primary = 1 OR + AND (contact_primary = 1 OR contact_important = 1 OR contact_billing = 1 OR - contact_technical = 1 ) + contact_technical = 1) ORDER BY contact_primary DESC, contact_important DESC" ); From 671cdd9832146c47178c832c141988b7c5e84a43 Mon Sep 17 00:00:00 2001 From: o-psi Date: Thu, 15 Feb 2024 22:16:01 +0000 Subject: [PATCH 8/8] Fix filtering to admin bulk mail --- admin_bulk_mail.php | 4 ++++ client_bulk_mail.php | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/admin_bulk_mail.php b/admin_bulk_mail.php index 1185e92e..d2f775b7 100644 --- a/admin_bulk_mail.php +++ b/admin_bulk_mail.php @@ -5,6 +5,10 @@ require_once "inc_all_admin.php"; $sql = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_archived_at IS NULL AND contact_email != '' + AND (contact_primary = 1 OR + contact_important = 1 OR + contact_billing = 1 OR + contact_technical = 1) ORDER BY contact_primary DESC, contact_important DESC" ); diff --git a/client_bulk_mail.php b/client_bulk_mail.php index 41d68cb2..472dd33a 100644 --- a/client_bulk_mail.php +++ b/client_bulk_mail.php @@ -5,10 +5,6 @@ $sql = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_client_id = $client_id AND contact_archived_at IS NULL AND contact_email != '' - AND (contact_primary = 1 OR - contact_important = 1 OR - contact_billing = 1 OR - contact_technical = 1) ORDER BY contact_primary DESC, contact_important DESC" );