1 Commits

Author SHA1 Message Date
Johnny
16ab6144f9 Revert "Update folder_create_modal.php" 2025-03-01 12:12:44 -05:00
629 changed files with 6838 additions and 131602 deletions

1
.gitignore vendored
View File

@@ -26,4 +26,3 @@ xcustom/*
!xcustom/readme.php !xcustom/readme.php
post/xcustom post/xcustom
!post/xcustom/readme.php !post/xcustom/readme.php
.zed

View File

@@ -2,139 +2,31 @@
This file documents all notable changes made to ITFlow. This file documents all notable changes made to ITFlow.
## [25.03]
### Fixed
- Resolved missing attachments in ticket replies processed via the email parser.
- Fixed issue where the top half of portrait image uploads appeared cut off at the bottom.
- Ensured all tables and fields use `CHARACTER SET utf8mb4` and `COLLATE utf8mb4_general_ci` for updates and new installations.
- Converted `service_domains` table to use InnoDB instead of MyISAM.
- Fixed the initials function to properly handle UTF-8 characters, preventing contact-related issues.
- Interfaces can now start with `0`.
- Adjusted AI prompt handling to focus solely on content, avoiding unnecessary additions.
### Added / Changed
- Introduced bulk delete functionality for assets.
- Added the ability to redact ticket replies after a ticket is closed.
- Added support for redacting specific text while a ticket is open.
- Switched file upload hashing from SHA256 to MD5 to significantly improve performance.
- Enabled assigning multiple assets to a single ticket.
- Updated all many-to-many tables to support cascading deletes using foreign key associations, improving efficiency, performance, and data integrity.
- Enabled caching for AJAX modals to reduce repeated reloads and enhance browser performance.
- Upgraded DataTables from 2.2.1 to 2.2.2.
- Upgraded TinyMCE from 7.6.1 to 7.7.1, providing a significant performance boost.
- Added “Copy Credentials to Clipboard” button in AJAX asset and contact views.
- Renamed and reorganized several tables.
- Improved theme color organization by grouping primary colors and their related shades.
- Displayed a user icon next to contacts who have user accounts.
- New image uploads are now converted to optimized `.webp` format by default; original files are no longer saved. Existing images remain unchanged.
- Added international phone number support throughout the system.
- Introduced user signatures in preferences, which are now appended to all ticket replies.
- Optimized search filters to only display defined tags.
- Added “Projects” to the client-side navigation.
- Enabled “Create New Ticket” from within project details.
- Reintroduced batch payment functionality in client invoices.
- Included client abbreviations in both client and global search options.
- Added assigned software license details (User/Asset) to the client PDF export.
- Replaced client-side `pdfMake` with the PHP-based `TCPDF` library for generating client export runbooks.
- Introduced the ability to download documents as PDFs.
- Added a “Reference” field to tickets and invoices generated from recurring templates (not yet in active use).
### Breaking Changes
> **Important:** To update to this version, you **must** run the following commands from the command line from the scripts directory:
>
> ```bash
> php update_cli.php
> php update_cli.php --db_update
> ```
>
> Repeat `--db_update` until no further updates are found.
>
> **Back up your system before upgrading.**
> This version includes numerous backend changes critical for future development.
## [25.02.4]
### Fixed
- Resolved issue preventing the addition or editing of licenses when no vendor was selected.
- Fixed several undeclared variables in AJAX contact details.
- Corrected the contact ticket count display.
- Addressed an issue where clicking "More Details" in AJAX contact/asset details failed to include the `client_id` in the URL.
- Fixed an issue with recurring invoices in the client URL: clicking "Inactive" or "Active" would unexpectedly navigate away from the client section.
- Added new php function getFieldById() to return a record using just an id and sanitized as well.
## [25.02.3]
### Fixed
- Fixed notifications being reversed as dismissed notifications.
## [25.02.2]
### Fixed
- Corrected some edit modals not showing notes correctly.
- Bugfix: When exporting to CSV, the first asset wasn't being shown.
- Fix broken create / edit credentials.
- Fixed missing Notificatons link.
- Fixed a few dead links.
- Fixed Overdue count also counting Non-Billable Invoices.
- Fix Edit Client Notes.
### Added / Changed
- Implemented SSL certificate history tracking.
- Added Inactive / Active Filter to Recurring Invoices.
- Merged Dismissed notifications and notification in one.
- Added Link Button to addd / edit Document WYSIWYG.
- Added Physical location to the asset export / import.
## [25.02.1]
### Fixed
- Resolved broken links in the client overview, project and client listings, and rack details.
- Corrected asset transfer functionality to clients.
- Fixed the ticket scheduling redirect.
- Corrected the ticket link in the Scheduled Ticket Agent Notification email.
- Addressed issues with credentials and ticket actions in the Contact Detail Modal.
- Fixed text wrapping in notifications.
- Adjusted notifications so that they are sorted with the newest first.
- Fixed drag-and-drop functionality for tickets in the Kanban view on mobile devices.
- Resolved a weird issue with TinyMCE that prevented using links referencing your ITFlow instance url.
- Corrected image orientation issues during upload and the preview optimization process.
### Added / Changed
- Introduced entity link indicator icons and counts in the contacts and credentials section.
- Implemented a fade animation for the new AJAX modal.
- Removed the Client Overview Expire Day Select and replaced it with simplified 1, 7, or 45-day options.
- Added the ability to link and unlink entities within asset details.
- Introduced quick tag/category creation across the app.
- Added a Vendor Quick Details Modal.
- Enabled vendor linking and added a License Purchase Reference in the Software Licenses section.
- Added download original, optimized and thumbnail option for images.
- Added Paid status to the top corner of Invoice PDFs.
## [25.02] ## [25.02]
### Fixed ### Fixed
- Migrated several reports to the new permissions/roles system. - Migrated several reports to the new permissions/roles system
- Resolved issue with empty task box showing for closed/resolved tickets. - Resolved issue with empty task box showing for closed/resolved tickets
- Corrected ticket priority sorting. - Corrected ticket priority sorting
- Cloned asset interfaces when transferring assets between clients. - Cloned asset interfaces when transferring assets between clients
### Added / Changed ### Added / Changed
- Restored max number of records per page option back to 500 since we dont have repeating modals. - Restored max number of records per page option back to 500 since we dont have repeating modals.
- Bulk Categorize Tickets feature. - Bulk Categorize Tickets feature
- Renamed "Interface port" to "Interface Description." "Interface Name" should now refer to port name and/or number. - Renamed "Interface port" to "Interface Description." "Interface Name" should now refer to port name and/or number
- Changed "Transfer Asset to Client" from a single action to a bulk action. - Changed "Transfer Asset to Client" from a single action to a bulk action
- Updated Filter Footer UI to show "Showing x to x of x records" instead of just the total records. - Updated Filter Footer UI to show "Showing x to x of x records" instead of just the total records
- Added Client Overview section to view client assets, contacts, licenses, credentials, etc. - Added Client Overview section to view client assets, contacts, licenses, credentials, etc.
- Introduced Quick Peek for asset details, contact information, and document viewing throughout the ITFlow App, all made possible by AJAX. - Introduced Quick Peek for asset details, contact information, and document viewing throughout the ITFlow App, all made possible by AJAX
- Enabled Simple Drag-and-Drop Ordering for Invoices, Recurring Invoices, Quotes, Ticket Tasks, and Ticket Template Tasks. - Enabled Simple Drag-and-Drop Ordering for Invoices, Recurring Invoices, Quotes, Ticket Tasks, and Ticket Template Tasks
- Added new Ticket View options: Kanban and Simple View. - Added new Ticket View options: Kanban and Simple View
- Migrated all repeating modals to the new AJAX modal function for faster loading times and quicker development. - Migrated all repeating modals to the new AJAX modal function for faster loading times and quicker development
- Allowed clients to upload PDF documents to accepted quotes. - Allowed clients to upload PDF documents to accepted quotes
- Client Portal now shows ticket category. - Client Portal now shows ticket category
- Custom links can now be added to the Client Portal navbar. - Custom links can now be added to the Client Portal navbar
- Lots of little tweaks to UI, performance, bugs, etc. - Lots of little tweaks to UI, performance, bugs, etc.
### Breaking Changes ### Breaking Changes
- Cron scripts have officially been moved to the /scripts folder and are no longer in the root directory; they must be updated to function properly. - Cron scripts have officially been moved to the /scripts folder and are no longer in the root directory; they must be updated to function properly
## [25.01.3] ## [25.01.3]
### Fixed ### Fixed

View File

@@ -1,7 +1,7 @@
<?php <?php
// Default Column Sortby Filter // Default Column Sortby Filter
$sort = "role_is_admin"; $sort = "user_role_is_admin";
$order = "DESC"; $order = "DESC";
require_once "includes/inc_all_admin.php"; require_once "includes/inc_all_admin.php";
@@ -13,8 +13,8 @@ $url_query_strings_sort = http_build_query($get_copy);
$sql = mysqli_query( $sql = mysqli_query(
$mysqli, $mysqli,
"SELECT SQL_CALC_FOUND_ROWS * FROM user_roles "SELECT SQL_CALC_FOUND_ROWS * FROM user_roles
WHERE (role_name LIKE '%$q%' OR role_description LIKE '%$q%') WHERE (user_roles.user_role_name LIKE '%$q%' OR user_roles.user_role_description LIKE '%$q%')
AND role_archived_at IS NULL AND user_roles.user_role_archived_at IS NULL
ORDER BY $sort $order LIMIT $record_from, $record_to" ORDER BY $sort $order LIMIT $record_from, $record_to"
); );
@@ -53,14 +53,14 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<thead class="text-dark <?php if ($num_rows[0] == 0) { echo "d-none"; } ?>"> <thead class="text-dark <?php if ($num_rows[0] == 0) { echo "d-none"; } ?>">
<tr> <tr>
<th> <th>
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=role_name&order=<?php echo $disp; ?>"> <a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=user_role_name&order=<?php echo $disp; ?>">
Role <?php if ($sort == 'role_name') { echo $order_icon; } ?> Role <?php if ($sort == 'user_role_name') { echo $order_icon; } ?>
</a> </a>
</th> </th>
<th>Members</th> <th>Members</th>
<th> <th>
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=role_is_admin&order=<?php echo $disp; ?>"> <a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=user_role_is_admin&order=<?php echo $disp; ?>">
Admin <?php if ($sort == 'role_is_admin') { echo $order_icon; } ?> Admin <?php if ($sort == 'user_role_is_admin') { echo $order_icon; } ?>
</a> </a>
</th> </th>
<th class="text-center">Action</th> <th class="text-center">Action</th>
@@ -70,17 +70,17 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<?php <?php
while ($row = mysqli_fetch_array($sql)) { while ($row = mysqli_fetch_array($sql)) {
$role_id = intval($row['role_id']); $role_id = intval($row['user_role_id']);
$role_name = nullable_htmlentities($row['role_name']); $role_name = nullable_htmlentities($row['user_role_name']);
$role_description = nullable_htmlentities($row['role_description']); $role_description = nullable_htmlentities($row['user_role_description']);
$role_admin = intval($row['role_is_admin']); $role_admin = intval($row['user_role_is_admin']);
$role_archived_at = nullable_htmlentities($row['role_archived_at']); $role_archived_at = nullable_htmlentities($row['user_role_archived_at']);
// Count number of users that have each role // Count number of users that have each role
$sql_role_user_count = mysqli_query($mysqli, "SELECT COUNT(user_id) FROM users WHERE user_role_id = $role_id AND user_archived_at IS NULL"); $sql_role_user_count = mysqli_query($mysqli, "SELECT COUNT(users.user_id) FROM users LEFT JOIN user_settings on users.user_id = user_settings.user_id WHERE user_role = $role_id AND user_archived_at IS NULL");
$role_user_count = mysqli_fetch_row($sql_role_user_count)[0]; $role_user_count = mysqli_fetch_row($sql_role_user_count)[0];
$sql_users = mysqli_query($mysqli, "SELECT * FROM users WHERE user_role_id = $role_id AND user_archived_at IS NULL"); $sql_users = mysqli_query($mysqli, "SELECT * FROM users LEFT JOIN user_settings on users.user_id = user_settings.user_id WHERE user_role = $role_id AND user_archived_at IS NULL");
// Initialize an empty array to hold user names // Initialize an empty array to hold user names
$user_names = []; $user_names = [];
@@ -90,7 +90,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
} }
// Convert the array of user names to a comma-separated string // Convert the array of user names to a comma-separated string
$user_names_string = implode(",", $user_names); $user_names_string = implode(",", $user_names) ;
if (empty($user_names_string)) { if (empty($user_names_string)) {
$user_names_string = "-"; $user_names_string = "-";

View File

@@ -12,8 +12,7 @@ $company_address = nullable_htmlentities($row['company_address']);
$company_city = nullable_htmlentities($row['company_city']); $company_city = nullable_htmlentities($row['company_city']);
$company_state = nullable_htmlentities($row['company_state']); $company_state = nullable_htmlentities($row['company_state']);
$company_zip = nullable_htmlentities($row['company_zip']); $company_zip = nullable_htmlentities($row['company_zip']);
$company_phone_country_code = formatPhoneNumber($row['company_phone_country_code']); $company_phone = formatPhoneNumber($row['company_phone']);
$company_phone = nullable_htmlentities(formatPhoneNumber($row['company_phone'], $company_phone_country_code));
$company_email = nullable_htmlentities($row['company_email']); $company_email = nullable_htmlentities($row['company_email']);
$company_website = nullable_htmlentities($row['company_website']); $company_website = nullable_htmlentities($row['company_website']);
$company_logo = nullable_htmlentities($row['company_logo']); $company_logo = nullable_htmlentities($row['company_logo']);
@@ -111,18 +110,13 @@ $company_initials = nullable_htmlentities(initials($company_name));
</div> </div>
</div> </div>
<label>Phone</label> <div class="form-group">
<div class="form-row"> <label>Phone</label>
<div class="col-9"> <div class="input-group">
<div class="form-group"> <div class="input-group-prepend">
<div class="input-group"> <span class="input-group-text"><i class="fa fa-fw fa-phone"></i></span>
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-phone"></i></span>
</div>
<input type="tel" class="form-control col-2" name="phone_country_code" value="+<?php echo $company_phone_country_code; ?>" placeholder="Code" maxlength="4">
<input type="tel" class="form-control" name="phone" value="<?php echo $company_phone; ?>" placeholder="Phone Number" maxlength="200">
</div>
</div> </div>
<input type="text" class="form-control" name="phone" placeholder="Phone Number" value="<?php echo $company_phone; ?>">
</div> </div>
</div> </div>
@@ -158,3 +152,4 @@ $company_initials = nullable_htmlentities(initials($company_name));
<?php <?php
require_once "includes/footer.php"; require_once "includes/footer.php";

View File

@@ -218,6 +218,28 @@ require_once "includes/inc_all_admin.php";
</div> </div>
</div> </div>
<div class="form-group">
<label>Phone Mask</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-phone"></i></span>
</div>
<select class="form-control select2" name="phone_mask">
<?php
$sql = mysqli_query($mysqli, "SELECT config_phone_mask FROM settings WHERE company_id = 1");
while ($row = mysqli_fetch_array($sql)) {
$phone_mask = intval($row['config_phone_mask']);
} ?>
<option <?php if ($phone_mask == 1) { echo "selected"; }?> value=1>
US Format - e.g. (412) 888-9999
</option>
<option <?php if ($phone_mask == 0) { echo "selected"; }?> value=0>
Non-US Format - e.g. 4128889999
</option>
</select>
</div>
</div>
<hr> <hr>
<button type="submit" name="edit_default_settings" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Save</button> <button type="submit" name="edit_default_settings" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Save</button>

View File

@@ -77,7 +77,7 @@ require_once "includes/inc_all_admin.php";
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-barcode"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-barcode"></i></span>
</div> </div>
<input type="text" class="form-control" name="config_recurring_invoice_prefix" placeholder="Recurring Invoice Prefix" value="<?php echo nullable_htmlentities($config_recurring_invoice_prefix); ?>" required> <input type="text" class="form-control" name="config_recurring_prefix" placeholder="Recurring Prefix" value="<?php echo nullable_htmlentities($config_recurring_prefix); ?>" required>
</div> </div>
</div> </div>
@@ -87,7 +87,7 @@ require_once "includes/inc_all_admin.php";
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-barcode"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-barcode"></i></span>
</div> </div>
<input type="number" min="0" class="form-control" name="config_recurring_invoice_next_number" placeholder="Next Recurring Invoice Number" value="<?php echo intval($config_recurring_invoice_next_number); ?>" required> <input type="number" min="0" class="form-control" name="config_recurring_next_number" placeholder="Next Recurring Number" value="<?php echo intval($config_recurring_next_number); ?>" required>
</div> </div>
</div> </div>

View File

@@ -37,7 +37,7 @@ require_once "includes/inc_all_admin.php";
<th> <th>
<div><i class="fas fa-fw fa-globe mr-2"></i>Domain Expiration Notice</div> <div><i class="fas fa-fw fa-globe mr-2"></i>Domain Expiration Notice</div>
<small class="text-muted"> <small class="text-muted">
(This setting triggers a notification when a domain is approaching its expiration date, specifically at 1, 7 and 45 days prior to expiry.) (This setting triggers a notification when a domain is approaching its expiration date, specifically at 1, 7, 14, 30 and 90 days prior to expiry.)
</small> </small>
</th> </th>
<td> <td>
@@ -54,7 +54,7 @@ require_once "includes/inc_all_admin.php";
<th> <th>
<div><i class="fas fa-fw fa-lock mr-2"></i>Certificate Expiration Notice</div> <div><i class="fas fa-fw fa-lock mr-2"></i>Certificate Expiration Notice</div>
<small class="text-muted"> <small class="text-muted">
(This setting triggers a notification when a certificate is approaching its expiration date, specifically at 1, 7 and 45 days prior to expiry.) (This setting triggers a notification when a certificate is approaching its expiration date, specifically at 1, 7, 14, 30 and 90 days prior to expiry.)
</small> </small>
</th> </th>
<td> <td>
@@ -67,7 +67,7 @@ require_once "includes/inc_all_admin.php";
<th> <th>
<div><i class="fas fa-fw fa-desktop mr-2"></i>Asset Warranty Expiration Notice</div> <div><i class="fas fa-fw fa-desktop mr-2"></i>Asset Warranty Expiration Notice</div>
<small class="text-muted"> <small class="text-muted">
(This setting triggers a notification when an asset is approaching its expiration date, specifically at 1, 7 and 45 days prior to expiry.) (This setting triggers a notification when an asset is approaching its expiration date, specifically at 1, 7, 14, 30 and 90 days prior to expiry.)
</small> </small>
</th> </th>
<td> <td>

View File

@@ -19,7 +19,7 @@ require_once "includes/inc_all_admin.php";
?> ?>
<div class="col-4 text-center mb-3"> <div class="col-3 text-center mb-3">
<div class="form-group"> <div class="form-group">
<div class="custom-control custom-radio"> <div class="custom-control custom-radio">
<input class="custom-control-input" type="radio" onchange="this.form.submit()" id="customRadio<?php echo $theme_color; ?>" name="edit_theme_settings" value="<?php echo $theme_color; ?>" <?php if ($config_theme == $theme_color) { echo "checked"; } ?>> <input class="custom-control-input" type="radio" onchange="this.form.submit()" id="customRadio<?php echo $theme_color; ?>" name="edit_theme_settings" value="<?php echo $theme_color; ?>" <?php if ($config_theme == $theme_color) { echo "checked"; } ?>>

View File

@@ -6,13 +6,16 @@ $order = "ASC";
require_once "includes/inc_all_admin.php"; require_once "includes/inc_all_admin.php";
//Rebuild URL
$url_query_strings_sort = http_build_query($get_copy);
$sql = mysqli_query( $sql = mysqli_query(
$mysqli, $mysqli,
"SELECT SQL_CALC_FOUND_ROWS * FROM users "SELECT SQL_CALC_FOUND_ROWS * FROM users, user_settings, user_roles
LEFT JOIN user_roles ON user_role_id = role_id WHERE users.user_id = user_settings.user_id
LEFT JOIN user_settings ON users.user_id = user_settings.user_id AND user_settings.user_role = user_roles.user_role_id
WHERE (user_name LIKE '%$q%' OR user_email LIKE '%$q%') AND (user_name LIKE '%$q%' OR user_email LIKE '%$q%')
AND user_type = 1
AND user_archived_at IS NULL AND user_archived_at IS NULL
ORDER BY $sort $order LIMIT $record_from, $record_to" ORDER BY $sort $order LIMIT $record_from, $record_to"
); );
@@ -33,7 +36,6 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<div class="dropdown-menu"> <div class="dropdown-menu">
<!--<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#userInviteModal"><i class="fas fa-paper-plane mr-2"></i>Invite User</a>--> <!--<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#userInviteModal"><i class="fas fa-paper-plane mr-2"></i>Invite User</a>-->
<?php if ($num_rows[0] > 1) { ?> <?php if ($num_rows[0] > 1) { ?>
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#exportUserModal"><i class="fa fa-fw fa-download mr-2"></i>Export</a>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item text-danger" href="#" data-toggle="modal" data-target="#resetAllUserPassModal"><i class="fas fa-skull-crossbones mr-2"></i>IR</a> <a class="dropdown-item text-danger" href="#" data-toggle="modal" data-target="#resetAllUserPassModal"><i class="fas fa-skull-crossbones mr-2"></i>IR</a>
<?php } ?> <?php } ?>
@@ -53,6 +55,9 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
</div> </div>
</div> </div>
<div class="col-md-8"> <div class="col-md-8">
<div class="float-right">
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#exportUserModal"><i class="fa fa-fw fa-download mr-2"></i>Export</button>
</div>
</div> </div>
</div> </div>
</form> </form>
@@ -72,8 +77,8 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
</a> </a>
</th> </th>
<th> <th>
<a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=role_name&order=<?php echo $disp; ?>"> <a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=user_role&order=<?php echo $disp; ?>">
Role <?php if ($sort == 'role_name') { echo $order_icon; } ?> Role <?php if ($sort == 'user_role') { echo $order_icon; } ?>
</a> </a>
</th> </th>
<th> <th>
@@ -111,8 +116,8 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
$mfa_status_display = "<i class='fas fa-fw fa-lock text-success'></i>"; $mfa_status_display = "<i class='fas fa-fw fa-lock text-success'></i>";
} }
$user_config_force_mfa = intval($row['user_config_force_mfa']); $user_config_force_mfa = intval($row['user_config_force_mfa']);
$user_role = intval($row['user_role_id']); $user_role = $row['user_role'];
$user_role_display = nullable_htmlentities($row['role_name']); $user_role_display = nullable_htmlentities($row['user_role_name']);
$user_initials = nullable_htmlentities(initials($user_name)); $user_initials = nullable_htmlentities(initials($user_name));
$sql_last_login = mysqli_query( $sql_last_login = mysqli_query(
@@ -134,7 +139,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
} }
// Get User Client Access Permissions // Get User Client Access Permissions
$user_client_access_sql = mysqli_query($mysqli,"SELECT client_id FROM user_client_permissions WHERE user_id = $user_id"); $user_client_access_sql = mysqli_query($mysqli,"SELECT client_id FROM user_permissions WHERE user_id = $user_id");
$client_access_array = []; $client_access_array = [];
while ($row = mysqli_fetch_assoc($user_client_access_sql)) { while ($row = mysqli_fetch_assoc($user_client_access_sql)) {
$client_access_array[] = intval($row['client_id']); $client_access_array[] = intval($row['client_id']);

View File

@@ -8,7 +8,7 @@
require_once "config.php"; require_once "config.php";
require_once "functions.php"; require_once "functions.php";
require_once "includes/check_login.php"; require_once "check_login.php";
require_once "plugins/totp/totp.php"; require_once "plugins/totp/totp.php";
/* /*
@@ -165,7 +165,7 @@ if (isset($_GET['ticket_query_views'])) {
} }
/* /*
* Generates public/guest links for sharing credentials/docs * Generates public/guest links for sharing logins/docs
*/ */
if (isset($_GET['share_generate_link'])) { if (isset($_GET['share_generate_link'])) {
enforceUserPermission('module_support', 2); enforceUserPermission('module_support', 2);
@@ -207,23 +207,23 @@ if (isset($_GET['share_generate_link'])) {
$item_name = sanitizeInput($row['file_name']); $item_name = sanitizeInput($row['file_name']);
} }
if ($item_type == "Credential") { if ($item_type == "Login") {
$credential = mysqli_query($mysqli, "SELECT credential_name, credential_username, credential_password FROM credentials WHERE credential_id = $item_id AND credential_client_id = $client_id LIMIT 1"); $login = mysqli_query($mysqli, "SELECT login_name, login_username, login_password FROM logins WHERE login_id = $item_id AND login_client_id = $client_id LIMIT 1");
$row = mysqli_fetch_array($credential); $row = mysqli_fetch_array($login);
$item_name = sanitizeInput($row['credential_name']); $item_name = sanitizeInput($row['login_name']);
// Decrypt & re-encrypt username/password for sharing // Decrypt & re-encrypt username/password for sharing
$credential_encryption_key = randomString(); $login_encryption_key = randomString();
$credential_username_cleartext = decryptCredentialEntry($row['credential_username']); $login_username_cleartext = decryptLoginEntry($row['login_username']);
$iv = randomString(); $iv = randomString();
$username_ciphertext = openssl_encrypt($credential_username_cleartext, 'aes-128-cbc', $credential_encryption_key, 0, $iv); $username_ciphertext = openssl_encrypt($login_username_cleartext, 'aes-128-cbc', $login_encryption_key, 0, $iv);
$item_encrypted_username = $iv . $username_ciphertext; $item_encrypted_username = $iv . $username_ciphertext;
$credential_password_cleartext = decryptCredentialEntry($row['credential_password']); $login_password_cleartext = decryptLoginEntry($row['login_password']);
$iv = randomString(); $iv = randomString();
$password_ciphertext = openssl_encrypt($credential_password_cleartext, 'aes-128-cbc', $credential_encryption_key, 0, $iv); $password_ciphertext = openssl_encrypt($login_password_cleartext, 'aes-128-cbc', $login_encryption_key, 0, $iv);
$item_encrypted_credential = $iv . $password_ciphertext; $item_encrypted_credential = $iv . $password_ciphertext;
} }
@@ -232,8 +232,8 @@ if (isset($_GET['share_generate_link'])) {
$share_id = $mysqli->insert_id; $share_id = $mysqli->insert_id;
// Return URL // Return URL
if ($item_type == "Credential") { if ($item_type == "Login") {
$url = "https://$config_base_url/guest/guest_view_item.php?id=$share_id&key=$item_key&ek=$credential_encryption_key"; $url = "https://$config_base_url/guest/guest_view_item.php?id=$share_id&key=$item_key&ek=$login_encryption_key";
} }
else { else {
$url = "https://$config_base_url/guest/guest_view_item.php?id=$share_id&key=$item_key"; $url = "https://$config_base_url/guest/guest_view_item.php?id=$share_id&key=$item_key";
@@ -242,7 +242,7 @@ if (isset($_GET['share_generate_link'])) {
$sql = mysqli_query($mysqli,"SELECT * FROM companies WHERE company_id = 1"); $sql = mysqli_query($mysqli,"SELECT * FROM companies WHERE company_id = 1");
$row = mysqli_fetch_array($sql); $row = mysqli_fetch_array($sql);
$company_name = sanitizeInput($row['company_name']); $company_name = sanitizeInput($row['company_name']);
$company_phone = sanitizeInput(formatPhoneNumber($row['company_phone'], $row['company_phone_country_code'])); $company_phone = sanitizeInput(formatPhoneNumber($row['company_phone']));
// Sanitize Config vars from get_settings.php // Sanitize Config vars from get_settings.php
$config_ticket_from_name = sanitizeInput($config_ticket_from_name); $config_ticket_from_name = sanitizeInput($config_ticket_from_name);
@@ -333,24 +333,24 @@ if (isset($_GET['get_client_contacts'])) {
if (isset($_GET['get_totp_token_via_id'])) { if (isset($_GET['get_totp_token_via_id'])) {
enforceUserPermission('module_credential'); enforceUserPermission('module_credential');
$credential_id = intval($_GET['credential_id']); $login_id = intval($_GET['login_id']);
$sql = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT credential_name, credential_otp_secret, credential_client_id FROM credentials WHERE credential_id = $credential_id")); $sql = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT login_name, login_otp_secret, login_client_id FROM logins WHERE login_id = $login_id"));
$name = sanitizeInput($sql['credential_name']); $name = sanitizeInput($sql['login_name']);
$totp_secret = $sql['credential_otp_secret']; $totp_secret = $sql['login_otp_secret'];
$client_id = intval($sql['credential_client_id']); $client_id = intval($sql['login_client_id']);
$otp = TokenAuth6238::getTokenCode(strtoupper($totp_secret)); $otp = TokenAuth6238::getTokenCode(strtoupper($totp_secret));
echo json_encode($otp); echo json_encode($otp);
// Logging // Logging
// Only log the TOTP view if the user hasn't already viewed this specific login entry recently, this prevents logs filling if a user hovers across an entry a few times // Only log the TOTP view if the user hasn't already viewed this specific login entry recently, this prevents logs filling if a user hovers across an entry a few times
$check_recent_totp_view_logged_sql = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT(log_id) AS recent_totp_view FROM logs WHERE log_type = 'Credential' AND log_action = 'View TOTP' AND log_user_id = $session_user_id AND log_entity_id = $credential_id AND log_client_id = $client_id AND log_created_at > (NOW() - INTERVAL 5 MINUTE)")); $check_recent_totp_view_logged_sql = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT(log_id) AS recent_totp_view FROM logs WHERE log_type = 'Login' AND log_action = 'View TOTP' AND log_user_id = $session_user_id AND log_entity_id = $login_id AND log_client_id = $client_id AND log_created_at > (NOW() - INTERVAL 5 MINUTE)"));
$recent_totp_view_logged_count = intval($check_recent_totp_view_logged_sql['recent_totp_view']); $recent_totp_view_logged_count = intval($check_recent_totp_view_logged_sql['recent_totp_view']);
if ($recent_totp_view_logged_count == 0) { if ($recent_totp_view_logged_count == 0) {
// Logging // Logging
logAction("Credential", "View TOTP", "$session_name viewed credential TOTP code for $name", $client_id, $credential_id); logAction("Credential", "View TOTP", "$session_name viewed credential TOTP code for $name", $client_id, $login_id);
} }
} }
@@ -444,10 +444,10 @@ if (isset($_POST['update_kanban_ticket'])) {
$config_base_url = sanitizeInput($config_base_url); $config_base_url = sanitizeInput($config_base_url);
// Get Company Info // Get Company Info
$sql = mysqli_query($mysqli, "SELECT company_name, company_phone, company_phone_country_code FROM companies WHERE company_id = 1"); $sql = mysqli_query($mysqli, "SELECT company_name, company_phone FROM companies WHERE company_id = 1");
$row = mysqli_fetch_array($sql); $row = mysqli_fetch_array($sql);
$company_name = sanitizeInput($row['company_name']); $company_name = sanitizeInput($row['company_name']);
$company_phone = sanitizeInput(formatPhoneNumber($row['company_phone'], $row['company_phone_country_code'])); $company_phone = sanitizeInput(formatPhoneNumber($row['company_phone']));
// EMAIL // EMAIL
$subject = "Ticket resolved - [$ticket_prefix$ticket_number] - $ticket_subject | (pending closure)"; $subject = "Ticket resolved - [$ticket_prefix$ticket_number] - $ticket_subject | (pending closure)";
@@ -599,3 +599,4 @@ if (isset($_POST['update_recurring_invoice_items_order'])) {
echo json_encode(['status' => 'success']); echo json_encode(['status' => 'success']);
exit; exit;
} }

View File

@@ -50,7 +50,6 @@ $device_icon = getAssetIcon($asset_type);
$contact_name = nullable_htmlentities($row['contact_name']); $contact_name = nullable_htmlentities($row['contact_name']);
$contact_email = nullable_htmlentities($row['contact_email']); $contact_email = nullable_htmlentities($row['contact_email']);
$contact_phone = nullable_htmlentities($row['contact_phone']); $contact_phone = nullable_htmlentities($row['contact_phone']);
$contact_extension = nullable_htmlentities($row['contact_extension']);
$contact_mobile = nullable_htmlentities($row['contact_mobile']); $contact_mobile = nullable_htmlentities($row['contact_mobile']);
$contact_archived_at = nullable_htmlentities($row['contact_archived_at']); $contact_archived_at = nullable_htmlentities($row['contact_archived_at']);
if ($contact_archived_at) { if ($contact_archived_at) {
@@ -112,53 +111,48 @@ $interface_count = mysqli_num_rows($sql_related_interfaces);
// Related Credentials Query // Related Credentials Query
$sql_related_credentials = mysqli_query($mysqli, " $sql_related_credentials = mysqli_query($mysqli, "
SELECT SELECT
credentials.credential_id AS credential_id, logins.login_id AS login_id,
credentials.credential_name, logins.login_name,
credentials.credential_description, logins.login_description,
credentials.credential_uri, logins.login_uri,
credentials.credential_username, logins.login_username,
credentials.credential_password, logins.login_password,
credentials.credential_otp_secret, logins.login_otp_secret,
credentials.credential_note, logins.login_note,
credentials.credential_important, logins.login_important,
credentials.credential_contact_id, logins.login_contact_id,
credentials.credential_asset_id logins.login_vendor_id,
FROM credentials logins.login_asset_id,
LEFT JOIN credential_tags ON credential_tags.credential_id = credentials.credential_id logins.login_software_id
LEFT JOIN tags ON tags.tag_id = credential_tags.tag_id FROM logins
WHERE credential_asset_id = $asset_id LEFT JOIN login_tags ON login_tags.login_id = logins.login_id
AND credential_archived_at IS NULL LEFT JOIN tags ON tags.tag_id = login_tags.tag_id
GROUP BY credentials.credential_id WHERE login_asset_id = $asset_id
ORDER BY credential_name DESC AND login_archived_at IS NULL
GROUP BY logins.login_id
ORDER BY login_name DESC
"); ");
$credential_count = mysqli_num_rows($sql_related_credentials); $credential_count = mysqli_num_rows($sql_related_credentials);
// Related Tickets Query // Related Tickets Query
$sql_related_tickets = mysqli_query($mysqli, " $sql_related_tickets = mysqli_query($mysqli, "SELECT * FROM tickets
SELECT tickets.*, users.*, ticket_statuses.* LEFT JOIN users on ticket_assigned_to = user_id
FROM tickets
LEFT JOIN users ON ticket_assigned_to = user_id
LEFT JOIN ticket_statuses ON ticket_status_id = ticket_status LEFT JOIN ticket_statuses ON ticket_status_id = ticket_status
LEFT JOIN ticket_assets ON tickets.ticket_id = ticket_assets.ticket_id WHERE ticket_asset_id = $asset_id
WHERE ticket_asset_id = $asset_id OR ticket_assets.asset_id = $asset_id ORDER BY ticket_number DESC"
GROUP BY tickets.ticket_id );
ORDER BY ticket_number DESC
");
$ticket_count = mysqli_num_rows($sql_related_tickets); $ticket_count = mysqli_num_rows($sql_related_tickets);
// Related Recurring Tickets Query // Related Recurring Tickets Query
$sql_related_recurring_tickets = mysqli_query($mysqli, "SELECT * FROM recurring_tickets $sql_related_recurring_tickets = mysqli_query($mysqli, "SELECT * FROM scheduled_tickets
LEFT JOIN recurring_ticket_assets ON recurring_tickets.recurring_ticket_id = recurring_ticket_assets.recurring_ticket_id WHERE scheduled_ticket_asset_id = $asset_id
WHERE recurring_ticket_asset_id = $asset_id OR recurring_ticket_assets.asset_id = $asset_id ORDER BY scheduled_ticket_next_run DESC"
GROUP BY recurring_tickets.recurring_ticket_id
ORDER BY recurring_ticket_next_run DESC"
); );
$recurring_ticket_count = mysqli_num_rows($sql_related_recurring_tickets); $recurring_ticket_count = mysqli_num_rows($sql_related_recurring_tickets);
// Related Documents // Related Documents
$sql_related_documents = mysqli_query($mysqli, "SELECT * FROM asset_documents $sql_related_documents = mysqli_query($mysqli, "SELECT * FROM asset_documents
LEFT JOIN documents ON asset_documents.document_id = documents.document_id LEFT JOIN documents ON asset_documents.document_id = documents.document_id
LEFT JOIN users ON user_id = document_created_by
WHERE asset_documents.asset_id = $asset_id WHERE asset_documents.asset_id = $asset_id
AND document_archived_at IS NULL AND document_archived_at IS NULL
ORDER BY document_name DESC" ORDER BY document_name DESC"
@@ -454,69 +448,70 @@ ob_start();
<?php <?php
while ($row = mysqli_fetch_array($sql_related_credentials)) { while ($row = mysqli_fetch_array($sql_related_credentials)) {
$credential_id = intval($row['credential_id']); $login_id = intval($row['login_id']);
$credential_name = nullable_htmlentities($row['credential_name']); $login_name = nullable_htmlentities($row['login_name']);
$credential_description = nullable_htmlentities($row['credential_description']); $login_description = nullable_htmlentities($row['login_description']);
$credential_uri = nullable_htmlentities($row['credential_uri']); $login_uri = nullable_htmlentities($row['login_uri']);
if (empty($credential_uri)) { if (empty($login_uri)) {
$credential_uri_display = "-"; $login_uri_display = "-";
} else { } else {
$credential_uri_display = "$credential_uri"; $login_uri_display = "$login_uri";
} }
$credential_username = nullable_htmlentities(decryptCredentialEntry($row['credential_username'])); $login_username = nullable_htmlentities(decryptLoginEntry($row['login_username']));
if (empty($credential_username)) { if (empty($login_username)) {
$credential_username_display = "-"; $login_username_display = "-";
} else { } else {
$credential_username_display = "$credential_username <button type='button' class='btn btn-sm clipboardjs' data-clipboard-text='$credential_username'><i class='far fa-copy text-secondary'></i></button>"; $login_username_display = "$login_username";
} }
$credential_password = nullable_htmlentities(decryptCredentialEntry($row['credential_password'])); $login_password = nullable_htmlentities(decryptLoginEntry($row['login_password']));
$credential_otp_secret = nullable_htmlentities($row['credential_otp_secret']); $login_otp_secret = nullable_htmlentities($row['login_otp_secret']);
$credential_id_with_secret = '"' . $row['credential_id'] . '","' . $row['credential_otp_secret'] . '"'; $login_id_with_secret = '"' . $row['login_id'] . '","' . $row['login_otp_secret'] . '"';
if (empty($credential_otp_secret)) { if (empty($login_otp_secret)) {
$otp_display = "-"; $otp_display = "-";
} else { } else {
$otp_display = "<span onmouseenter='showOTPViaCredentialID($credential_id)'><i class='far fa-clock'></i> <span id='otp_$credential_id'><i>Hover..</i></span></span>"; $otp_display = "<span onmouseenter='showOTPViaLoginID($login_id)'><i class='far fa-clock'></i> <span id='otp_$login_id'><i>Hover..</i></span></span>";
} }
$credential_note = nullable_htmlentities($row['credential_note']); $login_note = nullable_htmlentities($row['login_note']);
$credential_important = intval($row['credential_important']); $login_important = intval($row['login_important']);
$credential_contact_id = intval($row['credential_contact_id']); $login_contact_id = intval($row['login_contact_id']);
$credential_asset_id = intval($row['credential_asset_id']); $login_vendor_id = intval($row['login_vendor_id']);
$login_asset_id = intval($row['login_asset_id']);
$login_software_id = intval($row['login_software_id']);
// Tags // Tags
$credential_tag_name_display_array = array(); $login_tag_name_display_array = array();
$credential_tag_id_array = array(); $login_tag_id_array = array();
$sql_credential_tags = mysqli_query($mysqli, "SELECT * FROM credential_tags LEFT JOIN tags ON credential_tags.tag_id = tags.tag_id WHERE credential_id = $credential_id ORDER BY tag_name ASC"); $sql_login_tags = mysqli_query($mysqli, "SELECT * FROM login_tags LEFT JOIN tags ON login_tags.tag_id = tags.tag_id WHERE login_id = $login_id ORDER BY tag_name ASC");
while ($row = mysqli_fetch_array($sql_credential_tags)) { while ($row = mysqli_fetch_array($sql_login_tags)) {
$credential_tag_id = intval($row['tag_id']); $login_tag_id = intval($row['tag_id']);
$credential_tag_name = nullable_htmlentities($row['tag_name']); $login_tag_name = nullable_htmlentities($row['tag_name']);
$credential_tag_color = nullable_htmlentities($row['tag_color']); $login_tag_color = nullable_htmlentities($row['tag_color']);
if (empty($credential_tag_color)) { if (empty($login_tag_color)) {
$credential_tag_color = "dark"; $login_tag_color = "dark";
} }
$credential_tag_icon = nullable_htmlentities($row['tag_icon']); $login_tag_icon = nullable_htmlentities($row['tag_icon']);
if (empty($credential_tag_icon)) { if (empty($login_tag_icon)) {
$credential_tag_icon = "tag"; $login_tag_icon = "tag";
} }
$credential_tag_id_array[] = $credential_tag_id; $login_tag_id_array[] = $login_tag_id;
$credential_tag_name_display_array[] = "<a href='credentials.php?client_id=$client_id&tags[]=$credential_tag_id'><span class='badge text-light p-1 mr-1' style='background-color: $credential_tag_color;'><i class='fa fa-fw fa-$credential_tag_icon mr-2'></i>$credential_tag_name</span></a>"; $login_tag_name_display_array[] = "<a href='client_logins.php?client_id=$client_id&tags[]=$login_tag_id'><span class='badge text-light p-1 mr-1' style='background-color: $login_tag_color;'><i class='fa fa-fw fa-$login_tag_icon mr-2'></i>$login_tag_name</span></a>";
} }
$credential_tags_display = implode('', $credential_tag_name_display_array); $login_tags_display = implode('', $login_tag_name_display_array);
?> ?>
<tr> <tr>
<td> <td>
<i class="fa fa-fw fa-key text-secondary"></i> <i class="fa fa-fw fa-key text-secondary"></i>
<?php echo $credential_name; ?> <?php echo $login_name; ?>
</td> </td>
<td><?php echo $credential_username_display; ?></td> <td><?php echo $login_username_display; ?></td>
<td> <td>
<button class="btn p-0" type="button" data-toggle="popover" data-trigger="focus" data-placement="top" data-content="<?php echo $credential_password; ?>"><i class="fas fa-2x fa-ellipsis-h text-secondary"></i><i class="fas fa-2x fa-ellipsis-h text-secondary"></i></button> <button class="btn p-0" type="button" data-toggle="popover" data-trigger="focus" data-placement="top" data-content="<?php echo $login_password; ?>"><i class="fas fa-2x fa-ellipsis-h text-secondary"></i><i class="fas fa-2x fa-ellipsis-h text-secondary"></i></button>
<button type='button' class='btn btn-sm clipboardjs' data-clipboard-text='<?php echo $credential_password; ?>'><i class='far fa-copy text-secondary'></i></button>
</td> </td>
<td><?php echo $otp_display; ?></td> <td><?php echo $otp_display; ?></td>
<td><?php echo $credential_uri_display; ?></td> <td><?php echo $login_uri_display; ?></td>
</tr> </tr>
<?php <?php
@@ -529,7 +524,7 @@ ob_start();
</table> </table>
</div> </div>
</div> </div>
<!-- Include script to get TOTP code via the credentials ID --> <!-- Include script to get TOTP code via the login ID -->
<script src="js/credential_show_otp_via_id.js"></script> <script src="js/credential_show_otp_via_id.js"></script>
<?php } ?> <?php } ?>
@@ -556,13 +551,12 @@ ob_start();
$ticket_number = intval($row['ticket_number']); $ticket_number = intval($row['ticket_number']);
$ticket_subject = nullable_htmlentities($row['ticket_subject']); $ticket_subject = nullable_htmlentities($row['ticket_subject']);
$ticket_priority = nullable_htmlentities($row['ticket_priority']); $ticket_priority = nullable_htmlentities($row['ticket_priority']);
$ticket_status_id = intval($row['ticket_status_id']);
$ticket_status_name = nullable_htmlentities($row['ticket_status_name']); $ticket_status_name = nullable_htmlentities($row['ticket_status_name']);
$ticket_status_color = nullable_htmlentities($row['ticket_status_color']); $ticket_status_color = nullable_htmlentities($row['ticket_status_color']);
$ticket_created_at = nullable_htmlentities($row['ticket_created_at']); $ticket_created_at = nullable_htmlentities($row['ticket_created_at']);
$ticket_updated_at = nullable_htmlentities($row['ticket_updated_at']); $ticket_updated_at = nullable_htmlentities($row['ticket_updated_at']);
if (empty($ticket_updated_at)) { if (empty($ticket_updated_at)) {
if ($ticket_status_name == "Closed") { if ($ticket_status == "Closed") {
$ticket_updated_at_display = "<p>Never</p>"; $ticket_updated_at_display = "<p>Never</p>";
} else { } else {
$ticket_updated_at_display = "<p class='text-danger'>Never</p>"; $ticket_updated_at_display = "<p class='text-danger'>Never</p>";
@@ -583,7 +577,7 @@ ob_start();
} }
$ticket_assigned_to = intval($row['ticket_assigned_to']); $ticket_assigned_to = intval($row['ticket_assigned_to']);
if (empty($ticket_assigned_to)) { if (empty($ticket_assigned_to)) {
if ($ticket_status_id == 5) { if ($ticket_status == 5) {
$ticket_assigned_to_display = "<p>Not Assigned</p>"; $ticket_assigned_to_display = "<p>Not Assigned</p>";
} else { } else {
$ticket_assigned_to_display = "<p class='text-danger'>Not Assigned</p>"; $ticket_assigned_to_display = "<p class='text-danger'>Not Assigned</p>";
@@ -638,18 +632,18 @@ ob_start();
<?php <?php
while ($row = mysqli_fetch_array($sql_related_recurring_tickets)) { while ($row = mysqli_fetch_array($sql_related_recurring_tickets)) {
$recurring_ticket_id = intval($row['recurring_ticket_id']); $scheduled_ticket_id = intval($row['scheduled_ticket_id']);
$recurring_ticket_subject = nullable_htmlentities($row['recurring_ticket_subject']); $scheduled_ticket_subject = nullable_htmlentities($row['scheduled_ticket_subject']);
$recurring_ticket_priority = nullable_htmlentities($row['recurring_ticket_priority']); $scheduled_ticket_priority = nullable_htmlentities($row['scheduled_ticket_priority']);
$recurring_ticket_frequency = nullable_htmlentities($row['recurring_ticket_frequency']); $scheduled_ticket_frequency = nullable_htmlentities($row['scheduled_ticket_frequency']);
$recurring_ticket_next_run = nullable_htmlentities($row['recurring_ticket_next_run']); $scheduled_ticket_next_run = nullable_htmlentities($row['scheduled_ticket_next_run']);
?> ?>
<tr> <tr>
<td class="text-bold"><?php echo $recurring_ticket_subject ?></td> <td class="text-bold"><?php echo $scheduled_ticket_subject ?></td>
<td><?php echo $recurring_ticket_priority ?></td> <td><?php echo $scheduled_ticket_priority ?></td>
<td><?php echo $recurring_ticket_frequency ?></td> <td><?php echo $scheduled_ticket_frequency ?></td>
<td><?php echo $recurring_ticket_next_run ?></td> <td><?php echo $scheduled_ticket_next_run ?></td>
</tr> </tr>
<?php } ?> <?php } ?>
@@ -689,6 +683,11 @@ ob_start();
$seat_count = 0; $seat_count = 0;
// Get Login
$login_id = intval($row['login_id']);
$login_username = nullable_htmlentities(decryptLoginEntry($row['login_username']));
$login_password = nullable_htmlentities(decryptLoginEntry($row['login_password']));
// Asset Licenses // Asset Licenses
$asset_licenses_sql = mysqli_query($mysqli, "SELECT asset_id FROM software_assets WHERE software_id = $software_id"); $asset_licenses_sql = mysqli_query($mysqli, "SELECT asset_id FROM software_assets WHERE software_id = $software_id");
$asset_licenses_array = array(); $asset_licenses_array = array();
@@ -853,11 +852,7 @@ ob_start();
</div> </div>
<div class="modal-footer bg-white"> <div class="modal-footer bg-white">
<a href="asset_details.php?client_id=<?php echo $client_id; ?>&asset_id=<?php echo $asset_id; ?>" class="btn btn-primary text-bold"><span class="text-white"><i class="fas fa-info-circle mr-2"></i>More Details</span></a> <a href="asset_details.php?<?php echo $client_url; ?>asset_id=<?php echo $asset_id; ?>" class="btn btn-primary text-bold"><span class="text-white">More Details</span></a>
<a href="#" class="btn btn-secondary"
data-toggle="ajax-modal" data-ajax-url="ajax/ajax_asset_edit.php" data-ajax-id="<?php echo $asset_id; ?>">
<span class="text-white"><i class="fas fa-edit mr-2"></i>Edit</span>
</a>
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Close</button> <button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Close</button>
</div> </div>

View File

@@ -4,7 +4,7 @@ require_once '../includes/ajax_header.php';
$event_id = intval($_GET['id']); $event_id = intval($_GET['id']);
$sql = mysqli_query($mysqli, "SELECT * FROM calendar_events LEFT JOIN calendars ON event_calendar_id = calendar_id WHERE event_id = $event_id LIMIT 1"); $sql = mysqli_query($mysqli, "SELECT * FROM events LEFT JOIN calendars ON event_calendar_id = calendar_id WHERE event_id = $event_id LIMIT 1");
$row = mysqli_fetch_array($sql); $row = mysqli_fetch_array($sql);
$event_title = nullable_htmlentities($row['event_title']); $event_title = nullable_htmlentities($row['event_title']);

View File

@@ -1,43 +0,0 @@
<?php
require_once '../includes/ajax_header.php';
$category = nullable_htmlentities($_GET['category']);
?>
<div class="modal-header">
<h5 class="modal-title"><i class="fa fa-fw fa-list-ul mr-2"></i>New Category</h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="type" value="<?php echo ($category); ?>">
<div class="modal-body bg-white">
<div class="form-row">
<div class="form-group col-sm-9">
<div class="input-group">
<input type="text" class="form-control" name="name" placeholder="Category name" maxlength="200" required autofocus>
</div>
</div>
<div class="form-group col-sm-3">
<div class="input-group">
<input type="color" class="form-control" name="color" required>
</div>
</div>
</div>
</div>
<div class="modal-footer bg-white">
<button type="submit" name="add_category" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Create</button>
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
</div>
</form>
<?php
require_once "../includes/ajax_footer.php";

View File

@@ -12,14 +12,10 @@ $certificate_description = nullable_htmlentities($row['certificate_description']
$certificate_domain = nullable_htmlentities($row['certificate_domain']); $certificate_domain = nullable_htmlentities($row['certificate_domain']);
$certificate_domain_id = intval($row['certificate_domain_id']); $certificate_domain_id = intval($row['certificate_domain_id']);
$certificate_issued_by = nullable_htmlentities($row['certificate_issued_by']); $certificate_issued_by = nullable_htmlentities($row['certificate_issued_by']);
$certificate_public_key = nullable_htmlentities($row['certificate_public_key']);
$certificate_notes = nullable_htmlentities($row['certificate_notes']);
$certificate_expire = nullable_htmlentities($row['certificate_expire']); $certificate_expire = nullable_htmlentities($row['certificate_expire']);
$certificate_created_at = nullable_htmlentities($row['certificate_created_at']); $certificate_created_at = nullable_htmlentities($row['certificate_created_at']);
$client_id = intval($row['certificate_client_id']); $client_id = intval($row['certificate_client_id']);
$history_sql = mysqli_query($mysqli, "SELECT * FROM certificate_history WHERE certificate_history_certificate_id = $certificate_id");
// Generate the HTML form content using output buffering. // Generate the HTML form content using output buffering.
ob_start(); ob_start();
?> ?>
@@ -45,9 +41,6 @@ ob_start();
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" data-toggle="pill" href="#pillsEditNotes<?php echo $certificate_id; ?>">Notes</a> <a class="nav-link" data-toggle="pill" href="#pillsEditNotes<?php echo $certificate_id; ?>">Notes</a>
</li> </li>
<li class="nav-item">
<a class="nav-link" data-toggle="pill" href="#pillsEditHistory<?php echo $certificate_id; ?>">History</a>
</li>
</ul> </ul>
<hr> <hr>
@@ -147,40 +140,11 @@ ob_start();
</div> </div>
<div class="tab-pane fade" id="pillsEditNotes<?php echo $certificate_id; ?>"> <div class="tab-pane fade" id="pillsEditNotes<?php echo $certificate_id; ?>">
<div class="form-group"> <div class="form-group">
<textarea class="form-control" name="notes" rows="12" placeholder="Enter some notes"><?php echo $certificate_notes; ?></textarea> <textarea class="form-control" name="notes" rows="12" placeholder="Enter some notes"><?php echo $certificate_notes; ?></textarea>
</div> </div>
</div>
<div class="tab-pane fade" id="pillsEditHistory<?php echo $certificate_id; ?>">
<div class="table-responsive">
<table class='table table-sm table-striped border table-hover'>
<thead class='thead-dark'>
<tr>
<th>Date</th>
<th>Field</th>
<th>Before</th>
<th>After</th>
</tr>
</thead>
<tbody>
<?php
while ($row = mysqli_fetch_array($history_sql)) {
$certificate_modified_at = nullable_htmlentities($row['certificate_history_modified_at']);
$certificate_field = nullable_htmlentities($row['certificate_history_column']);
$certificate_before_value = nullable_htmlentities($row['certificate_history_old_value']);
$certificate_after_value = nullable_htmlentities($row['certificate_history_new_value']);
?>
<tr>
<td><?php echo $certificate_modified_at; ?></td>
<td><?php echo $certificate_field; ?></td>
<td><?php echo $certificate_before_value; ?></td>
<td><?php echo $certificate_after_value; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div> </div>
</div> </div>

View File

@@ -125,14 +125,6 @@ ob_start();
} }
?> ?>
</select> </select>
<div class="input-group-append">
<button class="btn btn-secondary" type="button"
data-toggle="ajax-modal"
data-modal-size="sm"
data-ajax-url="ajax/ajax_category_add.php?category=Referral">
<i class="fas fa-fw fa-plus"></i>
</button>
</div>
</div> </div>
</div> </div>
@@ -165,15 +157,6 @@ ob_start();
<?php } ?> <?php } ?>
</select> </select>
<div class="input-group-append">
<button class="btn btn-secondary" type="button"
data-toggle="ajax-modal"
data-modal-size="sm"
data-ajax-url="ajax/ajax_tag_add.php"
data-ajax-id="1">
<i class="fas fa-fw fa-plus"></i>
</button>
</div>
</div> </div>
</div> </div>
@@ -251,7 +234,9 @@ ob_start();
<div class="tab-pane fade" id="pills-client-notes<?php echo $client_id; ?>"> <div class="tab-pane fade" id="pills-client-notes<?php echo $client_id; ?>">
<div class="form-group"> <div class="form-group">
<textarea class="form-control" rows="10" placeholder="Enter some notes" name="notes"><?php echo $client_notes; ?></textarea> <textarea class="form-control" rows="10" placeholder="Enter some notes"
name="notes"><?php echo $client_notes; ?>
</textarea>
</div> </div>
</div> </div>

View File

@@ -9,7 +9,7 @@ $sql = mysqli_query($mysqli, "SELECT * FROM contacts
LEFT JOIN locations ON location_id = contact_location_id LEFT JOIN locations ON location_id = contact_location_id
LEFT JOIN users ON user_id = contact_user_id LEFT JOIN users ON user_id = contact_user_id
WHERE contact_id = $contact_id WHERE contact_id = $contact_id
LIMIT 1 $client_query
"); ");
$row = mysqli_fetch_array($sql); $row = mysqli_fetch_array($sql);
@@ -18,11 +18,9 @@ $client_name = nullable_htmlentities($row['client_name']);
$contact_name = nullable_htmlentities($row['contact_name']); $contact_name = nullable_htmlentities($row['contact_name']);
$contact_title = nullable_htmlentities($row['contact_title']); $contact_title = nullable_htmlentities($row['contact_title']);
$contact_department =nullable_htmlentities($row['contact_department']); $contact_department =nullable_htmlentities($row['contact_department']);
$contact_phone_country_code = nullable_htmlentities($row['contact_phone_country_code']); $contact_phone = formatPhoneNumber($row['contact_phone']);
$contact_phone = nullable_htmlentities(formatPhoneNumber($row['contact_phone'], $contact_phone_country_code));
$contact_extension = nullable_htmlentities($row['contact_extension']); $contact_extension = nullable_htmlentities($row['contact_extension']);
$contact_mobile_country_code = nullable_htmlentities($row['contact_mobile_country_code']); $contact_mobile = formatPhoneNumber($row['contact_mobile']);
$contact_mobile = nullable_htmlentities(formatPhoneNumber($row['contact_phone'], $contact_mobile_country_code));
$contact_email = nullable_htmlentities($row['contact_email']); $contact_email = nullable_htmlentities($row['contact_email']);
$contact_photo = nullable_htmlentities($row['contact_photo']); $contact_photo = nullable_htmlentities($row['contact_photo']);
$contact_pin = nullable_htmlentities($row['contact_pin']); $contact_pin = nullable_htmlentities($row['contact_pin']);
@@ -53,21 +51,21 @@ $software_count = mysqli_num_rows($sql_linked_software);
$linked_software = array(); $linked_software = array();
// Related Credentials Query 1 to 1 relationship // Related Logins Query 1 to 1 relationship
$sql_related_credentials = mysqli_query($mysqli, " $sql_related_logins = mysqli_query($mysqli, "
SELECT SELECT
credentials.credential_id AS credentials_credential_id, -- Alias for credentials.credential_id logins.login_id AS logins_login_id, -- Alias for logins.login_id
credentials.*, -- All other columns from credentials logins.*, -- All other columns from logins
credential_tags.*, -- All columns from credential_tags login_tags.*, -- All columns from login_tags
tags.* -- All columns from tags tags.* -- All columns from tags
FROM credentials FROM logins
LEFT JOIN credential_tags ON credential_tags.credential_id = credentials.credential_id LEFT JOIN login_tags ON login_tags.login_id = logins.login_id
LEFT JOIN tags ON tags.tag_id = credential_tags.tag_id LEFT JOIN tags ON tags.tag_id = login_tags.tag_id
WHERE credential_contact_id = $contact_id WHERE login_contact_id = $contact_id
GROUP BY credentials.credential_id GROUP BY logins.login_id
ORDER BY credential_name DESC ORDER BY login_name DESC
"); ");
$credential_count = mysqli_num_rows($sql_related_credentials); $credential_count = mysqli_num_rows($sql_related_logins);
// Related Tickets Query - 1 to 1 relationship // Related Tickets Query - 1 to 1 relationship
$sql_related_tickets = mysqli_query($mysqli, "SELECT * FROM tickets $sql_related_tickets = mysqli_query($mysqli, "SELECT * FROM tickets
@@ -77,9 +75,9 @@ $sql_related_tickets = mysqli_query($mysqli, "SELECT * FROM tickets
$ticket_count = mysqli_num_rows($sql_related_tickets); $ticket_count = mysqli_num_rows($sql_related_tickets);
// Related Recurring Tickets Query // Related Recurring Tickets Query
$sql_related_recurring_tickets = mysqli_query($mysqli, "SELECT * FROM recurring_tickets $sql_related_recurring_tickets = mysqli_query($mysqli, "SELECT * FROM scheduled_tickets
WHERE recurring_ticket_contact_id = $contact_id WHERE scheduled_ticket_contact_id = $contact_id
ORDER BY recurring_ticket_next_run DESC" ORDER BY scheduled_ticket_next_run DESC"
); );
$recurring_ticket_count = mysqli_num_rows($sql_related_recurring_tickets); $recurring_ticket_count = mysqli_num_rows($sql_related_recurring_tickets);
@@ -116,7 +114,7 @@ $sql_linked_services = mysqli_query($mysqli, "SELECT * FROM service_contacts, se
AND service_contacts.service_id = services.service_id AND service_contacts.service_id = services.service_id
ORDER BY service_name ASC" ORDER BY service_name ASC"
); );
$services_count = mysqli_num_rows($sql_linked_services); $service_count = mysqli_num_rows($sql_linked_services);
$linked_services = array(); $linked_services = array();
@@ -191,6 +189,11 @@ ob_start();
<a class="nav-link" data-toggle="pill" href="#pills-contact-recurring-tickets<?php echo $contact_id; ?>"><i class="fas fa-fw fa-redo-alt fa-2x"></i><br>Rcr Tickets (<?php echo $recurring_ticket_count; ?>)</a> <a class="nav-link" data-toggle="pill" href="#pills-contact-recurring-tickets<?php echo $contact_id; ?>"><i class="fas fa-fw fa-redo-alt fa-2x"></i><br>Rcr Tickets (<?php echo $recurring_ticket_count; ?>)</a>
</li> </li>
<?php } ?> <?php } ?>
<?php if ($services_count) { ?>
<li class="nav-item">
<a class="nav-link" data-toggle="pill" href="#pills-contact-services<?php echo $contact_id; ?>"><i class="fas fa-fw fa-stream fa-2x"></i><br>Services (<?php echo $services_count; ?>)</a>
</li>
<?php } ?>
<?php if ($document_count) { ?> <?php if ($document_count) { ?>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" data-toggle="pill" href="#pills-contact-documents<?php echo $contact_id; ?>"><i class="fas fa-fw fa-file-alt fa-2x"></i><br>Documents (<?php echo $document_count; ?>)</a> <a class="nav-link" data-toggle="pill" href="#pills-contact-documents<?php echo $contact_id; ?>"><i class="fas fa-fw fa-file-alt fa-2x"></i><br>Documents (<?php echo $document_count; ?>)</a>
@@ -241,7 +244,7 @@ ob_start();
<div><i class="fa fa-fw fa-map-marker-alt text-secondary mr-2"></i><?php echo $location_name; ?></div> <div><i class="fa fa-fw fa-map-marker-alt text-secondary mr-2"></i><?php echo $location_name; ?></div>
<?php } <?php }
if ($contact_email) { ?> if ($contact_email) { ?>
<div class="mt-2"><i class="fa fa-fw fa-envelope text-secondary mr-2"></i><a href='mailto:<?php echo $contact_email; ?>'><?php echo $contact_email; ?></a><button type="button" class='btn btn-sm clipboardjs' data-clipboard-text='<?php echo $contact_email; ?>'><i class='far fa-copy text-secondary'></i></button></div> <div class="mt-2"><i class="fa fa-fw fa-envelope text-secondary mr-2"></i><a href='mailto:<?php echo $contact_email; ?>'><?php echo $contact_email; ?></a><button class='btn btn-sm clipboardjs' data-clipboard-text='<?php echo $contact_email; ?>'><i class='far fa-copy text-secondary'></i></button></div>
<?php } <?php }
if ($contact_phone) { ?> if ($contact_phone) { ?>
<div class="mt-2"><i class="fa fa-fw fa-phone text-secondary mr-2"></i><a href="tel:<?php echo "$contact_phone"?>"><?php echo $contact_phone; ?></a></div> <div class="mt-2"><i class="fa fa-fw fa-phone text-secondary mr-2"></i><a href="tel:<?php echo "$contact_phone"?>"><?php echo $contact_phone; ?></a></div>
@@ -399,9 +402,9 @@ ob_start();
<?php } ?> <?php } ?>
<?php if ($credential_count) { ?> <?php if ($credential_count) { ?>
<div class="tab-pane fade" id="pills-contact-credentials<?php echo $contact_id; ?>"> <div class="tab-pane fade" id="pills-contact-credentials<?php echo $asset_id; ?>">
<div class="table-responsive-sm"> <div class="table-responsive-sm">
<table class="table table-striped table-borderless table-hover table-sm dataTables" style="width:100%"> <table class="table table-striped table-borderless table-hover table-sm">
<thead> <thead>
<tr> <tr>
<th>Name</th> <th>Name</th>
@@ -415,70 +418,70 @@ ob_start();
<tbody> <tbody>
<?php <?php
while ($row = mysqli_fetch_array($sql_related_credentials)) { while ($row = mysqli_fetch_array($sql_related_logins)) {
$credential_id = intval($row['credentials_credential_id']); $login_id = intval($row['logins_login_id']);
$credential_name = nullable_htmlentities($row['credential_name']); $login_name = nullable_htmlentities($row['login_name']);
$credential_description = nullable_htmlentities($row['credential_description']); $login_description = nullable_htmlentities($row['login_description']);
$credential_uri = nullable_htmlentities($row['credential_uri']); $login_uri = nullable_htmlentities($row['login_uri']);
if (empty($credential_uri)) { if (empty($login_uri)) {
$credential_uri_display = "-"; $login_uri_display = "-";
} else { } else {
$credential_uri_display = "$credential_uri"; $login_uri_display = "$login_uri";
} }
$credential_uri_2 = nullable_htmlentities($row['credential_uri_2']); $login_uri_2 = nullable_htmlentities($row['login_uri_2']);
$credential_username = nullable_htmlentities(decryptCredentialEntry($row['credential_username'])); $login_username = nullable_htmlentities(decryptLoginEntry($row['login_username']));
if (empty($credential_username)) { if (empty($login_username)) {
$credential_username_display = "-"; $login_username_display = "-";
} else { } else {
$credential_username_display = "$credential_username <button type='button' class='btn btn-sm clipboardjs' data-clipboard-text='$credential_username'><i class='far fa-copy text-secondary'></i></button>"; $login_username_display = "$login_username";
} }
$credential_password = nullable_htmlentities(decryptCredentialEntry($row['credential_password'])); $login_password = nullable_htmlentities(decryptLoginEntry($row['login_password']));
$credential_otp_secret = nullable_htmlentities($row['credential_otp_secret']); $login_otp_secret = nullable_htmlentities($row['login_otp_secret']);
$credential_id_with_secret = '"' . $row['credential_id'] . '","' . $row['credential_otp_secret'] . '"'; $login_id_with_secret = '"' . $row['login_id'] . '","' . $row['login_otp_secret'] . '"';
if (empty($credential_otp_secret)) { if (empty($login_otp_secret)) {
$otp_display = "-"; $otp_display = "-";
} else { } else {
$otp_display = "<span onmouseenter='showOTPViaCredentialID($credential_id)'><i class='far fa-clock'></i> <span id='otp_$credential_id'><i>Hover..</i></span></span>"; $otp_display = "<span onmouseenter='showOTPViaLoginID($login_id)'><i class='far fa-clock'></i> <span id='otp_$login_id'><i>Hover..</i></span></span>";
} }
$credential_note = nullable_htmlentities($row['credential_note']); $login_note = nullable_htmlentities($row['login_note']);
$credential_important = intval($row['credential_important']); $login_important = intval($row['login_important']);
$credential_contact_id = intval($row['credential_contact_id']); $login_contact_id = intval($row['login_contact_id']);
$credential_asset_id = intval($row['credential_asset_id']); $login_vendor_id = intval($row['login_vendor_id']);
$login_asset_id = intval($row['login_asset_id']);
$login_software_id = intval($row['login_software_id']);
// Tags // Tags
$credential_tag_name_display_array = array(); $login_tag_name_display_array = array();
$credential_tag_id_array = array(); $login_tag_id_array = array();
$sql_credential_tags = mysqli_query($mysqli, "SELECT * FROM credential_tags LEFT JOIN tags ON credential_tags.tag_id = tags.tag_id WHERE credential_id = $credential_id ORDER BY tag_name ASC"); $sql_login_tags = mysqli_query($mysqli, "SELECT * FROM login_tags LEFT JOIN tags ON login_tags.tag_id = tags.tag_id WHERE login_id = $login_id ORDER BY tag_name ASC");
while ($row = mysqli_fetch_array($sql_credential_tags)) { while ($row = mysqli_fetch_array($sql_login_tags)) {
$credential_tag_id = intval($row['tag_id']); $login_tag_id = intval($row['tag_id']);
$credential_tag_name = nullable_htmlentities($row['tag_name']); $login_tag_name = nullable_htmlentities($row['tag_name']);
$credential_tag_color = nullable_htmlentities($row['tag_color']); $login_tag_color = nullable_htmlentities($row['tag_color']);
if (empty($credential_tag_color)) { if (empty($login_tag_color)) {
$credential_tag_color = "dark"; $login_tag_color = "dark";
} }
$credential_tag_icon = nullable_htmlentities($row['tag_icon']); $login_tag_icon = nullable_htmlentities($row['tag_icon']);
if (empty($credential_tag_icon)) { if (empty($login_tag_icon)) {
$credential_tag_icon = "tag"; $login_tag_icon = "tag";
} }
$credential_tag_id_array[] = $credential_tag_id; $login_tag_id_array[] = $login_tag_id;
$credential_tag_name_display_array[] = "<a href='credentials.php?client_id=$client_id&tags[]=$credential_tag_id'><span class='badge text-light p-1 mr-1' style='background-color: $credential_tag_color;'><i class='fa fa-fw fa-$credential_tag_icon mr-2'></i>$credential_tag_name</span></a>"; $login_tag_name_display_array[] = "<a href='client_logins.php?client_id=$client_id&tags[]=$login_tag_id'><span class='badge text-light p-1 mr-1' style='background-color: $login_tag_color;'><i class='fa fa-fw fa-$login_tag_icon mr-2'></i>$login_tag_name</span></a>";
} }
$credential_tags_display = implode('', $credential_tag_name_display_array); $login_tags_display = implode('', $login_tag_name_display_array);
?> ?>
<tr> <tr>
<td><i class="fa fa-fw fa-key text-secondary mr-2"></i><?php echo $credential_name; ?></td> <td><i class="fa fa-fw fa-key text-secondary mr-2"></i><?php echo $login_name; ?></td>
<td><?php echo $credential_description; ?></td> <td><?php echo $login_description; ?></td>
<td><?php echo $credential_username_display; ?></td> <td><?php echo $login_username_display; ?></td>
<td> <td>
<button class="btn p-0" type="button" data-toggle="popover" data-trigger="focus" data-placement="top" data-content="<?php echo $credential_password; ?>"><i class="fas fa-2x fa-ellipsis-h text-secondary"></i><i class="fas fa-2x fa-ellipsis-h text-secondary"></i></button> <button class="btn p-0" type="button" data-toggle="popover" data-trigger="focus" data-placement="top" data-content="<?php echo $login_password; ?>"><i class="fas fa-2x fa-ellipsis-h text-secondary"></i><i class="fas fa-2x fa-ellipsis-h text-secondary"></i></button>
<button type="button" class='btn btn-sm clipboardjs' data-clipboard-text='<?php echo $credential_password; ?>'><i class='far fa-copy text-secondary'></i></button>
</td> </td>
<td><?php echo $otp_display; ?></td> <td><?php echo $otp_display; ?></td>
<td><?php echo $credential_uri_display; ?></td> <td><?php echo $login_uri_display; ?></td>
</tr> </tr>
<?php <?php
@@ -491,12 +494,12 @@ ob_start();
</table> </table>
</div> </div>
</div> </div>
<!-- Include script to get TOTP code via the credential ID --> <!-- Include script to get TOTP code via the login ID -->
<script src="js/credential_show_otp_via_id.js"></script> <script src="js/credential_show_otp_via_id.js"></script>
<?php } ?> <?php } ?>
<?php if ($ticket_count) { ?> <?php if ($ticket_count) { ?>
<div class="tab-pane fade" id="pills-contact-tickets<?php echo $contact_id; ?>"> <div class="tab-pane fade" id="pills-contact-tickets<?php echo $asset_id; ?>">
<div class="table-responsive-sm"> <div class="table-responsive-sm">
<table class="table table-striped table-borderless table-hover table-sm"> <table class="table table-striped table-borderless table-hover table-sm">
<thead class="text-dark"> <thead class="text-dark">
@@ -596,18 +599,18 @@ ob_start();
<?php <?php
while ($row = mysqli_fetch_array($sql_related_recurring_tickets)) { while ($row = mysqli_fetch_array($sql_related_recurring_tickets)) {
$recurring_ticket_id = intval($row['recurring_ticket_id']); $scheduled_ticket_id = intval($row['scheduled_ticket_id']);
$recurring_ticket_subject = nullable_htmlentities($row['recurring_ticket_subject']); $scheduled_ticket_subject = nullable_htmlentities($row['scheduled_ticket_subject']);
$recurring_ticket_priority = nullable_htmlentities($row['recurring_ticket_priority']); $scheduled_ticket_priority = nullable_htmlentities($row['scheduled_ticket_priority']);
$recurring_ticket_frequency = nullable_htmlentities($row['recurring_ticket_frequency']); $scheduled_ticket_frequency = nullable_htmlentities($row['scheduled_ticket_frequency']);
$recurring_ticket_next_run = nullable_htmlentities($row['recurring_ticket_next_run']); $scheduled_ticket_next_run = nullable_htmlentities($row['scheduled_ticket_next_run']);
?> ?>
<tr> <tr>
<td class="text-bold"><?php echo $recurring_ticket_subject ?></td> <td class="text-bold"><?php echo $scheduled_ticket_subject ?></td>
<td><?php echo $recurring_ticket_priority ?></td> <td><?php echo $scheduled_ticket_priority ?></td>
<td><?php echo $recurring_ticket_frequency ?></td> <td><?php echo $scheduled_ticket_frequency ?></td>
<td><?php echo $recurring_ticket_next_run ?></td> <td><?php echo $scheduled_ticket_next_run ?></td>
</tr> </tr>
<?php } ?> <?php } ?>
@@ -845,13 +848,7 @@ ob_start();
</div> </div>
<div class="modal-footer bg-white"> <div class="modal-footer bg-white">
<a href="contact_details.php?client_id=<?php echo $client_id; ?>&contact_id=<?php echo $contact_id; ?>" class="btn btn-primary text-bold"> <a href="contact_details.php?<?php echo $client_url; ?>contact_id=<?php echo $contact_id; ?>" class="btn btn-primary text-bold"><span class="text-white">More Details</span></a>
<span class="text-white"><i class="fas fa-info-circle mr-2"></i>More Details</span>
</a>
<a href="#" class="btn btn-secondary"
data-toggle="ajax-modal" data-ajax-url="ajax/ajax_contact_edit.php" data-ajax-id="<?php echo $contact_id; ?>">
<span class="text-white"><i class="fas fa-edit mr-2"></i>Edit</span>
</a>
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Close</button> <button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Close</button>
</div> </div>

View File

@@ -16,10 +16,8 @@ $contact_name = nullable_htmlentities($row['contact_name']);
$contact_title = nullable_htmlentities($row['contact_title']); $contact_title = nullable_htmlentities($row['contact_title']);
$contact_department = nullable_htmlentities($row['contact_department']); $contact_department = nullable_htmlentities($row['contact_department']);
$contact_extension = nullable_htmlentities($row['contact_extension']); $contact_extension = nullable_htmlentities($row['contact_extension']);
$contact_phone_country_code = nullable_htmlentities($row['contact_phone_country_code']); $contact_phone = formatPhoneNumber($row['contact_phone']);
$contact_phone = nullable_htmlentities(formatPhoneNumber($row['contact_phone'], $contact_phone_country_code)); $contact_mobile = formatPhoneNumber($row['contact_mobile']);
$contact_mobile_country_code = nullable_htmlentities($row['contact_mobile_country_code']);
$contact_mobile = nullable_htmlentities(formatPhoneNumber($row['contact_phone'], $contact_mobile_country_code));
$contact_email = nullable_htmlentities($row['contact_email']); $contact_email = nullable_htmlentities($row['contact_email']);
$contact_pin = nullable_htmlentities($row['contact_pin']); $contact_pin = nullable_htmlentities($row['contact_pin']);
$contact_photo = nullable_htmlentities($row['contact_photo']); $contact_photo = nullable_htmlentities($row['contact_photo']);
@@ -113,38 +111,30 @@ ob_start();
</div> </div>
</div> </div>
<label>Phone / <span class="text-secondary">Extension</span></label> <label>Phone</label>
<div class="form-row"> <div class="form-row">
<div class="col-9"> <div class="col-8">
<div class="form-group"> <div class="form-group">
<div class="input-group"> <div class="input-group">
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-phone"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-phone"></i></span>
</div> </div>
<input type="tel" class="form-control col-2" name="phone_country_code" value="<?php echo "+$contact_phone_country_code"; ?>" placeholder="Code" maxlength="4"> <input type="text" class="form-control" name="phone" placeholder="Phone Number" maxlength="200" value="<?php echo $contact_phone; ?>">
<input type="tel" class="form-control" name="phone" value="<?php echo $contact_phone; ?>" placeholder="Phone Number" maxlength="200">
</div> </div>
</div> </div>
</div> </div>
<div class="col-3"> <div class="col-4">
<div class="form-group"> <input type="text" class="form-control" name="extension" placeholder="Extension" maxlength="200" value="<?php echo $contact_extension; ?>">
<input type="text" class="form-control" name="extension" value="<?php echo $contact_extension; ?>" placeholder="ext." maxlength="200">
</div>
</div> </div>
</div> </div>
<label>Mobile</label> <div class="form-group">
<div class="form-row"> <label>Mobile</label>
<div class="col-9"> <div class="input-group">
<div class="form-group"> <div class="input-group-prepend">
<div class="input-group"> <span class="input-group-text"><i class="fa fa-fw fa-mobile-alt"></i></span>
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-mobile-alt"></i></span>
</div>
<input type="tel" class="form-control col-2" name="mobile_country_code" value="<?php echo "+$contact_mobile_country_code"; ?>" placeholder="Code" maxlength="4">
<input type="tel" class="form-control" name="mobile" value="<?php echo $contact_mobile; ?>" placeholder="Phone Number">
</div>
</div> </div>
<input type="text" class="form-control" name="mobile" placeholder="Mobile Phone Number" maxlength="200" value="<?php echo $contact_mobile; ?>">
</div> </div>
</div> </div>
@@ -321,15 +311,6 @@ ob_start();
<?php } ?> <?php } ?>
</select> </select>
<div class="input-group-append">
<button class="btn btn-secondary" type="button"
data-toggle="ajax-modal"
data-modal-size="sm"
data-ajax-url="ajax/ajax_tag_add.php"
data-ajax-id="3">
<i class="fas fa-plus"></i>
</button>
</div>
</div> </div>
</div> </div>

View File

@@ -2,32 +2,35 @@
require_once '../includes/ajax_header.php'; require_once '../includes/ajax_header.php';
$credential_id = intval($_GET['id']); $login_id = intval($_GET['id']);
$sql = mysqli_query($mysqli, "SELECT * FROM credentials WHERE credential_id = $credential_id LIMIT 1"); $sql = mysqli_query($mysqli, "SELECT * FROM logins WHERE login_id = $login_id LIMIT 1");
$row = mysqli_fetch_array($sql); $row = mysqli_fetch_array($sql);
$client_id = intval($row['credential_client_id']); $client_id = intval($row['login_client_id']);
$credential_name = nullable_htmlentities($row['credential_name']); $login_id = intval($row['login_id']);
$credential_description = nullable_htmlentities($row['credential_description']); $login_name = nullable_htmlentities($row['login_name']);
$credential_uri = nullable_htmlentities($row['credential_uri']); $login_description = nullable_htmlentities($row['login_description']);
$credential_uri_2 = nullable_htmlentities($row['credential_uri_2']); $login_uri = nullable_htmlentities($row['login_uri']);
$credential_username = nullable_htmlentities(decryptCredentialEntry($row['credential_username'])); $login_uri_2 = nullable_htmlentities($row['login_uri_2']);
$credential_password = nullable_htmlentities(decryptCredentialEntry($row['credential_password'])); $login_username = nullable_htmlentities(decryptLoginEntry($row['login_username']));
$credential_otp_secret = nullable_htmlentities($row['credential_otp_secret']); $login_password = nullable_htmlentities(decryptLoginEntry($row['login_password']));
$credential_note = nullable_htmlentities($row['credential_note']); $login_otp_secret = nullable_htmlentities($row['login_otp_secret']);
$credential_created_at = nullable_htmlentities($row['credential_created_at']); $login_note = nullable_htmlentities($row['login_note']);
$credential_archived_at = nullable_htmlentities($row['credential_archived_at']); $login_created_at = nullable_htmlentities($row['login_created_at']);
$credential_important = intval($row['credential_important']); $login_archived_at = nullable_htmlentities($row['login_archived_at']);
$credential_contact_id = intval($row['credential_contact_id']); $login_important = intval($row['login_important']);
$credential_asset_id = intval($row['credential_asset_id']); $login_contact_id = intval($row['login_contact_id']);
$login_vendor_id = intval($row['login_vendor_id']);
$login_asset_id = intval($row['login_asset_id']);
$login_software_id = intval($row['login_software_id']);
// Tags // Tags
$credential_tag_id_array = array(); $login_tag_id_array = array();
$sql_credential_tags = mysqli_query($mysqli, "SELECT tag_id FROM credential_tags WHERE credential_id = $credential_id"); $sql_login_tags = mysqli_query($mysqli, "SELECT tag_id FROM login_tags WHERE login_id = $login_id");
while ($row = mysqli_fetch_array($sql_credential_tags)) { while ($row = mysqli_fetch_array($sql_login_tags)) {
$credential_tag_id = intval($row['tag_id']); $login_tag_id = intval($row['tag_id']);
$credential_tag_id_array[] = $credential_tag_id; $login_tag_id_array[] = $login_tag_id;
} }
// Generate the HTML form content using output buffering. // Generate the HTML form content using output buffering.
@@ -35,26 +38,26 @@ ob_start();
?> ?>
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title"><i class='fas fa-fw fa-key mr-2'></i>Editing credential: <strong><?php echo $credential_name; ?></strong></h5> <h5 class="modal-title"><i class='fas fa-fw fa-key mr-2'></i>Editing credential: <strong><?php echo $login_name; ?></strong></h5>
<button type="button" class="close text-white" data-dismiss="modal"> <button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span> <span>&times;</span>
</button> </button>
</div> </div>
<form action="post.php" method="post" autocomplete="off"> <form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="credential_id" value="<?php echo $credential_id; ?>"> <input type="hidden" name="login_id" value="<?php echo $login_id; ?>">
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>"> <input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
<div class="modal-body bg-white"> <div class="modal-body bg-white">
<ul class="nav nav-pills nav-justified mb-3"> <ul class="nav nav-pills nav-justified mb-3">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link active" data-toggle="pill" href="#pills-credential-details<?php echo $credential_id; ?>">Details</a> <a class="nav-link active" data-toggle="pill" href="#pills-login-details<?php echo $login_id; ?>">Details</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" data-toggle="pill" href="#pills-credential-relation<?php echo $credential_id; ?>">Relation</a> <a class="nav-link" data-toggle="pill" href="#pills-login-relation<?php echo $login_id; ?>">Relation</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" data-toggle="pill" href="#pills-credential-notes<?php echo $credential_id; ?>">Notes</a> <a class="nav-link" data-toggle="pill" href="#pills-login-notes<?php echo $login_id; ?>">Notes</a>
</li> </li>
</ul> </ul>
@@ -62,7 +65,7 @@ ob_start();
<div class="tab-content" <?php if (lookupUserPermission('module_credential') <= 1) { echo 'inert'; } ?>> <div class="tab-content" <?php if (lookupUserPermission('module_credential') <= 1) { echo 'inert'; } ?>>
<div class="tab-pane fade show active" id="pills-credential-details<?php echo $credential_id; ?>"> <div class="tab-pane fade show active" id="pills-login-details<?php echo $login_id; ?>">
<div class="form-group"> <div class="form-group">
<label>Name <strong class="text-danger">*</strong> / <span class="text-secondary">Important?</span></label> <label>Name <strong class="text-danger">*</strong> / <span class="text-secondary">Important?</span></label>
@@ -70,10 +73,10 @@ ob_start();
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-key"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-key"></i></span>
</div> </div>
<input type="text" class="form-control" name="name" placeholder="Name of Credential" maxlength="200" value="<?php echo $credential_name; ?>" required> <input type="text" class="form-control" name="name" placeholder="Name of Login" maxlength="200" value="<?php echo $login_name; ?>" required>
<div class="input-group-append"> <div class="input-group-append">
<div class="input-group-text"> <div class="input-group-text">
<input type="checkbox" name="important" value="1" <?php if ($credential_important == 1) { echo "checked"; } ?>> <input type="checkbox" name="important" value="1" <?php if ($login_important == 1) { echo "checked"; } ?>>
</div> </div>
</div> </div>
</div> </div>
@@ -85,7 +88,7 @@ ob_start();
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-angle-right"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-angle-right"></i></span>
</div> </div>
<input type="text" class="form-control" name="description" placeholder="Description" value="<?php echo $credential_description; ?>"> <input type="text" class="form-control" name="description" placeholder="Description" value="<?php echo $login_description; ?>">
</div> </div>
</div> </div>
@@ -95,7 +98,7 @@ ob_start();
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-user"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-user"></i></span>
</div> </div>
<input type="text" class="form-control" name="username" placeholder="Username or ID" maxlength="350" value="<?php echo $credential_username; ?>"> <input type="text" class="form-control" name="username" placeholder="Username or ID" maxlength="350" value="<?php echo $login_username; ?>">
</div> </div>
</div> </div>
@@ -105,12 +108,12 @@ ob_start();
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-lock"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-lock"></i></span>
</div> </div>
<input type="password" class="form-control" data-toggle="password" name="password" placeholder="Password or Key" maxlength="350" value="<?php echo $credential_password; ?>" required autocomplete="new-password"> <input type="password" class="form-control" data-toggle="password" name="password" placeholder="Password or Key" maxlength="350" value="<?php echo $login_password; ?>" required autocomplete="new-password">
<div class="input-group-append"> <div class="input-group-append">
<span class="input-group-text"><i class="fa fa-fw fa-eye"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-eye"></i></span>
</div> </div>
<div class="input-group-append"> <div class="input-group-append">
<button class="btn btn-default clipboardjs" type="button" data-clipboard-text="<?php echo $credential_password; ?>"><i class="fa fa-fw fa-copy"></i></button> <button class="btn btn-default clipboardjs" type="button" data-clipboard-text="<?php echo $login_password; ?>"><i class="fa fa-fw fa-copy"></i></button>
</div> </div>
</div> </div>
</div> </div>
@@ -121,7 +124,7 @@ ob_start();
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-key"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-key"></i></span>
</div> </div>
<input type="password" class="form-control" data-toggle="password" name="otp_secret" maxlength="200" value="<?php echo $credential_otp_secret; ?>" placeholder="Insert secret key"> <input type="password" class="form-control" data-toggle="password" name="otp_secret" maxlength="200" value="<?php echo $login_otp_secret; ?>" placeholder="Insert secret key">
<div class="input-group-append"> <div class="input-group-append">
<span class="input-group-text"><i class="fa fa-fw fa-eye"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-eye"></i></span>
</div> </div>
@@ -134,13 +137,13 @@ ob_start();
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-link"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-link"></i></span>
</div> </div>
<input type="text" class="form-control" name="uri" placeholder="ex. http://192.168.1.1" maxlength="500" value="<?php echo $credential_uri; ?>"> <input type="text" class="form-control" name="uri" placeholder="ex. http://192.168.1.1" maxlength="500" value="<?php echo $login_uri; ?>">
<div class="input-group-append"> <div class="input-group-append">
<a href="<?php echo $credential_uri; ?>" class="input-group-text"><i class="fa fa-fw fa-link"></i></a> <a href="<?php echo $login_uri; ?>" class="input-group-text"><i class="fa fa-fw fa-link"></i></a>
</div> </div>
<div class="input-group-append"> <div class="input-group-append">
<button class="input-group-text clipboardjs" type="button" data-clipboard-text="<?php echo $credential_uri; ?>"><i class="fa fa-fw fa-copy"></i></button> <button class="input-group-text clipboardjs" type="button" data-clipboard-text="<?php echo $login_uri; ?>"><i class="fa fa-fw fa-copy"></i></button>
</div> </div>
</div> </div>
</div> </div>
@@ -151,19 +154,19 @@ ob_start();
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-link"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-link"></i></span>
</div> </div>
<input type="text" class="form-control" name="uri_2" placeholder="ex. https://server.company.com:5001" maxlength="500" value="<?php echo $credential_uri_2; ?>"> <input type="text" class="form-control" name="uri_2" placeholder="ex. https://server.company.com:5001" maxlength="500" value="<?php echo $login_uri_2; ?>">
<div class="input-group-append"> <div class="input-group-append">
<a href="<?php echo $credential_uri_2; ?>" class="input-group-text"><i class="fa fa-fw fa-link"></i></a> <a href="<?php echo $login_uri_2; ?>" class="input-group-text"><i class="fa fa-fw fa-link"></i></a>
</div> </div>
<div class="input-group-append"> <div class="input-group-append">
<button class="input-group-text clipboardjs" type="button" data-clipboard-text="<?php echo $credential_uri_2; ?>"><i class="fa fa-fw fa-copy"></i></button> <button class="input-group-text clipboardjs" type="button" data-clipboard-text="<?php echo $login_uri_2; ?>"><i class="fa fa-fw fa-copy"></i></button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="tab-pane fade" id="pills-credential-relation<?php echo $credential_id; ?>"> <div class="tab-pane fade" id="pills-login-relation<?php echo $login_id; ?>">
<div class="form-group"> <div class="form-group">
<label>Contact</label> <label>Contact</label>
@@ -172,7 +175,7 @@ ob_start();
<span class="input-group-text"><i class="fa fa-fw fa-user"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-user"></i></span>
</div> </div>
<select class="form-control select2" name="contact"> <select class="form-control select2" name="contact">
<option value="">- Select Contact -</option> <option value="">- Contact -</option>
<?php <?php
$sql_contacts = mysqli_query($mysqli, "SELECT contact_id, contact_name FROM contacts WHERE contact_client_id = $client_id ORDER BY contact_name ASC"); $sql_contacts = mysqli_query($mysqli, "SELECT contact_id, contact_name FROM contacts WHERE contact_client_id = $client_id ORDER BY contact_name ASC");
@@ -180,12 +183,34 @@ ob_start();
$contact_id_select = intval($row['contact_id']); $contact_id_select = intval($row['contact_id']);
$contact_name_select = nullable_htmlentities($row['contact_name']); $contact_name_select = nullable_htmlentities($row['contact_name']);
?> ?>
<option <?php if ($credential_contact_id == $contact_id_select) { echo "selected"; } ?> value="<?php echo $contact_id_select; ?>"><?php echo $contact_name_select; ?></option> <option <?php if ($login_contact_id == $contact_id_select) { echo "selected"; } ?> value="<?php echo $contact_id_select; ?>"><?php echo $contact_name_select; ?></option>
<?php } ?> <?php } ?>
</select> </select>
</div> </div>
</div> </div>
<div class="form-group">
<label>Vendor</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-building"></i></span>
</div>
<select class="form-control select2" name="vendor">
<option value="0">- None -</option>
<?php
$sql_vendors = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_client_id = $client_id ORDER BY vendor_name ASC");
while ($row = mysqli_fetch_array($sql_vendors)) {
$vendor_id_select = intval($row['vendor_id']);
$vendor_name_select = nullable_htmlentities($row['vendor_name']);
?>
<option <?php if ($login_vendor_id == $vendor_id_select) { echo "selected"; } ?> value="<?php echo $vendor_id_select; ?>"><?php echo $vendor_name_select; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label>Asset</label> <label>Asset</label>
<div class="input-group"> <div class="input-group">
@@ -193,7 +218,7 @@ ob_start();
<span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span>
</div> </div>
<select class="form-control select2" name="asset"> <select class="form-control select2" name="asset">
<option value="0">- Select Asset -</option> <option value="0">- None -</option>
<?php <?php
$sql_assets = mysqli_query($mysqli, "SELECT asset_id, asset_name, location_name FROM assets LEFT JOIN locations on asset_location_id = location_id WHERE asset_client_id = $client_id AND asset_archived_at IS NULL ORDER BY asset_name ASC"); $sql_assets = mysqli_query($mysqli, "SELECT asset_id, asset_name, location_name FROM assets LEFT JOIN locations on asset_location_id = location_id WHERE asset_client_id = $client_id AND asset_archived_at IS NULL ORDER BY asset_name ASC");
@@ -208,7 +233,29 @@ ob_start();
} }
?> ?>
<option <?php if ($credential_asset_id == $asset_id_select) { echo "selected"; } ?> value="<?php echo $asset_id_select; ?>"><?php echo $asset_select_display_string; ?></option> <option <?php if ($login_asset_id == $asset_id_select) { echo "selected"; } ?> value="<?php echo $asset_id_select; ?>"><?php echo $asset_select_display_string; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label>Software</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-box"></i></span>
</div>
<select class="form-control select2" name="software">
<option value="0">- None -</option>
<?php
$sql_software = mysqli_query($mysqli, "SELECT software_id, software_name FROM software WHERE software_client_id = $client_id ORDER BY software_name ASC");
while ($row = mysqli_fetch_array($sql_software)) {
$software_id_select = intval($row['software_id']);
$software_name_select = nullable_htmlentities($row['software_name']);
?>
<option <?php if ($login_software_id == $software_id_select) { echo "selected"; } ?> value="<?php echo $software_id_select; ?>"><?php echo $software_name_select; ?></option>
<?php } ?> <?php } ?>
</select> </select>
@@ -217,10 +264,10 @@ ob_start();
</div> </div>
<div class="tab-pane fade" id="pills-credential-notes<?php echo $credential_id; ?>"> <div class="tab-pane fade" id="pills-login-notes<?php echo $login_id; ?>">
<div class="form-group"> <div class="form-group">
<textarea class="form-control" rows="12" placeholder="Enter some notes" name="note"><?php echo $credential_note; ?></textarea> <textarea class="form-control" rows="12" placeholder="Enter some notes" name="note"><?php echo $login_note; ?></textarea>
</div> </div>
<div class="form-group"> <div class="form-group">
@@ -237,19 +284,10 @@ ob_start();
$tag_id_select = intval($row['tag_id']); $tag_id_select = intval($row['tag_id']);
$tag_name_select = nullable_htmlentities($row['tag_name']); $tag_name_select = nullable_htmlentities($row['tag_name']);
?> ?>
<option value="<?php echo $tag_id_select; ?>" <?php if (in_array($tag_id_select, $credential_tag_id_array)) { echo "selected"; } ?>><?php echo $tag_name_select; ?></option> <option value="<?php echo $tag_id_select; ?>" <?php if (in_array($tag_id_select, $login_tag_id_array)) { echo "selected"; } ?>><?php echo $tag_name_select; ?></option>
<?php } ?> <?php } ?>
</select> </select>
<div class="input-group-append">
<button class="btn btn-secondary" type="button"
data-toggle="ajax-modal"
data-modal-size="sm"
data-ajax-url="ajax/ajax_tag_add.php"
data-ajax-id="4">
<i class="fas fa-plus"></i>
</button>
</div>
</div> </div>
</div> </div>
@@ -258,7 +296,7 @@ ob_start();
</div> </div>
</div> </div>
<div class="modal-footer bg-white"> <div class="modal-footer bg-white">
<button type="submit" name="edit_credential" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Save</button> <button type="submit" name="edit_login" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Save</button>
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button> <button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
</div> </div>
</form> </form>

View File

@@ -1,94 +0,0 @@
<?php
require_once '../includes/ajax_header.php';
$credential_id = intval($_GET['id']);
$sql = mysqli_query($mysqli, "SELECT * FROM credentials WHERE credential_id = $credential_id LIMIT 1");
$row = mysqli_fetch_array($sql);
$credential_name = nullable_htmlentities($row['credential_name']);
$credential_description = nullable_htmlentities($row['credential_description']);
$credential_uri = nullable_htmlentities($row['credential_uri']);
$credential_uri_2 = nullable_htmlentities($row['credential_uri_2']);
$credential_username = nullable_htmlentities(decryptLoginEntry($row['credential_username']));
$credential_password = nullable_htmlentities(decryptLoginEntry($row['credential_password']));
$credential_otp_secret = nullable_htmlentities($row['credential_otp_secret']);
$credential_id_with_secret = '"' . $row['credential_id'] . '","' . $row['credential_otp_secret'] . '"';
if (empty($credential_otp_secret)) {
$otp_display = "-";
} else {
$otp_display = "<span onmouseenter='showOTPViaCredentialID($credential_id)'><i class='far fa-clock'></i> <span id='otp_$credential_id'><i>Hover..</i></span></span>";
}
$credential_note = nullable_htmlentities($row['credential_note']);
$credential_created_at = nullable_htmlentities($row['credential_created_at']);
// Generate the HTML form content using output buffering.
ob_start();
?>
<div class="modal-header bg-dark text-white">
<div class="d-flex align-items-center">
<i class="fas fa-fw fa-building fa-2x mr-3"></i>
<div>
<h5 class="modal-title mb-0"><?php echo $name; ?></h5>
<div class="text-muted"><?php echo getFallback($description); ?></div>
</div>
</div>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<div class="modal-body bg-light">
<!-- Vendor Info Card -->
<div class="card mb-3 shadow-sm rounded">
<div class="card-body">
<h6 class="text-secondary"><i class="fas fa-info-circle mr-2"></i>Vendor Details</h6>
<div class="row">
<div class="col-sm-6">
<div><strong>Account Number:</strong> <?php echo getFallback($account_number); ?></div>
<div><strong>Hours:</strong> <?php echo getFallback($hours); ?></div>
<div><strong>SLA:</strong> <?php echo getFallback($sla); ?></div>
</div>
<div class="col-sm-6">
<div><strong>Code:</strong> <?php echo getFallback($code); ?></div>
<div><strong>Website:</strong> <?php echo !empty($website) ? '<a href="' . $website . '" target="_blank" class="text-primary">' . $website . '</a>' : '<span class="text-muted">Not Available</span>'; ?></div>
</div>
</div>
</div>
</div>
<!-- Contact Info Card -->
<div class="card mb-3 shadow-sm rounded">
<div class="card-body">
<h6 class="text-secondary"><i class="fas fa-user mr-2"></i>Contact Information</h6>
<div class="row">
<div class="col-sm-6">
<div><strong>Contact Name:</strong> <?php echo getFallback($contact_name); ?></div>
<div><strong>Phone:</strong> <?php echo getFallback($phone); ?></div>
</div>
<div class="col-sm-6">
<div><strong>Email:</strong> <?php echo !empty($email) ? '<a href="mailto:' . $email . '" class="text-primary">' . $email . '</a>' : '<span class="text-muted">Not Available</span>'; ?></div>
</div>
</div>
</div>
</div>
<!-- Notes Card -->
<div class="card mb-3 shadow-sm rounded">
<div class="card-body">
<h6 class="text-secondary"><i class="fas fa-sticky-note mr-2"></i>Notes</h6>
<div>
<?php echo getFallback($notes); ?>
</div>
</div>
</div>
</div>
<script src="js/credential_show_otp_via_id.js"></script>
<?php
require_once "../includes/ajax_footer.php";

View File

@@ -131,12 +131,7 @@ ob_start();
?> ?>
</select> </select>
<div class="input-group-append"> <div class="input-group-append">
<button class="btn btn-secondary" type="button" <a class="btn btn-secondary" href="vendors.php" target="_blank"><i class="fas fa-fw fa-plus"></i></a>
data-toggle="ajax-modal"
data-modal-size="sm"
data-ajax-url="ajax/ajax_category_add.php?category=Expense">
<i class="fas fa-plus"></i>
</button>
</div> </div>
</div> </div>
</div> </div>
@@ -181,12 +176,7 @@ ob_start();
?> ?>
</select> </select>
<div class="input-group-append"> <div class="input-group-append">
<button class="btn btn-secondary" type="button" <a class="btn btn-secondary" href="admin_category.php?category=Expense" target="_blank"><i class="fas fa-fw fa-plus"></i></a>
data-toggle="ajax-modal"
data-modal-size="sm"
data-ajax-url="ajax/ajax_category_add.php?category=Expense">
<i class="fas fa-plus"></i>
</button>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -77,12 +77,7 @@ ob_start();
?> ?>
</select> </select>
<div class="input-group-append"> <div class="input-group-append">
<button class="btn btn-secondary" type="button" <a class="btn btn-secondary" href="admin_category.php?category=Income" target="_blank"><i class="fas fa-fw fa-plus"></i></a>
data-toggle="ajax-modal"
data-modal-size="sm"
data-ajax-url="ajax/ajax_category_add.php?category=Income">
<i class="fas fa-fw fa-plus"></i>
</button>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -14,11 +14,8 @@ $location_address = nullable_htmlentities($row['location_address']);
$location_city = nullable_htmlentities($row['location_city']); $location_city = nullable_htmlentities($row['location_city']);
$location_state = nullable_htmlentities($row['location_state']); $location_state = nullable_htmlentities($row['location_state']);
$location_zip = nullable_htmlentities($row['location_zip']); $location_zip = nullable_htmlentities($row['location_zip']);
$location_phone_country_code = nullable_htmlentities($row['location_phone_country_code']); $location_phone = formatPhoneNumber($row['location_phone']);
$location_phone = nullable_htmlentities(formatPhoneNumber($row['location_phone'], $location_phone_country_code)); $location_fax = formatPhoneNumber($row['location_fax']);
$location_extension = formatPhoneNumber($row['location_extension']);
$location_fax_country_code = nullable_htmlentities($row['location_fax_country_code']);
$location_fax = nullable_htmlentities(formatPhoneNumber($row['location_fax'], $location_fax_country_code));
$location_hours = nullable_htmlentities($row['location_hours']); $location_hours = nullable_htmlentities($row['location_hours']);
$location_photo = nullable_htmlentities($row['location_photo']); $location_photo = nullable_htmlentities($row['location_photo']);
$location_notes = nullable_htmlentities($row['location_notes']); $location_notes = nullable_htmlentities($row['location_notes']);
@@ -201,38 +198,23 @@ ob_start();
</div> </div>
</div> </div>
<label>Phone / <span class="text-secondary">Extension</span></label> <div class="form-group">
<div class="form-row"> <label>Phone</label>
<div class="col-9"> <div class="input-group">
<div class="form-group"> <div class="input-group-prepend">
<div class="input-group"> <span class="input-group-text"><i class="fa fa-fw fa-phone"></i></span>
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-phone"></i></span>
</div>
<input type="tel" class="form-control col-2" name="phone_country_code" value="<?php echo "+$location_phone_country_code"; ?>" placeholder="Code" maxlength="4">
<input type="tel" class="form-control" name="phone" value="<?php echo $location_phone; ?>" placeholder="Phone Number" maxlength="200">
</div>
</div>
</div>
<div class="col-3">
<div class="form-group">
<input type="text" class="form-control" name="extension" value="<?php echo $location_extension; ?>" placeholder="ext." maxlength="200">
</div> </div>
<input type="text" class="form-control" name="phone" placeholder="Phone Number" maxlength="200" value="<?php echo $location_phone; ?>">
</div> </div>
</div> </div>
<label>Fax</label> <div class="form-group">
<div class="form-row"> <label>Fax</label>
<div class="col-9"> <div class="input-group">
<div class="form-group"> <div class="input-group-prepend">
<div class="input-group"> <span class="input-group-text"><i class="fa fa-fw fa-fax"></i></span>
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-fax"></i></span>
</div>
<input type="tel" class="form-control col-2" name="fax_country_code" value="<?php echo "+$location_fax_country_code"; ?>" placeholder="Code" maxlength="4">
<input type="tel" class="form-control" name="fax" value="<?php echo $location_fax; ?>" placeholder="Phone Number" maxlength="200">
</div>
</div> </div>
<input type="text" class="form-control" name="fax" placeholder="Fax Number" maxlength="200" value="<?php echo $location_fax; ?>">
</div> </div>
</div> </div>
@@ -272,15 +254,6 @@ ob_start();
<?php } ?> <?php } ?>
</select> </select>
<div class="input-group-append">
<button class="btn btn-secondary" type="button"
data-toggle="ajax-modal"
data-modal-size="sm"
data-ajax-url="ajax/ajax_tag_add.php"
data-ajax-id="2">
<i class="fas fa-plus"></i>
</button>
</div>
</div> </div>
</div> </div>

View File

@@ -1,13 +1,11 @@
<?php <?php
require_once "../includes/ajax_header.php"; require_once '../includes/ajax_header.php';
$sql = mysqli_query( $sql = mysqli_query($mysqli, "SELECT * FROM notifications
$mysqli,
"SELECT * FROM notifications
WHERE notification_user_id = $session_user_id WHERE notification_user_id = $session_user_id
AND notification_dismissed_at IS NULL AND notification_dismissed_at IS NULL
ORDER BY notification_id DESC" ORDER BY notification_id"
); );
$num_notifications = mysqli_num_rows($sql); $num_notifications = mysqli_num_rows($sql);
@@ -26,23 +24,18 @@ ob_start();
<div class="modal-body bg-white"> <div class="modal-body bg-white">
<?php if ($num_notifications) { ?> <?php if ($num_notifications) { ?>
<?php while ($row = mysqli_fetch_array($sql)) { <?php
while ($row = mysqli_fetch_array($sql)) {
$notification_id = intval($row['notification_id']);
$notification_type = nullable_htmlentities($row['notification_type']);
$notification_details = nullable_htmlentities($row['notification']);
$notification_action = nullable_htmlentities($row['notification_action']);
$notification_timestamp_formated = date('M d g:ia',strtotime($row['notification_timestamp']));
$notification_client_id = intval($row['notification_client_id']);
if(empty($notification_action)) { $notification_action = "#"; }
?>
$notification_id = intval($row["notification_id"]);
$notification_type = nullable_htmlentities($row["notification_type"]);
$notification_details = nullable_htmlentities($row["notification"]);
$notification_action = nullable_htmlentities(
$row["notification_action"]
);
$notification_timestamp_formated = date(
"M d g:ia",
strtotime($row["notification_timestamp"])
);
$notification_client_id = intval($row["notification_client_id"]);
if (empty($notification_action)) {
$notification_action = "#";
}
?>
<a class="text-dark dropdown-item px-1" href="<?php echo $notification_action; ?>"> <a class="text-dark dropdown-item px-1" href="<?php echo $notification_action; ?>">
<div> <div>
@@ -53,11 +46,14 @@ ob_start();
<?php echo $notification_timestamp_formated; ?> <?php echo $notification_timestamp_formated; ?>
</small> </small>
</div> </div>
<small class="text-secondary text-wrap"><?php echo $notification_details; ?></small> <small class="text-secondary"><?php echo $notification_details; ?></small>
</a> </a>
<?php <?php
}} else { ?> }
} else {
?>
<div class="text-center text-secondary py-5"> <div class="text-center text-secondary py-5">
<i class='far fa-6x fa-bell-slash'></i> <i class='far fa-6x fa-bell-slash'></i>
<h3 class="mt-3">No Notifications</h3> <h3 class="mt-3">No Notifications</h3>
@@ -66,17 +62,11 @@ ob_start();
</div> </div>
<div class="modal-footer bg-white justify-content-end"> <div class="modal-footer bg-white justify-content-end">
<?php if ($num_notifications) { ?> <?php if ($num_notifications) { ?>
<a href="post.php?dismiss_all_notifications&csrf_token=<?php echo $_SESSION['csrf_token'] ?>" class="btn btn-primary">
<a href="post.php?dismiss_all_notifications&csrf_token=<?php echo $_SESSION[
"csrf_token"
]; ?>" class="btn btn-primary">
<span class="text-white text-bold"><i class="fas fa-check mr-2"></i>Dismiss all</span> <span class="text-white text-bold"><i class="fas fa-check mr-2"></i>Dismiss all</span>
</a> </a>
<a href="notifications.php" class="btn btn-secondary">
<span class="text-white">See all Notifications</span>
</a>
<?php } else { ?> <?php } else { ?>
<a href="notifications.php?dismissed" class="btn btn-dark"> <a href="notifications_dismissed.php" class="btn btn-dark">
<span class="text-white text-bold">See Dismissed Notifications</span> <span class="text-white text-bold">See Dismissed Notifications</span>
</a> </a>
<?php } ?> <?php } ?>
@@ -85,4 +75,5 @@ ob_start();
</button> </button>
</div> </div>
<?php require_once "../includes/ajax_footer.php"; <?php
require_once "../includes/ajax_footer.php";

View File

@@ -59,12 +59,7 @@ ob_start();
?> ?>
</select> </select>
<div class="input-group-append"> <div class="input-group-append">
<button class="btn btn-secondary" type="button" <a class="btn btn-secondary" href="admin_category.php?category=Income" target="_blank"><i class="fas fa-fw fa-plus"></i></a>
data-toggle="ajax-modal"
data-modal-size="sm"
data-ajax-url="ajax/ajax_category_add.php?category=Income">
<i class="fas fa-fw fa-plus"></i>
</button>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -74,8 +74,9 @@ ob_start();
<?php <?php
$sql_project_managers_select = mysqli_query( $sql_project_managers_select = mysqli_query(
$mysqli, $mysqli,
"SELECT user_id, user_name FROM users "SELECT users.user_id, user_name FROM users
WHERE user_role_id > 1 AND user_status = 1 AND user_archived_at IS NULL ORDER BY user_name ASC" LEFT JOIN user_settings on users.user_id = user_settings.user_id
WHERE user_role > 1 AND user_status = 1 AND user_archived_at IS NULL ORDER BY user_name ASC"
); );
while ($row = mysqli_fetch_array($sql_project_managers_select)) { while ($row = mysqli_fetch_array($sql_project_managers_select)) {
$user_id_select = intval($row['user_id']); $user_id_select = intval($row['user_id']);

View File

@@ -73,12 +73,7 @@ ob_start();
</select> </select>
<div class="input-group-append"> <div class="input-group-append">
<button class="btn btn-secondary" type="button" <a class="btn btn-secondary" href="admin_category.php?category=Income" target="_blank"><i class="fas fa-fw fa-plus"></i></a>
data-toggle="ajax-modal"
data-modal-size="sm"
data-ajax-url="ajax/ajax_category_add.php?category=Income">
<i class="fas fa-fw fa-plus"></i>
</button>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -214,12 +214,7 @@ ob_start();
?> ?>
</select> </select>
<div class="input-group-append"> <div class="input-group-append">
<button class="btn btn-secondary" type="button" <a class="btn btn-secondary" href="admin_category.php?category=Expense" target="_blank"><i class="fas fa-fw fa-plus"></i></a>
data-toggle="ajax-modal"
data-modal-size="sm"
data-ajax-url="ajax/ajax_category_add.php?category=Expense">
<i class="fas fa-plus"></i>
</button>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -2,33 +2,33 @@
require_once '../includes/ajax_header.php'; require_once '../includes/ajax_header.php';
$recurring_invoice_id = intval($_GET['id']); $recurring_id = intval($_GET['id']);
$sql = mysqli_query($mysqli, "SELECT * FROM recurring_invoices WHERE recurring_invoice_id = $recurring_invoice_id LIMIT 1"); $sql = mysqli_query($mysqli, "SELECT * FROM recurring WHERE recurring_id = $recurring_id LIMIT 1");
$row = mysqli_fetch_array($sql); $row = mysqli_fetch_array($sql);
$recurring_invoice_prefix = nullable_htmlentities($row['recurring_invoice_prefix']); $recurring_prefix = nullable_htmlentities($row['recurring_prefix']);
$recurring_invoice_number = intval($row['recurring_invoice_number']); $recurring_number = intval($row['recurring_number']);
$recurring_invoice_scope = nullable_htmlentities($row['recurring_invoice_scope']); $recurring_scope = nullable_htmlentities($row['recurring_scope']);
$recurring_invoice_frequency = nullable_htmlentities($row['recurring_invoice_frequency']); $recurring_frequency = nullable_htmlentities($row['recurring_frequency']);
$recurring_invoice_status = nullable_htmlentities($row['recurring_invoice_status']); $recurring_status = nullable_htmlentities($row['recurring_status']);
$recurring_invoice_created_at = date('Y-m-d', strtotime($row['recurring_invoice_created_at'])); $recurring_created_at = date('Y-m-d', strtotime($row['recurring_created_at']));
$recurring_invoice_next_date = nullable_htmlentities($row['recurring_invoice_next_date']); $recurring_next_date = nullable_htmlentities($row['recurring_next_date']);
$recurring_invoice_discount = floatval($row['recurring_invoice_discount_amount']); $recurring_discount = floatval($row['recurring_discount_amount']);
$category_id = intval($row['recurring_invoice_category_id']); $category_id = intval($row['recurring_category_id']);
// Generate the HTML form content using output buffering. // Generate the HTML form content using output buffering.
ob_start(); ob_start();
?> ?>
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title"><i class="fas fa-fw fa-redo-alt mr-2"></i>Editing Recur Invoice: <strong><?php echo "$recurring_invoice_prefix$recurring_invoice_number"; ?></strong></h5> <h5 class="modal-title"><i class="fas fa-fw fa-redo-alt mr-2"></i>Editing Recur Invoice: <strong><?php echo "$recurring_prefix$recurring_number"; ?></strong></h5>
<button type="button" class="close text-white" data-dismiss="modal"> <button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span> <span>&times;</span>
</button> </button>
</div> </div>
<form action="post.php" method="post" autocomplete="off"> <form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="recurring_invoice_id" value="<?php echo $recurring_invoice_id; ?>"> <input type="hidden" name="recurring_id" value="<?php echo $recurring_id; ?>">
<div class="modal-body bg-white"> <div class="modal-body bg-white">
@@ -38,7 +38,7 @@ ob_start();
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-comment"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-comment"></i></span>
</div> </div>
<input type="text" class="form-control" name="scope" placeholder="Quick description" maxlength="255" value="<?php echo $recurring_invoice_scope; ?>"> <input type="text" class="form-control" name="scope" placeholder="Quick description" maxlength="255" value="<?php echo $recurring_scope; ?>">
</div> </div>
</div> </div>
@@ -50,8 +50,8 @@ ob_start();
</div> </div>
<select class="form-control select2" name="frequency" required> <select class="form-control select2" name="frequency" required>
<option value="">- Frequency -</option> <option value="">- Frequency -</option>
<option <?php if ($recurring_invoice_frequency == 'month') { echo "selected"; } ?> value="month">Monthly</option> <option <?php if ($recurring_frequency == 'month') { echo "selected"; } ?> value="month">Monthly</option>
<option <?php if ($recurring_invoice_frequency == 'year') { echo "selected"; } ?> value="year">Yearly</option> <option <?php if ($recurring_frequency == 'year') { echo "selected"; } ?> value="year">Yearly</option>
</select> </select>
</div> </div>
</div> </div>
@@ -62,7 +62,7 @@ ob_start();
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
</div> </div>
<input type="date" class="form-control" name="next_date" max="2999-12-31" value="<?php echo $recurring_invoice_next_date; ?>" required> <input type="date" class="form-control" name="next_date" max="2999-12-31" value="<?php echo $recurring_next_date; ?>" required>
</div> </div>
</div> </div>
@@ -76,7 +76,7 @@ ob_start();
<option value="">- Category -</option> <option value="">- Category -</option>
<?php <?php
$sql_income_category = mysqli_query($mysqli, "SELECT * FROM categories WHERE category_type = 'Income' AND (category_archived_at > '$recurring_invoice_created_at' OR category_archived_at IS NULL) ORDER BY category_name ASC"); $sql_income_category = mysqli_query($mysqli, "SELECT * FROM categories WHERE category_type = 'Income' AND (category_archived_at > '$recurring_created_at' OR category_archived_at IS NULL) ORDER BY category_name ASC");
while ($row = mysqli_fetch_array($sql_income_category)) { while ($row = mysqli_fetch_array($sql_income_category)) {
$category_id_select = intval($row['category_id']); $category_id_select = intval($row['category_id']);
$category_name_select = nullable_htmlentities($row['category_name']); $category_name_select = nullable_htmlentities($row['category_name']);
@@ -88,12 +88,7 @@ ob_start();
?> ?>
</select> </select>
<div class="input-group-append"> <div class="input-group-append">
<button class="btn btn-secondary" type="button" <a class="btn btn-secondary" href="admin_category.php?category=Income" target="_blank"><i class="fas fa-fw fa-plus"></i></a>
data-toggle="ajax-modal"
data-modal-size="sm"
data-ajax-url="ajax/ajax_category_add.php?category=Income">
<i class="fas fa-fw fa-plus"></i>
</button>
</div> </div>
</div> </div>
</div> </div>
@@ -104,7 +99,7 @@ ob_start();
<div class='input-group-prepend'> <div class='input-group-prepend'>
<span class='input-group-text'><i class='fa fa-fw fa-dollar-sign'></i></span> <span class='input-group-text'><i class='fa fa-fw fa-dollar-sign'></i></span>
</div> </div>
<input type='text' class='form-control' inputmode="numeric" pattern="-?[0-9]*\.?[0-9]{0,2}" name='recurring_invoice_discount' placeholder='0.00' value="<?php echo number_format($recurring_invoice_discount, 2, '.', ''); ?>"> <input type='text' class='form-control' inputmode="numeric" pattern="-?[0-9]*\.?[0-9]{0,2}" name='recurring_discount' placeholder='0.00' value="<?php echo number_format($recurring_discount, 2, '.', ''); ?>">
</div> </div>
</div> </div>
@@ -115,10 +110,10 @@ ob_start();
<span class="input-group-text"><i class="fa fa-fw fa-clock"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-clock"></i></span>
</div> </div>
<select class="form-control select2" name="status" required> <select class="form-control select2" name="status" required>
<option <?php if ($recurring_invoice_status == 1) { <option <?php if ($recurring_status == 1) {
echo "selected"; echo "selected";
} ?> value="1">Active</option> } ?> value="1">Active</option>
<option <?php if ($recurring_invoice_status == 0) { <option <?php if ($recurring_status == 0) {
echo "selected"; echo "selected";
} ?> value="0">InActive</option> } ?> value="0">InActive</option>
</select> </select>
@@ -127,7 +122,7 @@ ob_start();
</div> </div>
<div class="modal-footer bg-white"> <div class="modal-footer bg-white">
<button type="submit" name="edit_recurring_invoice" class="btn btn-primary text-bold"><i class="fas fa-check mr-2"></i>Save</button> <button type="submit" name="edit_recurring" class="btn btn-primary text-bold"><i class="fas fa-check mr-2"></i>Save</button>
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fas fa-times mr-2"></i>Cancel</button> <button type="button" class="btn btn-light" data-dismiss="modal"><i class="fas fa-times mr-2"></i>Cancel</button>
</div> </div>
</form> </form>

View File

@@ -2,64 +2,56 @@
require_once '../includes/ajax_header.php'; require_once '../includes/ajax_header.php';
$recurring_ticket_id = intval($_GET['id']); $scheduled_ticket_id = intval($_GET['id']);
$sql = mysqli_query($mysqli, "SELECT * FROM recurring_tickets WHERE recurring_ticket_id = $recurring_ticket_id LIMIT 1"); $sql = mysqli_query($mysqli, "SELECT * FROM scheduled_tickets WHERE scheduled_ticket_id = $scheduled_ticket_id LIMIT 1");
$row = mysqli_fetch_array($sql); $row = mysqli_fetch_array($sql);
$client_id = intval($row['recurring_ticket_client_id']); $client_id = intval($row['scheduled_ticket_client_id']);
$recurring_ticket_subject = nullable_htmlentities($row['recurring_ticket_subject']); $scheduled_ticket_subject = nullable_htmlentities($row['scheduled_ticket_subject']);
$recurring_ticket_details = nullable_htmlentities($row['recurring_ticket_details']); $scheduled_ticket_details = nullable_htmlentities($row['scheduled_ticket_details']);
$recurring_ticket_priority = nullable_htmlentities($row['recurring_ticket_priority']); $scheduled_ticket_priority = nullable_htmlentities($row['scheduled_ticket_priority']);
$recurring_ticket_frequency = nullable_htmlentities($row['recurring_ticket_frequency']); $scheduled_ticket_frequency = nullable_htmlentities($row['scheduled_ticket_frequency']);
$recurring_ticket_next_run = nullable_htmlentities($row['recurring_ticket_next_run']); $scheduled_ticket_next_run = nullable_htmlentities($row['scheduled_ticket_next_run']);
$recurring_ticket_assigned_to = intval($row['recurring_ticket_assigned_to']); $scheduled_ticket_assigned_to = intval($row['scheduled_ticket_assigned_to']);
$recurring_ticket_contact_id = intval($row['recurring_ticket_contact_id']); $scheduled_ticket_contact_id = intval($row['scheduled_ticket_contact_id']);
$recurring_ticket_asset_id = intval($row['recurring_ticket_asset_id']); $scheduled_ticket_asset_id = intval($row['scheduled_ticket_asset_id']);
$recurring_ticket_billable = intval($row['recurring_ticket_billable']); $scheduled_ticket_billable = intval($row['scheduled_ticket_billable']);
// Additional Assets Selected
$additional_assets_array = array();
$sql_additional_assets = mysqli_query($mysqli, "SELECT asset_id FROM recurring_ticket_assets WHERE recurring_ticket_id = $recurring_ticket_id");
while ($row = mysqli_fetch_array($sql_additional_assets)) {
$additional_asset_id = intval($row['asset_id']);
$additional_assets_array[] = $additional_asset_id;
}
// Generate the HTML form content using output buffering. // Generate the HTML form content using output buffering.
ob_start(); ob_start();
?> ?>
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title"><i class="fas fa-fw fa-calendar-check mr-2"></i>Editing Recurring Ticket: <strong><?php echo $recurring_ticket_subject; ?></strong></h5> <h5 class="modal-title"><i class="fas fa-fw fa-calendar-check mr-2"></i>Editing Recurring Ticket: <strong><?php echo $scheduled_ticket_subject; ?></strong></h5>
<button type="button" class="close text-white" data-dismiss="modal"> <button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span> <span>&times;</span>
</button> </button>
</div> </div>
<form action="post.php" method="post" autocomplete="off"> <form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="recurring_ticket_id" value="<?php echo $recurring_ticket_id; ?>"> <input type="hidden" name="scheduled_ticket_id" value="<?php echo $scheduled_ticket_id; ?>">
<input type="hidden" name="client" value="<?php echo $client_id; ?>"> <input type="hidden" name="client" value="<?php echo $client_id; ?>">
<div class="modal-body bg-white"> <div class="modal-body bg-white">
<ul class="nav nav-pills nav-justified mb-3"> <ul class="nav nav-pills nav-justified mb-3">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link active" data-toggle="pill" href="#pills-edit-details<?php echo $recurring_ticket_id; ?>"><i class="fa fa-fw fa-life-ring mr-2"></i>Details</a> <a class="nav-link active" data-toggle="pill" href="#pills-edit-details<?php echo $scheduled_ticket_id; ?>"><i class="fa fa-fw fa-life-ring mr-2"></i>Details</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" data-toggle="pill" href="#pills-edit-contacts<?php echo $recurring_ticket_id; ?>"><i class="fa fa-fw fa-users mr-2"></i>Contact</a> <a class="nav-link" data-toggle="pill" href="#pills-edit-contacts<?php echo $scheduled_ticket_id; ?>"><i class="fa fa-fw fa-users mr-2"></i>Contacts</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" data-toggle="pill" href="#pills-edit-schedule<?php echo $recurring_ticket_id; ?>"><i class="fa fa-fw fa-building mr-2"></i>Schedule</a> <a class="nav-link" data-toggle="pill" href="#pills-edit-schedule<?php echo $scheduled_ticket_id; ?>"><i class="fa fa-fw fa-building mr-2"></i>Schedule</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" data-toggle="pill" href="#pills-edit-assets<?php echo $recurring_ticket_id; ?>"><i class="fa fa-fw fa-desktop mr-2"></i>Assets</a> <a class="nav-link" data-toggle="pill" href="#pills-edit-assets<?php echo $scheduled_ticket_id; ?>"><i class="fa fa-fw fa-desktop mr-2"></i>Assets</a>
</li> </li>
</ul> </ul>
<div class="tab-content" <?php if (lookupUserPermission('module_support') <= 1) { echo 'inert'; } ?>> <div class="tab-content" <?php if (lookupUserPermission('module_support') <= 1) { echo 'inert'; } ?>>
<div class="tab-pane fade show active" id="pills-edit-details<?php echo $recurring_ticket_id; ?>"> <div class="tab-pane fade show active" id="pills-edit-details<?php echo $scheduled_ticket_id; ?>">
<div class="form-group"> <div class="form-group">
<label>Subject <strong class="text-danger">*</strong></label> <label>Subject <strong class="text-danger">*</strong></label>
@@ -67,12 +59,12 @@ ob_start();
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span>
</div> </div>
<input type="text" class="form-control" name="subject" placeholder="Subject" maxlength="500" value="<?php echo $recurring_ticket_subject; ?>" required > <input type="text" class="form-control" name="subject" placeholder="Subject" maxlength="500" value="<?php echo $scheduled_ticket_subject; ?>" required >
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<textarea class="form-control tinymce" name="details"><?php echo $recurring_ticket_details; ?></textarea> <textarea class="form-control tinymce" name="details"><?php echo $scheduled_ticket_details; ?></textarea>
</div> </div>
<div class="form-group"> <div class="form-group">
@@ -82,9 +74,9 @@ ob_start();
<span class="input-group-text"><i class="fa fa-fw fa-thermometer-half"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-thermometer-half"></i></span>
</div> </div>
<select class="form-control select2" name="priority" required> <select class="form-control select2" name="priority" required>
<option <?php if ($recurring_ticket_priority == "Low") { echo "selected"; } ?> >Low</option> <option <?php if ($scheduled_ticket_priority == "Low") { echo "selected"; } ?> >Low</option>
<option <?php if ($recurring_ticket_priority == "Medium") { echo "selected"; } ?> >Medium</option> <option <?php if ($scheduled_ticket_priority == "Medium") { echo "selected"; } ?> >Medium</option>
<option <?php if ($recurring_ticket_priority == "High") { echo "selected"; } ?> >High</option> <option <?php if ($scheduled_ticket_priority == "High") { echo "selected"; } ?> >High</option>
</select> </select>
</div> </div>
</div> </div>
@@ -108,7 +100,7 @@ ob_start();
$user_name_select = nullable_htmlentities($row['user_name']); $user_name_select = nullable_htmlentities($row['user_name']);
?> ?>
<option value="<?php echo $user_id_select; ?>" <?php if ($recurring_ticket_assigned_to == $user_id_select) { echo "selected"; } ?>><?php echo $user_name_select; ?></option> <option value="<?php echo $user_id_select; ?>" <?php if ($scheduled_ticket_assigned_to == $user_id_select) { echo "selected"; } ?>><?php echo $user_name_select; ?></option>
<?php } ?> <?php } ?>
</select> </select>
</div> </div>
@@ -117,7 +109,7 @@ ob_start();
<div class="form-group <?php if (!$config_module_enable_accounting) { echo 'd-none'; } ?>"> <div class="form-group <?php if (!$config_module_enable_accounting) { echo 'd-none'; } ?>">
<div class="custom-control custom-switch"> <div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="editTicketBillable" name="billable" <input type="checkbox" class="custom-control-input" id="editTicketBillable" name="billable"
<?php if ($recurring_ticket_billable == 1) { echo "checked"; } ?> value="1" <?php if ($scheduled_ticket_billable == 1) { echo "checked"; } ?> value="1"
> >
<label class="custom-control-label" for="editTicketBillable">Mark Billable</label> <label class="custom-control-label" for="editTicketBillable">Mark Billable</label>
</div> </div>
@@ -125,7 +117,7 @@ ob_start();
</div> </div>
<div class="tab-pane fade" id="pills-edit-contacts<?php echo $recurring_ticket_id; ?>"> <div class="tab-pane fade" id="pills-edit-contacts<?php echo $scheduled_ticket_id; ?>">
<div class="form-group"> <div class="form-group">
<label>Contact</label> <label>Contact</label>
@@ -160,7 +152,7 @@ ob_start();
} }
?> ?>
<option value="<?php echo $contact_id_select; ?>" <?php if ($contact_id_select == $recurring_ticket_contact_id) { echo "selected"; } ?>><?php echo "$contact_name_select$contact_title_display_select$contact_primary_display_select$contact_technical_display_select"; ?></option> <option value="<?php echo $contact_id_select; ?>" <?php if ($contact_id_select == $scheduled_ticket_contact_id) { echo "selected"; } ?>><?php echo "$contact_name_select$contact_title_display_select$contact_primary_display_select$contact_technical_display_select"; ?></option>
<?php } ?> <?php } ?>
</select> </select>
</div> </div>
@@ -168,7 +160,7 @@ ob_start();
</div> </div>
<div class="tab-pane fade" id="pills-edit-schedule<?php echo $recurring_ticket_id; ?>"> <div class="tab-pane fade" id="pills-edit-schedule<?php echo $scheduled_ticket_id; ?>">
<div class="form-group"> <div class="form-group">
<label>Frequency <strong class="text-danger">*</strong></label> <label>Frequency <strong class="text-danger">*</strong></label>
@@ -177,11 +169,11 @@ ob_start();
<span class="input-group-text"><i class="fa fa-fw fa-recycle"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-recycle"></i></span>
</div> </div>
<select class="form-control select2" name="frequency"> <select class="form-control select2" name="frequency">
<option <?php if ($recurring_ticket_frequency == "Weekly") { echo "selected"; } ?>>Weekly</option> <option <?php if ($scheduled_ticket_frequency == "Weekly") { echo "selected"; } ?>>Weekly</option>
<option <?php if ($recurring_ticket_frequency == "Monthly") { echo "selected"; } ?>>Monthly</option> <option <?php if ($scheduled_ticket_frequency == "Monthly") { echo "selected"; } ?>>Monthly</option>
<option <?php if ($recurring_ticket_frequency == "Quarterly") { echo "selected"; } ?>>Quarterly</option> <option <?php if ($scheduled_ticket_frequency == "Quarterly") { echo "selected"; } ?>>Quarterly</option>
<option <?php if ($recurring_ticket_frequency == "Biannually") { echo "selected"; } ?>>Biannually</option> <option <?php if ($scheduled_ticket_frequency == "Biannually") { echo "selected"; } ?>>Biannually</option>
<option <?php if ($recurring_ticket_frequency == "Annually") { echo "selected"; } ?>>Annually</option> <option <?php if ($scheduled_ticket_frequency == "Annually") { echo "selected"; } ?>>Annually</option>
</select> </select>
</div> </div>
</div> </div>
@@ -192,13 +184,13 @@ ob_start();
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar-day"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-calendar-day"></i></span>
</div> </div>
<input class="form-control" type="date" name="next_date" max="2999-12-31" value="<?php echo $recurring_ticket_next_run; ?>"> <input class="form-control" type="date" name="next_date" max="2999-12-31" value="<?php echo $scheduled_ticket_next_run; ?>">
</div> </div>
</div> </div>
</div> </div>
<div class="tab-pane fade" id="pills-edit-assets<?php echo $recurring_ticket_id; ?>"> <div class="tab-pane fade" id="pills-edit-assets<?php echo $scheduled_ticket_id; ?>">
<div class="form-group"> <div class="form-group">
<label>Asset</label> <label>Asset</label>
@@ -216,7 +208,7 @@ ob_start();
$asset_name_select = nullable_htmlentities($row['asset_name']); $asset_name_select = nullable_htmlentities($row['asset_name']);
$asset_contact_name_select = nullable_htmlentities($row['contact_name']); $asset_contact_name_select = nullable_htmlentities($row['contact_name']);
?> ?>
<option <?php if ($recurring_ticket_asset_id == $asset_id_select) { echo "selected"; } ?> value="<?php echo $asset_id_select; ?>"><?php echo "$asset_name_select - $asset_contact_name_select"; ?></option> <option <?php if ($scheduled_ticket_asset_id == $asset_id_select) { echo "selected"; } ?> value="<?php echo $asset_id_select; ?>"><?php echo "$asset_name_select - $asset_contact_name_select"; ?></option>
<?php <?php
} }
@@ -225,31 +217,6 @@ ob_start();
</div> </div>
</div> </div>
<div class="form-group">
<label>Additional Assets</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-desktop"></i></span>
</div>
<select class="form-control select2" name="additional_assets[]" data-tags="true" data-placeholder="- Select Additional Assets -" multiple>
<option value=""></option>
<?php
$sql_assets = mysqli_query($mysqli, "SELECT asset_id, asset_name, contact_name FROM assets LEFT JOIN contacts ON contact_id = asset_contact_id WHERE asset_client_id = $client_id AND asset_id != $recurring_ticket_asset_id AND asset_archived_at IS NULL ORDER BY asset_name ASC");
while ($row = mysqli_fetch_array($sql_assets)) {
$asset_id_select = intval($row['asset_id']);
$asset_name_select = nullable_htmlentities($row['asset_name']);
$asset_contact_name_select = nullable_htmlentities($row['contact_name']);
?>
<option value="<?php echo $asset_id_select; ?>"
<?php if (in_array($asset_id_select, $additional_assets_array)) { echo "selected"; } ?>
><?php echo "$asset_name_select - $asset_contact_name_select"; ?></option>
<?php } ?>
</select>
</div>
</div>
</div> </div>
</div> </div>

View File

@@ -125,12 +125,7 @@ ob_start();
?> ?>
</select> </select>
<div class="input-group-append"> <div class="input-group-append">
<button class="btn btn-secondary" type="button" <a class="btn btn-secondary" href="admin_category.php?category=Income" target="_blank"><i class="fas fa-fw fa-plus"></i></a>
data-toggle="ajax-modal"
data-modal-size="sm"
data-ajax-url="ajax/ajax_category_add.php?category=Income">
<i class="fas fa-fw fa-plus"></i>
</button>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -4,18 +4,18 @@ require_once '../includes/ajax_header.php';
$role_id = intval($_GET['id']); $role_id = intval($_GET['id']);
$sql = mysqli_query($mysqli, "SELECT * FROM user_roles WHERE role_id = $role_id LIMIT 1"); $sql = mysqli_query($mysqli, "SELECT * FROM user_roles WHERE user_role_id = $role_id LIMIT 1");
$row = mysqli_fetch_array($sql); $row = mysqli_fetch_array($sql);
$role_name = nullable_htmlentities($row['role_name']); $role_name = nullable_htmlentities($row['user_role_name']);
$role_description = nullable_htmlentities($row['role_description']); $role_description = nullable_htmlentities($row['user_role_description']);
$role_admin = intval($row['role_is_admin']); $role_admin = intval($row['user_role_is_admin']);
// Count number of users that have each role // Count number of users that have each role
$sql_role_user_count = mysqli_query($mysqli, "SELECT COUNT(user_id) FROM users WHERE user_role_id = $role_id AND user_archived_at IS NULL"); $sql_role_user_count = mysqli_query($mysqli, "SELECT COUNT(users.user_id) FROM users LEFT JOIN user_settings on users.user_id = user_settings.user_id WHERE user_role = $role_id AND user_archived_at IS NULL");
$role_user_count = mysqli_fetch_row($sql_role_user_count)[0]; $role_user_count = mysqli_fetch_row($sql_role_user_count)[0];
$sql_users = mysqli_query($mysqli, "SELECT * FROM users WHERE user_role_id = $role_id AND user_archived_at IS NULL"); $sql_users = mysqli_query($mysqli, "SELECT * FROM users LEFT JOIN user_settings on users.user_id = user_settings.user_id WHERE user_role = $role_id AND user_archived_at IS NULL");
// Initialize an empty array to hold user names // Initialize an empty array to hold user names
$user_names = []; $user_names = [];

View File

@@ -28,23 +28,23 @@ if ($service_importance == "High") {
$service_importance_display = "-"; $service_importance_display = "-";
} }
// Associated Assets (and their credentials/networks/locations) // Associated Assets (and their logins/networks/locations)
$sql_assets = mysqli_query( $sql_assets = mysqli_query(
$mysqli, $mysqli,
"SELECT * FROM service_assets "SELECT * FROM service_assets
LEFT JOIN assets ON service_assets.asset_id = assets.asset_id LEFT JOIN assets ON service_assets.asset_id = assets.asset_id
LEFT JOIN asset_interfaces ON interface_asset_id = assets.asset_id AND interface_primary = 1 LEFT JOIN asset_interfaces ON interface_asset_id = assets.asset_id AND interface_primary = 1
LEFT JOIN credentials ON service_assets.asset_id = credentials.credential_asset_id LEFT JOIN logins ON service_assets.asset_id = logins.login_asset_id
LEFT JOIN networks ON interface_network_id = networks.network_id LEFT JOIN networks ON interface_network_id = networks.network_id
LEFT JOIN locations ON assets.asset_location_id = locations.location_id LEFT JOIN locations ON assets.asset_location_id = locations.location_id
WHERE service_id = $service_id" WHERE service_id = $service_id"
); );
// Associated credentials // Associated logins
$sql_credentials = mysqli_query( $sql_logins = mysqli_query(
$mysqli, $mysqli,
"SELECT * FROM service_credentials "SELECT * FROM service_logins
LEFT JOIN credentials ON service_credentials.credential_id = credentials.credential_id LEFT JOIN logins ON service_logins.login_id = logins.login_id
WHERE service_id = $service_id" WHERE service_id = $service_id"
); );
@@ -275,16 +275,7 @@ ob_start();
<ul> <ul>
<?php <?php
while ($row = mysqli_fetch_array($sql_vendors)) { while ($row = mysqli_fetch_array($sql_vendors)) {
echo "<li><a href=\"vendors.php?client_id=$client_id&q=$row[vendor_name]\">$row[vendor_name]</a></li>";
$vendor_id = intval($row['vendor_id']);
$vendor_name = nullable_htmlentities($row['vendor_name']);
echo "<li><a href='#' data-toggle='ajax-modal'
data-modal-size='lg'
data-ajax-url='ajax/ajax_vendor_details.php'
data-ajax-id='$vendor_id'>
$vendor_name
</a>
</li>";
} }
?> ?>
</ul> </ul>
@@ -318,27 +309,27 @@ ob_start();
} }
?> ?>
<!-- Credentials --> <!-- Logins -->
<?php <?php
if (mysqli_num_rows($sql_assets) > 0 || mysqli_num_rows($sql_credentials) > 0) { ?> if (mysqli_num_rows($sql_assets) > 0 || mysqli_num_rows($sql_logins) > 0) { ?>
<h5><i class="fas fa-fw fa-key mr-2"></i>Credentials</h5> <h5><i class="fas fa-fw fa-key mr-2"></i>Logins</h5>
<ul> <ul>
<?php <?php
// Reset the $sql_assets/credentials pointer to the start // Reset the $sql_assets/logins pointer to the start
mysqli_data_seek($sql_assets, 0); mysqli_data_seek($sql_assets, 0);
mysqli_data_seek($sql_credentials, 0); mysqli_data_seek($sql_logins, 0);
// Showing credentials linked to assets // Showing logins linked to assets
while ($row = mysqli_fetch_array($sql_assets)) { while ($row = mysqli_fetch_array($sql_assets)) {
if (!empty($row['credential_name'])) { if (!empty($row['login_name'])) {
echo "<li><a href=\"credentials.php?client_id=$client_id&q=$row[credential_name]\">$row[credential_name]</a></li>"; echo "<li><a href=\"credentials.php?client_id=$client_id&q=$row[login_name]\">$row[login_name]</a></li>";
} }
} }
// Showing explicitly linked credentials // Showing explicitly linked logins
while ($row = mysqli_fetch_array($sql_credentials)) { while ($row = mysqli_fetch_array($sql_logins)) {
if (!empty($row['credential_name'])) { if (!empty($row['login_name'])) {
echo "<li><a href=\"credentials.php?client_id=$client_id&q=$row[credential_name]\">$row[credential_name]</a></li>"; echo "<li><a href=\"credentials.php?client_id=$client_id&q=$row[login_name]\">$row[login_name]</a></li>";
} }
} }
?> ?>
@@ -349,27 +340,27 @@ ob_start();
<!-- URLs --> <!-- URLs -->
<?php <?php
if ($sql_credentials || $sql_assets) { ?> if ($sql_logins || $sql_assets) { ?>
<h5><i class="fas fa-fw fa-link mr-2"></i>URLs</h5> <h5><i class="fas fa-fw fa-link mr-2"></i>URLs</h5>
<ul> <ul>
<?php <?php
// Reset the $sql_credentials pointer to the start // Reset the $sql_logins pointer to the start
mysqli_data_seek($sql_credentials, 0); mysqli_data_seek($sql_logins, 0);
// Showing URLs linked to credentials // Showing URLs linked to logins
while ($row = mysqli_fetch_array($sql_credentials)) { while ($row = mysqli_fetch_array($sql_logins)) {
if (!empty($row['credential_uri'])) { if (!empty($row['login_uri'])) {
echo "<li><a href=\"https://$row[credential_uri]\">$row[credential_uri]</a></li>"; echo "<li><a href=\"https://$row[login_uri]\">$row[login_uri]</a></li>";
} }
} }
// Reset the $sql_assets pointer to the start // Reset the $sql_assets pointer to the start
mysqli_data_seek($sql_assets, 0); mysqli_data_seek($sql_assets, 0);
// Show URLs linked to assets, that also have credentials // Show URLs linked to assets, that also have logins
while ($row = mysqli_fetch_array($sql_assets)) { while ($row = mysqli_fetch_array($sql_assets)) {
if (!empty($row['credential_uri'])) { if (!empty($row['login_uri'])) {
echo "<li><a href=\"https://$row[credential_uri]\">$row[credential_uri]</a></li>"; echo "<li><a href=\"https://$row[login_uri]\">$row[login_uri]</a></li>";
} }
} }
?> ?>
@@ -388,15 +379,7 @@ ob_start();
mysqli_data_seek($sql_docs, 0); mysqli_data_seek($sql_docs, 0);
while ($row = mysqli_fetch_array($sql_docs)) { while ($row = mysqli_fetch_array($sql_docs)) {
$document_id = intval($row['document_id']); echo "<li><a href=\"client_document_details.php?client_id=$client_id&document_id=$row[document_id]\">$row[document_name]</a></li>";
$document_name = nullable_htmlentities($row['document_name']);
echo "<li><a href='#' data-toggle='ajax-modal'
data-modal-size='lg'
data-ajax-url='ajax/ajax_document_view.php'
data-ajax-id='$document_id'>
$document_name
</a>
</li>";
} }
?> ?>
</ul> </ul>

View File

@@ -18,23 +18,23 @@ $service_updated_at = nullable_htmlentities($row['service_updated_at']);
$service_review_due = nullable_htmlentities($row['service_review_due']); $service_review_due = nullable_htmlentities($row['service_review_due']);
$client_id = intval($row['service_client_id']); $client_id = intval($row['service_client_id']);
// Associated Assets (and their credentials/networks/locations) // Associated Assets (and their logins/networks/locations)
$sql_assets = mysqli_query( $sql_assets = mysqli_query(
$mysqli, $mysqli,
"SELECT * FROM service_assets "SELECT * FROM service_assets
LEFT JOIN assets ON service_assets.asset_id = assets.asset_id LEFT JOIN assets ON service_assets.asset_id = assets.asset_id
LEFT JOIN asset_interfaces ON interface_asset_id = assets.asset_id AND interface_primary = 1 LEFT JOIN asset_interfaces ON interface_asset_id = assets.asset_id AND interface_primary = 1
LEFT JOIN credentials ON service_assets.asset_id = credentials.credential_asset_id LEFT JOIN logins ON service_assets.asset_id = logins.login_asset_id
LEFT JOIN networks ON interface_network_id = networks.network_id LEFT JOIN networks ON interface_network_id = networks.network_id
LEFT JOIN locations ON assets.asset_location_id = locations.location_id LEFT JOIN locations ON assets.asset_location_id = locations.location_id
WHERE service_id = $service_id" WHERE service_id = $service_id"
); );
// Associated credentials // Associated logins
$sql_credentials = mysqli_query( $sql_logins = mysqli_query(
$mysqli, $mysqli,
"SELECT * FROM service_credentials "SELECT * FROM service_logins
LEFT JOIN credentials ON service_credentials.credential_id = credentials.credential_id LEFT JOIN logins ON service_logins.login_id = logins.login_id
WHERE service_id = $service_id" WHERE service_id = $service_id"
); );
@@ -280,21 +280,21 @@ ob_start();
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="credentials">Credentials</label> <label for="logins">Logins</label>
<select multiple class="form-control select2" name="credentials[]"> <select multiple class="form-control select2" name="logins[]">
<?php <?php
$selected_ids = array_column(mysqli_fetch_all($sql_credentials, MYSQLI_ASSOC), "credential_id"); $selected_ids = array_column(mysqli_fetch_all($sql_logins, MYSQLI_ASSOC), "login_id");
$sql_all = mysqli_query($mysqli, "SELECT * FROM credentials WHERE (credential_archived_at > '$service_created_at' OR credential_archived_at IS NULL) AND credential_client_id = $client_id"); $sql_all = mysqli_query($mysqli, "SELECT * FROM logins WHERE (login_archived_at > '$service_created_at' OR login_archived_at IS NULL) AND login_client_id = $client_id");
while ($row_all = mysqli_fetch_array($sql_all)) { while ($row_all = mysqli_fetch_array($sql_all)) {
$credential_id = intval($row_all['credential_id']); $login_id = intval($row_all['login_id']);
$credential_name = nullable_htmlentities($row_all['credential_name']); $login_name = nullable_htmlentities($row_all['login_name']);
if (in_array($credential_id, $selected_ids)) { if (in_array($login_id, $selected_ids)) {
echo "<option value=\"$credential_id\" selected>$credential_name</option>"; echo "<option value=\"$login_id\" selected>$login_name</option>";
} }
else{ else{
echo "<option value=\"$credential_id\">$credential_name</option>"; echo "<option value=\"$login_id\">$login_name</option>";
} }
} }
?> ?>

View File

@@ -14,12 +14,10 @@ $software_type = nullable_htmlentities($row['software_type']);
$software_license_type = nullable_htmlentities($row['software_license_type']); $software_license_type = nullable_htmlentities($row['software_license_type']);
$software_key = nullable_htmlentities($row['software_key']); $software_key = nullable_htmlentities($row['software_key']);
$software_seats = nullable_htmlentities($row['software_seats']); $software_seats = nullable_htmlentities($row['software_seats']);
$software_purchase_reference = nullable_htmlentities($row['software_purchase_reference']);
$software_purchase = nullable_htmlentities($row['software_purchase']); $software_purchase = nullable_htmlentities($row['software_purchase']);
$software_expire = nullable_htmlentities($row['software_expire']); $software_expire = nullable_htmlentities($row['software_expire']);
$software_notes = nullable_htmlentities($row['software_notes']); $software_notes = nullable_htmlentities($row['software_notes']);
$software_created_at = nullable_htmlentities($row['software_created_at']); $software_created_at = nullable_htmlentities($row['software_created_at']);
$software_vendor_id = intval($row['software_vendor_id']);
$client_id = intval($row['software_client_id']); $client_id = intval($row['software_client_id']);
$seat_count = 0; $seat_count = 0;
@@ -109,28 +107,6 @@ ob_start();
</div> </div>
</div> </div>
<div class="form-group">
<label>Vendor</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-building"></i></span>
</div>
<select class="form-control select2" name="vendor">
<option value="">- Select Vendor -</option>
<?php
$vendor_sql = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_client_id = $client_id AND vendor_archived_at IS NULL ORDER BY vendor_name ASC");
while ($row = mysqli_fetch_array($vendor_sql)) {
$vendor_id = $row['vendor_id'];
$vendor_name = $row['vendor_name'];
?>
<option <?php if ($software_vendor_id == $vendor_id) { echo "selected"; } ?> value="<?php echo $vendor_id; ?>"><?php echo $vendor_name; ?></option>
<?php
}
?>
</select>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label>Type <strong class="text-danger">*</strong></label> <label>Type <strong class="text-danger">*</strong></label>
<div class="input-group"> <div class="input-group">
@@ -184,16 +160,6 @@ ob_start();
</div> </div>
</div> </div>
<div class="form-group">
<label>Purchase Reference</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-shopping-cart"></i></span>
</div>
<input type="text" class="form-control" name="purchase_reference" placeholder="eg. Invoice, PO Number" value="<?php echo $software_purchase_reference; ?>">
</div>
</div>
<div class="form-group"> <div class="form-group">
<label>Purchase Date</label> <label>Purchase Date</label>
<div class="input-group"> <div class="input-group">

View File

@@ -1,49 +0,0 @@
<?php
require_once '../includes/ajax_header.php';
$type = intval($_GET['id']);
?>
<!-- <option value="1">Client Tag</option> -->
<!-- <option value="2">Location Tag</option> -->
<!-- <option value="3">Contact Tag</option> -->
<!-- <option value="4">Credential Tag</option> -->
<div class="modal-header">
<h5 class="modal-title"><i class="fas fa-fw fa-tag mr-2"></i>New Tag</h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="type" value="<?php echo $type; ?>">
<div class="modal-body bg-white">
<div class="form-group">
<div class="input-group">
<input type="text" class="form-control" name="name" placeholder="Tag name" maxlength="200" required autofocus>
</div>
</div>
<div class="form-group">
<div class="input-group">
<input type="color" class="form-control col-3" name="color" required>
</div>
</div>
<div class="form-group">
<div class="input-group">
<input type="text" class="form-control" name="icon" placeholder="Icon ex handshake">
</div>
</div>
</div>
<div class="modal-footer bg-white">
<button type="submit" name="add_tag" class="btn btn-primary text-bold"><i class="fas fa-check mr-2"></i>Create</button>
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fas fa-times mr-2"></i>Cancel</button>
</div>
</form>
<?php
require_once "../includes/ajax_footer.php";

View File

@@ -24,14 +24,6 @@ $location_id = intval($row['ticket_location_id']);
$vendor_id = intval($row['ticket_vendor_id']); $vendor_id = intval($row['ticket_vendor_id']);
$project_id = intval($row['ticket_project_id']); $project_id = intval($row['ticket_project_id']);
// Additional Assets Selected
$additional_assets_array = array();
$sql_additional_assets = mysqli_query($mysqli, "SELECT asset_id FROM ticket_assets WHERE ticket_id = $ticket_id");
while ($row = mysqli_fetch_array($sql_additional_assets)) {
$additional_asset_id = intval($row['asset_id']);
$additional_assets_array[] = $additional_asset_id;
}
// Generate the HTML form content using output buffering. // Generate the HTML form content using output buffering.
ob_start(); ob_start();
?> ?>
@@ -75,7 +67,7 @@ ob_start();
</div> </div>
<div class="form-group"> <div class="form-group">
<textarea class="form-control tinymceTicket" rows="8" name="details"><?php echo $ticket_details; ?></textarea> <textarea class="form-control tinymce" rows="8" name="details"><?php echo $ticket_details; ?></textarea>
</div> </div>
<div class="row"> <div class="row">
@@ -115,14 +107,6 @@ ob_start();
<?php } ?> <?php } ?>
</select> </select>
<div class="input-group-append">
<button class="btn btn-secondary" type="button"
data-toggle="ajax-modal"
data-modal-size="sm"
data-ajax-url="ajax/ajax_category_add.php?category=Ticket">
<i class="fas fa-fw fa-plus"></i>
</button>
</div>
</div> </div>
</div> </div>
</div> </div>
@@ -220,31 +204,6 @@ ob_start();
</div> </div>
</div> </div>
<div class="form-group">
<label>Additional Assets</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-desktop"></i></span>
</div>
<select class="form-control select2" name="additional_assets[]" data-tags="true" data-placeholder="- Select Additional Assets -" multiple>
<option value=""></option>
<?php
$sql_assets = mysqli_query($mysqli, "SELECT asset_id, asset_name, contact_name FROM assets LEFT JOIN contacts ON contact_id = asset_contact_id WHERE asset_client_id = $client_id AND asset_id != $asset_id AND asset_archived_at IS NULL ORDER BY asset_name ASC");
while ($row = mysqli_fetch_array($sql_assets)) {
$asset_id_select = intval($row['asset_id']);
$asset_name_select = nullable_htmlentities($row['asset_name']);
$asset_contact_name_select = nullable_htmlentities($row['contact_name']);
?>
<option value="<?php echo $asset_id_select; ?>"
<?php if (in_array($asset_id_select, $additional_assets_array)) { echo "selected"; } ?>
><?php echo "$asset_name_select - $asset_contact_name_select"; ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label>Location</label> <label>Location</label>
<div class="input-group"> <div class="input-group">

View File

@@ -1,54 +0,0 @@
<?php
require_once '../includes/ajax_header.php';
$ticket_reply_id = intval($_GET['id']);
$sql = mysqli_query($mysqli, "SELECT * FROM ticket_replies
LEFT JOIN tickets ON ticket_id = ticket_reply_ticket_id
WHERE ticket_reply_id = $ticket_reply_id
LIMIT 1"
);
$row = mysqli_fetch_array($sql);
$ticket_reply_type = nullable_htmlentities($row['ticket_reply_type']);
$ticket_reply_time_worked = date_create($row['ticket_reply_time_worked']);
$ticket_reply_time_worked_formatted = date_format($ticket_reply_time_worked, 'H:i:s');
$ticket_reply = nullable_htmlentities($row['ticket_reply']);
$client_id = intval($row['ticket_client_id']);
// Generate the HTML form content using output buffering.
ob_start();
?>
<div class="modal-header">
<h5 class="modal-title"><i class="fa fa-fw fa-edit mr-2"></i>Redacting Ticket Reply</h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="ticket_reply_id" value="<?php echo $ticket_reply_id; ?>">
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
<input type="hidden" name="ticket_reply_type" value="<?php echo $ticket_reply_type; ?>">
<?php if (!empty($ticket_reply_time_worked)) { ?>
<input type="hidden" name="time" value="<?php echo $ticket_reply_time_worked_formatted; ?>">
<?php } ?>
<div class="modal-body bg-white">
<div class="form-group">
<textarea class="form-control tinymceRedact" name="ticket_reply"><?php echo $ticket_reply; ?></textarea>
</div>
</div>
<div class="modal-footer bg-white">
<button type="submit" name="edit_ticket_reply" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Save</button>
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
</div>
</form>
<?php
require_once "../includes/ajax_footer.php";

View File

@@ -4,10 +4,7 @@ require_once '../includes/ajax_header.php';
$user_id = intval($_GET['id']); $user_id = intval($_GET['id']);
$sql = mysqli_query($mysqli, "SELECT * FROM users $sql = mysqli_query($mysqli, "SELECT * FROM users, user_settings WHERE users.user_id = user_settings.user_id AND users.user_id = $user_id LIMIT 1");
LEFT JOIN user_settings ON users.user_id = user_settings.user_id
WHERE users.user_id = $user_id LIMIT 1"
);
$row = mysqli_fetch_array($sql); $row = mysqli_fetch_array($sql);
$user_name = nullable_htmlentities($row['user_name']); $user_name = nullable_htmlentities($row['user_name']);
@@ -15,11 +12,11 @@ $user_email = nullable_htmlentities($row['user_email']);
$user_avatar = nullable_htmlentities($row['user_avatar']); $user_avatar = nullable_htmlentities($row['user_avatar']);
$user_token = nullable_htmlentities($row['user_token']); $user_token = nullable_htmlentities($row['user_token']);
$user_config_force_mfa = intval($row['user_config_force_mfa']); $user_config_force_mfa = intval($row['user_config_force_mfa']);
$user_role_id = intval($row['user_role_id']); $user_role = intval($row['user_role']);
$user_initials = nullable_htmlentities(initials($user_name)); $user_initials = nullable_htmlentities(initials($user_name));
// Get User Client Access Permissions // Get User Client Access Permissions
$user_client_access_sql = mysqli_query($mysqli,"SELECT client_id FROM user_client_permissions WHERE user_id = $user_id"); $user_client_access_sql = mysqli_query($mysqli,"SELECT client_id FROM user_permissions WHERE user_id = $user_id");
$client_access_array = []; $client_access_array = [];
while ($row = mysqli_fetch_assoc($user_client_access_sql)) { while ($row = mysqli_fetch_assoc($user_client_access_sql)) {
$client_access_array[] = intval($row['client_id']); $client_access_array[] = intval($row['client_id']);
@@ -110,13 +107,13 @@ ob_start();
</div> </div>
<select class="form-control select2" name="role" required> <select class="form-control select2" name="role" required>
<?php <?php
$sql_user_roles = mysqli_query($mysqli, "SELECT * FROM user_roles WHERE role_archived_at IS NULL"); $sql_user_roles = mysqli_query($mysqli, "SELECT * FROM user_roles WHERE user_role_archived_at IS NULL");
while ($row = mysqli_fetch_array($sql_user_roles)) { while ($row = mysqli_fetch_array($sql_user_roles)) {
$role_id = intval($row['role_id']); $user_role_id = intval($row['user_role_id']);
$role_name = nullable_htmlentities($row['role_name']); $user_role_name = nullable_htmlentities($row['user_role_name']);
?> ?>
<option <?php if ($role_id == $user_role_id) {echo "selected";} ?> value="<?php echo $role_id; ?>"><?php echo $role_name; ?></option> <option <?php if ($user_role == $user_role_id) {echo "selected";} ?> value="<?php echo $user_role_id; ?>"><?php echo $user_role_name; ?></option>
<?php } ?> <?php } ?>
</select> </select>

View File

@@ -1,89 +0,0 @@
<?php
require_once '../includes/ajax_header.php';
$vendor_id = intval($_GET['id']);
$sql = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_id = $vendor_id LIMIT 1");
$row = mysqli_fetch_array($sql);
$name = sanitizeInput($row['vendor_name']);
$description = sanitizeInput($row['vendor_description']);
$account_number = sanitizeInput($row['vendor_account_number']);
$contact_name = sanitizeInput($row['vendor_contact_name']);
$phone = preg_replace("/[^0-9]/", '',$row['vendor_phone']);
$extension = preg_replace("/[^0-9]/", '',$row['vendor_extension']);
$email = sanitizeInput($row['vendor_email']);
$website = sanitizeInput($row['vendor_website']);
$hours = sanitizeInput($row['vendor_hours']);
$sla = sanitizeInput($row['vendor_sla']);
$code = sanitizeInput($row['vendor_code']);
$notes = sanitizeInput($row['vendor_notes']);
// Generate the HTML form content using output buffering.
ob_start();
?>
<div class="modal-header bg-dark text-white">
<div class="d-flex align-items-center">
<i class="fas fa-fw fa-building fa-2x mr-3"></i>
<div>
<h5 class="modal-title mb-0"><?php echo $name; ?></h5>
<div class="text-muted"><?php echo getFallback($description); ?></div>
</div>
</div>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<div class="modal-body bg-light">
<!-- Vendor Info Card -->
<div class="card mb-3 shadow-sm rounded">
<div class="card-body">
<h6 class="text-secondary"><i class="fas fa-info-circle mr-2"></i>Vendor Details</h6>
<div class="row">
<div class="col-sm-6">
<div><strong>Account Number:</strong> <?php echo getFallback($account_number); ?></div>
<div><strong>Hours:</strong> <?php echo getFallback($hours); ?></div>
<div><strong>SLA:</strong> <?php echo getFallback($sla); ?></div>
</div>
<div class="col-sm-6">
<div><strong>Code:</strong> <?php echo getFallback($code); ?></div>
<div><strong>Website:</strong> <?php echo !empty($website) ? '<a href="' . $website . '" target="_blank" class="text-primary">' . $website . '</a>' : '<span class="text-muted">Not Available</span>'; ?></div>
</div>
</div>
</div>
</div>
<!-- Contact Info Card -->
<div class="card mb-3 shadow-sm rounded">
<div class="card-body">
<h6 class="text-secondary"><i class="fas fa-user mr-2"></i>Contact Information</h6>
<div class="row">
<div class="col-sm-6">
<div><strong>Contact Name:</strong> <?php echo getFallback($contact_name); ?></div>
<div><strong>Phone:</strong> <?php echo getFallback($phone); ?></div>
</div>
<div class="col-sm-6">
<div><strong>Email:</strong> <?php echo !empty($email) ? '<a href="mailto:' . $email . '" class="text-primary">' . $email . '</a>' : '<span class="text-muted">Not Available</span>'; ?></div>
</div>
</div>
</div>
</div>
<!-- Notes Card -->
<div class="card mb-3 shadow-sm rounded">
<div class="card-body">
<h6 class="text-secondary"><i class="fas fa-sticky-note mr-2"></i>Notes</h6>
<div>
<?php echo getFallback($notes); ?>
</div>
</div>
</div>
</div>
<?php
require_once "../includes/ajax_footer.php";

View File

@@ -11,8 +11,7 @@ $vendor_name = nullable_htmlentities($row['vendor_name']);
$vendor_description = nullable_htmlentities($row['vendor_description']); $vendor_description = nullable_htmlentities($row['vendor_description']);
$vendor_account_number = nullable_htmlentities($row['vendor_account_number']); $vendor_account_number = nullable_htmlentities($row['vendor_account_number']);
$vendor_contact_name = nullable_htmlentities($row['vendor_contact_name']); $vendor_contact_name = nullable_htmlentities($row['vendor_contact_name']);
$vendor_phone_country_code = nullable_htmlentities($row['vendor_phone_country_code']); $vendor_phone = formatPhoneNumber($row['vendor_phone']);
$vendor_phone = nullable_htmlentities(formatPhoneNumber($row['vendor_phone'], $vendor_phone_country_code));
$vendor_extension = nullable_htmlentities($row['vendor_extension']); $vendor_extension = nullable_htmlentities($row['vendor_extension']);
$vendor_email = nullable_htmlentities($row['vendor_email']); $vendor_email = nullable_htmlentities($row['vendor_email']);
$vendor_website = nullable_htmlentities($row['vendor_website']); $vendor_website = nullable_htmlentities($row['vendor_website']);
@@ -119,23 +118,20 @@ ob_start();
<div class="tab-pane fade" id="pills-support<?php echo $vendor_id; ?>"> <div class="tab-pane fade" id="pills-support<?php echo $vendor_id; ?>">
<label>Support Phone / <span class="text-secondary">Extension</span></label> <label>Support Phone</label>
<div class="form-row"> <div class="form-row">
<div class="col-9"> <div class="col-8">
<div class="form-group"> <div class="form-group">
<div class="input-group"> <div class="input-group">
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-phone"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-phone"></i></span>
</div> </div>
<input type="tel" class="form-control col-2" name="phone_country_code" value="<?php echo "+$vendor_phone_country_code"; ?>" placeholder="Code" maxlength="4"> <input type="text" class="form-control" name="phone" placeholder="Phone Number" maxlength="200" value="<?php echo $vendor_phone; ?>">
<input type="tel" class="form-control" name="phone" value="<?php echo $vendor_phone; ?>" placeholder="Phone Number" maxlength="200">
</div> </div>
</div> </div>
</div> </div>
<div class="col-3"> <div class="col-4">
<div class="form-group"> <input type="text" class="form-control" name="extension" placeholder="Prompts" maxlength="200" value="<?php echo $vendor_extension; ?>">
<input type="text" class="form-control" name="extension" value="<?php echo $vendor_extension; ?>" placeholder="ext." maxlength="200">
</div>
</div> </div>
</div> </div>

View File

@@ -134,7 +134,7 @@ ob_start();
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-phone"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-phone"></i></span>
</div> </div>
<input type="tel" class="form-control" name="phone" value="<?php echo $vendor_phone; ?>"> <input type="text" class="form-control" name="phone" placeholder="Phone Number" maxlength="200" value="<?php echo $vendor_phone; ?>">
<div class="input-group-append"> <div class="input-group-append">
<div class="input-group-text"> <div class="input-group-text">
<input type="checkbox" name="global_update_vendor_phone" value="1"> <input type="checkbox" name="global_update_vendor_phone" value="1">

View File

@@ -13,7 +13,7 @@ $insert_id = false;
if (!empty($api_key_decrypt_password) && !empty($name) && !(empty($password))) { if (!empty($api_key_decrypt_password) && !empty($name) && !(empty($password))) {
// Add credential // Add credential
$insert_sql = mysqli_query($mysqli,"INSERT INTO credentials SET credential_name = '$name', credential_description = '$description', credential_uri = '$uri', credential_uri_2 = '$uri_2', credential_username = '$username', credential_password = '$password', credential_otp_secret = '$otp_secret', credential_note = '$note', credential_important = $important, credential_contact_id = $contact_id, credential_vendor_id = $vendor_id, credential_asset_id = $asset_id, credential_software_id = $software_id, credential_client_id = $client_id"); $insert_sql = mysqli_query($mysqli,"INSERT INTO logins SET login_name = '$name', login_description = '$description', login_uri = '$uri', login_uri_2 = '$uri_2', login_username = '$username', login_password = '$password', login_otp_secret = '$otp_secret', login_note = '$note', login_important = $important, login_contact_id = $contact_id, login_vendor_id = $vendor_id, login_asset_id = $asset_id, login_software_id = $software_id, login_client_id = $client_id");
// Check insert & get insert ID // Check insert & get insert ID
if ($insert_sql) { if ($insert_sql) {

View File

@@ -8,53 +8,53 @@ if (isset($_POST['api_key_decrypt_password'])) {
$api_key_decrypt_password = $_POST['api_key_decrypt_password']; // No sanitization $api_key_decrypt_password = $_POST['api_key_decrypt_password']; // No sanitization
} }
if (isset($_POST['credential_name'])) { if (isset($_POST['login_name'])) {
$name = sanitizeInput($_POST['credential_name']); $name = sanitizeInput($_POST['login_name']);
} elseif (isset($credential_row) && isset($credential_row['credential_name'])) { } elseif (isset($credential_row) && isset($credential_row['login_name'])) {
$name = $credential_row['credential_name']; $name = $credential_row['login_name'];
} else { } else {
$name = ''; $name = '';
} }
if (isset($_POST['credential_description'])) { if (isset($_POST['login_description'])) {
$description = sanitizeInput($_POST['credential_description']); $description = sanitizeInput($_POST['login_description']);
} elseif (isset($credential_row) && isset($credential_row['credential_description'])) { } elseif (isset($credential_row) && isset($credential_row['login_description'])) {
$description = $credential_row['credential_description']; $description = $credential_row['login_description'];
} else { } else {
$description = ''; $description = '';
} }
if (isset($_POST['credential_uri'])) { if (isset($_POST['login_uri'])) {
$uri = sanitizeInput($_POST['credential_uri']); $uri = sanitizeInput($_POST['login_uri']);
} elseif (isset($credential_row) && isset($credential_row['credential_uri'])) { } elseif (isset($credential_row) && isset($credential_row['login_uri'])) {
$uri = $credential_row['credential_uri']; $uri = $credential_row['login_uri'];
} else { } else {
$uri = ''; $uri = '';
} }
if (isset($_POST['credential_uri_2'])) { if (isset($_POST['login_uri_2'])) {
$uri_2 = sanitizeInput($_POST['credential_uri_2']); $uri_2 = sanitizeInput($_POST['login_uri_2']);
} elseif (isset($credential_row) && isset($credential_row['credential_uri_2'])) { } elseif (isset($credential_row) && isset($credential_row['login_uri_2'])) {
$uri_2 = $credential_row['credential_uri_2']; $uri_2 = $credential_row['login_uri_2'];
} else { } else {
$uri_2 = ''; $uri_2 = '';
} }
if (isset($_POST['credential_username'])) { if (isset($_POST['login_username'])) {
$username = $_POST['credential_username']; $username = $_POST['login_username'];
$username = apiEncryptLoginEntry($username, $api_key_decrypt_hash, $api_key_decrypt_password); $username = apiEncryptLoginEntry($username, $api_key_decrypt_hash, $api_key_decrypt_password);
} elseif (isset($credential_row) && isset($credential_row['credential_username'])) { } elseif (isset($credential_row) && isset($credential_row['login_username'])) {
$username = $credential_row['credential_username']; $username = $credential_row['login_username'];
} else { } else {
$username = ''; $username = '';
} }
if (isset($_POST['credential_password'])) { if (isset($_POST['login_password'])) {
$password = $_POST['credential_password']; $password = $_POST['login_password'];
$password = apiEncryptLoginEntry($password, $api_key_decrypt_hash, $api_key_decrypt_password); $password = apiEncryptLoginEntry($password, $api_key_decrypt_hash, $api_key_decrypt_password);
$password_changed = true; $password_changed = true;
} elseif (isset($credential_row) && isset($credential_row['credential_password'])) { } elseif (isset($credential_row) && isset($credential_row['login_password'])) {
$password = $credential_row['credential_password']; $password = $credential_row['login_password'];
$password_changed = false; $password_changed = false;
} else { } else {
$password = ''; $password = '';
@@ -63,58 +63,58 @@ if (isset($_POST['credential_password'])) {
if (isset($_POST['credential_otp_secret'])) { if (isset($_POST['login_otp_secret'])) {
$otp_secret = sanitizeInput($_POST['credential_otp_secret']); $otp_secret = sanitizeInput($_POST['login_otp_secret']);
} elseif (isset($credential_row) && isset($credential_row['credential_otp_secret'])) { } elseif (isset($credential_row) && isset($credential_row['login_otp_secret'])) {
$otp_secret = $credential_row['credential_otp_secret']; $otp_secret = $credential_row['login_otp_secret'];
} else { } else {
$otp_secret = ''; $otp_secret = '';
} }
if (isset($_POST['credential_note'])) { if (isset($_POST['login_note'])) {
$note = sanitizeInput($_POST['credential_note']); $note = sanitizeInput($_POST['login_note']);
} elseif (isset($credential_row) && isset($credential_row['credential_note'])) { } elseif (isset($credential_row) && isset($credential_row['login_note'])) {
$note = $credential_row['credential_note']; $note = $credential_row['login_note'];
} else { } else {
$note = ''; $note = '';
} }
if (isset($_POST['credential_important'])) { if (isset($_POST['login_important'])) {
$important = intval($_POST['credential_important']); $important = intval($_POST['login_important']);
} elseif (isset($credential_row) && isset($credential_row['credential_important'])) { } elseif (isset($credential_row) && isset($credential_row['login_important'])) {
$important = $credential_row['credential_important']; $important = $credential_row['login_important'];
} else { } else {
$important = ''; $important = '';
} }
if (isset($_POST['credential_contact_id'])) { if (isset($_POST['login_contact_id'])) {
$contact_id = intval($_POST['credential_contact_id']); $contact_id = intval($_POST['login_contact_id']);
} elseif (isset($credential_row) && isset($credential_row['credential_contact_id'])) { } elseif (isset($credential_row) && isset($credential_row['login_contact_id'])) {
$contact_id = $credential_row['credential_contact_id']; $contact_id = $credential_row['login_contact_id'];
} else { } else {
$contact_id = ''; $contact_id = '';
} }
if (isset($_POST['credential_vendor_id'])) { if (isset($_POST['login_vendor_id'])) {
$vendor_id = intval($_POST['credential_vendor_id']); $vendor_id = intval($_POST['login_vendor_id']);
} elseif (isset($credential_row) && isset($credential_row['credential_vendor_id'])) { } elseif (isset($credential_row) && isset($credential_row['login_vendor_id'])) {
$vendor_id = $credential_row['credential_vendor_id']; $vendor_id = $credential_row['login_vendor_id'];
} else { } else {
$vendor_id = ''; $vendor_id = '';
} }
if (isset($_POST['credential_asset_id'])) { if (isset($_POST['login_asset_id'])) {
$asset_id = intval($_POST['credential_asset_id']); $asset_id = intval($_POST['login_asset_id']);
} elseif (isset($credential_row) && isset($credential_row['credential_asset_id'])) { } elseif (isset($credential_row) && isset($credential_row['login_asset_id'])) {
$asset_id = $credential_row['credential_asset_id']; $asset_id = $credential_row['login_asset_id'];
} else { } else {
$asset_id = ''; $asset_id = '';
} }
if (isset($_POST['credential_software_id'])) { if (isset($_POST['login_software_id'])) {
$software_id = intval($_POST['credential_software_id']); $software_id = intval($_POST['login_software_id']);
} elseif (isset($credential_row) && isset($credential_row['credential_software_id'])) { } elseif (isset($credential_row) && isset($credential_row['login_software_id'])) {
$software_id = $credential_row['credential_software_id']; $software_id = $credential_row['login_software_id'];
} else { } else {
$software_id = ''; $software_id = '';
} }

View File

@@ -13,17 +13,17 @@ if (isset($_GET['api_key_decrypt_password'])) {
} }
// Specific credential/login via ID (single) // Specific credential/login via ID (single)
if (isset($_GET['credential_id']) && !empty($api_key_decrypt_password)) { if (isset($_GET['login_id']) && !empty($api_key_decrypt_password)) {
$id = intval($_GET['credential_id']); $id = intval($_GET['login_id']);
$sql = mysqli_query($mysqli, "SELECT * FROM credentials WHERE credential_id = '$id' AND credential_client_id LIKE '$client_id' LIMIT 1"); $sql = mysqli_query($mysqli, "SELECT * FROM logins WHERE login_id = '$id' AND login_client_id LIKE '$client_id' LIMIT 1");
} elseif (!empty($api_key_decrypt_password)) { } elseif (!empty($api_key_decrypt_password)) {
// All credentials ("credentials") // All credentials ("logins")
$sql = mysqli_query($mysqli, "SELECT * FROM credentials WHERE credential_client_id LIKE '$client_id' ORDER BY credential_id LIMIT $limit OFFSET $offset"); $sql = mysqli_query($mysqli, "SELECT * FROM logins WHERE login_client_id LIKE '$client_id' ORDER BY login_id LIMIT $limit OFFSET $offset");
} }
@@ -37,8 +37,8 @@ if ($sql && mysqli_num_rows($sql) > 0) {
$row = array(); $row = array();
while ($row = mysqli_fetch_array($sql)) { while ($row = mysqli_fetch_array($sql)) {
$row['credential_username'] = apiDecryptCredentialEntry($row['credential_username'], $api_key_decrypt_hash, $api_key_decrypt_password); $row['login_username'] = apiDecryptLoginEntry($row['login_username'], $api_key_decrypt_hash, $api_key_decrypt_password);
$row['credential_password'] = apiDecryptCredentialEntry($row['credential_password'], $api_key_decrypt_hash, $api_key_decrypt_password); $row['login_password'] = apiDecryptLoginEntry($row['login_password'], $api_key_decrypt_hash, $api_key_decrypt_password);
$return_arr['data'][] = $row; $return_arr['data'][] = $row;
} }

View File

@@ -5,30 +5,30 @@ require_once '../validate_api_key.php';
require_once '../require_post_method.php'; require_once '../require_post_method.php';
// Parse ID // Parse ID
$credential_id = intval($_POST['credential_id']); $login_id = intval($_POST['login_id']);
// Default // Default
$update_count = false; $update_count = false;
if (!empty($_POST['api_key_decrypt_password']) && !empty($credential_id)) { if (!empty($_POST['api_key_decrypt_password']) && !empty($login_id)) {
$credential_row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT * FROM credentials WHERE credential_id = '$credential_id' AND credential_client_id = $client_id LIMIT 1")); $credential_row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT * FROM logins WHERE login_id = '$login_id' AND login_client_id = $client_id LIMIT 1"));
// Variable assignment from POST - assigning the current database value if a value is not provided // Variable assignment from POST - assigning the current database value if a value is not provided
require_once 'credential_model.php'; require_once 'credential_model.php';
$update_sql = mysqli_query($mysqli,"UPDATE credentials SET credential_name = '$name', credential_description = '$description', credential_uri = '$uri', credential_uri_2 = '$uri_2', credential_username = '$username', credential_password = '$password', credential_otp_secret = '$otp_secret', credential_note = '$note', credential_important = $important, credential_contact_id = $contact_id, credential_vendor_id = $vendor_id, credential_asset_id = $asset_id, credential_software_id = $software_id, credential_client_id = $client_id WHERE credential_id = '$credential_id' AND credential_client_id = $client_id LIMIT 1"); $update_sql = mysqli_query($mysqli,"UPDATE logins SET login_name = '$name', login_description = '$description', login_uri = '$uri', login_uri_2 = '$uri_2', login_username = '$username', login_password = '$password', login_otp_secret = '$otp_secret', login_note = '$note', login_important = $important, login_contact_id = $contact_id, login_vendor_id = $vendor_id, login_asset_id = $asset_id, login_software_id = $software_id, login_client_id = $client_id WHERE login_id = '$login_id' AND login_client_id = $client_id LIMIT 1");
// Check insert & get insert ID // Check insert & get insert ID
if ($update_sql) { if ($update_sql) {
$update_count = mysqli_affected_rows($mysqli); $update_count = mysqli_affected_rows($mysqli);
if ($password_changed) { if ($password_changed) {
mysqli_query($mysqli, "UPDATE credentials SET credential_password_changed_at = NOW() WHERE credential_id = $credential_id LIMIT 1"); mysqli_query($mysqli, "UPDATE logins SET login_password_changed_at = NOW() WHERE login_id = $login_id LIMIT 1");
} }
// Logging // Logging
logAction("Credential", "Edit", "$name via API ($api_key_name)", $client_id, $credential_id); logAction("Credential", "Edit", "$name via API ($api_key_name)", $client_id, $login_id);
logAction("API", "Success", "Updated credential $name via API ($api_key_name)", $client_id); logAction("API", "Success", "Updated credential $name via API ($api_key_name)", $client_id);
} }

View File

@@ -5,7 +5,7 @@ require_once '../validate_api_key.php';
require_once '../require_post_method.php'; require_once '../require_post_method.php';
// Ticket-related settings // Ticket-related settings
require_once "../../../includes/get_settings.php"; require_once "../../../get_settings.php";
$sql = mysqli_query($mysqli, "SELECT company_name, company_phone FROM companies WHERE company_id = 1"); $sql = mysqli_query($mysqli, "SELECT company_name, company_phone FROM companies WHERE company_id = 1");
$row = mysqli_fetch_array($sql); $row = mysqli_fetch_array($sql);
@@ -39,7 +39,7 @@ if (!empty($subject)) {
// Insert ticket // Insert ticket
$url_key = randomString(156); $url_key = randomString(156);
$insert_sql = mysqli_query($mysqli,"INSERT INTO tickets SET ticket_prefix = '$config_ticket_prefix', ticket_number = $ticket_number, ticket_subject = '$subject', ticket_details = '$details', ticket_priority = '$priority', ticket_status = 1, ticket_billable = $billable, ticket_vendor_ticket_number = '$vendor_ticket_number', ticket_vendor_id = $vendor_id, ticket_created_by = 0, ticket_assigned_to = $assigned_to, ticket_contact_id = $contact, ticket_url_key = '$url_key', ticket_client_id = $client_id"); $insert_sql = mysqli_query($mysqli,"INSERT INTO tickets SET ticket_prefix = '$config_ticket_prefix', ticket_number = $ticket_number, ticket_subject = '$subject', ticket_details = '$details', ticket_priority = '$priority', ticket_status = 1, ticket_vendor_ticket_number = '$vendor_ticket_number', ticket_vendor_id = $vendor_id, ticket_created_by = 0, ticket_assigned_to = $assigned_to, ticket_contact_id = $contact, ticket_url_key = '$url_key', ticket_client_id = $client_id");
// Check insert & get insert ID // Check insert & get insert ID
if ($insert_sql) { if ($insert_sql) {

View File

@@ -59,11 +59,3 @@ if (isset($_POST['ticket_assigned_to'])) {
} else { } else {
$assigned_to = '0'; $assigned_to = '0';
} }
if (isset($_POST['ticket_billable'])) {
$billable = intval($_POST['ticket_billable']);
} elseif ($ticket_row) {
$billable = $ticket_row['ticket_billable'];
} else {
$billable = '0';
}

View File

@@ -81,24 +81,19 @@ if (isset($_GET['asset_id'])) {
// Override Tab Title // No Sanitizing needed as this var will opnly be used in the tab title // Override Tab Title // No Sanitizing needed as this var will opnly be used in the tab title
$page_title = $row['asset_name']; $page_title = $row['asset_name'];
$sql_related_tickets = mysqli_query($mysqli, " // Related Tickets Query
SELECT tickets.*, users.*, ticket_statuses.* $sql_related_tickets = mysqli_query($mysqli, "SELECT * FROM tickets
FROM tickets LEFT JOIN users on ticket_assigned_to = user_id
LEFT JOIN users ON ticket_assigned_to = user_id
LEFT JOIN ticket_statuses ON ticket_status_id = ticket_status LEFT JOIN ticket_statuses ON ticket_status_id = ticket_status
LEFT JOIN ticket_assets ON tickets.ticket_id = ticket_assets.ticket_id WHERE ticket_asset_id = $asset_id
WHERE ticket_asset_id = $asset_id OR ticket_assets.asset_id = $asset_id ORDER BY ticket_number DESC"
GROUP BY tickets.ticket_id );
ORDER BY ticket_number DESC
");
$ticket_count = mysqli_num_rows($sql_related_tickets); $ticket_count = mysqli_num_rows($sql_related_tickets);
// Related Recurring Tickets Query // Related Recurring Tickets Query
$sql_related_recurring_tickets = mysqli_query($mysqli, "SELECT * FROM recurring_tickets $sql_related_recurring_tickets = mysqli_query($mysqli, "SELECT * FROM scheduled_tickets
LEFT JOIN recurring_ticket_assets ON recurring_tickets.recurring_ticket_id = recurring_ticket_assets.recurring_ticket_id WHERE scheduled_ticket_asset_id = $asset_id
WHERE recurring_ticket_asset_id = $asset_id OR recurring_ticket_assets.asset_id = $asset_id ORDER BY scheduled_ticket_next_run DESC"
GROUP BY recurring_tickets.recurring_ticket_id
ORDER BY recurring_ticket_next_run DESC"
); );
$recurring_ticket_count = mysqli_num_rows($sql_related_recurring_tickets); $recurring_ticket_count = mysqli_num_rows($sql_related_recurring_tickets);
@@ -184,29 +179,31 @@ if (isset($_GET['asset_id'])) {
$document_count = mysqli_num_rows($sql_related_documents); $document_count = mysqli_num_rows($sql_related_documents);
// Related Credentials Query // Related Logins Query
$sql_related_credentials = mysqli_query($mysqli, " $sql_related_logins = mysqli_query($mysqli, "
SELECT SELECT
credentials.credential_id AS credential_id, logins.login_id AS login_id,
credentials.credential_name, logins.login_name,
credentials.credential_description, logins.login_description,
credentials.credential_uri, logins.login_uri,
credentials.credential_username, logins.login_username,
credentials.credential_password, logins.login_password,
credentials.credential_otp_secret, logins.login_otp_secret,
credentials.credential_note, logins.login_note,
credentials.credential_important, logins.login_important,
credentials.credential_contact_id, logins.login_contact_id,
credentials.credential_asset_id logins.login_vendor_id,
FROM credentials logins.login_asset_id,
LEFT JOIN credential_tags ON credential_tags.credential_id = credentials.credential_id logins.login_software_id
LEFT JOIN tags ON tags.tag_id = credential_tags.tag_id FROM logins
WHERE credential_asset_id = $asset_id LEFT JOIN login_tags ON login_tags.login_id = logins.login_id
AND credential_archived_at IS NULL LEFT JOIN tags ON tags.tag_id = login_tags.tag_id
GROUP BY credentials.credential_id WHERE login_asset_id = $asset_id
ORDER BY credential_name DESC AND login_archived_at IS NULL
GROUP BY logins.login_id
ORDER BY login_name DESC
"); ");
$credential_count = mysqli_num_rows($sql_related_credentials); $login_count = mysqli_num_rows($sql_related_logins);
// Related Software Query // Related Software Query
$sql_related_software = mysqli_query( $sql_related_software = mysqli_query(
@@ -220,16 +217,6 @@ if (isset($_GET['asset_id'])) {
$software_count = mysqli_num_rows($sql_related_software); $software_count = mysqli_num_rows($sql_related_software);
// Linked Services
$sql_linked_services = mysqli_query($mysqli, "SELECT * FROM service_assets, services
WHERE service_assets.asset_id = $asset_id
AND service_assets.service_id = services.service_id
ORDER BY service_name ASC"
);
$service_count = mysqli_num_rows($sql_linked_services);
$linked_services = array();
?> ?>
<div class="row"> <div class="row">
@@ -361,16 +348,8 @@ if (isset($_GET['asset_id'])) {
<i class="fa fa-fw fa-recycle mr-2"></i>New Recurring Ticket <i class="fa fa-fw fa-recycle mr-2"></i>New Recurring Ticket
</a> </a>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#addCredentialModal"> <a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#createContactNoteModal<?php echo $contact_id; ?>">
<i class="fa fa-fw fa-key mr-2"></i>New Credential <i class="fa fa-fw fa-sticky-note mr-2"></i>New Note (WIP)
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#addDocumentModal">
<i class="fa fa-fw fa-file-alt mr-2"></i>New Document
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#uploadFilesModal">
<i class="fa fa-fw fa-upload mr-2"></i>Upload file(s)
</a> </a>
</div> </div>
</div> </div>
@@ -378,24 +357,28 @@ if (isset($_GET['asset_id'])) {
<div class="dropdown dropleft"> <div class="dropdown dropleft">
<button type="button" class="btn btn-outline-primary" data-toggle="dropdown"><i class="fas fa-link mr-2"></i>Link</button> <button type="button" class="btn btn-outline-primary" data-toggle="dropdown"><i class="fas fa-link mr-2"></i>Link</button>
<div class="dropdown-menu"> <div class="dropdown-menu">
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#linkAssetModal">
<i class="fa fa-fw fa-desktop mr-2"></i>Asset (WIP)
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#linkSoftwareModal"> <a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#linkSoftwareModal">
<i class="fa fa-fw fa-cube mr-2"></i>License <i class="fa fa-fw fa-cube mr-2"></i>License (WIP)
</a> </a>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#linkCredentialModal"> <a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#linkCredentialModal">
<i class="fa fa-fw fa-key mr-2"></i>Credential <i class="fa fa-fw fa-key mr-2"></i>Credential (WIP)
</a> </a>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#linkServiceModal"> <a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#linkServiceModal">
<i class="fa fa-fw fa-stream mr-2"></i>Service <i class="fa fa-fw fa-stream mr-2"></i>Service (WIP)
</a> </a>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#linkDocumentModal"> <a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#linkDocumentModal">
<i class="fa fa-fw fa-folder mr-2"></i>Document <i class="fa fa-fw fa-folder mr-2"></i>Document (WIP)
</a> </a>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#linkFileModal"> <a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#linkFileModal">
<i class="fa fa-fw fa-paperclip mr-2"></i>File <i class="fa fa-fw fa-paperclip mr-2"></i>File (WIP)
</a> </a>
@@ -477,7 +460,6 @@ if (isset($_GET['asset_id'])) {
// Show either "-" or "AssetName - Port" // Show either "-" or "AssetName - Port"
if ($connected_asset_name) { if ($connected_asset_name) {
$connected_to_display = "<a href='#' $connected_to_display = "<a href='#'
data-toggle='ajax-modal'
data-modal-size='lg' data-modal-size='lg'
data-ajax-url='ajax/ajax_asset_details.php' data-ajax-url='ajax/ajax_asset_details.php'
data-ajax-id='$connected_asset_id'> data-ajax-id='$connected_asset_id'>
@@ -531,7 +513,7 @@ if (isset($_GET['asset_id'])) {
</div> </div>
</div> </div>
<div class="card card-dark <?php if ($credential_count == 0) { echo "d-none"; } ?>"> <div class="card card-dark <?php if ($login_count == 0) { echo "d-none"; } ?>">
<div class="card-header"> <div class="card-header">
<h3 class="card-title"><i class="fa fa-fw fa-key mr-2"></i>Credentials</h3> <h3 class="card-title"><i class="fa fa-fw fa-key mr-2"></i>Credentials</h3>
</div> </div>
@@ -552,56 +534,58 @@ if (isset($_GET['asset_id'])) {
<tbody> <tbody>
<?php <?php
while ($row = mysqli_fetch_array($sql_related_credentials)) { while ($row = mysqli_fetch_array($sql_related_logins)) {
$credential_id = intval($row['credential_id']); $login_id = intval($row['login_id']);
$credential_name = nullable_htmlentities($row['credential_name']); $login_name = nullable_htmlentities($row['login_name']);
$credential_description = nullable_htmlentities($row['credential_description']); $login_description = nullable_htmlentities($row['login_description']);
$credential_uri = nullable_htmlentities($row['credential_uri']); $login_uri = nullable_htmlentities($row['login_uri']);
if (empty($credential_uri)) { if (empty($login_uri)) {
$credential_uri_display = "-"; $login_uri_display = "-";
} else { } else {
$credential_uri_display = "$credential_uri<button class='btn btn-sm clipboardjs' data-clipboard-text='$credential_uri'><i class='far fa-copy text-secondary'></i></button><a href='$credential_uri' target='_blank'><i class='fa fa-external-link-alt text-secondary'></i></a>"; $login_uri_display = "$login_uri<button class='btn btn-sm clipboardjs' data-clipboard-text='$login_uri'><i class='far fa-copy text-secondary'></i></button><a href='$login_uri' target='_blank'><i class='fa fa-external-link-alt text-secondary'></i></a>";
} }
$credential_username = nullable_htmlentities(decryptCredentialEntry($row['credential_username'])); $login_username = nullable_htmlentities(decryptLoginEntry($row['login_username']));
if (empty($credential_username)) { if (empty($login_username)) {
$credential_username_display = "-"; $login_username_display = "-";
} else { } else {
$credential_username_display = "$credential_username<button class='btn btn-sm clipboardjs' data-clipboard-text='$credential_username'><i class='far fa-copy text-secondary'></i></button>"; $login_username_display = "$login_username<button class='btn btn-sm clipboardjs' data-clipboard-text='$login_username'><i class='far fa-copy text-secondary'></i></button>";
} }
$credential_password = nullable_htmlentities(decryptCredentialEntry($row['credential_password'])); $login_password = nullable_htmlentities(decryptLoginEntry($row['login_password']));
$credential_otp_secret = nullable_htmlentities($row['credential_otp_secret']); $login_otp_secret = nullable_htmlentities($row['login_otp_secret']);
$credential_id_with_secret = '"' . $row['credential_id'] . '","' . $row['credential_otp_secret'] . '"'; $login_id_with_secret = '"' . $row['login_id'] . '","' . $row['login_otp_secret'] . '"';
if (empty($credential_otp_secret)) { if (empty($login_otp_secret)) {
$otp_display = "-"; $otp_display = "-";
} else { } else {
$otp_display = "<span onmouseenter='showOTPViaCredentialID($credential_id)'><i class='far fa-clock'></i> <span id='otp_$credential_id'><i>Hover..</i></span></span>"; $otp_display = "<span onmouseenter='showOTPViaLoginID($login_id)'><i class='far fa-clock'></i> <span id='otp_$login_id'><i>Hover..</i></span></span>";
} }
$credential_note = nullable_htmlentities($row['credential_note']); $login_note = nullable_htmlentities($row['login_note']);
$credential_important = intval($row['credential_important']); $login_important = intval($row['login_important']);
$credential_contact_id = intval($row['credential_contact_id']); $login_contact_id = intval($row['login_contact_id']);
$credential_asset_id = intval($row['credential_asset_id']); $login_vendor_id = intval($row['login_vendor_id']);
$login_asset_id = intval($row['login_asset_id']);
$login_software_id = intval($row['login_software_id']);
// Tags // Tags
$credential_tag_name_display_array = array(); $login_tag_name_display_array = array();
$credential_tag_id_array = array(); $login_tag_id_array = array();
$sql_credential_tags = mysqli_query($mysqli, "SELECT * FROM credential_tags LEFT JOIN tags ON credential_tags.tag_id = tags.tag_id WHERE credential_id = $credential_id ORDER BY tag_name ASC"); $sql_login_tags = mysqli_query($mysqli, "SELECT * FROM login_tags LEFT JOIN tags ON login_tags.tag_id = tags.tag_id WHERE login_id = $login_id ORDER BY tag_name ASC");
while ($row = mysqli_fetch_array($sql_credential_tags)) { while ($row = mysqli_fetch_array($sql_login_tags)) {
$credential_tag_id = intval($row['tag_id']); $login_tag_id = intval($row['tag_id']);
$credential_tag_name = nullable_htmlentities($row['tag_name']); $login_tag_name = nullable_htmlentities($row['tag_name']);
$credential_tag_color = nullable_htmlentities($row['tag_color']); $login_tag_color = nullable_htmlentities($row['tag_color']);
if (empty($credential_tag_color)) { if (empty($login_tag_color)) {
$credential_tag_color = "dark"; $login_tag_color = "dark";
} }
$credential_tag_icon = nullable_htmlentities($row['tag_icon']); $login_tag_icon = nullable_htmlentities($row['tag_icon']);
if (empty($credential_tag_icon)) { if (empty($login_tag_icon)) {
$credential_tag_icon = "tag"; $login_tag_icon = "tag";
} }
$credential_tag_id_array[] = $credential_tag_id; $login_tag_id_array[] = $login_tag_id;
$credential_tag_name_display_array[] = "<a href='credentials.php?client_id=$client_id&tags[]=$credential_tag_id'><span class='badge text-light p-1 mr-1' style='background-color: $credential_tag_color;'><i class='fa fa-fw fa-$credential_tag_icon mr-2'></i>$credential_tag_name</span></a>"; $login_tag_name_display_array[] = "<a href='client_logins.php?client_id=$client_id&tags[]=$login_tag_id'><span class='badge text-light p-1 mr-1' style='background-color: $login_tag_color;'><i class='fa fa-fw fa-$login_tag_icon mr-2'></i>$login_tag_name</span></a>";
} }
$credential_tags_display = implode('', $credential_tag_name_display_array); $login_tags_display = implode('', $login_tag_name_display_array);
?> ?>
<tr> <tr>
@@ -610,18 +594,18 @@ if (isset($_GET['asset_id'])) {
<a class="text-dark" href="#" <a class="text-dark" href="#"
data-toggle="ajax-modal" data-toggle="ajax-modal"
data-ajax-url="ajax/ajax_credential_edit.php" data-ajax-url="ajax/ajax_credential_edit.php"
data-ajax-id="<?php echo $credential_id; ?>" data-ajax-id="<?php echo $login_id; ?>"
> >
<?php echo $credential_name; ?> <?php echo $login_name; ?>
</a> </a>
</td> </td>
<td><?php echo $credential_description; ?></td> <td><?php echo $login_description; ?></td>
<td><?php echo $credential_username_display; ?></td> <td><?php echo $login_username_display; ?></td>
<td> <td>
<button class="btn p-0" type="button" data-toggle="popover" data-trigger="focus" data-placement="top" data-content="<?php echo $credential_password; ?>"><i class="fas fa-2x fa-ellipsis-h text-secondary"></i><i class="fas fa-2x fa-ellipsis-h text-secondary"></i></button><button class="btn btn-sm clipboardjs" data-clipboard-text="<?php echo $credential_password; ?>"><i class="far fa-copy text-secondary"></i></button> <button class="btn p-0" type="button" data-toggle="popover" data-trigger="focus" data-placement="top" data-content="<?php echo $login_password; ?>"><i class="fas fa-2x fa-ellipsis-h text-secondary"></i><i class="fas fa-2x fa-ellipsis-h text-secondary"></i></button><button class="btn btn-sm clipboardjs" data-clipboard-text="<?php echo $login_password; ?>"><i class="far fa-copy text-secondary"></i></button>
</td> </td>
<td><?php echo $otp_display; ?></td> <td><?php echo $otp_display; ?></td>
<td><?php echo $credential_uri_display; ?></td> <td><?php echo $login_uri_display; ?></td>
<td> <td>
<div class="dropdown dropleft text-center"> <div class="dropdown dropleft text-center">
<button class="btn btn-secondary btn-sm" type="button" data-toggle="dropdown"> <button class="btn btn-secondary btn-sm" type="button" data-toggle="dropdown">
@@ -631,20 +615,16 @@ if (isset($_GET['asset_id'])) {
<a class="dropdown-item" href="#" <a class="dropdown-item" href="#"
data-toggle="ajax-modal" data-toggle="ajax-modal"
data-ajax-url="ajax/ajax_credential_edit.php" data-ajax-url="ajax/ajax_credential_edit.php"
data-ajax-id="<?php echo $credential_id; ?>" data-ajax-id="<?php echo $login_id; ?>"
> >
<i class="fas fa-fw fa-edit mr-2"></i>Edit <i class="fas fa-fw fa-edit mr-2"></i>Edit
</a> </a>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#shareModal" onclick="populateShareModal(<?php echo "$client_id, 'Credential', $credential_id"; ?>)"> <a class="dropdown-item" href="#" data-toggle="modal" data-target="#shareModal" onclick="populateShareModal(<?php echo "$client_id, 'Login', $login_id"; ?>)">
<i class="fas fa-fw fa-share-alt mr-2"></i>Share <i class="fas fa-fw fa-share-alt mr-2"></i>Share
</a> </a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="post.php?unlink_credential_from_asset&asset_id=<?php echo $asset_id; ?>&credential_id=<?php echo $credential_id; ?>">
<i class="fas fa-fw fa-unlink mr-2"></i>Unlink
</a>
<?php if ($session_user_role == 3) { ?> <?php if ($session_user_role == 3) { ?>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item text-danger text-bold" href="post.php?delete_credential=<?php echo $credential_id; ?>"> <a class="dropdown-item text-danger text-bold" href="post.php?delete_login=<?php echo $login_id; ?>">
<i class="fas fa-fw fa-trash mr-2"></i>Delete <i class="fas fa-fw fa-trash mr-2"></i>Delete
</a> </a>
<?php } ?> <?php } ?>
@@ -679,7 +659,6 @@ if (isset($_GET['asset_id'])) {
<th>Type</th> <th>Type</th>
<th>License Type</th> <th>License Type</th>
<th>Seats</th> <th>Seats</th>
<th class="text-center">Action</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -699,6 +678,11 @@ if (isset($_GET['asset_id'])) {
$seat_count = 0; $seat_count = 0;
// Get Login
$login_id = intval($row['login_id']);
$login_username = nullable_htmlentities(decryptLoginEntry($row['login_username']));
$login_password = nullable_htmlentities(decryptLoginEntry($row['login_password']));
// Asset Licenses // Asset Licenses
$asset_licenses_sql = mysqli_query($mysqli, "SELECT asset_id FROM software_assets WHERE software_id = $software_id"); $asset_licenses_sql = mysqli_query($mysqli, "SELECT asset_id FROM software_assets WHERE software_id = $software_id");
$asset_licenses_array = array(); $asset_licenses_array = array();
@@ -717,8 +701,6 @@ if (isset($_GET['asset_id'])) {
} }
$contact_licenses = implode(',', $contact_licenses_array); $contact_licenses = implode(',', $contact_licenses_array);
$linked_software[] = $software_id;
?> ?>
<tr> <tr>
<td> <td>
@@ -733,9 +715,6 @@ if (isset($_GET['asset_id'])) {
<td><?php echo $software_type; ?></td> <td><?php echo $software_type; ?></td>
<td><?php echo $software_license_type; ?></td> <td><?php echo $software_license_type; ?></td>
<td><?php echo "$seat_count / $software_seats"; ?></td> <td><?php echo "$seat_count / $software_seats"; ?></td>
<td class="text-center">
<a href="post.php?unlink_software_from_asset&asset_id=<?php echo $asset_id; ?>&software_id=<?php echo $software_id; ?>" class="btn btn-secondary btn-sm" title="Unlink"><i class="fas fa-fw fa-unlink"></i></a>
</td>
</tr> </tr>
<?php <?php
@@ -846,7 +825,7 @@ if (isset($_GET['asset_id'])) {
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Uploaded</th> <th>Uploaded</th>
<th class="text-center">Action</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -882,16 +861,10 @@ if (isset($_GET['asset_id'])) {
$file_icon = "file"; $file_icon = "file";
} }
$file_created_at = nullable_htmlentities($row['file_created_at']); $file_created_at = nullable_htmlentities($row['file_created_at']);
$linked_files[] = $file_id;
?> ?>
<tr> <tr>
<td><a class="text-dark" href="<?php echo "uploads/clients/$client_id/$file_reference_name"; ?>" target="_blank" ><?php echo "$file_name<br><span class='text-secondary'>$file_description</span>"; ?></a></td> <td><a class="text-dark" href="<?php echo "uploads/clients/$client_id/$file_reference_name"; ?>" target="_blank" ><?php echo "$file_name<br><span class='text-secondary'>$file_description</span>"; ?></a></td>
<td><?php echo $file_created_at; ?></td> <td><?php echo $file_created_at; ?></td>
<td class="text-center">
<a href="post.php?unlink_asset_from_file&asset_id=<?php echo $asset_id; ?>&file_id=<?php echo $file_id; ?>" class="btn btn-secondary btn-sm" title="Unlink"><i class="fas fa-fw fa-unlink"></i></a>
</td>
</tr> </tr>
<?php <?php
@@ -925,30 +898,29 @@ if (isset($_GET['asset_id'])) {
<?php <?php
while ($row = mysqli_fetch_array($sql_related_recurring_tickets)) { while ($row = mysqli_fetch_array($sql_related_recurring_tickets)) {
$recurring_ticket_id = intval($row['recurring_ticket_id']); $scheduled_ticket_id = intval($row['scheduled_ticket_id']);
$recurring_ticket_subject = nullable_htmlentities($row['recurring_ticket_subject']); $scheduled_ticket_subject = nullable_htmlentities($row['scheduled_ticket_subject']);
$recurring_ticket_priority = nullable_htmlentities($row['recurring_ticket_priority']); $scheduled_ticket_priority = nullable_htmlentities($row['scheduled_ticket_priority']);
$recurring_ticket_frequency = nullable_htmlentities($row['recurring_ticket_frequency']); $scheduled_ticket_frequency = nullable_htmlentities($row['scheduled_ticket_frequency']);
$recurring_ticket_next_run = nullable_htmlentities($row['recurring_ticket_next_run']); $scheduled_ticket_next_run = nullable_htmlentities($row['scheduled_ticket_next_run']);
?> ?>
<tr> <tr>
<td class="text-bold"> <td class="text-bold">
<a href="#" <a href="#"
data-toggle="ajax-modal" data-toggle="ajax-modal"
data-modal-size="lg"
data-ajax-url="ajax/ajax_recurring_ticket_edit.php" data-ajax-url="ajax/ajax_recurring_ticket_edit.php"
data-ajax-id="<?php echo $recurring_ticket_id; ?>" data-ajax-id="<?php echo $scheduled_ticket_id; ?>"
> >
<?php echo $recurring_ticket_subject ?> <?php echo $scheduled_ticket_subject ?>
</a> </a>
</td> </td>
<td><?php echo $recurring_ticket_priority ?></td> <td><?php echo $scheduled_ticket_priority ?></td>
<td><?php echo $recurring_ticket_frequency ?></td> <td><?php echo $scheduled_ticket_frequency ?></td>
<td><?php echo $recurring_ticket_next_run ?></td> <td><?php echo $scheduled_ticket_next_run ?></td>
<td> <td>
<div class="dropdown dropleft text-center"> <div class="dropdown dropleft text-center">
@@ -958,20 +930,19 @@ if (isset($_GET['asset_id'])) {
<div class="dropdown-menu"> <div class="dropdown-menu">
<a class="dropdown-item" href="#" <a class="dropdown-item" href="#"
data-toggle="ajax-modal" data-toggle="ajax-modal"
data-modal-size="lg"
data-ajax-url="ajax/ajax_recurring_ticket_edit.php" data-ajax-url="ajax/ajax_recurring_ticket_edit.php"
data-ajax-id="<?php echo $recurring_ticket_id; ?>" data-ajax-id="<?php echo $scheduled_ticket_id; ?>"
> >
<i class="fas fa-fw fa-edit mr-2"></i>Edit <i class="fas fa-fw fa-edit mr-2"></i>Edit
</a> </a>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item" href="post.php?force_recurring_ticket=<?php echo $recurring_ticket_id; ?>&csrf_token=<?php echo $_SESSION['csrf_token'] ?>"> <a class="dropdown-item" href="post.php?force_recurring_ticket=<?php echo $scheduled_ticket_id; ?>&csrf_token=<?php echo $_SESSION['csrf_token'] ?>">
<i class="fa fa-fw fa-paper-plane text-secondary mr-2"></i>Force Reoccur <i class="fa fa-fw fa-paper-plane text-secondary mr-2"></i>Force Reoccur
</a> </a>
<?php <?php
if ($session_user_role == 3) { ?> if ($session_user_role == 3) { ?>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item text-danger text-bold confirm-link" href="post.php?delete_recurring_ticket=<?php echo $recurring_ticket_id; ?>"> <a class="dropdown-item text-danger text-bold confirm-link" href="post.php?delete_recurring_ticket=<?php echo $scheduled_ticket_id; ?>">
<i class="fas fa-fw fa-trash mr-2"></i>Delete <i class="fas fa-fw fa-trash mr-2"></i>Delete
</a> </a>
</div> </div>
@@ -1015,13 +986,12 @@ if (isset($_GET['asset_id'])) {
$ticket_number = intval($row['ticket_number']); $ticket_number = intval($row['ticket_number']);
$ticket_subject = nullable_htmlentities($row['ticket_subject']); $ticket_subject = nullable_htmlentities($row['ticket_subject']);
$ticket_priority = nullable_htmlentities($row['ticket_priority']); $ticket_priority = nullable_htmlentities($row['ticket_priority']);
$ticket_status_id = intval($row['ticket_status_id']);
$ticket_status_name = nullable_htmlentities($row['ticket_status_name']); $ticket_status_name = nullable_htmlentities($row['ticket_status_name']);
$ticket_status_color = nullable_htmlentities($row['ticket_status_color']); $ticket_status_color = nullable_htmlentities($row['ticket_status_color']);
$ticket_created_at = nullable_htmlentities($row['ticket_created_at']); $ticket_created_at = nullable_htmlentities($row['ticket_created_at']);
$ticket_updated_at = nullable_htmlentities($row['ticket_updated_at']); $ticket_updated_at = nullable_htmlentities($row['ticket_updated_at']);
if (empty($ticket_updated_at)) { if (empty($ticket_updated_at)) {
if ($ticket_status_name == "Closed") { if ($ticket_status == "Closed") {
$ticket_updated_at_display = "<p>Never</p>"; $ticket_updated_at_display = "<p>Never</p>";
} else { } else {
$ticket_updated_at_display = "<p class='text-danger'>Never</p>"; $ticket_updated_at_display = "<p class='text-danger'>Never</p>";
@@ -1042,7 +1012,7 @@ if (isset($_GET['asset_id'])) {
} }
$ticket_assigned_to = intval($row['ticket_assigned_to']); $ticket_assigned_to = intval($row['ticket_assigned_to']);
if (empty($ticket_assigned_to)) { if (empty($ticket_assigned_to)) {
if ($ticket_status_id == 5) { if ($ticket_status == 5) {
$ticket_assigned_to_display = "<p>Not Assigned</p>"; $ticket_assigned_to_display = "<p>Not Assigned</p>";
} else { } else {
$ticket_assigned_to_display = "<p class='text-danger'>Not Assigned</p>"; $ticket_assigned_to_display = "<p class='text-danger'>Not Assigned</p>";
@@ -1077,64 +1047,6 @@ if (isset($_GET['asset_id'])) {
</div> </div>
</div> </div>
<div class="card card-dark <?php if ($service_count == 0) { echo "d-none"; } ?>">
<div class="card-header py-2">
<h3 class="card-title mt-2"><i class="fa fa-fw fa-stream mr-2"></i>Linked Services</h3>
<div class="card-tools">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#linkServiceModal">
<i class="fas fa-link mr-2"></i>Link Service
</button>
</div>
</div>
<div class="card-body">
<div class="table-responsive-sm">
<table class="table table-striped table-borderless table-hover dataTables" style="width:100%">
<thead class="text-dark">
<tr>
<th>Service</th>
<th>Category</th>
<th>Importance</th>
<th class="text-center">Action</th>
</tr>
</thead>
<tbody>
<?php
while ($row = mysqli_fetch_array($sql_linked_services)) {
$service_id = intval($row['service_id']);
$service_name = nullable_htmlentities($row['service_name']);
$service_description = nullable_htmlentities($row['service_description']);
$service_category = nullable_htmlentities($row['service_category']);
$service_importance = nullable_htmlentities($row['service_importance']);
$linked_services[] = $service_id;
?>
<tr>
<td>
<div><?php echo $service_name; ?></div>
<div class="text-secondary"><?php echo $service_description; ?></div>
</td>
<td><?php echo $service_category; ?></td>
<td><?php echo $service_importance; ?></td>
<td class="text-center">
<a href="post.php?unlink_service_from_asset&asset_id=<?php echo $asset_id; ?>&service_id=<?php echo $service_id; ?>" class="btn btn-secondary btn-sm" title="Unlink"><i class="fas fa-fw fa-unlink"></i></a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div> </div>
</div> </div>
@@ -1178,7 +1090,7 @@ if (isset($_GET['asset_id'])) {
}); });
</script> </script>
<!-- Include script to get TOTP code via the credential ID --> <!-- Include script to get TOTP code via the login ID -->
<script src="js/credential_show_otp_via_id.js"></script> <script src="js/credential_show_otp_via_id.js"></script>
<?php <?php
@@ -1189,14 +1101,4 @@ require_once "modals/asset_interface_import_modal.php";
require_once "modals/asset_interface_export_modal.php"; require_once "modals/asset_interface_export_modal.php";
require_once "modals/ticket_add_modal.php"; require_once "modals/ticket_add_modal.php";
require_once "modals/recurring_ticket_add_modal.php"; require_once "modals/recurring_ticket_add_modal.php";
require_once "modals/credential_add_modal.php";
require_once "modals/client_document_add_modal.php";
require_once "modals/client_file_upload_modal.php";
require_once "modals/asset_link_software_modal.php";
require_once "modals/asset_link_credential_modal.php";
require_once "modals/asset_link_service_modal.php";
require_once "modals/asset_link_document_modal.php";
require_once "modals/asset_link_file_modal.php";
require_once "includes/footer.php"; require_once "includes/footer.php";

View File

@@ -53,7 +53,7 @@ if ($client_url && isset($_GET['location']) && !empty($_GET['location'])) {
} else { } else {
// Default - any // Default - any
$location_query = ''; $location_query = '';
$location_filter = 0; $location_filter = '';
} }
//Get Asset Counts //Get Asset Counts
@@ -210,15 +210,7 @@ if (mysqli_num_rows($os_sql) > 0) {
<option value="">- All Locations -</option> <option value="">- All Locations -</option>
<?php <?php
$sql_locations_filter = mysqli_query($mysqli, " $sql_locations_filter = mysqli_query($mysqli, "SELECT * FROM locations WHERE location_client_id = $client_id AND location_archived_at IS NULL ORDER BY location_name ASC");
SELECT DISTINCT location_id, location_name
FROM locations
LEFT JOIN assets ON asset_location_id = location_id
WHERE location_client_id = $client_id
AND location_archived_at IS NULL
AND (asset_location_id != 0 OR location_id = $location_filter)
ORDER BY location_name ASC
");
while ($row = mysqli_fetch_array($sql_locations_filter)) { while ($row = mysqli_fetch_array($sql_locations_filter)) {
$location_id = intval($row['location_id']); $location_id = intval($row['location_id']);
$location_name = nullable_htmlentities($row['location_name']); $location_name = nullable_htmlentities($row['location_name']);
@@ -238,14 +230,7 @@ if (mysqli_num_rows($os_sql) > 0) {
<option value="" <?php if ($client == "") { echo "selected"; } ?>>- All Clients -</option> <option value="" <?php if ($client == "") { echo "selected"; } ?>>- All Clients -</option>
<?php <?php
$sql_clients_filter = mysqli_query($mysqli, " $sql_clients_filter = mysqli_query($mysqli, "SELECT * FROM clients WHERE client_archived_at IS NULL $access_permission_query ORDER BY client_name ASC");
SELECT DISTINCT client_id, client_name
FROM clients
JOIN assets ON asset_client_id = client_id
WHERE client_archived_at IS NULL
$access_permission_query
ORDER BY client_name ASC
");
while ($row = mysqli_fetch_array($sql_clients_filter)) { while ($row = mysqli_fetch_array($sql_clients_filter)) {
$client_id = intval($row['client_id']); $client_id = intval($row['client_id']);
$client_name = nullable_htmlentities($row['client_name']); $client_name = nullable_htmlentities($row['client_name']);
@@ -313,11 +298,6 @@ if (mysqli_num_rows($os_sql) > 0) {
type="submit" form="bulkActions" name="bulk_unarchive_assets"> type="submit" form="bulkActions" name="bulk_unarchive_assets">
<i class="fas fa-fw fa-redo mr-2"></i>Unarchive <i class="fas fa-fw fa-redo mr-2"></i>Unarchive
</button> </button>
<div class="dropdown-divider"></div>
<button class="dropdown-item text-danger text-bold"
type="submit" form="bulkActions" name="bulk_delete_assets">
<i class="fas fa-fw fa-trash mr-2"></i>Delete
</button>
<?php } else { ?> <?php } else { ?>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<button class="dropdown-item text-danger confirm-link" <button class="dropdown-item text-danger confirm-link"
@@ -539,8 +519,8 @@ if (mysqli_num_rows($os_sql) > 0) {
$location_name_display = $location_name; $location_name_display = $location_name;
} }
$sql_credentials = mysqli_query($mysqli, "SELECT * FROM credentials WHERE credential_asset_id = $asset_id"); $sql_logins = mysqli_query($mysqli, "SELECT * FROM logins WHERE login_asset_id = $asset_id");
$credential_count = mysqli_num_rows($sql_credentials); $login_count = mysqli_num_rows($sql_logins);
?> ?>
<tr> <tr>
@@ -684,6 +664,14 @@ if (mysqli_num_rows($os_sql) > 0) {
<script src="js/bulk_actions.js"></script> <script src="js/bulk_actions.js"></script>
<?php
require_once "modals/asset_add_modal.php";
require_once "modals/asset_import_modal.php";
require_once "modals/asset_export_modal.php";
require_once "includes/footer.php";
?>
<!-- JSON Autocomplete / type ahead --> <!-- JSON Autocomplete / type ahead -->
<link rel="stylesheet" href="plugins/jquery-ui/jquery-ui.min.css"> <link rel="stylesheet" href="plugins/jquery-ui/jquery-ui.min.css">
<script src="plugins/jquery-ui/jquery-ui.min.js"></script> <script src="plugins/jquery-ui/jquery-ui.min.js"></script>
@@ -699,9 +687,3 @@ if (mysqli_num_rows($os_sql) > 0) {
}); });
}); });
</script> </script>
<?php
require_once "modals/asset_add_modal.php";
require_once "modals/asset_import_modal.php";
require_once "modals/asset_export_modal.php";
require_once "includes/footer.php";

View File

@@ -12,8 +12,6 @@
<h1>Blank Page</h1> <h1>Blank Page</h1>
<hr> <hr>
<p>This is a great starting point for new custom pages.</p> <p>This is a great starting point for new custom pages.</p>
<h1><?php echo $session_user_role; ?></h1>
<?php validateAdminRole(); ?>
<?php <?php
@@ -28,8 +26,6 @@ echo getUserAgent();
?> ?>
<br> <br>
<input type="tel" name="phone" id="phone">
<dl> <dl>
<dt>Requester</dt> <dt>Requester</dt>
<dd>Sam Adams</dd> <dd>Sam Adams</dd>

View File

@@ -89,7 +89,7 @@ require_once "modals/calendar_add_modal.php";
//loop through IDs and create a modal for each //loop through IDs and create a modal for each
$sql = mysqli_query($mysqli, "SELECT * FROM calendar_events LEFT JOIN calendars ON event_calendar_id = calendar_id $client_event_query"); $sql = mysqli_query($mysqli, "SELECT * FROM events LEFT JOIN calendars ON event_calendar_id = calendar_id $client_event_query");
while ($row = mysqli_fetch_array($sql)) { while ($row = mysqli_fetch_array($sql)) {
$event_id = intval($row['event_id']); $event_id = intval($row['event_id']);
$event_title = nullable_htmlentities($row['event_title']); $event_title = nullable_htmlentities($row['event_title']);
@@ -170,7 +170,7 @@ while ($row = mysqli_fetch_array($sql)) {
}, },
events: [ events: [
<?php <?php
$sql = mysqli_query($mysqli, "SELECT * FROM calendar_events LEFT JOIN calendars ON event_calendar_id = calendar_id $client_event_query"); $sql = mysqli_query($mysqli, "SELECT * FROM events LEFT JOIN calendars ON event_calendar_id = calendar_id $client_event_query");
while ($row = mysqli_fetch_array($sql)) { while ($row = mysqli_fetch_array($sql)) {
$event_id = intval($row['event_id']); $event_id = intval($row['event_id']);
$event_title = json_encode($row['event_title']); $event_title = json_encode($row['event_title']);
@@ -245,15 +245,15 @@ while ($row = mysqli_fetch_array($sql)) {
// Recurring Tickets // Recurring Tickets
$sql = mysqli_query($mysqli, "SELECT * FROM clients $sql = mysqli_query($mysqli, "SELECT * FROM clients
LEFT JOIN recurring_tickets ON client_id = recurring_ticket_client_id LEFT JOIN scheduled_tickets ON client_id = scheduled_ticket_client_id
LEFT JOIN users ON recurring_ticket_assigned_to = user_id LEFT JOIN users ON scheduled_ticket_assigned_to = user_id
$client_query" $client_query"
); );
while ($row = mysqli_fetch_array($sql)) { while ($row = mysqli_fetch_array($sql)) {
$event_id = intval($row['recurring_ticket_id']); $event_id = intval($row['scheduled_ticket_id']);
$client_id = intval($row['client_id']); $client_id = intval($row['client_id']);
$username = $row['user_name']; $username = $row['user_name'];
$frequency = $row['recurring_ticket_frequency']; $frequency = $row['scheduled_ticket_frequency'];
if (empty($username)) { if (empty($username)) {
$username = ""; $username = "";
} else { } else {
@@ -261,8 +261,8 @@ while ($row = mysqli_fetch_array($sql)) {
$username = "[". substr($row['user_name'], 0, 9) . "...]"; $username = "[". substr($row['user_name'], 0, 9) . "...]";
} }
$event_title = json_encode("R Ticket ($frequency) - " . $row['recurring_ticket_subject'] . " " . $username); $event_title = json_encode("R Ticket ($frequency) - " . $row['scheduled_ticket_subject'] . " " . $username);
$event_start = json_encode($row['recurring_ticket_next_run']); $event_start = json_encode($row['scheduled_ticket_next_run']);
echo "{ id: $event_id, title: $event_title, start: $event_start, color: '$event_color', url: 'recurring_tickets.php?client_id=$client_id$client_url' },"; echo "{ id: $event_id, title: $event_title, start: $event_start, color: '$event_color', url: 'recurring_tickets.php?client_id=$client_id$client_url' },";
} }

View File

@@ -18,17 +18,8 @@ if (isset($_GET['client_id'])) {
// Perms // Perms
enforceUserPermission('module_support'); enforceUserPermission('module_support');
if (!$client_url) { //Rebuild URL
// Client Filter $url_query_strings_sort = http_build_query($get_copy);
if (isset($_GET['client']) & !empty($_GET['client'])) {
$client_query = 'AND (certificate_client_id = ' . intval($_GET['client']) . ')';
$client = intval($_GET['client']);
} else {
// Default - any
$client_query = '';
$client = '';
}
}
$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS * FROM certificates $sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS * FROM certificates
LEFT JOIN clients ON client_id = certificate_client_id LEFT JOIN clients ON client_id = certificate_client_id
@@ -76,38 +67,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
</div> </div>
</div> </div>
<?php if ($client_url) { ?> <div class="col-md-8">
<div class="col-md-2"></div>
<?php } else { ?>
<div class="col-md-2">
<div class="input-group">
<select class="form-control select2" name="client" onchange="this.form.submit()">
<option value="" <?php if ($client == "") { echo "selected"; } ?>>- All Clients -</option>
<?php
$sql_clients_filter = mysqli_query($mysqli, "
SELECT DISTINCT client_id, client_name
FROM clients
JOIN certificates ON certificate_client_id = client_id
WHERE client_archived_at IS NULL
$access_permission_query
ORDER BY client_name ASC
");
while ($row = mysqli_fetch_array($sql_clients_filter)) {
$client_id = intval($row['client_id']);
$client_name = nullable_htmlentities($row['client_name']);
?>
<option <?php if ($client == $client_id) { echo "selected"; } ?> value="<?php echo $client_id; ?>"><?php echo $client_name; ?></option>
<?php
}
?>
</select>
</div>
</div>
<?php } ?>
<div class="col-md-6">
<div class="btn-group float-right"> <div class="btn-group float-right">
<div class="dropdown ml-2" id="bulkActionButton" hidden> <div class="dropdown ml-2" id="bulkActionButton" hidden>
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown"> <button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">
@@ -194,9 +154,9 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
// Determine the class based on the number of days until expiry // Determine the class based on the number of days until expiry
if ($days_until_expiry <= 0) { if ($days_until_expiry <= 0) {
$tr_class = "table-secondary"; $tr_class = "table-secondary";
} elseif ($days_until_expiry <= 1) { } elseif ($days_until_expiry <= 14) {
$tr_class = "table-danger"; $tr_class = "table-danger";
} elseif ($days_until_expiry <= 7) { } elseif ($days_until_expiry <= 90) {
$tr_class = "table-warning"; $tr_class = "table-warning";
} else { } else {
$tr_class = ''; $tr_class = '';

View File

@@ -13,25 +13,31 @@ if (!isset($_SESSION)) {
// Check to see if setup is enabled // Check to see if setup is enabled
if (!isset($config_enable_setup) || $config_enable_setup == 1) { if (!isset($config_enable_setup) || $config_enable_setup == 1) {
header("Location: ../setup.php"); header("Location: setup.php");
exit; exit;
} }
// Check user is logged in with a valid session // Check user is logged in with a valid session
if (!isset($_SESSION['logged']) || !$_SESSION['logged']) { if (!isset($_SESSION['logged']) || !$_SESSION['logged']) {
if ($_SERVER["REQUEST_URI"] == "/") { if ($_SERVER["REQUEST_URI"] == "/") {
header("Location: ../login.php"); header("Location: login.php");
} else { } else {
header("Location: ../login.php?last_visited=" . base64_encode($_SERVER["REQUEST_URI"]) ); header("Location: login.php?last_visited=" . base64_encode($_SERVER["REQUEST_URI"]) );
} }
exit; exit;
} }
// Check user type
if ($_SESSION['user_type'] !== 1) {
header("Location: login.php");
exit();
}
// Set Timezone // Set Timezone
require_once "inc_set_timezone.php"; require_once "inc_set_timezone.php";
// User Vars and User Settings // User IP & UA
$session_ip = sanitizeInput(getIP()); $session_ip = sanitizeInput(getIP());
$session_user_agent = sanitizeInput($_SERVER['HTTP_USER_AGENT']); $session_user_agent = sanitizeInput($_SERVER['HTTP_USER_AGENT']);
@@ -41,7 +47,7 @@ $sql = mysqli_query(
$mysqli, $mysqli,
"SELECT * FROM users "SELECT * FROM users
LEFT JOIN user_settings ON users.user_id = user_settings.user_id LEFT JOIN user_settings ON users.user_id = user_settings.user_id
LEFT JOIN user_roles ON user_role_id = role_id LEFT JOIN user_roles ON user_settings.user_role = user_roles.user_role_id
WHERE users.user_id = $session_user_id"); WHERE users.user_id = $session_user_id");
$row = mysqli_fetch_array($sql); $row = mysqli_fetch_array($sql);
@@ -49,10 +55,9 @@ $session_name = sanitizeInput($row['user_name']);
$session_email = $row['user_email']; $session_email = $row['user_email'];
$session_avatar = $row['user_avatar']; $session_avatar = $row['user_avatar'];
$session_token = $row['user_token']; // MFA Token $session_token = $row['user_token']; // MFA Token
$session_user_type = intval($row['user_type']); $session_user_role = intval($row['user_role']);
$session_user_role = intval($row['user_role_id']); $session_user_role_display = sanitizeInput($row['user_role_name']);
$session_user_role_display = sanitizeInput($row['role_name']); if (isset($row['user_role_is_admin']) && $row['user_role_is_admin'] == 1) {
if (isset($row['role_is_admin']) && $row['role_is_admin'] == 1) {
$session_is_admin = true; $session_is_admin = true;
} else { } else {
$session_is_admin = false; $session_is_admin = false;
@@ -60,15 +65,6 @@ if (isset($row['role_is_admin']) && $row['role_is_admin'] == 1) {
$session_user_config_force_mfa = intval($row['user_config_force_mfa']); $session_user_config_force_mfa = intval($row['user_config_force_mfa']);
$user_config_records_per_page = intval($row['user_config_records_per_page']); $user_config_records_per_page = intval($row['user_config_records_per_page']);
// Check user type
if ($session_user_type !== 1) {
session_unset();
session_destroy();
header("Location: login.php");
exit();
}
// Company Vars and Company Settings
$sql = mysqli_query($mysqli, "SELECT * FROM companies, settings WHERE settings.company_id = companies.company_id AND companies.company_id = 1"); $sql = mysqli_query($mysqli, "SELECT * FROM companies, settings WHERE settings.company_id = companies.company_id AND companies.company_id = 1");
$row = mysqli_fetch_array($sql); $row = mysqli_fetch_array($sql);
@@ -82,7 +78,7 @@ $session_company_currency = $row['company_currency'];
$currency_format = numfmt_create($session_company_locale, NumberFormatter::CURRENCY); $currency_format = numfmt_create($session_company_locale, NumberFormatter::CURRENCY);
// Get User Client Access Permissions // Get User Client Access Permissions
$user_client_access_sql = "SELECT client_id FROM user_client_permissions WHERE user_id = $session_user_id"; $user_client_access_sql = "SELECT client_id FROM user_permissions WHERE user_id = $session_user_id";
$user_client_access_result = mysqli_query($mysqli, $user_client_access_sql); $user_client_access_result = mysqli_query($mysqli, $user_client_access_sql);
$client_access_array = []; $client_access_array = [];

View File

@@ -27,7 +27,7 @@ if ($_SESSION['user_type'] !== 2) {
} }
// Set Timezone // Set Timezone
require_once "../includes/inc_set_timezone.php"; require_once "../inc_set_timezone.php";
// User IP & UA // User IP & UA
$session_ip = sanitizeInput(getIP()); $session_ip = sanitizeInput(getIP());

View File

@@ -5,7 +5,7 @@
*/ */
require_once '../config.php'; require_once '../config.php';
require_once '../includes/get_settings.php'; require_once '../get_settings.php';
require_once '../functions.php'; require_once '../functions.php';
require_once 'check_login.php'; require_once 'check_login.php';
require_once 'functions.php'; require_once 'functions.php';

View File

@@ -10,7 +10,7 @@ require_once '../config.php';
require_once '../functions.php'; require_once '../functions.php';
require_once '../includes/get_settings.php'; require_once '../get_settings.php';
if (!isset($_SESSION)) { if (!isset($_SESSION)) {
// HTTP Only cookies // HTTP Only cookies
@@ -23,7 +23,7 @@ if (!isset($_SESSION)) {
} }
// Set Timezone after session_start // Set Timezone after session_start
require_once "../includes/inc_set_timezone.php"; require_once "../inc_set_timezone.php";
// Check to see if client portal is enabled // Check to see if client portal is enabled
if($config_client_portal_enable == 0) { if($config_client_portal_enable == 0) {

View File

@@ -18,7 +18,7 @@ if (!isset($_SESSION)) {
} }
// Set Timezone after session starts // Set Timezone after session starts
require_once "../includes/inc_set_timezone.php"; require_once "../inc_set_timezone.php";
$session_ip = sanitizeInput(getIP()); $session_ip = sanitizeInput(getIP());
$session_user_agent = sanitizeInput($_SERVER['HTTP_USER_AGENT']); $session_user_agent = sanitizeInput($_SERVER['HTTP_USER_AGENT']);

View File

@@ -8,7 +8,7 @@ header("Content-Security-Policy: default-src 'self'");
require_once '../config.php'; require_once '../config.php';
require_once '../functions.php'; require_once '../functions.php';
require_once '../includes/get_settings.php'; require_once '../get_settings.php';
if (empty($config_smtp_host)) { if (empty($config_smtp_host)) {
@@ -33,7 +33,7 @@ if (!isset($_SESSION)) {
} }
// Set Timezone after session // Set Timezone after session
require_once "../includes/inc_set_timezone.php"; require_once "../inc_set_timezone.php";
$ip = sanitizeInput(getIP()); $ip = sanitizeInput(getIP());
$user_agent = sanitizeInput($_SERVER['HTTP_USER_AGENT']); $user_agent = sanitizeInput($_SERVER['HTTP_USER_AGENT']);

View File

@@ -5,9 +5,9 @@
*/ */
require_once '../config.php'; require_once '../config.php';
require_once '../includes/get_settings.php'; require_once '../get_settings.php';
require_once '../functions.php'; require_once '../functions.php';
require_once 'includes/check_login.php'; require_once 'check_login.php';
require_once 'functions.php'; require_once 'functions.php';
if (isset($_POST['add_ticket'])) { if (isset($_POST['add_ticket'])) {
@@ -605,7 +605,6 @@ if (isset($_GET['stripe_save_card'])) {
$sql_settings = mysqli_query($mysqli, "SELECT * FROM companies, settings WHERE companies.company_id = settings.company_id AND companies.company_id = 1"); $sql_settings = mysqli_query($mysqli, "SELECT * FROM companies, settings WHERE companies.company_id = settings.company_id AND companies.company_id = 1");
$row = mysqli_fetch_array($sql_settings); $row = mysqli_fetch_array($sql_settings);
$company_name = sanitizeInput($row['company_name']); $company_name = sanitizeInput($row['company_name']);
$company_phone = sanitizeInput(formatPhoneNumber($row['company_phone'], $row['company_phone_country_code']));
$config_smtp_host = $row['config_smtp_host']; $config_smtp_host = $row['config_smtp_host'];
$config_smtp_port = intval($row['config_smtp_port']); $config_smtp_port = intval($row['config_smtp_port']);
$config_smtp_encryption = $row['config_smtp_encryption']; $config_smtp_encryption = $row['config_smtp_encryption'];

View File

@@ -83,16 +83,14 @@ if (isset($_GET['id']) && intval($_GET['id'])) {
</ol> </ol>
<div class="card"> <div class="card">
<div class="card-header bg-dark my-2"> <div class="card-header bg-dark text-center">
<h4 class="card-title mt-1"> <h4 class="mt-1">
Ticket <?php echo $ticket_prefix, $ticket_number ?> Ticket <?php echo $ticket_prefix, $ticket_number ?>
</h4>
<div class="card-tools">
<?php <?php
if (empty($ticket_resolved_at) && $task_count == $completed_task_count) { ?> if (empty($ticket_resolved_at) && $task_count == $completed_task_count) { ?>
<a href="post.php?resolve_ticket=<?php echo $ticket_id; ?>" class="btn btn-sm btn-outline-success float-right text-white confirm-link"><i class="fas fa-fw fa-check text-success"></i> Resolve ticket</a> <a href="post.php?resolve_ticket=<?php echo $ticket_id; ?>" class="btn btn-sm btn-outline-success float-right text-white confirm-link"><i class="fas fa-fw fa-check text-success"></i> Resolve ticket</a>
<?php } ?> <?php } ?>
</div> </h4>
</div> </div>
<div class="card-body prettyContent"> <div class="card-body prettyContent">
@@ -124,7 +122,7 @@ if (isset($_GET['id']) && intval($_GET['id'])) {
while ($ticket_attachment = mysqli_fetch_array($sql_ticket_attachments)) { while ($ticket_attachment = mysqli_fetch_array($sql_ticket_attachments)) {
$name = nullable_htmlentities($ticket_attachment['ticket_attachment_name']); $name = nullable_htmlentities($ticket_attachment['ticket_attachment_name']);
$ref_name = nullable_htmlentities($ticket_attachment['ticket_attachment_reference_name']); $ref_name = nullable_htmlentities($ticket_attachment['ticket_attachment_reference_name']);
echo "<hr><i class='fas fa-fw fa-paperclip text-secondary mr-1'></i>$name | <a href='../uploads/tickets/$ticket_id/$ref_name' download='$name'><i class='fas fa-fw fa-download mr-1'></i>Download</a> | <a target='_blank' href='../uploads/tickets/$ticket_id/$ref_name'><i class='fas fa-fw fa-external-link-alt mr-1'></i>View</a>"; echo "<hr class=''><i class='fas fa-fw fa-paperclip text-secondary mr-1'></i>$name | <a target='_blank' href='https://$config_base_url/uploads/tickets/$ticket_id/$ref_name'><i class='fas fa-fw fa-external-link-alt mr-1'></i>View</a>";
} }
?> ?>
</div> </div>
@@ -261,7 +259,7 @@ if (isset($_GET['id']) && intval($_GET['id'])) {
while ($ticket_attachment = mysqli_fetch_array($sql_ticket_reply_attachments)) { while ($ticket_attachment = mysqli_fetch_array($sql_ticket_reply_attachments)) {
$name = nullable_htmlentities($ticket_attachment['ticket_attachment_name']); $name = nullable_htmlentities($ticket_attachment['ticket_attachment_name']);
$ref_name = nullable_htmlentities($ticket_attachment['ticket_attachment_reference_name']); $ref_name = nullable_htmlentities($ticket_attachment['ticket_attachment_reference_name']);
echo "<hr><i class='fas fa-fw fa-paperclip text-secondary mr-1'></i>$name | <a href='../uploads/tickets/$ticket_id/$ref_name' download='$name'><i class='fas fa-fw fa-download mr-1'></i>Download</a> | <a target='_blank' href='../uploads/tickets/$ticket_id/$ref_name'><i class='fas fa-fw fa-external-link-alt mr-1'></i>View</a>"; echo "<hr><i class='fas fa-fw fa-paperclip text-secondary mr-1'></i>$name | <a target='_blank' href='https://$config_base_url/uploads/tickets/$ticket_id/$ref_name'><i class='fas fa-fw fa-external-link-alt mr-1'></i>View</a>";
} }
?> ?>
</div> </div>

View File

@@ -171,14 +171,13 @@ $page_title = $row['document_name'];
data-ajax-url="ajax/ajax_document_edit.php" data-ajax-url="ajax/ajax_document_edit.php"
data-ajax-id="<?php echo $document_id; ?>" data-ajax-id="<?php echo $document_id; ?>"
> >
<i class="fas fa-fw fa-edit"></i> <i class="fas fa-fw fa-edit mr-2"></i>Edit
</button> </button>
<button type="button" class="btn btn-secondary mr-2" data-toggle="modal" data-target="#shareModal" <button type="button" class="btn btn-secondary mr-2" data-toggle="modal" data-target="#shareModal"
onclick="populateShareModal(<?php echo "$client_id, 'Document', $document_id"; ?>)"> onclick="populateShareModal(<?php echo "$client_id, 'Document', $document_id"; ?>)">
<i class="fas fa-fw fa-share"></i> <i class="fas fa-fw fa-share mr-2"></i>Share
</button> </button>
<a class="btn btn-success mr-2" href="post.php?export_document=<?php echo $document_id; ?>"><i class='fas fa-fw fa-file-pdf'></i></a> <button type="button" class="btn btn-secondary" onclick="window.print();"><i class="fas fa-fw fa-print mr-2"></i>Print</button>
<button type="button" class="btn btn-secondary" onclick="window.print();"><i class="fas fa-fw fa-print"></i></button>
</div> </div>
</div> </div>
<div class="card card-body bg-light"> <div class="card card-body bg-light">
@@ -341,12 +340,7 @@ $page_title = $row['document_name'];
?> ?>
<div class="ml-2"> <div class="ml-2">
<a href="#" <a href="vendors.php?client_id=<?php echo $client_id; ?>&q=<?php echo $vendor_name; ?>" target="_blank"><?php echo $vendor_name; ?></a>
data-toggle="ajax-modal"
data-ajax-url="ajax/ajax_vendor_details.php"
data-ajax-id="<?php echo $vendor_id; ?>">
<?php echo $vendor_name; ?>
</a>
<a class="confirm-link float-right" href="post.php?unlink_vendor_from_document&vendor_id=<?php echo $vendor_id; ?>&document_id=<?php echo $document_id; ?>"> <a class="confirm-link float-right" href="post.php?unlink_vendor_from_document&vendor_id=<?php echo $vendor_id; ?>&document_id=<?php echo $document_id; ?>">
<i class="fas fa-fw fa-trash-alt text-secondary"></i> <i class="fas fa-fw fa-trash-alt text-secondary"></i>
</a> </a>

View File

@@ -322,12 +322,22 @@ while ($folder_id > 0) {
$file_size_KB = number_format($file_size / 1024); $file_size_KB = number_format($file_size / 1024);
$file_mime_type = nullable_htmlentities($row['file_mime_type']); $file_mime_type = nullable_htmlentities($row['file_mime_type']);
$file_uploaded_by = nullable_htmlentities($row['user_name']); $file_uploaded_by = nullable_htmlentities($row['user_name']);
$file_has_thumbnail = intval($row['file_has_thumbnail']);
$file_has_preview = intval($row['file_has_preview']);
$file_thumbnail_source = $file_reference_name;
if ($file_has_thumbnail == 1) {
$file_thumbnail_source = "thumbnail_$file_reference_name";
}
$file_preview_source = $file_reference_name;
if ($file_has_preview == 1) {
$file_preview_source = "preview_$file_reference_name";
}
// Store file data into an array for JS // Store file data into an array for JS
$files[] = [ $files[] = [
'id' => $file_id, 'id' => $file_id,
'name' => $file_name, 'name' => $file_name,
'preview' => "uploads/clients/$client_id/$file_reference_name" 'preview' => "uploads/clients/$client_id/$file_preview_source"
]; ];
?> ?>
@@ -473,6 +483,8 @@ while ($folder_id > 0) {
$file_mime_type = nullable_htmlentities($row['file_mime_type']); $file_mime_type = nullable_htmlentities($row['file_mime_type']);
$file_size = intval($row['file_size']); $file_size = intval($row['file_size']);
$file_uploaded_by = nullable_htmlentities($row['user_name']); $file_uploaded_by = nullable_htmlentities($row['user_name']);
$file_has_thumbnail = intval($row['file_has_thumbnail']);
$file_has_preview = intval($row['file_has_preview']);
$file_created_at = nullable_htmlentities($row['file_created_at']); $file_created_at = nullable_htmlentities($row['file_created_at']);
$file_folder_id = intval($row['file_folder_id']); $file_folder_id = intval($row['file_folder_id']);

View File

@@ -2,6 +2,8 @@
require_once "includes/inc_all_client.php"; require_once "includes/inc_all_client.php";
// Get expiration days from select box
$expiration_days = isset($_GET['expiration_days']) ? intval($_GET['expiration_days']) : 90;
$sql_recent_activities = mysqli_query( $sql_recent_activities = mysqli_query(
$mysqli, $mysqli,
@@ -32,12 +34,12 @@ $sql_recent_tickets = mysqli_query(
LIMIT 5" LIMIT 5"
); );
$sql_recent_credentials = mysqli_query( $sql_recent_logins = mysqli_query(
$mysqli, $mysqli,
"SELECT * FROM credentials "SELECT * FROM logins
WHERE credential_client_id = $client_id WHERE login_client_id = $client_id
AND credential_archived_at IS NULL AND login_archived_at IS NULL
ORDER BY credential_updated_at ASC ORDER BY login_updated_at ASC
LIMIT 5" LIMIT 5"
); );
@@ -59,14 +61,13 @@ $sql_stale_tickets = mysqli_query(
$mysqli, $mysqli,
"SELECT * FROM tickets "SELECT * FROM tickets
WHERE ticket_client_id = $client_id WHERE ticket_client_id = $client_id
AND ticket_updated_at < CURRENT_DATE - INTERVAL 7 DAY AND ticket_updated_at < CURRENT_DATE - INTERVAL 3 DAY
AND ticket_resolved_At IS NULL AND ticket_resolved_At IS NULL
AND ticket_closed_at IS NULL AND ticket_closed_at IS NULL
ORDER BY ticket_updated_at ASC" ORDER BY ticket_updated_at ASC
LIMIT 5"
); );
// 8 - 45 Day Warning
// Get Domains Expiring // Get Domains Expiring
$sql_domains_expiring = mysqli_query( $sql_domains_expiring = mysqli_query(
$mysqli, $mysqli,
@@ -75,8 +76,9 @@ $sql_domains_expiring = mysqli_query(
AND domain_expire IS NOT NULL AND domain_expire IS NOT NULL
AND domain_archived_at IS NULL AND domain_archived_at IS NULL
AND domain_expire > CURRENT_DATE AND domain_expire > CURRENT_DATE
AND domain_expire < CURRENT_DATE + INTERVAL 45 DAY AND domain_expire < CURRENT_DATE + INTERVAL $expiration_days DAY
ORDER BY domain_expire ASC" ORDER BY domain_expire ASC
LIMIT 5"
); );
// Get Certificates Expiring // Get Certificates Expiring
@@ -87,8 +89,9 @@ $sql_certificates_expiring = mysqli_query(
AND certificate_expire IS NOT NULL AND certificate_expire IS NOT NULL
AND certificate_archived_at IS NULL AND certificate_archived_at IS NULL
AND certificate_expire > CURRENT_DATE AND certificate_expire > CURRENT_DATE
AND certificate_expire < CURRENT_DATE + INTERVAL 45 DAY AND certificate_expire < CURRENT_DATE + INTERVAL $expiration_days DAY
ORDER BY certificate_expire ASC" ORDER BY certificate_expire ASC
LIMIT 5"
); );
// Get Licenses Expiring // Get Licenses Expiring
@@ -99,8 +102,9 @@ $sql_licenses_expiring = mysqli_query(
AND software_expire IS NOT NULL AND software_expire IS NOT NULL
AND software_archived_at IS NULL AND software_archived_at IS NULL
AND software_expire > CURRENT_DATE AND software_expire > CURRENT_DATE
AND software_expire < CURRENT_DATE + INTERVAL 45 DAY AND software_expire < CURRENT_DATE + INTERVAL $expiration_days DAY
ORDER BY software_expire ASC" ORDER BY software_expire ASC
LIMIT 5"
); );
// Get Asset Warranties Expiring // Get Asset Warranties Expiring
@@ -111,8 +115,9 @@ $sql_asset_warranties_expiring = mysqli_query(
AND asset_warranty_expire IS NOT NULL AND asset_warranty_expire IS NOT NULL
AND asset_archived_at IS NULL AND asset_archived_at IS NULL
AND asset_warranty_expire > CURRENT_DATE AND asset_warranty_expire > CURRENT_DATE
AND asset_warranty_expire < CURRENT_DATE + INTERVAL 45 DAY AND asset_warranty_expire < CURRENT_DATE + INTERVAL $expiration_days DAY
ORDER BY asset_warranty_expire ASC" ORDER BY asset_warranty_expire ASC
LIMIT 5"
); );
// Get Assets Retiring 7 Year // Get Assets Retiring 7 Year
@@ -122,9 +127,10 @@ $sql_asset_retire = mysqli_query(
WHERE asset_client_id = $client_id WHERE asset_client_id = $client_id
AND asset_install_date IS NOT NULL AND asset_install_date IS NOT NULL
AND asset_archived_at IS NULL AND asset_archived_at IS NULL
AND asset_install_date + INTERVAL 7 YEAR > CURRENT_DATE AND asset_install_date + INTERVAL 7 YEAR > CURRENT_DATE -- Not yet expired
AND asset_install_date + INTERVAL 7 YEAR <= CURRENT_DATE + INTERVAL 45 DAY AND asset_install_date + INTERVAL 7 YEAR <= CURRENT_DATE + INTERVAL $expiration_days DAY
ORDER BY asset_install_date ASC" ORDER BY asset_install_date ASC
LIMIT 5"
); );
/* /*
@@ -139,7 +145,8 @@ $sql_domains_expired = mysqli_query(
AND domain_expire IS NOT NULL AND domain_expire IS NOT NULL
AND domain_archived_at IS NULL AND domain_archived_at IS NULL
AND domain_expire < CURRENT_DATE AND domain_expire < CURRENT_DATE
ORDER BY domain_expire ASC" ORDER BY domain_expire ASC
LIMIT 5"
); );
// Get Certificates Expired // Get Certificates Expired
@@ -150,7 +157,8 @@ $sql_certificates_expired = mysqli_query(
AND certificate_expire IS NOT NULL AND certificate_expire IS NOT NULL
AND certificate_archived_at IS NULL AND certificate_archived_at IS NULL
AND certificate_expire < CURRENT_DATE AND certificate_expire < CURRENT_DATE
ORDER BY certificate_expire ASC" ORDER BY certificate_expire ASC
LIMIT 5"
); );
// Get Licenses Expired // Get Licenses Expired
@@ -161,7 +169,8 @@ $sql_licenses_expired = mysqli_query(
AND software_expire IS NOT NULL AND software_expire IS NOT NULL
AND software_archived_at IS NULL AND software_archived_at IS NULL
AND software_expire < CURRENT_DATE AND software_expire < CURRENT_DATE
ORDER BY software_expire ASC" ORDER BY software_expire ASC
LIMIT 5"
); );
// Get Asset Warranties Expired // Get Asset Warranties Expired
@@ -172,7 +181,8 @@ $sql_asset_warranties_expired = mysqli_query(
AND asset_warranty_expire IS NOT NULL AND asset_warranty_expire IS NOT NULL
AND asset_archived_at IS NULL AND asset_archived_at IS NULL
AND asset_warranty_expire < CURRENT_DATE AND asset_warranty_expire < CURRENT_DATE
ORDER BY asset_warranty_expire ASC" ORDER BY asset_warranty_expire ASC
LIMIT 5"
); );
// Get Retired Assets // Get Retired Assets
@@ -183,7 +193,8 @@ $sql_asset_retired = mysqli_query(
AND asset_install_date IS NOT NULL AND asset_install_date IS NOT NULL
AND asset_archived_at IS NULL AND asset_archived_at IS NULL
AND asset_install_date + INTERVAL 7 YEAR < CURRENT_DATE -- Assets retired (installed more than 7 years ago) AND asset_install_date + INTERVAL 7 YEAR < CURRENT_DATE -- Assets retired (installed more than 7 years ago)
ORDER BY asset_install_date ASC" ORDER BY asset_install_date ASC
LIMIT 5"
); );
@@ -221,11 +232,9 @@ $sql_asset_retired = mysqli_query(
$contact_name = nullable_htmlentities($row['contact_name']); $contact_name = nullable_htmlentities($row['contact_name']);
$contact_title = nullable_htmlentities($row['contact_title']); $contact_title = nullable_htmlentities($row['contact_title']);
$contact_email = nullable_htmlentities($row['contact_email']); $contact_email = nullable_htmlentities($row['contact_email']);
$contact_phone_country_code = nullable_htmlentities($row['contact_phone_country_code']); $contact_phone = formatPhoneNumber($row['contact_phone']);
$contact_phone = nullable_htmlentities(formatPhoneNumber($row['contact_phone'], $contact_phone_country_code));
$contact_extension = nullable_htmlentities($row['contact_extension']); $contact_extension = nullable_htmlentities($row['contact_extension']);
$contact_mobile_country_code = nullable_htmlentities($row['contact_mobile_country_code']); $contact_mobile = formatPhoneNumber($row['contact_mobile']);
$contact_mobile = nullable_htmlentities(formatPhoneNumber($row['contact_mobile'], $contact_mobile_country_code));
?> ?>
<tr> <tr>
@@ -288,10 +297,10 @@ $sql_asset_retired = mysqli_query(
$item_expire_at = nullable_htmlentities($row['item_expire_at']); $item_expire_at = nullable_htmlentities($row['item_expire_at']);
$item_expire_at_human = timeAgo($row['item_expire_at']); $item_expire_at_human = timeAgo($row['item_expire_at']);
if ($item_type == 'Credential') { if ($item_type == 'Login') {
$share_item_sql = mysqli_query($mysqli, "SELECT credential_name FROM credentials WHERE credential_id = $item_related_id AND credential_client_id = $client_id"); $share_item_sql = mysqli_query($mysqli, "SELECT login_name FROM logins WHERE login_id = $item_related_id AND login_client_id = $client_id");
$share_item = mysqli_fetch_array($share_item_sql); $share_item = mysqli_fetch_array($share_item_sql);
$item_name = nullable_htmlentities($share_item['credential_name']); $item_name = nullable_htmlentities($share_item['login_name']);
$item_icon = "fas fa-key"; $item_icon = "fas fa-key";
} elseif ($item_type == 'Document') { } elseif ($item_type == 'Document') {
$share_item_sql = mysqli_query($mysqli, "SELECT document_name FROM documents WHERE document_id = $item_related_id AND document_client_id = $client_id"); $share_item_sql = mysqli_query($mysqli, "SELECT document_name FROM documents WHERE document_id = $item_related_id AND document_client_id = $client_id");
@@ -344,7 +353,17 @@ $sql_asset_retired = mysqli_query(
<div class="card card-dark mb-3"> <div class="card card-dark mb-3">
<div class="card-header"> <div class="card-header">
<h5 class="card-title"><i class="fa fa-fw fa-exclamation-triangle text-warning mr-2"></i>Expiring in the Next 45 Days</h5> <h5 class="card-title"><i class="fa fa-fw fa-exclamation-triangle text-warning mr-2"></i>Upcoming Expirations</h5>
<div class="card-tools">
<form class="form-inline">
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
<select onchange="this.form.submit()" class="form-control form-control-sm" name="expiration_days">
<option value="7" <?php if ($expiration_days == 7) { echo "selected"; } ?>>Within 7 Days</option>
<option value="30" <?php if ($expiration_days == 30) { echo "selected"; } ?>>Within 30 Days</option>
<option value="90" <?php if ($expiration_days == 90) { echo "selected"; } ?>>Within 90 Days</option>
</select>
</form>
</div>
</div> </div>
<div class="card-body p-2"> <div class="card-body p-2">
@@ -359,8 +378,8 @@ $sql_asset_retired = mysqli_query(
?> ?>
<p class="mb-1"> <p class="mb-1">
<i class="fa fa-fw fa-globe text-secondary mr-1"></i> <i class="fa fa-fw fa-globe text-secondary mr-1"></i>
<a href="domains.php?client_id=<?php echo $client_id; ?>&q=<?php echo $domain_name; ?>">Domain: <?php echo $domain_name; ?></a> <a href="client_domains.php?client_id=<?php echo $client_id; ?>&q=<?php echo $domain_name; ?>"><?php echo $domain_name; ?></a>
<span>-- <?php echo $domain_expire; ?> (<?php echo $domain_expire_human; ?>)</span> <span>-- <?php echo $domain_expire_human; ?> <small class="text-muted"><?php echo $domain_expire; ?></small></span>
</p> </p>
<?php <?php
} }
@@ -377,8 +396,8 @@ $sql_asset_retired = mysqli_query(
?> ?>
<p class="mb-1"> <p class="mb-1">
<i class="fa fa-fw fa-lock text-secondary mr-1"></i> <i class="fa fa-fw fa-lock text-secondary mr-1"></i>
<a href="certificates.php?client_id=<?php echo $client_id; ?>&q=<?php echo $certificate_name; ?>">Certificate: <?php echo $certificate_name; ?></a> <a href="client_certificates.php?client_id=<?php echo $client_id; ?>&q=<?php echo $certificate_name; ?>"><?php echo $certificate_name; ?></a>
<span>-- <?php echo $certificate_expire; ?> (<?php echo $certificate_expire_human; ?>)</span> <span>-- <?php echo $certificate_expire_human; ?> <small class="text-muted"><?php echo $certificate_expire; ?></small></span>
</p> </p>
<?php <?php
} }
@@ -395,8 +414,8 @@ $sql_asset_retired = mysqli_query(
?> ?>
<p class="mb-1"> <p class="mb-1">
<i class="fa fa-fw fa-laptop text-secondary mr-1"></i> <i class="fa fa-fw fa-laptop text-secondary mr-1"></i>
<a href="asset_details.php?client_id=<?php echo $client_id; ?>&asset_id=<?php echo $asset_id; ?>">Asset Warranty: <?php echo $asset_name; ?></a> <a href="asset_details.php?client_id=<?php echo $client_id; ?>&asset_id=<?php echo $asset_id; ?>"><?php echo $asset_name; ?></a>
<span>-- <?php echo $asset_warranty_expire; ?> (<?php echo $asset_warranty_expire_human; ?>)</span> <span>-- <?php echo $asset_warranty_expire_human; ?> <small class="text-muted"><?php echo $asset_warranty_expire; ?></small></span>
</p> </p>
@@ -415,8 +434,8 @@ $sql_asset_retired = mysqli_query(
?> ?>
<p class="mb-1"> <p class="mb-1">
<i class="fa fa-fw fa-laptop text-secondary mr-1"></i> <i class="fa fa-fw fa-laptop text-secondary mr-1"></i>
<a href="asset_details.php?client_id=<?php echo $client_id; ?>&asset_id=<?php echo $asset_id; ?>">Asset Retire: <?php echo $asset_name; ?></a> <a href="asset_details.php?client_id=<?php echo $client_id; ?>&asset_id=<?php echo $asset_id; ?>"><?php echo $asset_name; ?></a>
<span>-- <?php echo $asset_install_date; ?> (<?php echo $asset_install_date_human; ?>)</span> <span>-- <?php echo $asset_install_date_human; ?> <small class="text-muted"><?php echo $asset_install_date; ?></small></span>
</p> </p>
<?php <?php
@@ -434,8 +453,8 @@ $sql_asset_retired = mysqli_query(
?> ?>
<p class="mb-1"> <p class="mb-1">
<i class="fa fa-fw fa-cube text-secondary mr-1"></i> <i class="fa fa-fw fa-cube text-secondary mr-1"></i>
<a href="software.php?client_id=<?php echo $client_id; ?>&q=<?php echo $software_name; ?>">License: <?php echo $software_name; ?></a> <a href="client_software.php?client_id=<?php echo $client_id; ?>&q=<?php echo $software_name; ?>"><?php echo $software_name; ?></a>
<span>-- <?php echo $software_expire; ?> (<?php echo $software_expire_human; ?>)</span> <span>-- <?php echo $software_expire_human; ?> <small class="text-muted"><?php echo $software_expire; ?></small></span>
</p> </p>
<?php <?php
@@ -477,8 +496,8 @@ $sql_asset_retired = mysqli_query(
?> ?>
<p class="mb-1"> <p class="mb-1">
<i class="fa fa-fw fa-globe text-secondary mr-1"></i> <i class="fa fa-fw fa-globe text-secondary mr-1"></i>
<a href="domains.php?client_id=<?php echo $client_id; ?>&q=<?php echo $domain_name; ?>">Domain: <?php echo $domain_name; ?></a> <a href="client_domains.php?client_id=<?php echo $client_id; ?>&q=<?php echo $domain_name; ?>"><?php echo $domain_name; ?></a>
<span>-- <?php echo $domain_expire; ?> (<?php echo $domain_expire_human; ?>)</span> <span>-- <?php echo $domain_expire_human; ?> <small class="text-muted"><?php echo $domain_expire; ?></small></span>
</p> </p>
<?php <?php
} }
@@ -495,8 +514,8 @@ $sql_asset_retired = mysqli_query(
?> ?>
<p class="mb-1"> <p class="mb-1">
<i class="fa fa-fw fa-lock text-secondary mr-1"></i> <i class="fa fa-fw fa-lock text-secondary mr-1"></i>
<a href="certificates.php?client_id=<?php echo $client_id; ?>&q=<?php echo $certificate_name; ?>">Certificate: <?php echo $certificate_name; ?></a> <a href="client_certificates.php?client_id=<?php echo $client_id; ?>&q=<?php echo $certificate_name; ?>"><?php echo $certificate_name; ?></a>
<span>-- <?php echo $certificate_expire; ?> (<?php echo $certificate_expire_human; ?>)</span> <span>-- <?php echo $certificate_expire_human; ?> <small class="text-muted"><?php echo $certificate_expire; ?></small></span>
</p> </p>
<?php <?php
} }
@@ -512,9 +531,9 @@ $sql_asset_retired = mysqli_query(
?> ?>
<p class="mb-1"> <p class="mb-1">
<i class="fa fa-fw fa-laptop text-secondary mr-1"></i>Asset Warranty: <i class="fa fa-fw fa-laptop text-secondary mr-1"></i>
<a href="asset_details.php?client_id=<?php echo $client_id; ?>&asset_id=<?php echo $asset_id; ?>"><?php echo $asset_name; ?></a> <a href="asset_details.php?client_id=<?php echo $client_id; ?>&asset_id=<?php echo $asset_id; ?>"><?php echo $asset_name; ?></a>
<span>-- <?php echo $asset_warranty_expire; ?> (<?php echo $asset_warranty_expire_human; ?>)</span> <span>-- <?php echo $asset_warranty_expire_human; ?> <small class="text-muted"><?php echo $asset_warranty_expire; ?></small></span>
</p> </p>
@@ -533,8 +552,8 @@ $sql_asset_retired = mysqli_query(
?> ?>
<p class="mb-1"> <p class="mb-1">
<i class="fa fa-fw fa-laptop text-secondary mr-1"></i> <i class="fa fa-fw fa-laptop text-secondary mr-1"></i>
<a href="asset_details.php?client_id=<?php echo $client_id; ?>&asset_id=<?php echo $asset_id; ?>">Asset Retire: <?php echo $asset_name; ?></a> <a href="asset_details.php?client_id=<?php echo $client_id; ?>&asset_id=<?php echo $asset_id; ?>"><?php echo $asset_name; ?></a>
<span>-- <?php echo $asset_install_date; ?> (<?php echo $asset_install_date_human; ?>)</span> <span>-- <?php echo $asset_install_date_human; ?> <small class="text-muted"><?php echo $asset_install_date; ?></small></span>
</p> </p>
<?php <?php
@@ -552,8 +571,8 @@ $sql_asset_retired = mysqli_query(
?> ?>
<p class="mb-1"> <p class="mb-1">
<i class="fa fa-fw fa-cube text-secondary mr-1"></i> <i class="fa fa-fw fa-cube text-secondary mr-1"></i>
<a href="software.php?client_id=<?php echo $client_id; ?>&q=<?php echo $software_name; ?>">Software: <?php echo $software_name; ?></a> <a href="client_software.php?client_id=<?php echo $client_id; ?>&q=<?php echo $software_name; ?>"><?php echo $software_name; ?></a>
<span>-- <?php echo $software_expire; ?> (<?php echo $software_expire_human; ?>)</span> <span>-- <?php echo $software_expire_human; ?> <small class="text-muted"><?php echo $software_expire; ?></small></span>
</p> </p>
<?php <?php

View File

@@ -261,7 +261,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
$icon = $d['icon']; // already from getAssetIcon $icon = $d['icon']; // already from getAssetIcon
?> ?>
<i class="fa fa-<?php echo $icon; ?>"></i> <i class="fa fa-<?php echo $icon; ?>"></i>
<a href="asset_details.php?client_id=<?php echo $client_id; ?>&asset_id=<?php echo $d['asset_id']; ?>" <a href="client_asset_details.php?client_id=<?php echo $client_id; ?>&asset_id=<?php echo $d['asset_id']; ?>"
target="_blank"> target="_blank">
<?php echo $d['asset_name']; ?> <?php echo $d['asset_name']; ?>
<i class="fas fa-external-link-alt ml-1"></i> <i class="fas fa-external-link-alt ml-1"></i>

View File

@@ -20,13 +20,17 @@ if (isset($_GET['leads']) && $_GET['leads'] == 1) {
// Tags Filter // Tags Filter
if (isset($_GET['tags']) && is_array($_GET['tags']) && !empty($_GET['tags'])) { if (isset($_GET['tags']) && is_array($_GET['tags']) && !empty($_GET['tags'])) {
// Sanitize each element of the tags array // Sanitize each element of the status array
$sanitizedTags = array_map('intval', $_GET['tags']); $sanitizedTags = array();
foreach ($_GET['tags'] as $tag) {
// Escape each status to prevent SQL injection
$sanitizedTags[] = "'" . intval($tag) . "'";
}
// Convert the sanitized tags into a comma-separated string // Convert the sanitized tags into a comma-separated string
$tag_filter = implode(",", $sanitizedTags); $sanitizedTagsString = implode(",", $sanitizedTags);
$tag_query = "AND tags.tag_id IN ($tag_filter)"; $tag_query = "AND tags.tag_id IN ($sanitizedTagsString)";
} else { } else {
$tag_filter = 0;
$tag_query = ''; $tag_query = '';
} }
@@ -59,7 +63,7 @@ $sql = mysqli_query(
LEFT JOIN locations ON clients.client_id = locations.location_client_id AND location_primary = 1 LEFT JOIN locations ON clients.client_id = locations.location_client_id AND location_primary = 1
LEFT JOIN client_tags ON client_tags.client_id = clients.client_id LEFT JOIN client_tags ON client_tags.client_id = clients.client_id
LEFT JOIN tags ON tags.tag_id = client_tags.tag_id LEFT JOIN tags ON tags.tag_id = client_tags.tag_id
WHERE (client_name LIKE '%$q%' OR client_abbreviation LIKE '%$q%' OR client_type LIKE '%$q%' OR client_referral LIKE '%$q%' WHERE (client_name LIKE '%$q%' OR client_type LIKE '%$q%' OR client_referral LIKE '%$q%'
OR contact_email LIKE '%$q%' OR contact_name LIKE '%$q%' OR contact_phone LIKE '%$phone_query%' OR contact_email LIKE '%$q%' OR contact_name LIKE '%$q%' OR contact_phone LIKE '%$phone_query%'
OR contact_mobile LIKE '%$phone_query%' OR location_address LIKE '%$q%' OR contact_mobile LIKE '%$phone_query%' OR location_address LIKE '%$q%'
OR location_city LIKE '%$q%' OR location_state LIKE '%$q%' OR location_zip LIKE '%$q%' OR location_city LIKE '%$q%' OR location_state LIKE '%$q%' OR location_zip LIKE '%$q%'
@@ -181,20 +185,12 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
</div> </div>
</div> </div>
<div class="col-md-2"> <div class="col-md-2">
<label>Tag</label> <div class="form-group">
<div class="input-group"> <label>Tag</label>
<select onchange="this.form.submit()" class="form-control select2" name="tags[]" data-placeholder="- Select Tags -" multiple> <select onchange="this.form.submit()" class="form-control select2" name="tags[]" data-placeholder="- Select Tags -" multiple>
<?php <?php
$sql_tags_filter = mysqli_query($mysqli, " $sql_tags = mysqli_query($mysqli, "SELECT * FROM tags WHERE tag_type = 1");
SELECT tags.tag_id, tags.tag_name while ($row = mysqli_fetch_array($sql_tags)) {
FROM tags
LEFT JOIN client_tags ON client_tags.tag_id = tags.tag_id
WHERE tag_type = 1
GROUP BY tags.tag_id
HAVING COUNT(client_tags.client_id) > 0 OR tags.tag_id IN ($tag_filter)
");
while ($row = mysqli_fetch_array($sql_tags_filter)) {
$tag_id = intval($row['tag_id']); $tag_id = intval($row['tag_id']);
$tag_name = nullable_htmlentities($row['tag_name']); ?> $tag_name = nullable_htmlentities($row['tag_name']); ?>
@@ -291,11 +287,9 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
$contact_id = intval($row['contact_id']); $contact_id = intval($row['contact_id']);
$contact_name = nullable_htmlentities($row['contact_name']); $contact_name = nullable_htmlentities($row['contact_name']);
$contact_title = nullable_htmlentities($row['contact_title']); $contact_title = nullable_htmlentities($row['contact_title']);
$contact_phone_country_code = nullable_htmlentities($row['contact_phone_country_code']); $contact_phone = formatPhoneNumber($row['contact_phone']);
$contact_phone = nullable_htmlentities(formatPhoneNumber($row['contact_phone'], $contact_phone_country_code));
$contact_extension = nullable_htmlentities($row['contact_extension']); $contact_extension = nullable_htmlentities($row['contact_extension']);
$contact_mobile_country_code = nullable_htmlentities($row['contact_mobile_country_code']); $contact_mobile = formatPhoneNumber($row['contact_mobile']);
$contact_mobile = nullable_htmlentities(formatPhoneNumber($row['contact_mobile'], $contact_mobile_country_code));
$contact_email = nullable_htmlentities($row['contact_email']); $contact_email = nullable_htmlentities($row['contact_email']);
$client_website = nullable_htmlentities($row['client_website']); $client_website = nullable_htmlentities($row['client_website']);
$client_rate = floatval($row['client_rate']); $client_rate = floatval($row['client_rate']);
@@ -358,13 +352,13 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
} }
//Get Monthly Recurring Total //Get Monthly Recurring Total
$sql_recurring_monthly_total = mysqli_query($mysqli, "SELECT SUM(recurring_invoice_amount) AS recurring_monthly_total FROM recurring_invoices WHERE recurring_invoice_status = 1 AND recurring_invoice_frequency = 'month' AND recurring_invoice_client_id = $client_id"); $sql_recurring_monthly_total = mysqli_query($mysqli, "SELECT SUM(recurring_amount) AS recurring_monthly_total FROM recurring WHERE recurring_status = 1 AND recurring_frequency = 'month' AND recurring_client_id = $client_id");
$row = mysqli_fetch_array($sql_recurring_monthly_total); $row = mysqli_fetch_array($sql_recurring_monthly_total);
$recurring_monthly_total = floatval($row['recurring_monthly_total']); $recurring_monthly_total = floatval($row['recurring_monthly_total']);
//Get Yearly Recurring Total //Get Yearly Recurring Total
$sql_recurring_yearly_total = mysqli_query($mysqli, "SELECT SUM(recurring_invoice_amount) AS recurring_yearly_total FROM recurring_invoices WHERE recurring_invoice_status = 1 AND recurring_invoice_frequency = 'year' AND recurring_invoice_client_id = $client_id"); $sql_recurring_yearly_total = mysqli_query($mysqli, "SELECT SUM(recurring_amount) AS recurring_yearly_total FROM recurring WHERE recurring_status = 1 AND recurring_frequency = 'year' AND recurring_client_id = $client_id");
$row = mysqli_fetch_array($sql_recurring_yearly_total); $row = mysqli_fetch_array($sql_recurring_yearly_total);
$recurring_yearly_total = floatval($row['recurring_yearly_total']) / 12; $recurring_yearly_total = floatval($row['recurring_yearly_total']) / 12;
@@ -404,14 +398,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
if (!empty($contact_name)) { ?> if (!empty($contact_name)) { ?>
<div class="text-bold"> <div class="text-bold">
<i class="fa fa-fw fa-user text-secondary mr-2 mb-2"></i> <i class="fa fa-fw fa-user text-secondary mr-2 mb-2"></i><a href="client_contact_details.php?client_id=<?php echo $client_id ?>&contact_id=<?php echo $contact_id ?>"><?php echo $contact_name; ?></a>
<a href="#"
data-toggle="ajax-modal"
data-modal-size="lg"
data-ajax-url="ajax/ajax_contact_details.php?client_id=<?php echo $client_id; ?>"
data-ajax-id="<?php echo $contact_id; ?>">
<?php echo $contact_name; ?>
</a>
</div> </div>
<?php } else { <?php } else {
echo "-"; echo "-";
@@ -495,6 +482,10 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<?php <?php
require_once "modals/client_add_modal.php"; require_once "modals/client_add_modal.php";
require_once "modals/client_import_modal.php"; require_once "modals/client_import_modal.php";
require_once "modals/client_export_modal.php"; require_once "modals/client_export_modal.php";
require_once "includes/footer.php"; require_once "includes/footer.php";

View File

@@ -28,11 +28,9 @@ if (isset($_GET['contact_id'])) {
$contact_name = nullable_htmlentities($row['contact_name']); $contact_name = nullable_htmlentities($row['contact_name']);
$contact_title = nullable_htmlentities($row['contact_title']); $contact_title = nullable_htmlentities($row['contact_title']);
$contact_department =nullable_htmlentities($row['contact_department']); $contact_department =nullable_htmlentities($row['contact_department']);
$contact_phone_country_code = nullable_htmlentities($row['contact_phone_country_code']); $contact_phone = formatPhoneNumber($row['contact_phone']);
$contact_phone = nullable_htmlentities(formatPhoneNumber($row['contact_phone'], $contact_phone_country_code));
$contact_extension = nullable_htmlentities($row['contact_extension']); $contact_extension = nullable_htmlentities($row['contact_extension']);
$contact_mobile_country_code = nullable_htmlentities($row['contact_mobile_country_code']); $contact_mobile = formatPhoneNumber($row['contact_mobile']);
$contact_mobile = nullable_htmlentities(formatPhoneNumber($row['contact_phone'], $contact_mobile_country_code));
$contact_email = nullable_htmlentities($row['contact_email']); $contact_email = nullable_htmlentities($row['contact_email']);
$contact_photo = nullable_htmlentities($row['contact_photo']); $contact_photo = nullable_htmlentities($row['contact_photo']);
$contact_pin = nullable_htmlentities($row['contact_pin']); $contact_pin = nullable_htmlentities($row['contact_pin']);
@@ -71,21 +69,21 @@ if (isset($_GET['contact_id'])) {
$linked_software = array(); $linked_software = array();
// Related Credentials Query 1 to 1 relationship // Related Logins Query 1 to 1 relationship
$sql_related_credentials = mysqli_query($mysqli, " $sql_related_logins = mysqli_query($mysqli, "
SELECT SELECT
credentials.credential_id AS credentials_credential_id, -- Alias for credentials.credential_id logins.login_id AS logins_login_id, -- Alias for logins.login_id
credentials.*, -- All other columns from credentials logins.*, -- All other columns from logins
credential_tags.*, -- All columns from credential_tags login_tags.*, -- All columns from login_tags
tags.* -- All columns from tags tags.* -- All columns from tags
FROM credentials FROM logins
LEFT JOIN credential_tags ON credential_tags.credential_id = credentials.credential_id LEFT JOIN login_tags ON login_tags.login_id = logins.login_id
LEFT JOIN tags ON tags.tag_id = credential_tags.tag_id LEFT JOIN tags ON tags.tag_id = login_tags.tag_id
WHERE credential_contact_id = $contact_id WHERE login_contact_id = $contact_id
GROUP BY credentials.credential_id GROUP BY logins.login_id
ORDER BY credential_name DESC ORDER BY login_name DESC
"); ");
$credential_count = mysqli_num_rows($sql_related_credentials); $login_count = mysqli_num_rows($sql_related_logins);
// Related Tickets Query - 1 to 1 relationship // Related Tickets Query - 1 to 1 relationship
$sql_related_tickets = mysqli_query($mysqli, "SELECT * FROM tickets $sql_related_tickets = mysqli_query($mysqli, "SELECT * FROM tickets
@@ -95,9 +93,9 @@ if (isset($_GET['contact_id'])) {
$ticket_count = mysqli_num_rows($sql_related_tickets); $ticket_count = mysqli_num_rows($sql_related_tickets);
// Related Recurring Tickets Query // Related Recurring Tickets Query
$sql_related_recurring_tickets = mysqli_query($mysqli, "SELECT * FROM recurring_tickets $sql_related_recurring_tickets = mysqli_query($mysqli, "SELECT * FROM scheduled_tickets
WHERE recurring_ticket_contact_id = $contact_id WHERE scheduled_ticket_contact_id = $contact_id
ORDER BY recurring_ticket_next_run DESC" ORDER BY scheduled_ticket_next_run DESC"
); );
$recurring_ticket_count = mysqli_num_rows($sql_related_recurring_tickets); $recurring_ticket_count = mysqli_num_rows($sql_related_recurring_tickets);
@@ -266,22 +264,6 @@ if (isset($_GET['contact_id'])) {
<i class="fa fa-fw fa-recycle mr-2"></i>New Recurring Ticket <i class="fa fa-fw fa-recycle mr-2"></i>New Recurring Ticket
</a> </a>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#addAssetModal">
<i class="fa fa-fw fa-desktop mr-2"></i>New Asset
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#addCredentialModal">
<i class="fa fa-fw fa-key mr-2"></i>New Credential
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#addDocumentModal">
<i class="fa fa-fw fa-file-alt mr-2"></i>New Document
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#uploadFilesModal">
<i class="fa fa-fw fa-upload mr-2"></i>Upload file(s)
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-dark" href="#" <a class="dropdown-item text-dark" href="#"
data-toggle="ajax-modal" data-toggle="ajax-modal"
data-ajax-url="ajax/ajax_contact_note_create.php" data-ajax-url="ajax/ajax_contact_note_create.php"
@@ -464,7 +446,7 @@ if (isset($_GET['contact_id'])) {
</div> </div>
</div> </div>
<div class="card card-dark <?php if ($credential_count == 0) { echo "d-none"; } ?>"> <div class="card card-dark <?php if ($login_count == 0) { echo "d-none"; } ?>">
<div class="card-header"> <div class="card-header">
<h3 class="card-title"><i class="fa fa-fw fa-key mr-2"></i>Credentials</h3> <h3 class="card-title"><i class="fa fa-fw fa-key mr-2"></i>Credentials</h3>
</div> </div>
@@ -485,57 +467,59 @@ if (isset($_GET['contact_id'])) {
<tbody> <tbody>
<?php <?php
while ($row = mysqli_fetch_array($sql_related_credentials)) { while ($row = mysqli_fetch_array($sql_related_logins)) {
$credential_id = intval($row['credentials_credential_id']); $login_id = intval($row['logins_login_id']);
$credential_name = nullable_htmlentities($row['credential_name']); $login_name = nullable_htmlentities($row['login_name']);
$credential_description = nullable_htmlentities($row['credential_description']); $login_description = nullable_htmlentities($row['login_description']);
$credential_uri = nullable_htmlentities($row['credential_uri']); $login_uri = nullable_htmlentities($row['login_uri']);
if (empty($credential_uri)) { if (empty($login_uri)) {
$credential_uri_display = "-"; $login_uri_display = "-";
} else { } else {
$credential_uri_display = "$credential_uri<button class='btn btn-sm clipboardjs' data-clipboard-text='$credential_uri'><i class='far fa-copy text-secondary'></i></button><a href='$credential_uri' target='_blank'><i class='fa fa-external-link-alt text-secondary'></i></a>"; $login_uri_display = "$login_uri<button class='btn btn-sm clipboardjs' data-clipboard-text='$login_uri'><i class='far fa-copy text-secondary'></i></button><a href='$login_uri' target='_blank'><i class='fa fa-external-link-alt text-secondary'></i></a>";
} }
$credential_uri_2 = nullable_htmlentities($row['credential_uri_2']); $login_uri_2 = nullable_htmlentities($row['login_uri_2']);
$credential_username = nullable_htmlentities(decryptCredentialEntry($row['credential_username'])); $login_username = nullable_htmlentities(decryptLoginEntry($row['login_username']));
if (empty($credential_username)) { if (empty($login_username)) {
$credential_username_display = "-"; $login_username_display = "-";
} else { } else {
$credential_username_display = "$credential_username<button class='btn btn-sm clipboardjs' data-clipboard-text='$credential_username'><i class='far fa-copy text-secondary'></i></button>"; $login_username_display = "$login_username<button class='btn btn-sm clipboardjs' data-clipboard-text='$login_username'><i class='far fa-copy text-secondary'></i></button>";
} }
$credential_password = nullable_htmlentities(decryptCredentialEntry($row['credential_password'])); $login_password = nullable_htmlentities(decryptLoginEntry($row['login_password']));
$credential_otp_secret = nullable_htmlentities($row['credential_otp_secret']); $login_otp_secret = nullable_htmlentities($row['login_otp_secret']);
$credential_id_with_secret = '"' . $row['credential_id'] . '","' . $row['credential_otp_secret'] . '"'; $login_id_with_secret = '"' . $row['login_id'] . '","' . $row['login_otp_secret'] . '"';
if (empty($credential_otp_secret)) { if (empty($login_otp_secret)) {
$otp_display = "-"; $otp_display = "-";
} else { } else {
$otp_display = "<span onmouseenter='showOTPViaCredentialID($credential_id)'><i class='far fa-clock'></i> <span id='otp_$credential_id'><i>Hover..</i></span></span>"; $otp_display = "<span onmouseenter='showOTPViaLoginID($login_id)'><i class='far fa-clock'></i> <span id='otp_$login_id'><i>Hover..</i></span></span>";
} }
$credential_note = nullable_htmlentities($row['credential_note']); $login_note = nullable_htmlentities($row['login_note']);
$credential_important = intval($row['credential_important']); $login_important = intval($row['login_important']);
$credential_contact_id = intval($row['credential_contact_id']); $login_contact_id = intval($row['login_contact_id']);
$credential_asset_id = intval($row['credential_asset_id']); $login_vendor_id = intval($row['login_vendor_id']);
$login_asset_id = intval($row['login_asset_id']);
$login_software_id = intval($row['login_software_id']);
// Tags // Tags
$credential_tag_name_display_array = array(); $login_tag_name_display_array = array();
$credential_tag_id_array = array(); $login_tag_id_array = array();
$sql_credential_tags = mysqli_query($mysqli, "SELECT * FROM credential_tags LEFT JOIN tags ON credential_tags.tag_id = tags.tag_id WHERE credential_id = $credential_id ORDER BY tag_name ASC"); $sql_login_tags = mysqli_query($mysqli, "SELECT * FROM login_tags LEFT JOIN tags ON login_tags.tag_id = tags.tag_id WHERE login_id = $login_id ORDER BY tag_name ASC");
while ($row = mysqli_fetch_array($sql_credential_tags)) { while ($row = mysqli_fetch_array($sql_login_tags)) {
$credential_tag_id = intval($row['tag_id']); $login_tag_id = intval($row['tag_id']);
$credential_tag_name = nullable_htmlentities($row['tag_name']); $login_tag_name = nullable_htmlentities($row['tag_name']);
$credential_tag_color = nullable_htmlentities($row['tag_color']); $login_tag_color = nullable_htmlentities($row['tag_color']);
if (empty($credential_tag_color)) { if (empty($login_tag_color)) {
$credential_tag_color = "dark"; $login_tag_color = "dark";
} }
$credential_tag_icon = nullable_htmlentities($row['tag_icon']); $login_tag_icon = nullable_htmlentities($row['tag_icon']);
if (empty($credential_tag_icon)) { if (empty($login_tag_icon)) {
$credential_tag_icon = "tag"; $login_tag_icon = "tag";
} }
$credential_tag_id_array[] = $credential_tag_id; $login_tag_id_array[] = $login_tag_id;
$credential_tag_name_display_array[] = "<a href='credentials.php?client_id=$client_id&tags[]=$credential_tag_id'><span class='badge text-light p-1 mr-1' style='background-color: $credential_tag_color;'><i class='fa fa-fw fa-$credential_tag_icon mr-2'></i>$credential_tag_name</span></a>"; $login_tag_name_display_array[] = "<a href='client_logins.php?client_id=$client_id&tags[]=$login_tag_id'><span class='badge text-light p-1 mr-1' style='background-color: $login_tag_color;'><i class='fa fa-fw fa-$login_tag_icon mr-2'></i>$login_tag_name</span></a>";
} }
$credential_tags_display = implode('', $credential_tag_name_display_array); $login_tags_display = implode('', $login_tag_name_display_array);
?> ?>
<tr> <tr>
@@ -544,18 +528,18 @@ if (isset($_GET['contact_id'])) {
<a class="text-dark" href="#" <a class="text-dark" href="#"
data-toggle="ajax-modal" data-toggle="ajax-modal"
data-ajax-url="ajax/ajax_credential_edit.php" data-ajax-url="ajax/ajax_credential_edit.php"
data-ajax-id="<?php echo $credential_id; ?>" data-ajax-id="<?php echo $login_id; ?>"
> >
<?php echo $credential_name; ?> <?php echo $login_name; ?>
</a> </a>
</td> </td>
<td><?php echo $credential_description; ?></td> <td><?php echo $login_description; ?></td>
<td><?php echo $credential_username_display; ?></td> <td><?php echo $login_username_display; ?></td>
<td> <td>
<button class="btn p-0" type="button" data-toggle="popover" data-trigger="focus" data-placement="top" data-content="<?php echo $credential_password; ?>"><i class="fas fa-2x fa-ellipsis-h text-secondary"></i><i class="fas fa-2x fa-ellipsis-h text-secondary"></i></button><button class="btn btn-sm clipboardjs" data-clipboard-text="<?php echo $credential_password; ?>"><i class="far fa-copy text-secondary"></i></button> <button class="btn p-0" type="button" data-toggle="popover" data-trigger="focus" data-placement="top" data-content="<?php echo $login_password; ?>"><i class="fas fa-2x fa-ellipsis-h text-secondary"></i><i class="fas fa-2x fa-ellipsis-h text-secondary"></i></button><button class="btn btn-sm clipboardjs" data-clipboard-text="<?php echo $login_password; ?>"><i class="far fa-copy text-secondary"></i></button>
</td> </td>
<td><?php echo $otp_display; ?></td> <td><?php echo $otp_display; ?></td>
<td><?php echo $credential_uri_display; ?></td> <td><?php echo $login_uri_display; ?></td>
<td> <td>
<div class="dropdown dropleft text-center"> <div class="dropdown dropleft text-center">
<button class="btn btn-secondary btn-sm" type="button" data-toggle="dropdown"> <button class="btn btn-secondary btn-sm" type="button" data-toggle="dropdown">
@@ -565,21 +549,21 @@ if (isset($_GET['contact_id'])) {
<a class="dropdown-item" href="#" <a class="dropdown-item" href="#"
data-toggle="ajax-modal" data-toggle="ajax-modal"
data-ajax-url="ajax/ajax_credential_edit.php" data-ajax-url="ajax/ajax_credential_edit.php"
data-ajax-id="<?php echo $credential_id; ?>"> data-ajax-id="<?php echo $login_id; ?>">
<i class="fas fa-fw fa-edit mr-2"></i>Edit <i class="fas fa-fw fa-edit mr-2"></i>Edit
</a> </a>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#shareModal" onclick="populateShareModal(<?php echo "$client_id, 'Credential', $credential_id"; ?>)"> <a class="dropdown-item" href="#" data-toggle="modal" data-target="#shareModal" onclick="populateShareModal(<?php echo "$client_id, 'Login', $login_id"; ?>)">
<i class="fas fa-fw fa-share-alt mr-2"></i>Share <i class="fas fa-fw fa-share-alt mr-2"></i>Share
</a> </a>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item" <a class="dropdown-item"
href="post.php?unlink_credential_from_contact&contact_id=<?php echo $contact_id; ?>&credential_id=<?php echo $credential_id; ?>" href="post.php?unlink_credential_from_contact&contact_id=<?php echo $contact_id; ?>&login_id=<?php echo $login_id; ?>"
class="btn btn-secondary btn-sm" title="Unlink"> class="btn btn-secondary btn-sm" title="Unlink">
<i class="fas fa-fw fa-unlink mr-2"></i>Unlink <i class="fas fa-fw fa-unlink mr-2"></i>Unlink
</a> </a>
<?php if ($session_user_role == 3) { ?> <?php if ($session_user_role == 3) { ?>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item text-danger text-bold" href="post.php?delete_credential=<?php echo $credential_id; ?>"> <a class="dropdown-item text-danger text-bold" href="post.php?delete_login=<?php echo $login_id; ?>">
<i class="fas fa-fw fa-trash mr-2"></i>Delete <i class="fas fa-fw fa-trash mr-2"></i>Delete
</a> </a>
<?php } ?> <?php } ?>
@@ -701,11 +685,11 @@ if (isset($_GET['contact_id'])) {
<?php <?php
while ($row = mysqli_fetch_array($sql_related_recurring_tickets)) { while ($row = mysqli_fetch_array($sql_related_recurring_tickets)) {
$recurring_ticket_id = intval($row['recurring_ticket_id']); $scheduled_ticket_id = intval($row['scheduled_ticket_id']);
$recurring_ticket_subject = nullable_htmlentities($row['recurring_ticket_subject']); $scheduled_ticket_subject = nullable_htmlentities($row['scheduled_ticket_subject']);
$recurring_ticket_priority = nullable_htmlentities($row['recurring_ticket_priority']); $scheduled_ticket_priority = nullable_htmlentities($row['scheduled_ticket_priority']);
$recurring_ticket_frequency = nullable_htmlentities($row['recurring_ticket_frequency']); $scheduled_ticket_frequency = nullable_htmlentities($row['scheduled_ticket_frequency']);
$recurring_ticket_next_run = nullable_htmlentities($row['recurring_ticket_next_run']); $scheduled_ticket_next_run = nullable_htmlentities($row['scheduled_ticket_next_run']);
?> ?>
<tr> <tr>
@@ -713,14 +697,14 @@ if (isset($_GET['contact_id'])) {
<a href="#" <a href="#"
data-toggle="ajax-modal" data-toggle="ajax-modal"
data-ajax-url="ajax/ajax_recurring_ticket_edit.php" data-ajax-url="ajax/ajax_recurring_ticket_edit.php"
data-ajax-id="<?php echo $recurring_ticket_id; ?>" data-ajax-id="<?php echo $scheduled_ticket_id; ?>"
> >
<?php echo $recurring_ticket_subject ?> <?php echo $scheduled_ticket_subject ?>
</a> </a>
</td> </td>
<td><?php echo $recurring_ticket_priority ?></td> <td><?php echo $scheduled_ticket_priority ?></td>
<td><?php echo $recurring_ticket_frequency ?></td> <td><?php echo $scheduled_ticket_frequency ?></td>
<td><?php echo $recurring_ticket_next_run ?></td> <td><?php echo $scheduled_ticket_next_run ?></td>
<td> <td>
<div class="dropdown dropleft text-center"> <div class="dropdown dropleft text-center">
<button class="btn btn-secondary btn-sm" type="button" data-toggle="dropdown"> <button class="btn btn-secondary btn-sm" type="button" data-toggle="dropdown">
@@ -730,18 +714,18 @@ if (isset($_GET['contact_id'])) {
<a class="dropdown-item" href="#" <a class="dropdown-item" href="#"
data-toggle="ajax-modal" data-toggle="ajax-modal"
data-ajax-url="ajax/ajax_recurring_ticket_edit.php" data-ajax-url="ajax/ajax_recurring_ticket_edit.php"
data-ajax-id="<?php echo $recurring_ticket_id; ?>" data-ajax-id="<?php echo $scheduled_ticket_id; ?>"
> >
<i class="fas fa-fw fa-edit mr-2"></i>Edit <i class="fas fa-fw fa-edit mr-2"></i>Edit
</a> </a>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item" href="post.php?force_recurring_ticket=<?php echo $recurring_ticket_id; ?>&csrf_token=<?php echo $_SESSION['csrf_token'] ?>"> <a class="dropdown-item" href="post.php?force_recurring_ticket=<?php echo $scheduled_ticket_id; ?>&csrf_token=<?php echo $_SESSION['csrf_token'] ?>">
<i class="fa fa-fw fa-paper-plane text-secondary mr-2"></i>Force Reoccur <i class="fa fa-fw fa-paper-plane text-secondary mr-2"></i>Force Reoccur
</a> </a>
<?php <?php
if ($session_user_role == 3) { ?> if ($session_user_role == 3) { ?>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item text-danger text-bold confirm-link" href="post.php?delete_recurring_ticket=<?php echo $recurring_ticket_id; ?>"> <a class="dropdown-item text-danger text-bold confirm-link" href="post.php?delete_recurring_ticket=<?php echo $scheduled_ticket_id; ?>">
<i class="fas fa-fw fa-trash mr-2"></i>Delete <i class="fas fa-fw fa-trash mr-2"></i>Delete
</a> </a>
</div> </div>
@@ -1180,18 +1164,12 @@ if (isset($_GET['contact_id'])) {
}); });
</script> </script>
<!-- Include script to get TOTP code via the Credential ID --> <!-- Include script to get TOTP code via the login ID -->
<script src="js/credential_show_otp_via_id.js"></script> <script src="js/credential_show_otp_via_id.js"></script>
<?php <?php
require_once "modals/ticket_add_modal.php"; require_once "modals/ticket_add_modal.php";
require_once "modals/recurring_ticket_add_modal.php";
require_once "modals/asset_add_modal.php";
require_once "modals/credential_add_modal.php";
require_once "modals/client_document_add_modal.php";
require_once "modals/client_file_upload_modal.php";
require_once "modals/contact_link_asset_modal.php"; require_once "modals/contact_link_asset_modal.php";
require_once "modals/contact_link_software_modal.php"; require_once "modals/contact_link_software_modal.php";
require_once "modals/contact_link_credential_modal.php"; require_once "modals/contact_link_credential_modal.php";
@@ -1199,4 +1177,6 @@ require_once "modals/contact_link_service_modal.php";
require_once "modals/contact_link_document_modal.php"; require_once "modals/contact_link_document_modal.php";
require_once "modals/contact_link_file_modal.php"; require_once "modals/contact_link_file_modal.php";
require_once "modals/recurring_ticket_add_modal.php";
require_once "includes/footer.php"; require_once "includes/footer.php";

View File

@@ -17,13 +17,17 @@ if (isset($_GET['client_id'])) {
// Tags Filter // Tags Filter
if (isset($_GET['tags']) && is_array($_GET['tags']) && !empty($_GET['tags'])) { if (isset($_GET['tags']) && is_array($_GET['tags']) && !empty($_GET['tags'])) {
// Sanitize each element of the tags array // Sanitize each element of the status array
$sanitizedTags = array_map('intval', $_GET['tags']); $sanitizedTags = array();
foreach ($_GET['tags'] as $tag) {
// Escape each status to prevent SQL injection
$sanitizedTags[] = "'" . intval($tag) . "'";
}
// Convert the sanitized tags into a comma-separated string // Convert the sanitized tags into a comma-separated string
$tag_filter = implode(",", $sanitizedTags); $sanitizedTagsString = implode(",", $sanitizedTags);
$tag_query = "AND tags.tag_id IN ($tag_filter)"; $tag_query = "AND tags.tag_id IN ($sanitizedTagsString)";
} else { } else {
$tag_filter = 0;
$tag_query = ''; $tag_query = '';
} }
@@ -46,9 +50,12 @@ if ($client_url && isset($_GET['location']) && !empty($_GET['location'])) {
} else { } else {
// Default - any // Default - any
$location_query = ''; $location_query = '';
$location_filter = 0; $location_filter = '';
} }
//Rebuild URL
//$url_query_strings_sort = http_build_query($get_copy);
$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS contacts.*, clients.*, locations.*, users.*, GROUP_CONCAT(tags.tag_name) FROM contacts $sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS contacts.*, clients.*, locations.*, users.*, GROUP_CONCAT(tags.tag_name) FROM contacts
LEFT JOIN clients ON client_id = contact_client_id LEFT JOIN clients ON client_id = contact_client_id
LEFT JOIN locations ON location_id = contact_location_id LEFT JOIN locations ON location_id = contact_location_id
@@ -69,492 +76,433 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
?> ?>
<div class="card card-dark"> <div class="card card-dark">
<div class="card-header py-2"> <div class="card-header py-2">
<h3 class="card-title mt-2"><i class="fa fa-fw fa-address-book mr-2"></i>Contacts</h3> <h3 class="card-title mt-2"><i class="fa fa-fw fa-address-book mr-2"></i>Contacts</h3>
<div class="card-tools"> <div class="card-tools">
<div class="btn-group"> <div class="btn-group">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addContactModal"> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addContactModal">
<i class="fas fa-plus mr-2"></i>New Contact <i class="fas fa-plus mr-2"></i>New Contact
</button> </button>
<button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown"></button> <button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown"></button>
<div class="dropdown-menu"> <div class="dropdown-menu">
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#contactInviteModal"><i class="fas fa-fw fa-paper-plane mr-2"></i>Invite</a> <a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#contactInviteModal"><i class="fas fa-fw fa-paper-plane mr-2"></i>Invite</a>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#importContactModal"> <a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#importContactModal">
<i class="fa fa-fw fa-upload mr-2"></i>Import <i class="fa fa-fw fa-upload mr-2"></i>Import
</a> </a>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#exportContactModal"> <a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#exportContactModal">
<i class="fa fa-fw fa-download mr-2"></i>Export <i class="fa fa-fw fa-download mr-2"></i>Export
</a> </a>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> <div class="card-body">
<div class="card-body"> <form autocomplete="off">
<form autocomplete="off">
<?php if ($client_url) { ?>
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
<?php } ?>
<input type="hidden" name="archived" value="<?php echo $archived; ?>">
<div class="row">
<div class="col-md-4">
<div class="input-group mb-3 mb-md-0">
<input type="search" class="form-control" name="q" value="<?php if (isset($q)) { echo stripslashes(nullable_htmlentities($q)); } ?>" placeholder="Search Contacts">
<div class="input-group-append">
<button class="btn btn-dark"><i class="fa fa-search"></i></button>
</div>
</div>
</div>
<div class="col-md-3">
<div class="input-group">
<select onchange="this.form.submit()" class="form-control select2" name="tags[]" data-placeholder="- Select Tags -" multiple>
<?php
$sql_tags_filter = mysqli_query($mysqli, "
SELECT tags.tag_id, tags.tag_name
FROM tags
LEFT JOIN contact_tags ON contact_tags.tag_id = tags.tag_id
LEFT JOIN contacts ON contact_tags.contact_id = contacts.contact_id
WHERE tag_type = 3
$client_query OR tags.tag_id IN ($tag_filter)
GROUP BY tags.tag_id
HAVING COUNT(contact_tags.contact_id) > 0 OR tags.tag_id IN ($tag_filter)
");
while ($row = mysqli_fetch_array($sql_tags_filter)) {
$tag_id = intval($row['tag_id']);
$tag_name = nullable_htmlentities($row['tag_name']); ?>
<option value="<?php echo $tag_id ?>" <?php if (isset($_GET['tags']) && in_array($tag_id, $_GET['tags'])) { echo 'selected'; } ?>> <?php echo $tag_name ?> </option>
<?php } ?>
</select>
</div>
</div>
<?php if ($client_url) { ?> <?php if ($client_url) { ?>
<div class="col-md-2"> <input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
<div class="input-group">
<select class="form-control select2" name="location" onchange="this.form.submit()">
<option value="">- All Locations -</option>
<?php
$sql_locations_filter = mysqli_query($mysqli, "
SELECT DISTINCT location_id, location_name
FROM locations
LEFT JOIN contacts ON contact_location_id = location_id
WHERE location_client_id = $client_id
AND location_archived_at IS NULL
AND (contact_location_id != 0 OR location_id = $location_filter)
ORDER BY location_name ASC
");
while ($row = mysqli_fetch_array($sql_locations_filter)) {
$location_id = intval($row['location_id']);
$location_name = nullable_htmlentities($row['location_name']);
?>
<option <?php if ($location_filter == $location_id) { echo "selected"; } ?> value="<?php echo $location_id; ?>"><?php echo $location_name; ?></option>
<?php
}
?>
</select>
</div>
</div>
<?php } else { ?>
<div class="col-md-2">
<div class="input-group">
<select class="form-control select2" name="client" onchange="this.form.submit()">
<option value="" <?php if ($client == "") { echo "selected"; } ?>>- All Clients -</option>
<?php
$sql_clients_filter = mysqli_query($mysqli, "
SELECT DISTINCT client_id, client_name
FROM clients
JOIN contacts ON contact_client_id = client_id
WHERE client_archived_at IS NULL
$access_permission_query
ORDER BY client_name ASC
");
while ($row = mysqli_fetch_array($sql_clients_filter)) {
$client_id = intval($row['client_id']);
$client_name = nullable_htmlentities($row['client_name']);
?>
<option <?php if ($client == $client_id) { echo "selected"; } ?> value="<?php echo $client_id; ?>"><?php echo $client_name; ?></option>
<?php
}
?>
</select>
</div>
</div>
<?php } ?> <?php } ?>
<input type="hidden" name="archived" value="<?php echo $archived; ?>">
<div class="row">
<div class="col-md-3"> <div class="col-md-4">
<div class="btn-group float-right"> <div class="input-group mb-3 mb-md-0">
<a href="?<?php echo $client_url; ?>archived=<?php if($archived == 1){ echo 0; } else { echo 1; } ?>" <input type="search" class="form-control" name="q" value="<?php if (isset($q)) { echo stripslashes(nullable_htmlentities($q)); } ?>" placeholder="Search Contacts">
class="btn btn-<?php if($archived == 1){ echo "primary"; } else { echo "default"; } ?>"> <div class="input-group-append">
<i class="fa fa-fw fa-archive mr-2"></i>Archived <button class="btn btn-dark"><i class="fa fa-search"></i></button>
</a>
<div class="dropdown ml-2" id="bulkActionButton" hidden>
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">
<i class="fas fa-fw fa-layer-group mr-2"></i>Bulk Action (<span id="selectedCount">0</span>)
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#bulkAssignLocationModal">
<i class="fas fa-fw fa-map-marker-alt mr-2"></i>Assign Location
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#bulkEditPhoneModal">
<i class="fas fa-fw fa-phone-alt mr-2"></i>Set Phone Number
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#bulkEditDepartmentModal">
<i class="fas fa-fw fa-users mr-2"></i>Set Department
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#bulkEditRoleModal">
<i class="fas fa-fw fa-user-shield mr-2"></i>Set Roles
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#bulkAssignTagsModal">
<i class="fas fa-fw fa-tags mr-2"></i>Assign Tags
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#bulkSendEmailModal">
<i class="fas fa-fw fa-paper-plane mr-2"></i>Send Email
</a>
<?php if ($archived) { ?>
<div class="dropdown-divider"></div>
<button class="dropdown-item text-info"
type="submit" form="bulkActions" name="bulk_unarchive_contacts">
<i class="fas fa-fw fa-redo mr-2"></i>Unarchive
</button>
<div class="dropdown-divider"></div>
<button class="dropdown-item text-danger text-bold"
type="submit" form="bulkActions" name="bulk_delete_contacts">
<i class="fas fa-fw fa-trash mr-2"></i>Delete
</button>
<?php } else { ?>
<div class="dropdown-divider"></div>
<button class="dropdown-item text-danger confirm-link"
type="submit" form="bulkActions" name="bulk_archive_contacts">
<i class="fas fa-fw fa-archive mr-2"></i>Archive
</button>
<?php } ?>
</div> </div>
</div> </div>
</div> </div>
</div>
</div> <div class="col-md-3">
</form> <div class="form-group">
<hr> <select onchange="this.form.submit()" class="form-control select2" name="tags[]" data-placeholder="- Select Tags -" multiple>
<form id="bulkActions" action="post.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token'] ?>">
<div class="table-responsive-sm"> <?php $sql_tags = mysqli_query($mysqli, "SELECT * FROM tags WHERE tag_type = 3");
<table class="table border"> while ($row = mysqli_fetch_array($sql_tags)) {
<thead class="thead-light <?php if (!$num_rows[0]) { echo "d-none"; } ?>"> $tag_id = intval($row['tag_id']);
<tr> $tag_name = nullable_htmlentities($row['tag_name']); ?>
<td class="bg-light pr-0">
<div class="form-check"> <option value="<?php echo $tag_id ?>" <?php if (isset($_GET['tags']) && is_array($_GET['tags']) && in_array($tag_id, $_GET['tags'])) { echo 'selected'; } ?>> <?php echo $tag_name ?> </option>
<input class="form-check-input" id="selectAllCheckbox" type="checkbox" onclick="checkAll(this)">
<?php } ?>
</select>
</div>
</div>
<?php if ($client_url) { ?>
<div class="col-md-2">
<div class="input-group">
<select class="form-control select2" name="location" onchange="this.form.submit()">
<option value="">- All Locations -</option>
<?php
$sql_locations_filter = mysqli_query($mysqli, "SELECT * FROM locations WHERE location_client_id = $client_id AND location_archived_at IS NULL ORDER BY location_name ASC");
while ($row = mysqli_fetch_array($sql_locations_filter)) {
$location_id = intval($row['location_id']);
$location_name = nullable_htmlentities($row['location_name']);
?>
<option <?php if ($location_filter == $location_id) { echo "selected"; } ?> value="<?php echo $location_id; ?>"><?php echo $location_name; ?></option>
<?php
}
?>
</select>
</div>
</div>
<?php } else { ?>
<div class="col-md-2">
<div class="input-group">
<select class="form-control select2" name="client" onchange="this.form.submit()">
<option value="" <?php if ($client == "") { echo "selected"; } ?>>- All Clients -</option>
<?php
$sql_clients_filter = mysqli_query($mysqli, "SELECT * FROM clients WHERE client_archived_at IS NULL $access_permission_query ORDER BY client_name ASC");
while ($row = mysqli_fetch_array($sql_clients_filter)) {
$client_id = intval($row['client_id']);
$client_name = nullable_htmlentities($row['client_name']);
?>
<option <?php if ($client == $client_id) { echo "selected"; } ?> value="<?php echo $client_id; ?>"><?php echo $client_name; ?></option>
<?php
}
?>
</select>
</div>
</div>
<?php } ?>
<div class="col-md-3">
<div class="btn-group float-right">
<a href="?<?php echo $client_url; ?>archived=<?php if($archived == 1){ echo 0; } else { echo 1; } ?>"
class="btn btn-<?php if($archived == 1){ echo "primary"; } else { echo "default"; } ?>">
<i class="fa fa-fw fa-archive mr-2"></i>Archived
</a>
<div class="dropdown ml-2" id="bulkActionButton" hidden>
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">
<i class="fas fa-fw fa-layer-group mr-2"></i>Bulk Action (<span id="selectedCount">0</span>)
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#bulkAssignLocationModal">
<i class="fas fa-fw fa-map-marker-alt mr-2"></i>Assign Location
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#bulkEditPhoneModal">
<i class="fas fa-fw fa-phone-alt mr-2"></i>Set Phone Number
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#bulkEditDepartmentModal">
<i class="fas fa-fw fa-users mr-2"></i>Set Department
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#bulkEditRoleModal">
<i class="fas fa-fw fa-user-shield mr-2"></i>Set Roles
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#bulkAssignTagsModal">
<i class="fas fa-fw fa-tags mr-2"></i>Assign Tags
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#bulkSendEmailModal">
<i class="fas fa-fw fa-paper-plane mr-2"></i>Send Email
</a>
<?php if ($archived) { ?>
<div class="dropdown-divider"></div>
<button class="dropdown-item text-info"
type="submit" form="bulkActions" name="bulk_unarchive_contacts">
<i class="fas fa-fw fa-redo mr-2"></i>Unarchive
</button>
<div class="dropdown-divider"></div>
<button class="dropdown-item text-danger text-bold"
type="submit" form="bulkActions" name="bulk_delete_contacts">
<i class="fas fa-fw fa-trash mr-2"></i>Delete
</button>
<?php } else { ?>
<div class="dropdown-divider"></div>
<button class="dropdown-item text-danger confirm-link"
type="submit" form="bulkActions" name="bulk_archive_contacts">
<i class="fas fa-fw fa-archive mr-2"></i>Archive
</button>
<?php } ?>
</div>
</div> </div>
</td> </div>
<th> </div>
<a class="text-secondary ml-3" href="?<?php echo $url_query_strings_sort; ?>&sort=contact_name&order=<?php echo $disp; ?>">
Name <?php if ($sort == 'contact_name') { echo $order_icon; } ?>
</a>
</th>
<th>
<a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=contact_department&order=<?php echo $disp; ?>">
Department <?php if ($sort == 'contact_department') { echo $order_icon; } ?>
</a>
</th>
<th>Contact</th>
<th>
<a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=location_name&order=<?php echo $disp; ?>">
Location <?php if ($sort == 'location_name') { echo $order_icon; } ?>
</a>
</th>
<th></th>
<?php if (!$client_url) { ?>
<th>
<a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">
Client <?php if ($sort == 'client_name') { echo $order_icon; } ?>
</a>
</th>
<?php } ?>
<th class="text-center">Action</th>
</tr>
</thead>
<tbody>
<?php
while ($row = mysqli_fetch_array($sql)) { </div>
$client_id = intval($row['client_id']); </form>
$client_name = nullable_htmlentities($row['client_name']); <hr>
$contact_id = intval($row['contact_id']); <form id="bulkActions" action="post.php" method="post" enctype="multipart/form-data">
$contact_name = nullable_htmlentities($row['contact_name']); <input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token'] ?>">
$contact_title = nullable_htmlentities($row['contact_title']);
if (empty($contact_title)) {
$contact_title_display = "";
} else {
$contact_title_display = "<small class='text-secondary'>$contact_title</small>";
}
$contact_department = getFallBack(nullable_htmlentities($row['contact_department']));
$contact_extension = nullable_htmlentities($row['contact_extension']);
if (empty($contact_extension)) {
$contact_extension_display = "";
} else {
$contact_extension_display = "<small class='text-secondary ml-1'>x$contact_extension</small>";
}
$contact_phone_country_code = nullable_htmlentities($row['contact_phone_country_code']);
$contact_phone = nullable_htmlentities(formatPhoneNumber($row['contact_phone'], $contact_phone_country_code));
if (empty($contact_phone)) {
$contact_phone_display = "";
} else {
$contact_phone_display = "<div><i class='fas fa-fw fa-phone mr-2'></i><a href='tel:$contact_phone'>$contact_phone$contact_extension_display</a></div>";
}
$contact_mobile_country_code = nullable_htmlentities($row['contact_phone_country_code']);
$contact_mobile = nullable_htmlentities(formatPhoneNumber($row['contact_mobile'], $contact_mobile_country_code));
if (empty($contact_mobile)) {
$contact_mobile_display = "";
} else {
$contact_mobile_display = "<div class='mt-2'><i class='fas fa-fw fa-mobile-alt mr-2'></i><a href='tel:$contact_mobile'>$contact_mobile</a></div>";
}
$contact_email = nullable_htmlentities($row['contact_email']);
if (empty($contact_email)) {
$contact_email_display = "";
} else {
$contact_email_display = "<div class='mt-1'><i class='fas fa-fw fa-envelope mr-2'></i><a href='mailto:$contact_email'>$contact_email</a><button class='btn btn-sm clipboardjs' type='button' data-clipboard-text='$contact_email'><i class='far fa-copy text-secondary'></i></button></div>";
}
$contact_info_display = "$contact_phone_display $contact_mobile_display $contact_email_display";
if (empty($contact_info_display)) {
$contact_info_display = "-";
}
$contact_pin = nullable_htmlentities($row['contact_pin']);
$contact_photo = nullable_htmlentities($row['contact_photo']);
$contact_initials = initials($contact_name);
$contact_notes = nullable_htmlentities($row['contact_notes']);
$contact_primary = intval($row['contact_primary']);
$contact_important = intval($row['contact_important']);
$contact_billing = intval($row['contact_billing']);
$contact_technical = intval($row['contact_technical']);
$contact_created_at = nullable_htmlentities($row['contact_created_at']);
$contact_archived_at = nullable_htmlentities($row['contact_archived_at']);
if ($contact_primary == 1) {
$contact_primary_display = "<small class='text-success'>Primary Contact</small>";
} else {
$contact_primary_display = false;
}
$contact_location_id = intval($row['contact_location_id']);
$location_name = nullable_htmlentities($row['location_name']);
if (empty($location_name)) {
$location_name = "<span class='text-muted'>N/A</span>";
}
$location_archived_at = nullable_htmlentities($row['location_archived_at']);
if ($location_archived_at) {
$location_name_display = "<div class='text-danger' title='Archived'><s>$location_name</s></div>";
} else {
$location_name_display = $location_name;
}
$auth_method = nullable_htmlentities($row['user_auth_method']);
$contact_user_id = intval($row['contact_user_id']);
if ($contact_user_id) {
$user_exists_display = "<span class='badge badge-pill badge-dark p-1' title='User: $auth_method'><i class='fas fa-fw fa-user'></i></span>";
} else {
$user_exists_display = "";
}
// Related Assets Query <div class="table-responsive-sm">
$sql_related_assets = mysqli_query($mysqli, "SELECT * FROM assets WHERE asset_contact_id = $contact_id ORDER BY asset_id DESC"); <table class="table border">
$asset_count = mysqli_num_rows($sql_related_assets); <thead class="thead-light <?php if (!$num_rows[0]) { echo "d-none"; } ?>">
if ($asset_count) {
$asset_count_display = "<span class='mr-2 badge badge-pill badge-dark p-2' title='$asset_count Assets'><i class='fas fa-fw fa-desktop mr-2'></i>$asset_count</span>";
} else {
$asset_count_display = '';
}
// Related Credentials Query
$sql_related_credentials = mysqli_query($mysqli, "SELECT * FROM credentials WHERE credential_contact_id = $contact_id ORDER BY credential_id DESC");
$credential_count = mysqli_num_rows($sql_related_credentials);
if ($credential_count) {
$credential_count_display = "<span class='mr-2 badge badge-pill badge-secondary p-2' title='$credential_count Credentials'><i class='fas fa-fw fa-key mr-2'></i>$credential_count</span>";
} else {
$credential_count_display = '';
}
// Related Software Query
$sql_related_software = mysqli_query($mysqli, "SELECT * FROM software, software_contacts WHERE software.software_id = software_contacts.software_id AND software_contacts.contact_id = $contact_id");
$software_count = mysqli_num_rows($sql_related_software);
if ($software_count) {
$software_count_display = "<span class='mr-2 badge badge-pill badge-secondary p-2' title='$software_count Licenses'><i class='fas fa-fw fa-cube mr-2'></i>$software_count</span>";
} else {
$software_count_display = '';
}
// Related Tickets Query
$sql_related_tickets = mysqli_query($mysqli, "SELECT * FROM tickets WHERE ticket_contact_id = $contact_id");
$ticket_count = mysqli_num_rows($sql_related_tickets);
if ($ticket_count) {
$ticket_count_display = "<span class='mr-2 badge badge-pill badge-secondary p-2' title='$ticket_count Tickets'><i class='fas fa-fw fa-life-ring mr-2'></i>$ticket_count</span>";
} else {
$ticket_count_display = '';
}
// Related Documents Query
$sql_related_documents = mysqli_query($mysqli, "SELECT * FROM documents, contact_documents WHERE documents.document_id = contact_documents.document_id AND contact_documents.contact_id = $contact_id");
$document_count = mysqli_num_rows($sql_related_documents);
if ($document_count) {
$document_count_display = "<span class='mr-2 badge badge-pill badge-secondary p-2' title='$document_count Documents'><i class='fas fa-fw fa-file-alt mr-2'></i>$document_count</span>";
} else {
$document_count_display = '';
}
// Tags
$contact_tag_name_display_array = array();
$contact_tag_id_array = array();
$sql_contact_tags = mysqli_query($mysqli, "SELECT * FROM contact_tags LEFT JOIN tags ON contact_tags.tag_id = tags.tag_id WHERE contact_id = $contact_id ORDER BY tag_name ASC");
while ($row = mysqli_fetch_array($sql_contact_tags)) {
$contact_tag_id = intval($row['tag_id']);
$contact_tag_name = nullable_htmlentities($row['tag_name']);
$contact_tag_color = nullable_htmlentities($row['tag_color']);
if (empty($contact_tag_color)) {
$contact_tag_color = "dark";
}
$contact_tag_icon = nullable_htmlentities($row['tag_icon']);
if (empty($contact_tag_icon)) {
$contact_tag_icon = "tag";
}
$contact_tag_id_array[] = $contact_tag_id;
$contact_tag_name_display_array[] = "<a href='contacts.php?$client_url tags[]=$contact_tag_id'><span class='badge text-light p-1 mr-1' style='background-color: $contact_tag_color;'><i class='fa fa-fw fa-$contact_tag_icon mr-2'></i>$contact_tag_name</span></a>";
}
$contact_tags_display = implode('', $contact_tag_name_display_array);
?>
<tr> <tr>
<td class="pr-0 bg-light"> <td class="bg-light pr-0">
<div class="form-check"> <div class="form-check">
<input class="form-check-input bulk-select" type="checkbox" name="contact_ids[]" value="<?php echo $contact_id ?>"> <input class="form-check-input" id="selectAllCheckbox" type="checkbox" onclick="checkAll(this)">
</div> </div>
</td> </td>
<td> <th>
<a class="text-dark" href="#" <a class="text-secondary ml-3" href="?<?php echo $url_query_strings_sort; ?>&sort=contact_name&order=<?php echo $disp; ?>">
data-toggle="ajax-modal" Name <?php if ($sort == 'contact_name') { echo $order_icon; } ?>
data-modal-size="lg" </a>
data-ajax-url="ajax/ajax_contact_details.php?<?php echo $client_url; ?>" </th>
data-ajax-id="<?php echo $contact_id; ?>"> <th>
<div class="media"> <a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=contact_department&order=<?php echo $disp; ?>">
<?php if ($contact_photo) { ?> Department <?php if ($sort == 'contact_department') { echo $order_icon; } ?>
<span class="fa-stack fa-2x mr-3 text-center"> </a>
<img class="img-size-50 img-circle" src="<?php echo "uploads/clients/$client_id/$contact_photo"; ?>"> </th>
</span> <th>Contact</th>
<?php } else { ?> <th>
<span class="fa-stack fa-2x mr-3"> <a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=location_name&order=<?php echo $disp; ?>">
<i class="fa fa-circle fa-stack-2x text-secondary"></i> Location <?php if ($sort == 'location_name') { echo $order_icon; } ?>
<span class="fa fa-stack-1x text-white"><?php echo $contact_initials; ?></span> </a>
</span> </th>
<?php } ?> <?php if (!$client_url) { ?>
<th>
<a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">
Client <?php if ($sort == 'client_name') { echo $order_icon; } ?>
</a>
</th>
<?php } ?>
<th class="text-center">Action</th>
</tr>
</thead>
<tbody>
<?php
<div class="media-body"> while ($row = mysqli_fetch_array($sql)) {
<div class="<?php if($contact_important) { echo "text-bold"; } ?>"><?php echo $contact_name; ?> <?php echo $user_exists_display; ?></div> $client_id = intval($row['client_id']);
<?php echo $contact_title_display; ?> $client_name = nullable_htmlentities($row['client_name']);
<div><?php echo $contact_primary_display; ?></div> $contact_id = intval($row['contact_id']);
<?php $contact_name = nullable_htmlentities($row['contact_name']);
if (!empty($contact_tags_display)) { ?> $contact_title = nullable_htmlentities($row['contact_title']);
<div class="mt-1"> if (empty($contact_title)) {
<?php echo $contact_tags_display; ?> $contact_title_display = "";
</div> } else {
$contact_title_display = "<small class='text-secondary'>$contact_title</small>";
}
$contact_department = nullable_htmlentities($row['contact_department']);
if (empty($contact_department)) {
$contact_department_display = "-";
} else {
$contact_department_display = $contact_department;
}
$contact_extension = nullable_htmlentities($row['contact_extension']);
if (empty($contact_extension)) {
$contact_extension_display = "";
} else {
$contact_extension_display = "<small class='text-secondary ml-1'>x$contact_extension</small>";
}
$contact_phone = formatPhoneNumber($row['contact_phone']);
if (empty($contact_phone)) {
$contact_phone_display = "";
} else {
$contact_phone_display = "<div><i class='fas fa-fw fa-phone mr-2'></i><a href='tel:$contact_phone'>$contact_phone$contact_extension_display</a></div>";
}
$contact_mobile = formatPhoneNumber($row['contact_mobile']);
if (empty($contact_mobile)) {
$contact_mobile_display = "";
} else {
$contact_mobile_display = "<div class='mt-2'><i class='fas fa-fw fa-mobile-alt mr-2'></i><a href='tel:$contact_mobile'>$contact_mobile</a></div>";
}
$contact_email = nullable_htmlentities($row['contact_email']);
if (empty($contact_email)) {
$contact_email_display = "";
} else {
$contact_email_display = "<div class='mt-1'><i class='fas fa-fw fa-envelope mr-2'></i><a href='mailto:$contact_email'>$contact_email</a><button class='btn btn-sm clipboardjs' type='button' data-clipboard-text='$contact_email'><i class='far fa-copy text-secondary'></i></button></div>";
}
$contact_info_display = "$contact_phone_display $contact_mobile_display $contact_email_display";
if (empty($contact_info_display)) {
$contact_info_display = "-";
}
$contact_pin = nullable_htmlentities($row['contact_pin']);
$contact_photo = nullable_htmlentities($row['contact_photo']);
$contact_initials = initials($contact_name);
$contact_notes = nullable_htmlentities($row['contact_notes']);
$contact_primary = intval($row['contact_primary']);
$contact_important = intval($row['contact_important']);
$contact_billing = intval($row['contact_billing']);
$contact_technical = intval($row['contact_technical']);
$contact_created_at = nullable_htmlentities($row['contact_created_at']);
$contact_archived_at = nullable_htmlentities($row['contact_archived_at']);
if ($contact_primary == 1) {
$contact_primary_display = "<small class='text-success'>Primary Contact</small>";
} else {
$contact_primary_display = false;
}
$contact_location_id = intval($row['contact_location_id']);
$location_name = nullable_htmlentities($row['location_name']);
if (empty($location_name)) {
$location_name = "-";
}
$location_archived_at = nullable_htmlentities($row['location_archived_at']);
if ($location_archived_at) {
$location_name_display = "<div class='text-danger' title='Archived'><s>$location_name</s></div>";
} else {
$location_name_display = $location_name;
}
$auth_method = nullable_htmlentities($row['user_auth_method']);
$contact_user_id = intval($row['contact_user_id']);
// Related Assets Query
$sql_related_assets = mysqli_query($mysqli, "SELECT * FROM assets WHERE asset_contact_id = $contact_id ORDER BY asset_id DESC");
$asset_count = mysqli_num_rows($sql_related_assets);
// Related Logins Query
$sql_related_logins = mysqli_query($mysqli, "SELECT * FROM logins WHERE login_contact_id = $contact_id ORDER BY login_id DESC");
$login_count = mysqli_num_rows($sql_related_logins);
// Related Software Query
$sql_related_software = mysqli_query($mysqli, "SELECT * FROM software, software_contacts WHERE software.software_id = software_contacts.software_id AND software_contacts.contact_id = $contact_id ORDER BY software.software_id DESC");
$software_count = mysqli_num_rows($sql_related_software);
// Related Tickets Query
$sql_related_tickets = mysqli_query($mysqli, "SELECT * FROM tickets WHERE ticket_contact_id = $contact_id ORDER BY ticket_id DESC");
$ticket_count = mysqli_num_rows($sql_related_tickets);
// Tags
$contact_tag_name_display_array = array();
$contact_tag_id_array = array();
$sql_contact_tags = mysqli_query($mysqli, "SELECT * FROM contact_tags LEFT JOIN tags ON contact_tags.tag_id = tags.tag_id WHERE contact_id = $contact_id ORDER BY tag_name ASC");
while ($row = mysqli_fetch_array($sql_contact_tags)) {
$contact_tag_id = intval($row['tag_id']);
$contact_tag_name = nullable_htmlentities($row['tag_name']);
$contact_tag_color = nullable_htmlentities($row['tag_color']);
if (empty($contact_tag_color)) {
$contact_tag_color = "dark";
}
$contact_tag_icon = nullable_htmlentities($row['tag_icon']);
if (empty($contact_tag_icon)) {
$contact_tag_icon = "tag";
}
$contact_tag_id_array[] = $contact_tag_id;
$contact_tag_name_display_array[] = "<a href='contacts.php?$client_url tags[]=$contact_tag_id'><span class='badge text-light p-1 mr-1' style='background-color: $contact_tag_color;'><i class='fa fa-fw fa-$contact_tag_icon mr-2'></i>$contact_tag_name</span></a>";
}
$contact_tags_display = implode('', $contact_tag_name_display_array);
?>
<tr>
<td class="pr-0 bg-light">
<div class="form-check">
<input class="form-check-input bulk-select" type="checkbox" name="contact_ids[]" value="<?php echo $contact_id ?>">
</div>
</td>
<td>
<a class="text-dark" href="#"
data-toggle="ajax-modal"
data-modal-size="lg"
data-ajax-url="ajax/ajax_contact_details.php?<?php echo $client_url; ?>"
data-ajax-id="<?php echo $contact_id; ?>">
<div class="media">
<?php if ($contact_photo) { ?>
<span class="fa-stack fa-2x mr-3 text-center">
<img class="img-size-50 img-circle" src="<?php echo "uploads/clients/$client_id/$contact_photo"; ?>">
</span>
<?php } else { ?>
<span class="fa-stack fa-2x mr-3">
<i class="fa fa-circle fa-stack-2x text-secondary"></i>
<span class="fa fa-stack-1x text-white"><?php echo $contact_initials; ?></span>
</span>
<?php } ?>
<div class="media-body">
<div class="<?php if($contact_important) { echo "text-bold"; } ?>"><?php echo $contact_name; ?></div>
<?php echo $contact_title_display; ?>
<div><?php echo $contact_primary_display; ?></div>
<?php
if (!empty($contact_tags_display)) { ?>
<div class="mt-1">
<?php echo $contact_tags_display; ?>
</div>
<?php } ?>
</div>
</div>
</a>
</td>
<td><?php echo $contact_department_display; ?></td>
<td><?php echo $contact_info_display; ?></td>
<td><?php echo $location_name_display; ?></td>
<?php if (!$client_url) { ?>
<td><a href="contacts.php?client_id=<?php echo $client_id; ?>"><?php echo $client_name; ?></a></td>
<?php } ?>
<td>
<div class="dropdown dropleft text-center">
<button class="btn btn-secondary btn-sm" type="button" data-toggle="dropdown">
<i class="fas fa-ellipsis-h"></i>
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="contact_details.php?<?php echo $client_url; ?>contact_id=<?php echo $contact_id; ?>">
<i class="fas fa-fw fa-eye mr-2"></i>Details
</a>
<a class="dropdown-item" href="#"
data-toggle="ajax-modal"
data-ajax-url="ajax/ajax_contact_note_create.php"
data-ajax-id="<?php echo $contact_id; ?>">
<i class="fas fa-fw fa-sticky-note mr-2"></i>Make Note
</a>
<a class="dropdown-item" href="#"
data-toggle="ajax-modal"
data-ajax-url="ajax/ajax_contact_edit.php"
data-ajax-id="<?php echo $contact_id; ?>">
<i class="fas fa-fw fa-edit mr-2"></i>Edit
</a>
<?php if ($session_user_role == 3 && $contact_primary == 0) { ?>
<?php if ($contact_archived_at) { ?>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-info confirm-link" href="post.php?unarchive_contact=<?php echo $contact_id; ?>">
<i class="fas fa-fw fa-redo mr-2"></i>Unarchive
</a>
<?php } else { ?>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_contact=<?php echo $contact_id; ?>">
<i class="fas fa-fw fa-archive mr-2"></i>Archive
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-danger confirm-link" href="post.php?anonymize_contact=<?php echo $contact_id; ?>">
<i class="fas fa-fw fa-user-secret mr-2"></i>Anonymize & Archive
</a>
<?php } ?>
<?php if ($config_destructive_deletes_enable) { ?>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-danger text-bold confirm-link" href="post.php?delete_contact=<?php echo $contact_id; ?>">
<i class="fas fa-fw fa-trash mr-2"></i>Delete
</a>
<?php } ?>
<?php } ?> <?php } ?>
</div> </div>
</div> </div>
</a> </td>
</tr>
</td> <?php
<td><?php echo $contact_department; ?></td> }
<td><?php echo $contact_info_display; ?></td>
<td><?php echo $location_name_display; ?></td>
<td>
<?php echo "$asset_count_display$credential_count_display$software_count_display$ticket_count_display$document_count_display"; ?>
</td>
<?php if (!$client_url) { ?>
<td><a href="contacts.php?client_id=<?php echo $client_id; ?>"><?php echo $client_name; ?></a></td>
<?php } ?>
<td>
<div class="dropdown dropleft text-center">
<button class="btn btn-secondary btn-sm" type="button" data-toggle="dropdown">
<i class="fas fa-ellipsis-h"></i>
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="contact_details.php?<?php echo $client_url; ?>contact_id=<?php echo $contact_id; ?>">
<i class="fas fa-fw fa-eye mr-2"></i>Details
</a>
<a class="dropdown-item" href="#"
data-toggle="ajax-modal"
data-ajax-url="ajax/ajax_contact_note_create.php"
data-ajax-id="<?php echo $contact_id; ?>">
<i class="fas fa-fw fa-sticky-note mr-2"></i>Make Note
</a>
<a class="dropdown-item" href="#"
data-toggle="ajax-modal"
data-ajax-url="ajax/ajax_contact_edit.php"
data-ajax-id="<?php echo $contact_id; ?>">
<i class="fas fa-fw fa-edit mr-2"></i>Edit
</a>
<?php if ($session_user_role == 3 && $contact_primary == 0) { ?>
<?php if ($contact_archived_at) { ?>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-info confirm-link" href="post.php?unarchive_contact=<?php echo $contact_id; ?>">
<i class="fas fa-fw fa-redo mr-2"></i>Unarchive
</a>
<?php } else { ?>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_contact=<?php echo $contact_id; ?>">
<i class="fas fa-fw fa-archive mr-2"></i>Archive
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-danger confirm-link" href="post.php?anonymize_contact=<?php echo $contact_id; ?>">
<i class="fas fa-fw fa-user-secret mr-2"></i>Anonymize & Archive
</a>
<?php } ?>
<?php if ($config_destructive_deletes_enable) { ?> ?>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-danger text-bold confirm-link" href="post.php?delete_contact=<?php echo $contact_id; ?>">
<i class="fas fa-fw fa-trash mr-2"></i>Delete
</a>
<?php } ?>
<?php } ?>
</div>
</div>
</td>
</tr>
<?php </tbody>
} </table>
</div>
?> <?php require_once "modals/contact_bulk_assign_location_modal.php"; ?>
<?php require_once "modals/contact_bulk_edit_phone_modal.php"; ?>
</tbody> <?php require_once "modals/contact_bulk_edit_department_modal.php"; ?>
</table> <?php require_once "modals/contact_bulk_edit_role_modal.php"; ?>
</div> <?php require_once "modals/contact_bulk_assign_tags_modal.php"; ?>
<?php require_once "modals/contact_bulk_assign_location_modal.php"; ?> <?php require_once "modals/contact_bulk_email_modal.php"; ?>
<?php require_once "modals/contact_bulk_edit_phone_modal.php"; ?> </form>
<?php require_once "modals/contact_bulk_edit_department_modal.php"; ?> <?php require_once "includes/filter_footer.php";
<?php require_once "modals/contact_bulk_edit_role_modal.php"; ?>
<?php require_once "modals/contact_bulk_assign_tags_modal.php"; ?>
<?php require_once "modals/contact_bulk_email_modal.php"; ?>
</form>
<?php require_once "includes/filter_footer.php";
?> ?>
</div>
</div> </div>
</div>
<!-- JavaScript to Show/Hide Password Form Group --> <!-- JavaScript to Show/Hide Password Form Group -->
<script> <script>

View File

@@ -1,21 +1,21 @@
<?php <?php
// Default Column Sortby Filter // Default Column Sortby Filter
$sort = "credential_name"; $sort = "login_name";
$order = "ASC"; $order = "ASC";
// If client_id is in URI then show client Side Bar and client header // If client_id is in URI then show client Side Bar and client header
if (isset($_GET['client_id'])) { if (isset($_GET['client_id'])) {
require_once "includes/inc_all_client.php"; require_once "includes/inc_all_client.php";
$client_query = "AND credential_client_id = $client_id"; $client_query = "AND login_client_id = $client_id";
$client_url = "client_id=$client_id&"; $client_url = "client_id=$client_id&";
// Log when users load the Credentials page // Log when users load the Credentials/Logins page
logAction("Credential", "View", "$session_name viewed the Credentials page for client", $client_id); logAction("Credential", "View", "$session_name viewed the Credentials page for client", $client_id);
} else { } else {
require_once "includes/inc_client_overview_all.php"; require_once "includes/inc_client_overview_all.php";
$client_query = ''; $client_query = '';
$client_url = ''; $client_url = '';
// Log when users load the Credentials page // Log when users load the Credentials/Logins page
logAction("Credential", "View", "$session_name viewed the All Credentials page"); logAction("Credential", "View", "$session_name viewed the All Credentials page");
} }
@@ -24,20 +24,24 @@ enforceUserPermission('module_credential');
// Tags Filter // Tags Filter
if (isset($_GET['tags']) && is_array($_GET['tags']) && !empty($_GET['tags'])) { if (isset($_GET['tags']) && is_array($_GET['tags']) && !empty($_GET['tags'])) {
// Sanitize each element of the tags array // Sanitize each element of the status array
$sanitizedTags = array_map('intval', $_GET['tags']); $sanitizedTags = array();
foreach ($_GET['tags'] as $tag) {
// Escape each status to prevent SQL injection
$sanitizedTags[] = "'" . intval($tag) . "'";
}
// Convert the sanitized tags into a comma-separated string // Convert the sanitized tags into a comma-separated string
$tag_filter = implode(",", $sanitizedTags); $sanitizedTagsString = implode(",", $sanitizedTags);
$tag_query = "AND tags.tag_id IN ($tag_filter)"; $tag_query = "AND tags.tag_id IN ($sanitizedTagsString)";
} else { } else {
$tag_filter = 0;
$tag_query = ''; $tag_query = '';
} }
if (!$client_url) { if (!$client_url) {
// Client Filter // Client Filter
if (isset($_GET['client']) & !empty($_GET['client'])) { if (isset($_GET['client']) & !empty($_GET['client'])) {
$client_query = 'AND (credential_client_id = ' . intval($_GET['client']) . ')'; $client_query = 'AND (login_client_id = ' . intval($_GET['client']) . ')';
$client = intval($_GET['client']); $client = intval($_GET['client']);
} else { } else {
// Default - any // Default - any
@@ -49,7 +53,7 @@ if (!$client_url) {
// Location Filter // Location Filter
if ($client_url && isset($_GET['location']) && !empty($_GET['location'])) { if ($client_url && isset($_GET['location']) && !empty($_GET['location'])) {
$location_query = 'AND (a.asset_location_id = ' . intval($_GET['location']) . ')'; $location_query = 'AND (a.asset_location_id = ' . intval($_GET['location']) . ')';
$location_query_innerjoin = 'INNER JOIN assets a on a.asset_id = c.credential_asset_id '; $location_query_innerjoin = 'INNER JOIN assets a on a.asset_id = l.login_asset_id ';
$location_filter = intval($_GET['location']); $location_filter = intval($_GET['location']);
} else { } else {
// Default - any // Default - any
@@ -60,22 +64,20 @@ if ($client_url && isset($_GET['location']) && !empty($_GET['location'])) {
$sql = mysqli_query( $sql = mysqli_query(
$mysqli, $mysqli,
"SELECT SQL_CALC_FOUND_ROWS c.credential_id AS c_credential_id, c.*, credential_tags.*, tags.*, clients.*, contacts.*, assets.* "SELECT SQL_CALC_FOUND_ROWS l.login_id AS l_login_id, l.*, login_tags.*, tags.*, clients.*
FROM credentials c FROM logins l
LEFT JOIN credential_tags ON credential_tags.credential_id = c.credential_id LEFT JOIN login_tags ON login_tags.login_id = l.login_id
LEFT JOIN tags ON tags.tag_id = credential_tags.tag_id LEFT JOIN tags ON tags.tag_id = login_tags.tag_id
LEFT JOIN clients ON client_id = credential_client_id LEFT JOIN clients ON client_id = login_client_id
LEFT JOIN contacts ON contact_id = credential_contact_id
LEFT JOIN assets ON asset_id = credential_asset_id
$location_query_innerjoin $location_query_innerjoin
WHERE c.credential_$archive_query WHERE l.login_$archive_query
$tag_query $tag_query
AND (c.credential_name LIKE '%$q%' OR c.credential_description LIKE '%$q%' OR c.credential_uri LIKE '%$q%' OR tag_name LIKE '%$q%' OR client_name LIKE '%$q%') AND (l.login_name LIKE '%$q%' OR l.login_description LIKE '%$q%' OR l.login_uri LIKE '%$q%' OR tag_name LIKE '%$q%' OR client_name LIKE '%$q%')
$location_query $location_query
$access_permission_query $access_permission_query
$client_query $client_query
GROUP BY c.credential_id GROUP BY l.login_id
ORDER BY c.credential_important DESC, $sort $order LIMIT $record_from, $record_to" ORDER BY l.login_important DESC, $sort $order LIMIT $record_from, $record_to"
); );
$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
@@ -88,17 +90,17 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<div class="card-tools"> <div class="card-tools">
<?php if (lookupUserPermission("module_credential") >= 2) { ?> <?php if (lookupUserPermission("module_credential") >= 2) { ?>
<div class="btn-group"> <div class="btn-group">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addCredentialModal" <?php if (!isset($_COOKIE['user_encryption_session_key'])) { echo "disabled"; } ?>> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addLoginModal" <?php if (!isset($_COOKIE['user_encryption_session_key'])) { echo "disabled"; } ?>>
<i class="fas fa-plus mr-2"></i>New Credential <i class="fas fa-plus mr-2"></i>New Credential
</button> </button>
<button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown"></button> <button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown"></button>
<div class="dropdown-menu"> <div class="dropdown-menu">
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#importCredentialModal"> <a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#importLoginModal">
<i class="fa fa-fw fa-upload mr-2"></i>Import <i class="fa fa-fw fa-upload mr-2"></i>Import
</a> </a>
<?php if ($num_rows[0] > 0) { ?> <?php if ($num_rows[0] > 0) { ?>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#exportCredentialModal"> <a class="dropdown-item text-dark" href="#" data-toggle="modal" data-target="#exportLoginModal">
<i class="fa fa-fw fa-download mr-2"></i>Export <i class="fa fa-fw fa-download mr-2"></i>Export
</a> </a>
<?php } ?> <?php } ?>
@@ -123,32 +125,6 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
</div> </div>
</div> </div>
<div class="col-md-3">
<div class="input-group">
<select onchange="this.form.submit()" class="form-control select2" name="tags[]" data-placeholder="- Select Tags -" multiple>
<?php
$sql_tags_filter = mysqli_query($mysqli, "
SELECT tags.tag_id, tags.tag_name
FROM tags
LEFT JOIN credential_tags ON credential_tags.tag_id = tags.tag_id
LEFT JOIN credentials ON credential_tags.credential_id = credentials.credential_id
WHERE tag_type = 4
$client_query OR tags.tag_id IN ($tag_filter)
GROUP BY tags.tag_id
HAVING COUNT(credential_tags.credential_id) > 0 OR tags.tag_id IN ($tag_filter)
");
while ($row = mysqli_fetch_array($sql_tags_filter)) {
$tag_id = intval($row['tag_id']);
$tag_name = nullable_htmlentities($row['tag_name']); ?>
<option value="<?php echo $tag_id ?>" <?php if (isset($_GET['tags']) && is_array($_GET['tags']) && in_array($tag_id, $_GET['tags'])) { echo 'selected'; } ?>> <?php echo $tag_name ?> </option>
<?php } ?>
</select>
</div>
</div>
<?php if ($client_url) { ?> <?php if ($client_url) { ?>
<div class="col-md-2"> <div class="col-md-2">
<div class="input-group"> <div class="input-group">
@@ -176,14 +152,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<option value="" <?php if ($client == "") { echo "selected"; } ?>>- All Clients -</option> <option value="" <?php if ($client == "") { echo "selected"; } ?>>- All Clients -</option>
<?php <?php
$sql_clients_filter = mysqli_query($mysqli, " $sql_clients_filter = mysqli_query($mysqli, "SELECT * FROM clients WHERE client_archived_at IS NULL $access_permission_query ORDER BY client_name ASC");
SELECT DISTINCT client_id, client_name
FROM clients
JOIN credentials ON credential_client_id = client_id
WHERE client_archived_at IS NULL
$access_permission_query
ORDER BY client_name ASC
");
while ($row = mysqli_fetch_array($sql_clients_filter)) { while ($row = mysqli_fetch_array($sql_clients_filter)) {
$client_id = intval($row['client_id']); $client_id = intval($row['client_id']);
$client_name = nullable_htmlentities($row['client_name']); $client_name = nullable_htmlentities($row['client_name']);
@@ -198,6 +167,22 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
</div> </div>
<?php } ?> <?php } ?>
<div class="col-md-3">
<div class="form-group">
<select onchange="this.form.submit()" class="form-control select2" name="tags[]" data-placeholder="- Select Tags -" multiple>
<?php $sql_tags = mysqli_query($mysqli, "SELECT * FROM tags WHERE tag_type = 4");
while ($row = mysqli_fetch_array($sql_tags)) {
$tag_id = intval($row['tag_id']);
$tag_name = nullable_htmlentities($row['tag_name']); ?>
<option value="<?php echo $tag_id ?>" <?php if (isset($_GET['tags']) && is_array($_GET['tags']) && in_array($tag_id, $_GET['tags'])) { echo 'selected'; } ?>> <?php echo $tag_name ?> </option>
<?php } ?>
</select>
</div>
</div>
<div class="col-md-3"> <div class="col-md-3">
<div class="btn-group float-right"> <div class="btn-group float-right">
<a href="?<?php echo $client_url; ?>&archived=<?php if($archived == 1){ echo 0; } else { echo 1; } ?>" <a href="?<?php echo $client_url; ?>&archived=<?php if($archived == 1){ echo 0; } else { echo 1; } ?>"
@@ -211,12 +196,12 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<div class="dropdown-menu"> <div class="dropdown-menu">
<?php if ($archived) { ?> <?php if ($archived) { ?>
<button class="dropdown-item text-info" <button class="dropdown-item text-info"
type="submit" form="bulkActions" name="bulk_unarchive_credentials"> type="submit" form="bulkActions" name="bulk_unarchive_logins">
<i class="fas fa-fw fa-redo mr-2"></i>Unarchive <i class="fas fa-fw fa-redo mr-2"></i>Unarchive
</button> </button>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<button class="dropdown-item text-danger text-bold" <button class="dropdown-item text-danger text-bold"
type="submit" form="bulkActions" name="bulk_delete_credentials"> type="submit" form="bulkActions" name="bulk_delete_logins">
<i class="fas fa-fw fa-trash mr-2"></i>Delete <i class="fas fa-fw fa-trash mr-2"></i>Delete
</button> </button>
<?php } else { ?> <?php } else { ?>
@@ -225,7 +210,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
</a> </a>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<button class="dropdown-item text-danger confirm-link" <button class="dropdown-item text-danger confirm-link"
type="submit" form="bulkActions" name="bulk_archive_credentials"> type="submit" form="bulkActions" name="bulk_archive_logins">
<i class="fas fa-fw fa-archive mr-2"></i>Archive <i class="fas fa-fw fa-archive mr-2"></i>Archive
</button> </button>
<?php } ?> <?php } ?>
@@ -250,16 +235,16 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
</div> </div>
</td> </td>
<th> <th>
<a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=credential_name&order=<?php echo $disp; ?>"> <a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=login_name&order=<?php echo $disp; ?>">
Name <?php if ($sort == 'credential_name') { echo $order_icon; } ?> Name <?php if ($sort == 'login_name') { echo $order_icon; } ?>
</a> </a>
</th> </th>
<th>Username / ID</th> <th>Username / ID</th>
<th>Password / Key</th> <th>Password / Key</th>
<th>OTP</th> <th>OTP</th>
<th> <th>
<a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=credential_uri&order=<?php echo $disp; ?>"> <a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=login_uri&order=<?php echo $disp; ?>">
URI <?php if ($sort == 'credential_uri') { echo $order_icon; } ?> URI <?php if ($sort == 'login_uri') { echo $order_icon; } ?>
</a> </a>
</th> </th>
<th></th> <th></th>
@@ -279,81 +264,60 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
while ($row = mysqli_fetch_array($sql)) { while ($row = mysqli_fetch_array($sql)) {
$client_id = intval($row['client_id']); $client_id = intval($row['client_id']);
$client_name = nullable_htmlentities($row['client_name']); $client_name = nullable_htmlentities($row['client_name']);
$credential_id = intval($row['c_credential_id']); $login_id = intval($row['l_login_id']);
$credential_name = nullable_htmlentities($row['credential_name']); $login_name = nullable_htmlentities($row['login_name']);
$credential_description = nullable_htmlentities($row['credential_description']); $login_description = nullable_htmlentities($row['login_description']);
$credential_uri = nullable_htmlentities($row['credential_uri']); $login_uri = nullable_htmlentities($row['login_uri']);
if (empty($credential_uri)) { if (empty($login_uri)) {
$credential_uri_display = "-"; $login_uri_display = "-";
} else { } else {
$credential_uri_display = truncate($credential_uri,40) . "<button class='btn btn-sm clipboardjs' type='button' data-clipboard-text='$credential_uri'><i class='far fa-copy text-secondary'></i></button>"; $login_uri_display = truncate($login_uri,40) . "<button class='btn btn-sm clipboardjs' type='button' data-clipboard-text='$login_uri'><i class='far fa-copy text-secondary'></i></button>";
} }
$credential_uri_2 = nullable_htmlentities($row['credential_uri_2']); $login_uri_2 = nullable_htmlentities($row['login_uri_2']);
$credential_username = nullable_htmlentities(decryptCredentialEntry($row['credential_username'])); $login_username = nullable_htmlentities(decryptLoginEntry($row['login_username']));
if (empty($credential_username)) { if (empty($login_username)) {
$credential_username_display = "-"; $login_username_display = "-";
} else { } else {
$credential_username_display = "$credential_username<button class='btn btn-sm clipboardjs' type='button' data-clipboard-text='$credential_username'><i class='far fa-copy text-secondary'></i></button>"; $login_username_display = "$login_username<button class='btn btn-sm clipboardjs' type='button' data-clipboard-text='$login_username'><i class='far fa-copy text-secondary'></i></button>";
} }
$credential_password = nullable_htmlentities(decryptCredentialEntry($row['credential_password'])); $login_password = nullable_htmlentities(decryptLoginEntry($row['login_password']));
$credential_otp_secret = nullable_htmlentities($row['credential_otp_secret']); $login_otp_secret = nullable_htmlentities($row['login_otp_secret']);
$credential_id_with_secret = '"' . $row['credential_id'] . '","' . $row['credential_otp_secret'] . '"'; $login_id_with_secret = '"' . $row['login_id'] . '","' . $row['login_otp_secret'] . '"';
if (empty($credential_otp_secret)) { if (empty($login_otp_secret)) {
$otp_display = "-"; $otp_display = "-";
} else { } else {
$otp_display = "<span onmouseenter='showOTPViaCredentialID($credential_id)'><i class='far fa-clock'></i> <span id='otp_$credential_id'><i>Hover..</i></span></span>"; $otp_display = "<span onmouseenter='showOTPViaLoginID($login_id)'><i class='far fa-clock'></i> <span id='otp_$login_id'><i>Hover..</i></span></span>";
} }
$credential_note = nullable_htmlentities($row['credential_note']); $login_note = nullable_htmlentities($row['login_note']);
$credential_created_at = nullable_htmlentities($row['credential_created_at']); $login_created_at = nullable_htmlentities($row['login_created_at']);
$credential_archived_at = nullable_htmlentities($row['credential_archived_at']); $login_archived_at = nullable_htmlentities($row['login_archived_at']);
$credential_important = intval($row['credential_important']); $login_important = intval($row['login_important']);
$credential_contact_id = intval($row['credential_contact_id']); $login_contact_id = intval($row['login_contact_id']);
$contact_name = nullable_htmlentities($row['contact_name']); $login_vendor_id = intval($row['login_vendor_id']);
$credential_asset_id = intval($row['credential_asset_id']); $login_asset_id = intval($row['login_asset_id']);
$asset_name = nullable_htmlentities($row['asset_name']); $login_software_id = intval($row['login_software_id']);
// Tags // Tags
$credential_tag_name_display_array = array(); $login_tag_name_display_array = array();
$credential_tag_id_array = array(); $login_tag_id_array = array();
$sql_credential_tags = mysqli_query($mysqli, "SELECT * FROM credential_tags LEFT JOIN tags ON credential_tags.tag_id = tags.tag_id WHERE credential_id = $credential_id ORDER BY tag_name ASC"); $sql_login_tags = mysqli_query($mysqli, "SELECT * FROM login_tags LEFT JOIN tags ON login_tags.tag_id = tags.tag_id WHERE login_id = $login_id ORDER BY tag_name ASC");
while ($row = mysqli_fetch_array($sql_credential_tags)) { while ($row = mysqli_fetch_array($sql_login_tags)) {
$credential_tag_id = intval($row['tag_id']); $login_tag_id = intval($row['tag_id']);
$credential_tag_name = nullable_htmlentities($row['tag_name']); $login_tag_name = nullable_htmlentities($row['tag_name']);
$credential_tag_color = nullable_htmlentities($row['tag_color']); $login_tag_color = nullable_htmlentities($row['tag_color']);
if (empty($credential_tag_color)) { if (empty($login_tag_color)) {
$credential_tag_color = "dark"; $login_tag_color = "dark";
} }
$credential_tag_icon = nullable_htmlentities($row['tag_icon']); $login_tag_icon = nullable_htmlentities($row['tag_icon']);
if (empty($credential_tag_icon)) { if (empty($login_tag_icon)) {
$credential_tag_icon = "tag"; $login_tag_icon = "tag";
} }
$credential_tag_id_array[] = $credential_tag_id; $login_tag_id_array[] = $login_tag_id;
$credential_tag_name_display_array[] = "<a href='credentials.php?$client_url tags[]=$credential_tag_id'><span class='badge text-light p-1 mr-1' style='background-color: $credential_tag_color;'><i class='fa fa-fw fa-$credential_tag_icon mr-2'></i>$credential_tag_name</span></a>"; $login_tag_name_display_array[] = "<a href='credentials.php?$client_url tags[]=$login_tag_id'><span class='badge text-light p-1 mr-1' style='background-color: $login_tag_color;'><i class='fa fa-fw fa-$login_tag_icon mr-2'></i>$login_tag_name</span></a>";
}
$credential_tags_display = implode('', $credential_tag_name_display_array);
if ($credential_contact_id) {
$credential_contact_display = "<a href='#' class='mr-2 badge badge-pill badge-dark p-2' title='$contact_name'
data-toggle='ajax-modal'
data-modal-size='lg'
data-ajax-url='ajax/ajax_contact_details.php'
data-ajax-id='$credential_contact_id'>
<i class='fas fa-fw fa-user'></i></a>";
} else {
$credential_contact_display = '';
}
if ($credential_asset_id) {
$credential_asset_display = "<a href='#' class='mr-2 badge badge-pill badge-secondary p-2' title='$asset_name' data-toggle='ajax-modal'
data-modal-size='lg'
data-ajax-url='ajax/ajax_asset_details.php'
data-ajax-id='$credential_asset_id'>
<i class='fas fa-fw fa-desktop'></i></a>";
} else {
$credential_asset_display = '';
} }
$login_tags_display = implode('', $login_tag_name_display_array);
// Check if shared // Check if shared
$sql_shared = mysqli_query( $sql_shared = mysqli_query(
@@ -363,8 +327,8 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
AND item_active = 1 AND item_active = 1
AND item_views != item_view_limit AND item_views != item_view_limit
AND item_expire_at > NOW() AND item_expire_at > NOW()
AND item_type = 'Credential' AND item_type = 'Login'
AND item_related_id = $credential_id AND item_related_id = $login_id
LIMIT 1" LIMIT 1"
); );
if (mysqli_num_rows($sql_shared) > 0) { if (mysqli_num_rows($sql_shared) > 0) {
@@ -385,41 +349,40 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
?> ?>
<tr class="<?php if (!empty($credential_important)) { echo "text-bold"; } ?>"> <tr class="<?php if (!empty($login_important)) { echo "text-bold"; } ?>">
<td class="pr-0"> <td class="pr-0">
<div class="form-check"> <div class="form-check">
<input class="form-check-input bulk-select" type="checkbox" name="credential_ids[]" value="<?php echo $credential_id ?>"> <input class="form-check-input bulk-select" type="checkbox" name="login_ids[]" value="<?php echo $login_id ?>">
</div> </div>
</td> </td>
<td> <td>
<a class="text-dark" href="#" <a class="text-dark" href="#"
data-toggle="ajax-modal" data-toggle="ajax-modal"
data-ajax-url="ajax/ajax_credential_edit.php" data-ajax-url="ajax/ajax_credential_edit.php"
data-ajax-id="<?php echo $credential_id; ?>" data-ajax-id="<?php echo $login_id; ?>"
> >
<div class="media"> <div class="media">
<i class="fa fa-fw fa-2x fa-key mr-3"></i> <i class="fa fa-fw fa-2x fa-key mr-3"></i>
<div class="media-body"> <div class="media-body">
<div><?php echo $credential_name; ?></div> <div><?php echo $login_name; ?></div>
<div><small class="text-secondary"><?php echo $credential_description; ?></small></div> <div><small class="text-secondary"><?php echo $login_description; ?></small></div>
<?php <?php
if (!empty($credential_tags_display)) { ?> if (!empty($login_tags_display)) { ?>
<div class="mt-1"> <div class="mt-1">
<?php echo $credential_tags_display; ?> <?php echo $login_tags_display; ?>
</div> </div>
<?php } ?> <?php } ?>
</div> </div>
</div> </div>
</a> </a>
</td> </td>
<td><?php echo $credential_username_display; ?></td> <td><?php echo $login_username_display; ?></td>
<td> <td>
<button class="btn p-0" type="button" data-toggle="popover" data-trigger="focus" data-placement="top" data-content="<?php echo $credential_password; ?>"><i class="fas fa-2x fa-ellipsis-h text-secondary"></i><i class="fas fa-2x fa-ellipsis-h text-secondary"></i></button><button class="btn btn-sm clipboardjs" type="button" data-clipboard-text="<?php echo $credential_password; ?>"><i class="far fa-copy text-secondary"></i></button> <button class="btn p-0" type="button" data-toggle="popover" data-trigger="focus" data-placement="top" data-content="<?php echo $login_password; ?>"><i class="fas fa-2x fa-ellipsis-h text-secondary"></i><i class="fas fa-2x fa-ellipsis-h text-secondary"></i></button><button class="btn btn-sm clipboardjs" type="button" data-clipboard-text="<?php echo $login_password; ?>"><i class="far fa-copy text-secondary"></i></button>
</td> </td>
<td><?php echo $otp_display; ?></td> <td><?php echo $otp_display; ?></td>
<td><?php echo $credential_uri_display; ?></td> <td><?php echo $login_uri_display; ?></td>
<td> <td>
<?php echo "$credential_contact_display$credential_asset_display"; ?>
<?php if (mysqli_num_rows($sql_shared) > 0) { ?> <?php if (mysqli_num_rows($sql_shared) > 0) { ?>
<div class="media" title="Expires <?php echo $item_expire_at_human; ?>"> <div class="media" title="Expires <?php echo $item_expire_at_human; ?>">
<i class="fas fa-link mr-2 mt-1"></i> <i class="fas fa-link mr-2 mt-1"></i>
@@ -435,21 +398,21 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<?php } ?> <?php } ?>
<td class="text-center"> <td class="text-center">
<div class="btn-group"> <div class="btn-group">
<?php if ( !empty($credential_uri) || !empty($credential_uri_2) ) { ?> <?php if ( !empty($login_uri) || !empty($login_uri_2) ) { ?>
<div class="dropdown dropleft text-center"> <div class="dropdown dropleft text-center">
<button class="btn btn-default btn-sm" type="button" data-toggle="dropdown"> <button class="btn btn-default btn-sm" type="button" data-toggle="dropdown">
<i class="fa fa-fw fa-external-link-alt"></i> <i class="fa fa-fw fa-external-link-alt"></i>
</button> </button>
<div class="dropdown-menu"> <div class="dropdown-menu">
<?php if ($credential_uri) { ?> <?php if ($login_uri) { ?>
<a href="<?php echo $credential_uri; ?>" alt="<?php echo $credential_uri; ?>" target="_blank" class="dropdown-item" > <a href="<?php echo $login_uri; ?>" alt="<?php echo $login_uri; ?>" target="_blank" class="dropdown-item" >
<i class="fa fa-fw fa-external-link-alt"></i> <?php echo truncate($credential_uri,40); ?> <i class="fa fa-fw fa-external-link-alt"></i> <?php echo truncate($login_uri,40); ?>
</a> </a>
<?php } ?> <?php } ?>
<?php if ($credential_uri_2) { ?> <?php if ($login_uri_2) { ?>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a href="<?php echo $credential_uri_2; ?>" target="_blank" class="dropdown-item" > <a href="<?php echo $login_uri_2; ?>" target="_blank" class="dropdown-item" >
<i class="fa fa-fw fa-external-link-alt"></i> <?php echo truncate($credential_uri_2,40); ?> <i class="fa fa-fw fa-external-link-alt"></i> <?php echo truncate($login_uri_2,40); ?>
</a> </a>
<?php } ?> <?php } ?>
</div> </div>
@@ -463,29 +426,29 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<a class="dropdown-item" href="#" <a class="dropdown-item" href="#"
data-toggle="ajax-modal" data-toggle="ajax-modal"
data-ajax-url="ajax/ajax_credential_edit.php" data-ajax-url="ajax/ajax_credential_edit.php"
data-ajax-id="<?php echo $credential_id; ?>" data-ajax-id="<?php echo $login_id; ?>"
> >
<i class="fas fa-fw fa-edit mr-2"></i>Edit <i class="fas fa-fw fa-edit mr-2"></i>Edit
</a> </a>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#shareModal" onclick="populateShareModal(<?php echo "$client_id, 'Credential', $credential_id"; ?>)"> <a class="dropdown-item" href="#" data-toggle="modal" data-target="#shareModal" onclick="populateShareModal(<?php echo "$client_id, 'Login', $login_id"; ?>)">
<i class="fas fa-fw fa-share mr-2"></i>Share <i class="fas fa-fw fa-share mr-2"></i>Share
</a> </a>
<?php if (lookupUserPermission("module_credential") >= 2) { ?> <?php if (lookupUserPermission("module_credential") >= 2) { ?>
<?php if ($credential_archived_at) { ?> <?php if ($login_archived_at) { ?>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item text-info confirm-link" href="post.php?unarchive_credential=<?php echo $credential_id; ?>"> <a class="dropdown-item text-info confirm-link" href="post.php?unarchive_login=<?php echo $login_id; ?>">
<i class="fas fa-fw fa-redo mr-2"></i>Unarchive <i class="fas fa-fw fa-redo mr-2"></i>Unarchive
</a> </a>
<?php if (lookupUserPermission("module_credential") >= 3) { ?> <?php if (lookupUserPermission("module_credential") >= 3) { ?>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item text-danger text-bold confirm-link" href="post.php?delete_credential=<?php echo $credential_id; ?>"> <a class="dropdown-item text-danger text-bold confirm-link" href="post.php?delete_login=<?php echo $login_id; ?>">
<i class="fas fa-fw fa-trash mr-2"></i>Delete <i class="fas fa-fw fa-trash mr-2"></i>Delete
<?php } ?> <?php } ?>
</a> </a>
<?php } else { ?> <?php } else { ?>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_credential=<?php echo $credential_id; ?>"> <a class="dropdown-item text-danger confirm-link" href="post.php?archive_login=<?php echo $login_id; ?>">
<i class="fas fa-fw fa-archive mr-2"></i>Archive <i class="fas fa-fw fa-archive mr-2"></i>Archive
</a> </a>
<?php } ?> <?php } ?>

View File

@@ -32,10 +32,4 @@
margin: 5px 0; margin: 5px 0;
padding: 10px; padding: 10px;
border: 1px solid #ddd; border: 1px solid #ddd;
user-select: none; /* Prevent text selection */
}
.drag-handle-class {
touch-action: none;
float: right;
} }

View File

@@ -73,6 +73,11 @@ $sql_years_select = mysqli_query($mysqli, "
<?php <?php
if ($user_config_dashboard_financial_enable == 1) { if ($user_config_dashboard_financial_enable == 1) {
// Ensure the user has the appropriate role to view the financial dashboard
if ($_SESSION['user_role'] != 3 && $_SESSION['user_role'] != 1) {
exit('<script type="text/javascript">window.location.href = \'dashboard_technical.php\';</script>');
}
// Fetch financial data for the dashboard // Fetch financial data for the dashboard
// Define variables to avoid errors in logs // Define variables to avoid errors in logs
$largest_income_month = 0; $largest_income_month = 0;
@@ -124,11 +129,11 @@ if ($user_config_dashboard_financial_enable == 1) {
"); ");
// Get recurring invoice totals // Get recurring invoice totals
$sql_recurring_yearly_total = mysqli_query($mysqli, "SELECT SUM(recurring_invoice_amount) AS recurring_yearly_total FROM recurring_invoices WHERE recurring_invoice_status = 1 AND recurring_invoice_frequency = 'year' AND YEAR(recurring_invoice_created_at) <= $year"); $sql_recurring_yearly_total = mysqli_query($mysqli, "SELECT SUM(recurring_amount) AS recurring_yearly_total FROM recurring WHERE recurring_status = 1 AND recurring_frequency = 'year' AND YEAR(recurring_created_at) <= $year");
$row = mysqli_fetch_array($sql_recurring_yearly_total); $row = mysqli_fetch_array($sql_recurring_yearly_total);
$recurring_yearly_total = floatval($row['recurring_yearly_total']); $recurring_yearly_total = floatval($row['recurring_yearly_total']);
$sql_recurring_monthly_total = mysqli_query($mysqli, "SELECT SUM(recurring_invoice_amount) AS recurring_monthly_total FROM recurring_invoices WHERE recurring_invoice_status = 1 AND recurring_invoice_frequency = 'month' AND YEAR(recurring_invoice_created_at) <= $year"); $sql_recurring_monthly_total = mysqli_query($mysqli, "SELECT SUM(recurring_amount) AS recurring_monthly_total FROM recurring WHERE recurring_status = 1 AND recurring_frequency = 'month' AND YEAR(recurring_created_at) <= $year");
$row = mysqli_fetch_array($sql_recurring_monthly_total); $row = mysqli_fetch_array($sql_recurring_monthly_total);
$recurring_monthly_total = floatval($row['recurring_monthly_total']) + ($recurring_yearly_total / 12); $recurring_monthly_total = floatval($row['recurring_monthly_total']) + ($recurring_yearly_total / 12);
@@ -581,7 +586,7 @@ if ($user_config_dashboard_technical_enable == 1) {
<!-- ./col --> <!-- ./col -->
<div class="col-lg-4 col-6"> <div class="col-lg-4 col-6">
<a class="small-box bg-success" href="contacts.php"> <a class="small-box bg-success">
<div class="inner"> <div class="inner">
<h3><?php echo $contacts_added; ?></h3> <h3><?php echo $contacts_added; ?></h3>
<p>New Contacts</p> <p>New Contacts</p>
@@ -620,7 +625,7 @@ if ($user_config_dashboard_technical_enable == 1) {
<!-- ./col --> <!-- ./col -->
<div class="col-lg-4 col-6"> <div class="col-lg-4 col-6">
<a class="small-box bg-warning" href="domains.php?sort=domain_expire&order=ASC"> <a class="small-box bg-warning" href="domains.php">
<div class="inner"> <div class="inner">
<h3><?php echo $expiring_domains; ?></h3> <h3><?php echo $expiring_domains; ?></h3>
<p>Expiring Domains</p> <p>Expiring Domains</p>
@@ -633,7 +638,7 @@ if ($user_config_dashboard_technical_enable == 1) {
<!-- ./col --> <!-- ./col -->
<div class="col-lg-4 col-6"> <div class="col-lg-4 col-6">
<a class="small-box bg-primary" href="certificates.php?sort=certificate_expire&order=ASC"> <a class="small-box bg-primary">
<div class="inner"> <div class="inner">
<h3><?php echo $expiring_certificates; ?></h3> <h3><?php echo $expiring_certificates; ?></h3>
<p>Expiring Certificates</p> <p>Expiring Certificates</p>

File diff suppressed because it is too large Load Diff

1049
db.sql

File diff suppressed because it is too large Load Diff

View File

@@ -18,26 +18,13 @@ if (isset($_GET['client_id'])) {
// Perms // Perms
enforceUserPermission('module_support'); enforceUserPermission('module_support');
if (!$client_url) { //Rebuild URL
// Client Filter $url_query_strings_sort = http_build_query($get_copy);
if (isset($_GET['client']) & !empty($_GET['client'])) {
$client_query = 'AND (domain_client_id = ' . intval($_GET['client']) . ')';
$client = intval($_GET['client']);
} else {
// Default - any
$client_query = '';
$client = '';
}
}
$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS domains.*, clients.*, $sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS domains.*, clients.*,
registrar.vendor_id AS registrar_id,
registrar.vendor_name AS registrar_name, registrar.vendor_name AS registrar_name,
dnshost.vendor_id AS dnshost_id,
dnshost.vendor_name AS dnshost_name, dnshost.vendor_name AS dnshost_name,
mailhost.vendor_id AS mailhost_id,
mailhost.vendor_name AS mailhost_name, mailhost.vendor_name AS mailhost_name,
webhost.vendor_id AS webhost_id,
webhost.vendor_name AS webhost_name webhost.vendor_name AS webhost_name
FROM domains FROM domains
LEFT JOIN clients ON client_id = domain_client_id LEFT JOIN clients ON client_id = domain_client_id
@@ -88,38 +75,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
</div> </div>
</div> </div>
<?php if ($client_url) { ?> <div class="col-md-8">
<div class="col-md-2"></div>
<?php } else { ?>
<div class="col-md-2">
<div class="input-group">
<select class="form-control select2" name="client" onchange="this.form.submit()">
<option value="" <?php if ($client == "") { echo "selected"; } ?>>- All Clients -</option>
<?php
$sql_clients_filter = mysqli_query($mysqli, "
SELECT DISTINCT client_id, client_name
FROM clients
JOIN domains ON domain_client_id = client_id
WHERE client_archived_at IS NULL
$access_permission_query
ORDER BY client_name ASC
");
while ($row = mysqli_fetch_array($sql_clients_filter)) {
$client_id = intval($row['client_id']);
$client_name = nullable_htmlentities($row['client_name']);
?>
<option <?php if ($client == $client_id) { echo "selected"; } ?> value="<?php echo $client_id; ?>"><?php echo $client_name; ?></option>
<?php
}
?>
</select>
</div>
</div>
<?php } ?>
<div class="col-md-6">
<div class="btn-group float-right"> <div class="btn-group float-right">
<a href="?<?php echo $client_url; ?>archived=<?php if($archived == 1){ echo 0; } else { echo 1; } ?>" <a href="?<?php echo $client_url; ?>archived=<?php if($archived == 1){ echo 0; } else { echo 1; } ?>"
class="btn btn-<?php if($archived == 1){ echo "primary"; } else { echo "default"; } ?>"> class="btn btn-<?php if($archived == 1){ echo "primary"; } else { echo "default"; } ?>">
@@ -235,11 +191,12 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
} else { } else {
$tr_class = ''; $tr_class = '';
} }
$domain_registrar_id = intval($row['registrar_id']);
$domain_webhost_id = intval($row['webhost_id']);
$domain_dnshost_id = intval($row['dnshost_id']);
$domain_mailhost_id = intval($row['mailhost_id']);
$domain_registrar_name = nullable_htmlentities($row['registrar_name']); $domain_registrar_name = nullable_htmlentities($row['registrar_name']);
if($domain_registrar_name) {
$domain_registrar_name_display = $domain_registrar_name;
} else {
$domain_registrar_name_display = "-";
}
$domain_webhost_name = nullable_htmlentities($row['webhost_name']); $domain_webhost_name = nullable_htmlentities($row['webhost_name']);
$domain_dnshost_name = nullable_htmlentities($row['dnshost_name']); $domain_dnshost_name = nullable_htmlentities($row['dnshost_name']);
$domain_mailhost_name = nullable_htmlentities($row['mailhost_name']); $domain_mailhost_name = nullable_htmlentities($row['mailhost_name']);
@@ -248,26 +205,10 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
$client_id = intval($row['domain_client_id']); $client_id = intval($row['domain_client_id']);
$client_name = nullable_htmlentities($row['client_name']); $client_name = nullable_htmlentities($row['client_name']);
// Add - if empty on the table // Add - if empty on the table
$domain_registrar_name_display = $domain_registrar_name ? " $domain_registrar_name_display = $domain_registrar_name ? $domain_registrar_name : "-";
<a href='#' data-toggle='ajax-modal' $domain_webhost_name_display = $domain_webhost_name ? $domain_webhost_name : "-";
data-ajax-url='ajax/ajax_vendor_details.php' data-ajax-id='$domain_registrar_id'> $domain_dnshost_name_display = $domain_dnshost_name ? $domain_dnshost_name : "-";
$domain_registrar_name $domain_mailhost_name_display = $domain_mailhost_name ? $domain_mailhost_name : "-";
</a>" : "-";
$domain_webhost_name_display = $domain_webhost_name ? "
<a href='#' data-toggle='ajax-modal'
data-ajax-url='ajax/ajax_vendor_details.php' data-ajax-id='$domain_webhost_id'>
$domain_webhost_name
</a>" : "-";
$domain_dnshost_name_display = $domain_dnshost_name ? "
<a href='#' data-toggle='ajax-modal'
data-ajax-url='ajax/ajax_vendor_details.php' data-ajax-id='$domain_dnshost_id'>
$domain_dnshost_name
</a>" : "-";
$domain_mailhost_name_display = $domain_mailhost_name ? "
<a href='#' data-toggle='ajax-modal'
data-ajax-url='ajax/ajax_vendor_details.php' data-ajax-id='$domain_mailhost_id'>
$domain_mailhost_name
</a>" : "-";
?> ?>
<tr class="<?php echo $tr_class; ?>"> <tr class="<?php echo $tr_class; ?>">
@@ -301,7 +242,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<div><small><?php echo $domain_expire_ago; ?></small></div> <div><small><?php echo $domain_expire_ago; ?></small></div>
</td> </td>
<?php if (!$client_url) { ?> <?php if (!$client_url) { ?>
<td><a href="domains.php?client_id=<?php echo $client_id; ?>"><?php echo $client_name; ?></a></td> <td><?php echo $client_name; ?></td>
<?php } ?> <?php } ?>
<td> <td>
<div class="dropdown dropleft text-center"> <div class="dropdown dropleft text-center">

View File

@@ -13,7 +13,8 @@ use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception; use PHPMailer\PHPMailer\Exception;
// Function to generate both crypto & URL safe random strings // Function to generate both crypto & URL safe random strings
function randomString($length = 16) { function randomString($length = 16)
{
// Generate some cryptographically safe random bytes // Generate some cryptographically safe random bytes
// Generate a little more than requested as we'll lose some later converting // Generate a little more than requested as we'll lose some later converting
$random_bytes = random_bytes($length + 5); $random_bytes = random_bytes($length + 5);
@@ -30,7 +31,8 @@ function randomString($length = 16) {
} }
// Older keygen function - only used for TOTP currently // Older keygen function - only used for TOTP currently
function key32gen() { function key32gen()
{
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$chars .= "234567"; $chars .= "234567";
while (1) { while (1) {
@@ -44,23 +46,25 @@ function key32gen() {
return $key; return $key;
} }
function nullable_htmlentities($unsanitizedInput) { function nullable_htmlentities($unsanitizedInput)
{
//return htmlentities($unsanitizedInput ?? ''); //return htmlentities($unsanitizedInput ?? '');
return htmlspecialchars($unsanitizedInput ?? '', ENT_QUOTES, 'UTF-8'); return htmlspecialchars($unsanitizedInput ?? '', ENT_QUOTES, 'UTF-8');
} }
function initials($string) { function initials($str)
if (!empty($string)) { {
$return = ''; if (!empty($str)) {
foreach (explode(' ', $string) as $word) { $ret = '';
$return .= mb_strtoupper($word[0], 'UTF-8'); // Use mb_strtoupper for UTF-8 support foreach (explode(' ', $str) as $word)
} $ret .= strtoupper($word[0]);
$return = substr($return, 0, 2); $ret = substr($ret, 0, 2);
return $return; return $ret;
} }
} }
function removeDirectory($path) { function removeDirectory($path)
{
if (!file_exists($path)) { if (!file_exists($path)) {
return; return;
} }
@@ -72,11 +76,13 @@ function removeDirectory($path) {
rmdir($path); rmdir($path);
} }
function getUserAgent() { function getUserAgent()
{
return $_SERVER['HTTP_USER_AGENT']; return $_SERVER['HTTP_USER_AGENT'];
} }
function getIP() { function getIP()
{
if (defined("CONST_GET_IP_METHOD")) { if (defined("CONST_GET_IP_METHOD")) {
if (CONST_GET_IP_METHOD == "HTTP_X_FORWARDED_FOR") { if (CONST_GET_IP_METHOD == "HTTP_X_FORWARDED_FOR") {
$ip = getenv('HTTP_X_FORWARDED_FOR'); $ip = getenv('HTTP_X_FORWARDED_FOR');
@@ -94,7 +100,8 @@ function getIP() {
return $ip; return $ip;
} }
function getWebBrowser($user_browser) { function getWebBrowser($user_browser)
{
$browser = "-"; $browser = "-";
$browser_array = array( $browser_array = array(
'/msie/i' => "<i class='fab fa-fw fa-internet-explorer text-secondary'></i> Internet Explorer", '/msie/i' => "<i class='fab fa-fw fa-internet-explorer text-secondary'></i> Internet Explorer",
@@ -113,7 +120,8 @@ function getWebBrowser($user_browser) {
return $browser; return $browser;
} }
function getOS($user_os) { function getOS($user_os)
{
$os_platform = "-"; $os_platform = "-";
$os_array = array( $os_array = array(
'/windows/i' => "<i class='fab fa-fw fa-windows text-secondary'></i> Windows", '/windows/i' => "<i class='fab fa-fw fa-windows text-secondary'></i> Windows",
@@ -133,7 +141,8 @@ function getOS($user_os) {
return $os_platform; return $os_platform;
} }
function getDevice() { function getDevice()
{
$tablet_browser = 0; $tablet_browser = 0;
$mobile_browser = 0; $mobile_browser = 0;
if (preg_match('/(tablet|ipad|playbook)|(android(?!.*(mobi|opera mini)))/i', strtolower($_SERVER['HTTP_USER_AGENT']))) { if (preg_match('/(tablet|ipad|playbook)|(android(?!.*(mobi|opera mini)))/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
@@ -180,7 +189,8 @@ function getDevice() {
} }
} }
function truncate($text, $chars) { function truncate($text, $chars)
{
if (strlen($text) <= $chars) { if (strlen($text) <= $chars) {
return $text; return $text;
} }
@@ -193,147 +203,45 @@ function truncate($text, $chars) {
return $text . "..."; return $text . "...";
} }
function formatPhoneNumber($phoneNumber, $country_code = '', $show_country_code = false) { function formatPhoneNumber($phoneNumber)
{
global $mysqli;
// Remove all non-digit characters // Get Phone Mask Option
$digits = preg_replace('/\D/', '', $phoneNumber); $phone_mask = mysqli_fetch_array(mysqli_query($mysqli, "SELECT config_phone_mask FROM settings WHERE company_id = 1"))[0];
$formatted = '';
switch ($country_code) { if ($phone_mask == 0) {
case '1': // USA/Canada — (123) 456-7890 return $phoneNumber;
if (strlen($digits) === 10) {
$formatted = '(' . substr($digits, 0, 3) . ') ' . substr($digits, 3, 3) . '-' . substr($digits, 6);
}
break;
case '44': // UK — 07123 456 789
if ($digits[0] === '0') $digits = substr($digits, 1);
if (strlen($digits) === 10) {
$formatted = '0' . substr($digits, 0, 4) . ' ' . substr($digits, 4, 3) . ' ' . substr($digits, 7);
}
break;
case '61': // Australia — 0412 345 678
if ($digits[0] === '0') $digits = substr($digits, 1);
if (strlen($digits) === 9) {
$formatted = '0' . substr($digits, 0, 4) . ' ' . substr($digits, 4, 3) . ' ' . substr($digits, 7);
}
break;
case '91': // India — 91234 56789
if (strlen($digits) === 10) {
$formatted = substr($digits, 0, 5) . ' ' . substr($digits, 5);
}
break;
case '81': // Japan — 03-1234-5678
if ($digits[0] === '0') $digits = substr($digits, 1);
if (strlen($digits) >= 9 && strlen($digits) <= 10) {
$formatted = '0' . substr($digits, 0, 2) . '-' . substr($digits, 2, 4) . '-' . substr($digits, 6);
}
break;
case '49': // Germany — 030 12345678
if ($digits[0] === '0') $digits = substr($digits, 1);
if (strlen($digits) >= 10) {
$formatted = '0' . substr($digits, 0, 3) . ' ' . substr($digits, 3);
}
break;
case '33': // France — 01 23 45 67 89
if ($digits[0] === '0') $digits = substr($digits, 1);
if (strlen($digits) === 9) {
$formatted = '0' . implode(' ', str_split($digits, 2));
}
break;
case '34': // Spain — 612 345 678
if (strlen($digits) === 9) {
$formatted = substr($digits, 0, 3) . ' ' . substr($digits, 3, 3) . ' ' . substr($digits, 6);
}
break;
case '39': // Italy — 312 345 6789
if ($digits[0] === '0') $digits = substr($digits, 1);
$formatted = '0' . implode(' ', str_split($digits, 3));
break;
case '55': // Brazil — (11) 91234-5678
if (strlen($digits) === 11) {
$formatted = '(' . substr($digits, 0, 2) . ') ' . substr($digits, 2, 5) . '-' . substr($digits, 7);
}
break;
case '7': // Russia — 8 (912) 345-67-89
if ($digits[0] === '8') $digits = substr($digits, 1);
if (strlen($digits) === 10) {
$formatted = '8 (' . substr($digits, 0, 3) . ') ' . substr($digits, 3, 3) . '-' . substr($digits, 6, 2) . '-' . substr($digits, 8);
}
break;
case '86': // China — 138 0013 8000
if (strlen($digits) === 11) {
$formatted = substr($digits, 0, 3) . ' ' . substr($digits, 3, 4) . ' ' . substr($digits, 7);
}
break;
case '82': // South Korea — 010-1234-5678
if (strlen($digits) === 11) {
$formatted = substr($digits, 0, 3) . '-' . substr($digits, 3, 4) . '-' . substr($digits, 7);
}
break;
case '62': // Indonesia — 0812 3456 7890
if ($digits[0] !== '0') $digits = '0' . $digits;
if (strlen($digits) === 12) {
$formatted = substr($digits, 0, 4) . ' ' . substr($digits, 4, 4) . ' ' . substr($digits, 8);
}
break;
case '63': // Philippines — 0912 345 6789
if (strlen($digits) === 11) {
$formatted = substr($digits, 0, 4) . ' ' . substr($digits, 4, 3) . ' ' . substr($digits, 7);
}
break;
case '234': // Nigeria — 0801 234 5678
if ($digits[0] !== '0') $digits = '0' . $digits;
if (strlen($digits) === 11) {
$formatted = substr($digits, 0, 4) . ' ' . substr($digits, 4, 3) . ' ' . substr($digits, 7);
}
break;
case '27': // South Africa — 082 123 4567
if (strlen($digits) >= 9 && strlen($digits) <= 10) {
$formatted = substr($digits, 0, 3) . ' ' . substr($digits, 3, 3) . ' ' . substr($digits, 6);
}
break;
case '971': // UAE — 050 123 4567
if (strlen($digits) === 9) {
$formatted = substr($digits, 0, 3) . ' ' . substr($digits, 3, 3) . ' ' . substr($digits, 6);
}
break;
default:
// If no match, do nothing here and use fallback below
break;
} }
// Fallback if formatting failed
if (!$formatted && strlen($digits) >= 7) { $phoneNumber = $phoneNumber ? preg_replace('/[^0-9]/', '', $phoneNumber) : "";
$formatted = substr($digits, 0, 3) . ' ' . substr($digits, 3, 3) . ' ' . substr($digits, 6);
if (strlen($phoneNumber) > 10) {
$countryCode = substr($phoneNumber, 0, strlen($phoneNumber) - 10);
$areaCode = substr($phoneNumber, -10, 3);
$nextThree = substr($phoneNumber, -7, 3);
$lastFour = substr($phoneNumber, -4, 4);
$phoneNumber = '+' . $countryCode . ' (' . $areaCode . ') ' . $nextThree . '-' . $lastFour;
} else if (strlen($phoneNumber) == 10) {
$areaCode = substr($phoneNumber, 0, 3);
$nextThree = substr($phoneNumber, 3, 3);
$lastFour = substr($phoneNumber, 6, 4);
$phoneNumber = '(' . $areaCode . ') ' . $nextThree . '-' . $lastFour;
} else if (strlen($phoneNumber) == 7) {
$nextThree = substr($phoneNumber, 0, 3);
$lastFour = substr($phoneNumber, 3, 4);
$phoneNumber = $nextThree . '-' . $lastFour;
} }
// Still no formatting? Use raw digits return $phoneNumber;
if (!$formatted) {
$formatted = $digits ?: $phoneNumber; // Use original input if digits are empty
}
return $show_country_code && $country_code ? "+$country_code $formatted" : $formatted;
} }
function mkdirMissing($dir) { function mkdirMissing($dir)
{
if (!is_dir($dir)) { if (!is_dir($dir)) {
mkdir($dir); mkdir($dir);
} }
@@ -341,7 +249,8 @@ function mkdirMissing($dir) {
// Called during initial setup // Called during initial setup
// Encrypts the master key with the user's password // Encrypts the master key with the user's password
function setupFirstUserSpecificKey($user_password, $site_encryption_master_key) { function setupFirstUserSpecificKey($user_password, $site_encryption_master_key)
{
$iv = randomString(); $iv = randomString();
$salt = randomString(); $salt = randomString();
@@ -359,7 +268,8 @@ function setupFirstUserSpecificKey($user_password, $site_encryption_master_key)
* New Users: Requires the admin setting up their account have a Specific/Session key configured * New Users: Requires the admin setting up their account have a Specific/Session key configured
* Password Changes: Will use the current info in the session. * Password Changes: Will use the current info in the session.
*/ */
function encryptUserSpecificKey($user_password) { function encryptUserSpecificKey($user_password)
{
$iv = randomString(); $iv = randomString();
$salt = randomString(); $salt = randomString();
@@ -424,13 +334,13 @@ function generateUserSessionKey($site_encryption_master_key)
} }
} }
// Decrypts an encrypted password (website/asset credentials), returns it as a string // Decrypts an encrypted password (website/asset login), returns it as a string
function decryptCredentialEntry($credential_password_ciphertext) function decryptLoginEntry($login_password_ciphertext)
{ {
// Split the credential into IV and Ciphertext // Split the login into IV and Ciphertext
$credential_iv = substr($credential_password_ciphertext, 0, 16); $login_iv = substr($login_password_ciphertext, 0, 16);
$credential_ciphertext = $salt = substr($credential_password_ciphertext, 16); $login_ciphertext = $salt = substr($login_password_ciphertext, 16);
// Get the user session info. // Get the user session info.
$user_encryption_session_ciphertext = $_SESSION['user_encryption_session_ciphertext']; $user_encryption_session_ciphertext = $_SESSION['user_encryption_session_ciphertext'];
@@ -440,12 +350,12 @@ function decryptCredentialEntry($credential_password_ciphertext)
// Decrypt the session key to get the master key // Decrypt the session key to get the master key
$site_encryption_master_key = openssl_decrypt($user_encryption_session_ciphertext, 'aes-128-cbc', $user_encryption_session_key, 0, $user_encryption_session_iv); $site_encryption_master_key = openssl_decrypt($user_encryption_session_ciphertext, 'aes-128-cbc', $user_encryption_session_key, 0, $user_encryption_session_iv);
// Decrypt the credential password using the master key // Decrypt the login password using the master key
return openssl_decrypt($credential_ciphertext, 'aes-128-cbc', $site_encryption_master_key, 0, $credential_iv); return openssl_decrypt($login_ciphertext, 'aes-128-cbc', $site_encryption_master_key, 0, $login_iv);
} }
// Encrypts a website/asset credential password // Encrypts a website/asset login password
function encryptCredentialEntry($credential_password_cleartext) function encryptLoginEntry($login_password_cleartext)
{ {
$iv = randomString(); $iv = randomString();
@@ -457,26 +367,26 @@ function encryptCredentialEntry($credential_password_cleartext)
//Decrypt the session key to get the master key //Decrypt the session key to get the master key
$site_encryption_master_key = openssl_decrypt($user_encryption_session_ciphertext, 'aes-128-cbc', $user_encryption_session_key, 0, $user_encryption_session_iv); $site_encryption_master_key = openssl_decrypt($user_encryption_session_ciphertext, 'aes-128-cbc', $user_encryption_session_key, 0, $user_encryption_session_iv);
//Encrypt the website/asset credential using the master key //Encrypt the website/asset login using the master key
$ciphertext = openssl_encrypt($credential_password_cleartext, 'aes-128-cbc', $site_encryption_master_key, 0, $iv); $ciphertext = openssl_encrypt($login_password_cleartext, 'aes-128-cbc', $site_encryption_master_key, 0, $iv);
return $iv . $ciphertext; return $iv . $ciphertext;
} }
function apiDecryptCredentialEntry($credential_ciphertext, $api_key_decrypt_hash, #[\SensitiveParameter]$api_key_decrypt_password) function apiDecryptLoginEntry($login_ciphertext, $api_key_decrypt_hash, #[\SensitiveParameter]$api_key_decrypt_password)
{ {
// Split the Credential entry (username/password) into IV and Ciphertext // Split the login entry (username/password) into IV and Ciphertext
$credential_iv = substr($credential_ciphertext, 0, 16); $login_iv = substr($login_ciphertext, 0, 16);
$credential_ciphertext = $salt = substr($credential_ciphertext, 16); $login_ciphertext = $salt = substr($login_ciphertext, 16);
// Decrypt the api hash to get the master key // Decrypt the api hash to get the master key
$site_encryption_master_key = decryptUserSpecificKey($api_key_decrypt_hash, $api_key_decrypt_password); $site_encryption_master_key = decryptUserSpecificKey($api_key_decrypt_hash, $api_key_decrypt_password);
// Decrypt the credential password using the master key // Decrypt the login password using the master key
return openssl_decrypt($credential_ciphertext, 'aes-128-cbc', $site_encryption_master_key, 0, $credential_iv); return openssl_decrypt($login_ciphertext, 'aes-128-cbc', $site_encryption_master_key, 0, $login_iv);
} }
function apiEncryptCredentialEntry(#[\SensitiveParameter]$credential_cleartext, $api_key_decrypt_hash, #[\SensitiveParameter]$api_key_decrypt_password) function apiEncryptLoginEntry(#[\SensitiveParameter]$credential_cleartext, $api_key_decrypt_hash, #[\SensitiveParameter]$api_key_decrypt_password)
{ {
$iv = randomString(); $iv = randomString();
@@ -629,9 +539,9 @@ function validateCSRFToken($token)
* Accountant - 1 * Accountant - 1
*/ */
function validateAdminRole() { function validateAdminRole()
global $session_user_role; {
if (!isset($session_user_role) || $session_user_role != 3) { if (!isset($_SESSION['user_role']) || $_SESSION['user_role'] != 3) {
$_SESSION['alert_type'] = "danger"; $_SESSION['alert_type'] = "danger";
$_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED; $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]); header("Location: " . $_SERVER["HTTP_REFERER"]);
@@ -641,9 +551,9 @@ function validateAdminRole() {
// LEGACY // LEGACY
// Validates a user is a tech (or admin). Stops page load and attempts to direct away from the page if not (i.e. user is an accountant) // Validates a user is a tech (or admin). Stops page load and attempts to direct away from the page if not (i.e. user is an accountant)
function validateTechRole() { function validateTechRole()
global $session_user_role; {
if (!isset($session_user_role) || $session_user_role == 1) { if (!isset($_SESSION['user_role']) || $_SESSION['user_role'] == 1) {
$_SESSION['alert_type'] = "danger"; $_SESSION['alert_type'] = "danger";
$_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED; $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]); header("Location: " . $_SERVER["HTTP_REFERER"]);
@@ -653,9 +563,9 @@ function validateTechRole() {
// LEGACY // LEGACY
// Validates a user is an accountant (or admin). Stops page load and attempts to direct away from the page if not (i.e. user is a tech) // Validates a user is an accountant (or admin). Stops page load and attempts to direct away from the page if not (i.e. user is a tech)
function validateAccountantRole() { function validateAccountantRole()
global $session_user_role; {
if (!isset($session_user_role) || $session_user_role == 2) { if (!isset($_SESSION['user_role']) || $_SESSION['user_role'] == 2) {
$_SESSION['alert_type'] = "danger"; $_SESSION['alert_type'] = "danger";
$_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED; $_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
header("Location: " . $_SERVER["HTTP_REFERER"]); header("Location: " . $_SERVER["HTTP_REFERER"]);
@@ -855,7 +765,7 @@ function checkFileUpload($file, $allowed_extensions)
$fileContent = file_get_contents($tmp); $fileContent = file_get_contents($tmp);
// Hash the file content using SHA-256 // Hash the file content using SHA-256
$hashedContent = hash('md5', $fileContent); $hashedContent = hash('sha256', $fileContent);
// Generate a secure filename using the hashed content // Generate a secure filename using the hashed content
$secureFilename = $hashedContent . randomString(2) . '.' . $extension; $secureFilename = $hashedContent . randomString(2) . '.' . $extension;
@@ -1403,15 +1313,15 @@ function lookupUserPermission($module) {
$sql = mysqli_query( $sql = mysqli_query(
$mysqli, $mysqli,
"SELECT "SELECT
user_role_permissions.user_role_permission_level urp.user_role_permission_level
FROM FROM
modules modules AS m
JOIN JOIN
user_role_permissions user_role_permissions AS urp
ON ON
modules.module_id = user_role_permissions.module_id m.module_id = urp.module_id
WHERE WHERE
module_name = '$module' AND user_role_permissions.user_role_id = $session_user_role" m.module_name = '$module' AND urp.user_role_id = $session_user_role"
); );
$row = mysqli_fetch_array($sql); $row = mysqli_fetch_array($sql);
@@ -1499,120 +1409,3 @@ function logAuth($status, $details) {
mysqli_query($mysqli, "INSERT INTO auth_logs SET auth_log_status = $status, auth_log_details = '$details', auth_log_ip = '$session_ip', auth_log_user_agent = '$session_user_agent', auth_log_user_id = $session_user_id"); mysqli_query($mysqli, "INSERT INTO auth_logs SET auth_log_status = $status, auth_log_details = '$details', auth_log_ip = '$session_ip', auth_log_user_agent = '$session_user_agent', auth_log_user_id = $session_user_id");
} }
// Helper function for missing data fallback
function getFallback($data) {
return !empty($data) ? $data : '-';
}
/**
* Retrieves a specified field's value from a table based on the record's id.
* It validates the table and field names, automatically determines the primary key (or uses the first column as fallback),
* and returns the field value with an appropriate escaping method.
*
* @param string $table The name of the table.
* @param int $id The record's id.
* @param string $field The field (column) to retrieve.
* @param string $escape_method The escape method: 'sql' (default, auto-detects int), 'html', 'json', or 'int'.
*
* @return mixed The escaped field value, or null if not found or invalid input.
*/
function getFieldById($table, $id, $field, $escape_method = 'sql') {
global $mysqli; // Use the global MySQLi connection
// Validate table and field names to allow only letters, numbers, and underscores
if (!preg_match('/^[a-zA-Z0-9_]+$/', $table) || !preg_match('/^[a-zA-Z0-9_]+$/', $field)) {
return null; // Invalid table or field name
}
// Sanitize id as an integer
$id = (int)$id;
// Get the list of columns and their details from the table
$columns_result = mysqli_query($mysqli, "SHOW COLUMNS FROM `$table`");
if (!$columns_result || mysqli_num_rows($columns_result) == 0) {
return null; // Table not found or has no columns
}
// Build an associative array with column details
$columns = [];
while ($row = mysqli_fetch_assoc($columns_result)) {
$columns[$row['Field']] = [
'type' => $row['Type'],
'key' => $row['Key']
];
}
// Find the primary key field if available
$id_field = null;
foreach ($columns as $col => $details) {
if ($details['key'] === 'PRI') {
$id_field = $col;
break;
}
}
// Fallback: if no primary key is found, use the first column
if (!$id_field) {
reset($columns);
$id_field = key($columns);
}
// Ensure the requested field exists; if not, default to the id field
if (!array_key_exists($field, $columns)) {
$field = $id_field;
}
// Build and execute the query to fetch the specified field value
$query = "SELECT `$field` FROM `$table` WHERE `$id_field` = $id";
$sql = mysqli_query($mysqli, $query);
if ($sql && mysqli_num_rows($sql) > 0) {
$row = mysqli_fetch_assoc($sql);
$value = $row[$field];
// Apply the desired escaping method or auto-detect integer type if using SQL escaping
switch ($escape_method) {
case 'html':
return htmlspecialchars($value ?? '', ENT_QUOTES, 'UTF-8'); // Escape for HTML
case 'json':
return json_encode($value); // Escape for JSON
case 'int':
return (int)$value; // Explicitly cast value to integer
case 'sql':
default:
// Auto-detect if the field type is integer
if (stripos($columns[$field]['type'], 'int') !== false) {
return (int)$value;
} else {
return sanitizeInput($value); // Escape for SQL using a custom function
}
}
}
return null; // Return null if no record was found
}
// Recursive function to display folder options - Used in folders files and documents
function display_folder_options($parent_folder_id, $client_id, $indent = 0) {
global $mysqli;
$sql_folders = mysqli_query($mysqli, "SELECT * FROM folders WHERE parent_folder = $parent_folder_id AND folder_location = 1 AND folder_client_id = $client_id ORDER BY folder_name ASC");
while ($row = mysqli_fetch_array($sql_folders)) {
$folder_id = intval($row['folder_id']);
$folder_name = nullable_htmlentities($row['folder_name']);
// Indentation for subfolders
$indentation = str_repeat('&nbsp;', $indent * 4);
// Check if this folder is selected
$selected = '';
if ((isset($_GET['folder_id']) && $_GET['folder_id'] == $folder_id) || (isset($_POST['folder']) && $_POST['folder'] == $folder_id)) {
$selected = 'selected';
}
echo "<option value=\"$folder_id\" $selected>$indentation$folder_name</option>";
// Recursively display subfolders
display_folder_options($folder_id, $client_id, $indent + 1);
}
}

View File

@@ -49,8 +49,8 @@ $config_invoice_late_fee_percent = floatval($row['config_invoice_late_fee_percen
$config_invoice_paid_notification_email = $row['config_invoice_paid_notification_email']; $config_invoice_paid_notification_email = $row['config_invoice_paid_notification_email'];
// Recurring Invoices // Recurring Invoices
$config_recurring_invoice_prefix = $row['config_recurring_invoice_prefix']; $config_recurring_prefix = $row['config_recurring_prefix'];
$config_recurring_invoice_next_number = intval($row['config_recurring_invoice_next_number']); $config_recurring_next_number = intval($row['config_recurring_next_number']);
// Quotes // Quotes
$config_quote_prefix = $row['config_quote_prefix']; $config_quote_prefix = $row['config_quote_prefix'];
@@ -142,22 +142,21 @@ $config_whitelabel_key = $row['config_whitelabel_key'];
$theme_colors_array = array ( $theme_colors_array = array (
'lightblue', 'lightblue',
'blue', 'blue',
'cyan',
'green', 'green',
'olive', 'cyan',
'teal', 'yellow',
'red', 'red',
'maroon',
'pink',
'purple',
'indigo',
'fuchsia',
'yellow',
'orange',
'yellow',
'black', 'black',
'gray',
'indigo',
'navy', 'navy',
'gray' 'purple',
'fuchsia',
'pink',
'maroon',
'orange',
'teal',
'olive'
); );
$colors_array = array ( $colors_array = array (

View File

@@ -23,7 +23,7 @@ if (isset($_GET['query'])) {
$sql_clients = mysqli_query($mysqli, "SELECT * FROM clients $sql_clients = mysqli_query($mysqli, "SELECT * FROM clients
LEFT JOIN locations ON clients.client_id = locations.location_client_id AND location_primary = 1 LEFT JOIN locations ON clients.client_id = locations.location_client_id AND location_primary = 1
WHERE client_archived_at IS NULL WHERE client_archived_at IS NULL
AND (client_name LIKE '%$query%' OR client_abbreviation LIKE '%$query%') AND client_name LIKE '%$query%'
$access_permission_query $access_permission_query
ORDER BY client_id DESC LIMIT 5" ORDER BY client_id DESC LIMIT 5"
); );
@@ -91,21 +91,21 @@ if (isset($_GET['query'])) {
ORDER BY ticket_id DESC LIMIT 5" ORDER BY ticket_id DESC LIMIT 5"
); );
$sql_recurring_tickets = mysqli_query($mysqli, "SELECT * FROM recurring_tickets $sql_recurring_tickets = mysqli_query($mysqli, "SELECT * FROM scheduled_tickets
LEFT JOIN clients ON recurring_ticket_client_id = client_id LEFT JOIN clients ON scheduled_ticket_client_id = client_id
WHERE (recurring_ticket_subject LIKE '%$query%' WHERE (scheduled_ticket_subject LIKE '%$query%'
OR recurring_ticket_details LIKE '%$query%') OR scheduled_ticket_details LIKE '%$query%')
$access_permission_query $access_permission_query
ORDER BY recurring_ticket_id DESC LIMIT 5" ORDER BY scheduled_ticket_id DESC LIMIT 5"
); );
$sql_credentials = mysqli_query($mysqli, "SELECT * FROM credentials $sql_logins = mysqli_query($mysqli, "SELECT * FROM logins
LEFT JOIN contacts ON credential_contact_id = contact_id LEFT JOIN contacts ON login_contact_id = contact_id
LEFT JOIN clients ON credential_client_id = client_id LEFT JOIN clients ON login_client_id = client_id
WHERE credential_archived_at IS NULL WHERE login_archived_at IS NULL
AND (credential_name LIKE '%$query%' OR credential_description LIKE '%$query%') AND (login_name LIKE '%$query%' OR login_description LIKE '%$query%')
$access_permission_query $access_permission_query
ORDER BY credential_id DESC LIMIT 5" ORDER BY login_id DESC LIMIT 5"
); );
$sql_invoices = mysqli_query($mysqli, "SELECT * FROM invoices $sql_invoices = mysqli_query($mysqli, "SELECT * FROM invoices
@@ -172,8 +172,7 @@ if (isset($_GET['query'])) {
while ($row = mysqli_fetch_array($sql_clients)) { while ($row = mysqli_fetch_array($sql_clients)) {
$client_id = intval($row['client_id']); $client_id = intval($row['client_id']);
$client_name = nullable_htmlentities($row['client_name']); $client_name = nullable_htmlentities($row['client_name']);
$location_phone_country_code = nullable_htmlentities($row['location_phone_country_code']); $location_phone = formatPhoneNumber($row['location_phone']);
$location_phone = nullable_htmlentities(formatPhoneNumber($row['location_phone'], $location_phone_country_code));
$client_website = nullable_htmlentities($row['client_website']); $client_website = nullable_htmlentities($row['client_website']);
?> ?>
@@ -219,11 +218,9 @@ if (isset($_GET['query'])) {
$contact_id = intval($row['contact_id']); $contact_id = intval($row['contact_id']);
$contact_name = nullable_htmlentities($row['contact_name']); $contact_name = nullable_htmlentities($row['contact_name']);
$contact_title = nullable_htmlentities($row['contact_title']); $contact_title = nullable_htmlentities($row['contact_title']);
$contact_phone_country_code = nullable_htmlentities($row['contact_phone_country_code']); $contact_phone = formatPhoneNumber($row['contact_phone']);
$contact_phone = nullable_htmlentities(formatPhoneNumber($row['contact_phone'], $contact_phone_country_code));
$contact_extension = nullable_htmlentities($row['contact_extension']); $contact_extension = nullable_htmlentities($row['contact_extension']);
$contact_mobile_country_code = nullable_htmlentities($row['contact_mobile_country_code']); $contact_mobile = formatPhoneNumber($row['contact_mobile']);
$contact_mobile = nullable_htmlentities(formatPhoneNumber($row['contact_mobile'], $contact_mobile_country_code));
$contact_email = nullable_htmlentities($row['contact_email']); $contact_email = nullable_htmlentities($row['contact_email']);
$client_id = intval($row['client_id']); $client_id = intval($row['client_id']);
$client_name = nullable_htmlentities($row['client_name']); $client_name = nullable_htmlentities($row['client_name']);
@@ -275,8 +272,7 @@ if (isset($_GET['query'])) {
while ($row = mysqli_fetch_array($sql_vendors)) { while ($row = mysqli_fetch_array($sql_vendors)) {
$vendor_name = nullable_htmlentities($row['vendor_name']); $vendor_name = nullable_htmlentities($row['vendor_name']);
$vendor_description = nullable_htmlentities($row['vendor_description']); $vendor_description = nullable_htmlentities($row['vendor_description']);
$vendor_phone_country_code = nullable_htmlentities($row['vendor_phone_country_code']); $vendor_phone = formatPhoneNumber($row['vendor_phone']);
$vendor_phone = nullable_htmlentities(formatPhoneNumber($row['vendor_phone'], $vendor_phone_country_code));
$client_id = intval($row['client_id']); $client_id = intval($row['client_id']);
$client_name = nullable_htmlentities($row['client_name']); $client_name = nullable_htmlentities($row['client_name']);
@@ -548,18 +544,18 @@ if (isset($_GET['query'])) {
<?php <?php
while ($row = mysqli_fetch_array($sql_recurring_tickets)) { while ($row = mysqli_fetch_array($sql_recurring_tickets)) {
$recurring_ticket_id = intval($row['recurring_ticket_id']); $scheduled_ticket_id = intval($row['scheduled_ticket_id']);
$recurring_ticket_subject = nullable_htmlentities($row['recurring_ticket_subject']); $scheduled_ticket_subject = nullable_htmlentities($row['scheduled_ticket_subject']);
$recurring_ticket_frequency = nullable_htmlentities($row['recurring_ticket_frequency']); $scheduled_ticket_frequency = nullable_htmlentities($row['scheduled_ticket_frequency']);
$recurring_ticket_next_run = nullable_htmlentities($row['recurring_ticket_next_run']); $scheduled_ticket_next_run = nullable_htmlentities($row['scheduled_ticket_next_run']);
$client_name = nullable_htmlentities($row['client_name']); $client_name = nullable_htmlentities($row['client_name']);
$client_id = intval($row['client_id']); $client_id = intval($row['client_id']);
?> ?>
<tr> <tr>
<td><a href="recurring_tickets.php"><?php echo $recurring_ticket_subject; ?></a></td> <td><a href="recurring_tickets.php"><?php echo $scheduled_ticket_subject; ?></a></td>
<td><?php echo $recurring_ticket_frequency; ?></td> <td><?php echo $scheduled_ticket_frequency; ?></td>
<td><?php echo $recurring_ticket_next_run; ?></td> <td><?php echo $scheduled_ticket_next_run; ?></td>
<td><a href="recurring_tickets.php?client_id=<?php echo $client_id ?>"><?php echo $client_name; ?></a></td> <td><a href="recurring_tickets.php?client_id=<?php echo $client_id ?>"><?php echo $client_name; ?></a></td>
</tr> </tr>
@@ -575,9 +571,9 @@ if (isset($_GET['query'])) {
<?php } ?> <?php } ?>
<?php if (mysqli_num_rows($sql_credentials) > 0) { ?> <?php if (mysqli_num_rows($sql_logins) > 0) { ?>
<!-- Credentials --> <!-- Logins -->
<div class="col-sm-6"> <div class="col-sm-6">
<div class="card card-dark mb-3"> <div class="card card-dark mb-3">
<div class="card-header"> <div class="card-header">
@@ -597,21 +593,21 @@ if (isset($_GET['query'])) {
<tbody> <tbody>
<?php <?php
while ($row = mysqli_fetch_array($sql_credentials)) { while ($row = mysqli_fetch_array($sql_logins)) {
$credential_name = nullable_htmlentities($row['credential_name']); $login_name = nullable_htmlentities($row['login_name']);
$credential_description = nullable_htmlentities($row['credential_description']); $login_description = nullable_htmlentities($row['login_description']);
$credential_client_id = intval($row['credential_client_id']); $login_client_id = intval($row['login_client_id']);
$credential_username = nullable_htmlentities(decryptCredentialEntry($row['credential_username'])); $login_username = nullable_htmlentities(decryptLoginEntry($row['login_username']));
$credential_password = nullable_htmlentities(decryptCredentialEntry($row['credential_password'])); $login_password = nullable_htmlentities(decryptLoginEntry($row['login_password']));
$client_id = intval($row['client_id']); $client_id = intval($row['client_id']);
$client_name = nullable_htmlentities($row['client_name']); $client_name = nullable_htmlentities($row['client_name']);
?> ?>
<tr> <tr>
<td><a href="credentials.php?client_id=<?php echo $credential_client_id ?>&q=<?php echo $q ?>"><?php echo $credential_name; ?></a></td> <td><a href="credentials.php?client_id=<?php echo $login_client_id ?>&q=<?php echo $q ?>"><?php echo $login_name; ?></a></td>
<td><?php echo $credential_description; ?></td> <td><?php echo $login_description; ?></td>
<td><?php echo $credential_username; ?></td> <td><?php echo $login_username; ?></td>
<td><a tabindex="0" class="btn btn-sm" data-toggle="popover" data-trigger="focus" data-placement="left" data-content="<?php echo $credential_password; ?>"><i class="far fa-eye text-secondary"></i></a><button class="btn btn-sm clipboardjs" data-clipboard-text="<?php echo $credential_password; ?>"><i class="far fa-copy text-secondary"></i></button> <td><a tabindex="0" class="btn btn-sm" data-toggle="popover" data-trigger="focus" data-placement="left" data-content="<?php echo $login_password; ?>"><i class="far fa-eye text-secondary"></i></a><button class="btn btn-sm clipboardjs" data-clipboard-text="<?php echo $login_password; ?>"><i class="far fa-copy text-secondary"></i></button>
</td> </td>
<td><a href="credentials.php?client_id=<?php echo $client_id; ?>"><?php echo $client_name; ?></a></td> <td><a href="credentials.php?client_id=<?php echo $client_id; ?>"><?php echo $client_name; ?></a></td>
</tr> </tr>

View File

@@ -9,7 +9,7 @@
require_once "../config.php"; require_once "../config.php";
// Set Timezone // Set Timezone
require_once "../includes/inc_set_timezone.php"; require_once "../inc_set_timezone.php";
require_once "../functions.php"; require_once "../functions.php";
require_once "../plugins/totp/totp.php"; require_once "../plugins/totp/totp.php";

View File

@@ -3,7 +3,7 @@
require_once "../config.php"; require_once "../config.php";
// Set Timezone // Set Timezone
require_once "../includes/inc_set_timezone.php"; require_once "../inc_set_timezone.php";
require_once "../functions.php"; require_once "../functions.php";

View File

@@ -6,7 +6,7 @@ require_once "../functions.php";
session_start(); session_start();
// Set Timezone // Set Timezone
require_once "../includes/inc_set_timezone.php"; require_once "../inc_set_timezone.php";
$ip = sanitizeInput(getIP()); $ip = sanitizeInput(getIP());
$user_agent = sanitizeInput($_SERVER['HTTP_USER_AGENT']); $user_agent = sanitizeInput($_SERVER['HTTP_USER_AGENT']);

View File

@@ -1,6 +1,6 @@
<?php <?php
require_once 'includes/guest_header.php'; require_once 'guest_header.php';
// Define wording // Define wording
DEFINE("WORDING_PAYMENT_FAILED", "<br><h2>There was an error verifying your payment. Please contact us for more information before attempting payment again.</h2>"); DEFINE("WORDING_PAYMENT_FAILED", "<br><h2>There was an error verifying your payment. Please contact us for more information before attempting payment again.</h2>");
@@ -19,7 +19,7 @@ $config_stripe_flat_fee = floatval($stripe_vars['config_stripe_flat_fee']);
// Check Stripe is configured // Check Stripe is configured
if ($config_stripe_enable == 0 || $config_stripe_account == 0 || empty($config_stripe_publishable) || empty($config_stripe_secret)) { if ($config_stripe_enable == 0 || $config_stripe_account == 0 || empty($config_stripe_publishable) || empty($config_stripe_secret)) {
echo "<br><h2>Stripe payments not enabled/configured</h2>"; echo "<br><h2>Stripe payments not enabled/configured</h2>";
require_once 'includes/guest_footer.php'; require_once 'guest_footer.php';
error_log("Stripe payment error - disabled. Check payments are enabled, Expense account is set, Stripe publishable and secret keys are configured."); error_log("Stripe payment error - disabled. Check payments are enabled, Expense account is set, Stripe publishable and secret keys are configured.");
exit(); exit();
} }
@@ -47,7 +47,7 @@ if (isset($_GET['invoice_id'], $_GET['url_key']) && !isset($_GET['payment_intent
// Ensure we have a valid invoice // Ensure we have a valid invoice
if (!$sql || mysqli_num_rows($sql) !== 1) { if (!$sql || mysqli_num_rows($sql) !== 1) {
echo "<br><h2>Oops, something went wrong! Please ensure you have the correct URL and have not already paid this invoice.</h2>"; echo "<br><h2>Oops, something went wrong! Please ensure you have the correct URL and have not already paid this invoice.</h2>";
require_once 'includes/guest_footer.php'; require_once 'guest_footer.php';
error_log("Stripe payment error - Invoice with ID $invoice_id is unknown/not eligible to be paid."); error_log("Stripe payment error - Invoice with ID $invoice_id is unknown/not eligible to be paid.");
exit(); exit();
} }
@@ -357,4 +357,4 @@ if (isset($_GET['invoice_id'], $_GET['url_key']) && !isset($_GET['payment_intent
} }
require_once 'includes/guest_footer.php'; require_once 'guest_footer.php';

View File

@@ -5,7 +5,7 @@ require_once "../functions.php";
session_start(); session_start();
require_once "../includes/inc_set_timezone.php"; // Must be included after session_start to work require_once "../inc_set_timezone.php"; // Must be included after session_start to work
if (isset($_GET['accept_quote'], $_GET['url_key'])) { if (isset($_GET['accept_quote'], $_GET['url_key'])) {
$quote_id = intval($_GET['accept_quote']); $quote_id = intval($_GET['accept_quote']);

View File

@@ -1,10 +1,10 @@
<?php <?php
require_once "includes/guest_header.php"; require_once "guest_header.php";
if (!isset($_GET['invoice_id'], $_GET['url_key'])) { if (!isset($_GET['invoice_id'], $_GET['url_key'])) {
echo "<br><h2>Oops, something went wrong! Please raise a ticket if you believe this is an error.</h2>"; echo "<br><h2>Oops, something went wrong! Please raise a ticket if you believe this is an error.</h2>";
require_once "includes/guest_footer.php"; require_once "guest_footer.php";
exit(); exit();
} }
@@ -25,7 +25,7 @@ $sql = mysqli_query(
if (mysqli_num_rows($sql) !== 1) { if (mysqli_num_rows($sql) !== 1) {
// Invalid invoice/key // Invalid invoice/key
echo "<br><h2>Oops, something went wrong! Please raise a ticket if you believe this is an error.</h2>"; echo "<br><h2>Oops, something went wrong! Please raise a ticket if you believe this is an error.</h2>";
require_once "includes/guest_footer.php"; require_once "guest_footer.php";
exit(); exit();
} }
@@ -51,11 +51,9 @@ $location_city = nullable_htmlentities($row['location_city']);
$location_state = nullable_htmlentities($row['location_state']); $location_state = nullable_htmlentities($row['location_state']);
$location_zip = nullable_htmlentities($row['location_zip']); $location_zip = nullable_htmlentities($row['location_zip']);
$contact_email = nullable_htmlentities($row['contact_email']); $contact_email = nullable_htmlentities($row['contact_email']);
$contact_phone_country_code = nullable_htmlentities($row['contact_phone_country_code']); $contact_phone = formatPhoneNumber($row['contact_phone']);
$contact_phone = nullable_htmlentities(formatPhoneNumber($row['contact_phone'], $contact_phone_country_code));
$contact_extension = nullable_htmlentities($row['contact_extension']); $contact_extension = nullable_htmlentities($row['contact_extension']);
$contact_mobile_country_code = nullable_htmlentities($row['contact_mobile_country_code']); $contact_mobile = formatPhoneNumber($row['contact_mobile']);
$contact_mobile = nullable_htmlentities(formatPhoneNumber($row['contact_mobile'], $contact_mobile_country_code));
$client_website = nullable_htmlentities($row['client_website']); $client_website = nullable_htmlentities($row['client_website']);
$client_currency_code = nullable_htmlentities($row['client_currency_code']); $client_currency_code = nullable_htmlentities($row['client_currency_code']);
$client_net_terms = intval($row['client_net_terms']); $client_net_terms = intval($row['client_net_terms']);
@@ -71,8 +69,7 @@ $company_address = nullable_htmlentities($row['company_address']);
$company_city = nullable_htmlentities($row['company_city']); $company_city = nullable_htmlentities($row['company_city']);
$company_state = nullable_htmlentities($row['company_state']); $company_state = nullable_htmlentities($row['company_state']);
$company_zip = nullable_htmlentities($row['company_zip']); $company_zip = nullable_htmlentities($row['company_zip']);
$company_phone_country_code = nullable_htmlentities($row['company_phone_country_code']); $company_phone = formatPhoneNumber($row['company_phone']);
$company_phone = nullable_htmlentities(formatPhoneNumber($row['company_phone'], $company_phone_country_code));
$company_email = nullable_htmlentities($row['company_email']); $company_email = nullable_htmlentities($row['company_email']);
$company_website = nullable_htmlentities($row['company_website']); $company_website = nullable_htmlentities($row['company_website']);
$company_logo = nullable_htmlentities($row['company_logo']); $company_logo = nullable_htmlentities($row['company_logo']);
@@ -380,13 +377,6 @@ if ($balance > 0) {
style: 'invoiceNumber', style: 'invoiceNumber',
width: '*' width: '*'
}, },
<?php if ($invoice_status == "Paid") { ?>
{
text: 'PAID',
style: 'invoicePaid',
width: '*'
},
<?php } ?>
], ],
], ],
}, },
@@ -676,14 +666,6 @@ if ($balance > 0) {
fontSize: 14, fontSize: 14,
alignment: 'right' alignment: 'right'
}, },
// Invoice Paid
invoicePaid: {
fontSize: 13,
bold: true,
margin: [0,5,0,0],
alignment: 'right',
color: 'green'
},
// Billing Headers // Billing Headers
invoiceBillingTitle: { invoiceBillingTitle: {
fontSize: 14, fontSize: 14,
@@ -934,4 +916,4 @@ if ($outstanding_invoices_count > 0) { ?>
<?php } // End previous unpaid invoices <?php } // End previous unpaid invoices
require_once "includes/guest_footer.php"; require_once "guest_footer.php";

View File

@@ -4,7 +4,7 @@ header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false); header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache'); header('Pragma: no-cache');
require_once "includes/guest_header.php"; require_once "guest_header.php";
//Initialize the HTML Purifier to prevent XSS //Initialize the HTML Purifier to prevent XSS
@@ -23,8 +23,7 @@ $company_address = nullable_htmlentities($row['company_address']);
$company_city = nullable_htmlentities($row['company_city']); $company_city = nullable_htmlentities($row['company_city']);
$company_state = nullable_htmlentities($row['company_state']); $company_state = nullable_htmlentities($row['company_state']);
$company_zip = nullable_htmlentities($row['company_zip']); $company_zip = nullable_htmlentities($row['company_zip']);
$company_phone_country_code = nullable_htmlentities($row['company_phone_country_code']); $company_phone = formatPhoneNumber($row['company_phone']);
$company_phone = nullable_htmlentities(formatPhoneNumber($row['company_phone'], $company_phone_country_code));
$company_email = nullable_htmlentities($row['company_email']); $company_email = nullable_htmlentities($row['company_email']);
$company_website = nullable_htmlentities($row['company_website']); $company_website = nullable_htmlentities($row['company_website']);
$company_logo = nullable_htmlentities($row['company_logo']); $company_logo = nullable_htmlentities($row['company_logo']);
@@ -39,7 +38,7 @@ $currency_format = numfmt_create($company_locale, NumberFormatter::CURRENCY);
<?php <?php
if (!isset($_GET['id']) || !isset($_GET['key'])) { if (!isset($_GET['id']) || !isset($_GET['key'])) {
echo "<div class='alert alert-danger'>Incorrect URL.</div>"; echo "<div class='alert alert-danger'>Incorrect URL.</div>";
include "includes/guest_footer.php"; include "guest_footer.php";
exit(); exit();
} }
@@ -53,7 +52,7 @@ $row = mysqli_fetch_array($sql);
// Check we got a result // Check we got a result
if (mysqli_num_rows($sql) !== 1 || !$row) { if (mysqli_num_rows($sql) !== 1 || !$row) {
echo "<div class='alert alert-danger' >No item to view. Check with the person that sent you this link to ensure it is correct and has not expired.</div>"; echo "<div class='alert alert-danger' >No item to view. Check with the person that sent you this link to ensure it is correct and has not expired.</div>";
include "includes/guest_footer.php"; include "guest_footer.php";
exit(); exit();
} }
@@ -61,7 +60,7 @@ if (mysqli_num_rows($sql) !== 1 || !$row) {
// Check item share is active & hasn't been viewed too many times but allow 0 views as that is consider infinite views // Check item share is active & hasn't been viewed too many times but allow 0 views as that is consider infinite views
if ($row['item_active'] !== "1" || ($row['item_view_limit'] > 0 && $row['item_views'] >= $row['item_view_limit'])) { if ($row['item_active'] !== "1" || ($row['item_view_limit'] > 0 && $row['item_views'] >= $row['item_view_limit'])) {
echo "<div class='alert alert-danger'>Item cannot be viewed at this time. Check with the person that sent you this link to ensure it is correct and has not expired.</div>"; echo "<div class='alert alert-danger'>Item cannot be viewed at this time. Check with the person that sent you this link to ensure it is correct and has not expired.</div>";
include "includes/guest_footer.php"; include "guest_footer.php";
exit(); exit();
} }
@@ -123,7 +122,7 @@ if ($item_type == "Document") {
if (mysqli_num_rows($doc_sql) !== 1 || !$doc_row) { if (mysqli_num_rows($doc_sql) !== 1 || !$doc_row) {
echo "<div class='alert alert-danger'>Error retrieving document to view.</div>"; echo "<div class='alert alert-danger'>Error retrieving document to view.</div>";
require_once "includes/guest_footer.php"; require_once "guest_footer.php";
exit(); exit();
} }
@@ -150,7 +149,7 @@ if ($item_type == "Document") {
if (mysqli_num_rows($file_sql) !== 1 || !$file_row) { if (mysqli_num_rows($file_sql) !== 1 || !$file_row) {
echo "<div class='alert alert-danger'>Error retrieving file.</div>"; echo "<div class='alert alert-danger'>Error retrieving file.</div>";
include "includes/guest_footer.php"; include "guest_footer.php";
exit(); exit();
} }
@@ -164,61 +163,61 @@ if ($item_type == "Document") {
echo "<a href='guest_download_file.php?id=$item_id&key=$item_key'>Download $file_name</a>"; echo "<a href='guest_download_file.php?id=$item_id&key=$item_key'>Download $file_name</a>";
} elseif ($item_type == "Credential") { } elseif ($item_type == "Login") {
$encryption_key = $_GET['ek']; $encryption_key = $_GET['ek'];
$credential_sql = mysqli_query($mysqli, "SELECT * FROM credentials WHERE credential_id = $item_related_id AND credential_client_id = $client_id LIMIT 1"); $login_sql = mysqli_query($mysqli, "SELECT * FROM logins WHERE login_id = $item_related_id AND login_client_id = $client_id LIMIT 1");
$credential_row = mysqli_fetch_array($credential_sql); $login_row = mysqli_fetch_array($login_sql);
if (mysqli_num_rows($credential_sql) !== 1 || !$credential_row) { if (mysqli_num_rows($login_sql) !== 1 || !$login_row) {
echo "<div class='alert alert-danger'>Error retrieving login.</div>"; echo "<div class='alert alert-danger'>Error retrieving login.</div>";
include "includes/guest_footer.php"; include "guest_footer.php";
exit(); exit();
} }
$credential_id = intval($credential_row['credential_id']); $login_id = intval($login_row['login_id']);
$credential_name = nullable_htmlentities($credential_row['credential_name']); $login_name = nullable_htmlentities($login_row['login_name']);
$credential_uri = nullable_htmlentities($credential_row['credential_uri']); $login_uri = nullable_htmlentities($login_row['login_uri']);
$username_iv = substr($row['item_encrypted_username'], 0, 16); $username_iv = substr($row['item_encrypted_username'], 0, 16);
$username_ciphertext = substr($row['item_encrypted_username'], 16); $username_ciphertext = substr($row['item_encrypted_username'], 16);
$credential_username = nullable_htmlentities(openssl_decrypt($username_ciphertext, 'aes-128-cbc', $encryption_key, 0, $username_iv)); $login_username = nullable_htmlentities(openssl_decrypt($username_ciphertext, 'aes-128-cbc', $encryption_key, 0, $username_iv));
$password_iv = substr($row['item_encrypted_credential'], 0, 16); $password_iv = substr($row['item_encrypted_credential'], 0, 16);
$password_ciphertext = substr($row['item_encrypted_credential'], 16); $password_ciphertext = substr($row['item_encrypted_credential'], 16);
$credential_password = nullable_htmlentities(openssl_decrypt($password_ciphertext, 'aes-128-cbc', $encryption_key, 0, $password_iv)); $login_password = nullable_htmlentities(openssl_decrypt($password_ciphertext, 'aes-128-cbc', $encryption_key, 0, $password_iv));
$credential_otp = nullable_htmlentities($credential_row['credential_otp_secret']); $login_otp = nullable_htmlentities($login_row['login_otp_secret']);
$credential_otp_secret = nullable_htmlentities($credential_row['credential_otp_secret']); $login_otp_secret = nullable_htmlentities($login_row['login_otp_secret']);
$credential_id_with_secret = '"' . $credential_row['credential_id'] . '","' . $credential_row['credential_otp_secret'] . '"'; $login_id_with_secret = '"' . $login_row['login_id'] . '","' . $login_row['login_otp_secret'] . '"';
if (empty($credential_otp_secret)) { if (empty($login_otp_secret)) {
$otp_display = "-"; $otp_display = "-";
} else { } else {
$otp_display = "<span onmouseenter='showOTP($credential_id_with_secret)'><i class='far fa-clock'></i> <span id='otp_$credential_id'><i>Hover..</i></span></span>"; $otp_display = "<span onmouseenter='showOTP($login_id_with_secret)'><i class='far fa-clock'></i> <span id='otp_$login_id'><i>Hover..</i></span></span>";
} }
$credential_notes = nullable_htmlentities($credential_row['credential_note']); $login_notes = nullable_htmlentities($login_row['login_note']);
?> ?>
<h5><?php echo $credential_name; ?></h5> <h5><?php echo $login_name; ?></h5>
<table class="table col-md-3"> <table class="table col-md-3">
<tr> <tr>
<th>URL</th> <th>URL</th>
<td><?php echo $credential_uri; ?></td> <td><?php echo $login_uri; ?></td>
</tr> </tr>
<tr> <tr>
<th>Username</th> <th>Username</th>
<td><?php echo $credential_username ?></td> <td><?php echo $login_username ?></td>
</tr> </tr>
<tr> <tr>
<th>Password</th> <th>Password</th>
<td><?php echo $credential_password ?></td> <td><?php echo $login_password ?></td>
</tr> </tr>
<?php if(!empty($credential_otp_secret)){ ?> <?php if(!empty($login_otp_secret)){ ?>
<tr> <tr>
<th>2FA (TOTP)</th> <th>2FA (TOTP)</th>
<td><?php echo $otp_display ?></td> <td><?php echo $otp_display ?></td>
@@ -251,12 +250,12 @@ if ($item_type == "Document") {
<?php <?php
// Update credential view count // Update login view count
$new_item_views = $item_views + 1; $new_item_views = $item_views + 1;
mysqli_query($mysqli, "UPDATE shared_items SET item_views = $new_item_views WHERE item_id = $item_id"); mysqli_query($mysqli, "UPDATE shared_items SET item_views = $new_item_views WHERE item_id = $item_id");
// Logging // Logging
$name = sanitizeInput($credential_row['credential_name']); $name = sanitizeInput($login_row['login_name']);
logAction("Share", "View", "Viewed shared $item_type $name via link", $client_id); logAction("Share", "View", "Viewed shared $item_type $name via link", $client_id);
} }
@@ -274,6 +273,6 @@ if ($item_type == "Document") {
</div> </div>
<?php <?php
require_once "includes/guest_footer.php"; require_once "guest_footer.php";
?> ?>

View File

@@ -1,11 +1,11 @@
<?php <?php
require_once "includes/guest_header.php"; require_once "guest_header.php";
if (!isset($_GET['quote_id'], $_GET['url_key'])) { if (!isset($_GET['quote_id'], $_GET['url_key'])) {
echo "<br><h2>Oops, something went wrong! Please raise a ticket if you believe this is an error.</h2>"; echo "<br><h2>Oops, something went wrong! Please raise a ticket if you believe this is an error.</h2>";
require_once "includes/guest_footer.php"; require_once "guest_footer.php";
exit(); exit();
} }
@@ -27,7 +27,7 @@ $sql = mysqli_query(
if (mysqli_num_rows($sql) !== 1) { if (mysqli_num_rows($sql) !== 1) {
// Invalid quote/key // Invalid quote/key
echo "<br><h2>Oops, something went wrong! Please raise a ticket if you believe this is an error.</h2>"; echo "<br><h2>Oops, something went wrong! Please raise a ticket if you believe this is an error.</h2>";
require_once "includes/guest_footer.php"; require_once "guest_footer.php";
exit(); exit();
} }
@@ -52,11 +52,9 @@ $location_city = nullable_htmlentities($row['location_city']);
$location_state = nullable_htmlentities($row['location_state']); $location_state = nullable_htmlentities($row['location_state']);
$location_zip = nullable_htmlentities($row['location_zip']); $location_zip = nullable_htmlentities($row['location_zip']);
$contact_email = nullable_htmlentities($row['contact_email']); $contact_email = nullable_htmlentities($row['contact_email']);
$contact_phone_country_code = nullable_htmlentities($row['contact_phone_country_code']); $contact_phone = formatPhoneNumber($row['contact_phone']);
$contact_phone = nullable_htmlentities(formatPhoneNumber($row['contact_phone'], $contact_phone_country_code));
$contact_extension = nullable_htmlentities($row['contact_extension']); $contact_extension = nullable_htmlentities($row['contact_extension']);
$contact_mobile_country_code = nullable_htmlentities($row['contact_mobile_country_code']); $contact_mobile = formatPhoneNumber($row['contact_mobile']);
$contact_mobile = nullable_htmlentities(formatPhoneNumber($row['contact_mobile'], $contact_mobile_country_code));
$client_website = nullable_htmlentities($row['client_website']); $client_website = nullable_htmlentities($row['client_website']);
$client_currency_code = nullable_htmlentities($row['client_currency_code']); $client_currency_code = nullable_htmlentities($row['client_currency_code']);
$client_net_terms = intval($row['client_net_terms']); $client_net_terms = intval($row['client_net_terms']);
@@ -71,8 +69,7 @@ $company_address = nullable_htmlentities($row['company_address']);
$company_city = nullable_htmlentities($row['company_city']); $company_city = nullable_htmlentities($row['company_city']);
$company_state = nullable_htmlentities($row['company_state']); $company_state = nullable_htmlentities($row['company_state']);
$company_zip = nullable_htmlentities($row['company_zip']); $company_zip = nullable_htmlentities($row['company_zip']);
$company_phone_country_code = nullable_htmlentities($row['company_phone_country_code']); $company_phone = formatPhoneNumber($row['company_phone']);
$company_phone = nullable_htmlentities(formatPhoneNumber($row['company_phone'], $company_phone_country_code));
$company_email = nullable_htmlentities($row['company_email']); $company_email = nullable_htmlentities($row['company_email']);
$company_website = nullable_htmlentities($row['company_website']); $company_website = nullable_htmlentities($row['company_website']);
$company_logo = nullable_htmlentities($row['company_logo']); $company_logo = nullable_htmlentities($row['company_logo']);
@@ -720,5 +717,5 @@ if ($quote_status == "Draft" || $quote_status == "Sent" || $quote_status == "Vie
<?php <?php
require_once "guest_quote_upload_file_modal.php"; require_once "guest_quote_upload_file_modal.php";
require_once "includes/guest_footer.php"; require_once "guest_footer.php";

View File

@@ -1,6 +1,6 @@
<?php <?php
require_once "includes/guest_header.php"; require_once "guest_header.php";
//Initialize the HTML Purifier to prevent XSS //Initialize the HTML Purifier to prevent XSS
require "../plugins/htmlpurifier/HTMLPurifier.standalone.php"; require "../plugins/htmlpurifier/HTMLPurifier.standalone.php";
@@ -12,14 +12,13 @@ $purifier = new HTMLPurifier($purifier_config);
if (!isset($_GET['ticket_id'], $_GET['url_key'])) { if (!isset($_GET['ticket_id'], $_GET['url_key'])) {
echo "<br><h2>Oops, something went wrong! Please raise a ticket if you believe this is an error.</h2>"; echo "<br><h2>Oops, something went wrong! Please raise a ticket if you believe this is an error.</h2>";
require_once "includes/guest_footer.php"; require_once "guest_footer.php";
exit(); exit();
} }
// Company info // Company info
$company_sql_row = mysqli_fetch_array(mysqli_query($mysqli, "SELECT company_phone, company_website FROM companies, settings WHERE companies.company_id = settings.company_id AND companies.company_id = 1")); $company_sql_row = mysqli_fetch_array(mysqli_query($mysqli, "SELECT company_phone, company_website FROM companies, settings WHERE companies.company_id = settings.company_id AND companies.company_id = 1"));
$company_phone_country_code = nullable_htmlentities($company_sql_row['company_phone_country_code']); $company_phone = formatPhoneNumber($company_sql_row['company_phone']);
$company_phone = nullable_htmlentities(formatPhoneNumber($company_sql_row['company_phone'], $company_phone_country_code));
$company_website = nullable_htmlentities($company_sql_row['company_website']); $company_website = nullable_htmlentities($company_sql_row['company_website']);
$url_key = sanitizeInput($_GET['url_key']); $url_key = sanitizeInput($_GET['url_key']);
@@ -35,7 +34,7 @@ $ticket_sql = mysqli_query($mysqli,
if (mysqli_num_rows($ticket_sql) !== 1) { if (mysqli_num_rows($ticket_sql) !== 1) {
// Invalid invoice/key // Invalid invoice/key
echo "<br><h2>Oops, something went wrong! Please raise a ticket if you believe this is an error.</h2>"; echo "<br><h2>Oops, something went wrong! Please raise a ticket if you believe this is an error.</h2>";
require_once "includes/guest_footer.php"; require_once "guest_footer.php";
exit(); exit();
} }
@@ -209,4 +208,4 @@ if ($ticket_row) {
</div> </div>
<?php <?php
require_once "includes/guest_footer.php"; require_once "guest_footer.php";

View File

@@ -2,7 +2,7 @@
require_once "../config.php"; require_once "../config.php";
require_once "../functions.php"; require_once "../functions.php";
require_once "check_login.php"; require_once "../check_login.php";
header('Content-Type: application/json'); header('Content-Type: application/json');

View File

@@ -5,4 +5,4 @@
* Update this file each time we merge develop into master. Format is YY.MM (add a .v if there is more than one release a month. * Update this file each time we merge develop into master. Format is YY.MM (add a .v if there is more than one release a month.
*/ */
DEFINE("APP_VERSION", "25.03"); DEFINE("APP_VERSION", "25.02");

View File

@@ -74,26 +74,14 @@
<p> <p>
Recurring Tickets Recurring Tickets
<?php <?php
if ($num_recurring_tickets) { ?> if ($num_scheduled_tickets) { ?>
<span class="right badge"><?php echo $num_recurring_tickets; ?></span> <span class="right badge"><?php echo $num_scheduled_tickets; ?></span>
<?php } ?> <?php } ?>
</p> </p>
</a> </a>
</li> </li>
<li class="nav-item">
<a href="projects.php?client_id=<?php echo $client_id; ?>" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "projects.php" || basename($_SERVER["PHP_SELF"]) == "project_details.php") { echo "active"; } ?>">
<i class="nav-icon fas fa-project-diagram"></i>
<p>
Projects
<?php if ($num_active_projects) { ?>
<span class="right badge text-light" data-toggle="tooltip" title="Open Projects"><?php echo $num_active_projects; ?></span>
<?php } ?>
</p>
</a>
</li>
<?php } ?> <?php } ?>
<li class="nav-item"> <li class="nav-item">
@@ -115,8 +103,8 @@
<p> <p>
Calendar Calendar
<?php <?php
if ($num_calendar_events > 0) { ?> if ($num_events > 0) { ?>
<span class="right badge text-light"><?php echo $num_calendar_events; ?></span> <span class="right badge text-light"><?php echo $num_events; ?></span>
<?php } ?> <?php } ?>
</p> </p>
</a> </a>
@@ -159,8 +147,8 @@
<p> <p>
Credentials Credentials
<?php <?php
if ($num_credentials > 0) { ?> if ($num_logins > 0) { ?>
<span class="right badge text-light"><?php echo $num_credentials; ?></span> <span class="right badge text-light"><?php echo $num_logins; ?></span>
<?php } ?> <?php } ?>
</p> </p>
</a> </a>
@@ -214,7 +202,7 @@
<?php <?php
if ($num_domains > 0) { ?> if ($num_domains > 0) { ?>
<span class="right badge <?php if (isset($num_domains_expiring)) { ?> badge-warning text-dark<?php } ?> <?php if (isset($num_domains_expired)) { ?> badge-danger <?php } ?> text-white"><?php echo $num_domains; ?></span> <span class="right badge <?php if ($num_domains_expiring > 0) { ?> badge-warning text-dark<?php } ?> <?php if ($num_domains_expired > 0) { ?> badge-danger <?php } ?> text-white"><?php echo $num_domains; ?></span>
<?php } ?> <?php } ?>
</p> </p>
</a> </a>
@@ -289,8 +277,8 @@
<p> <p>
Recurring Invoices Recurring Invoices
<?php <?php
if ($num_recurring_invoices) { ?> if ($num_recurring > 0) { ?>
<span class="right badge"><?php echo $num_recurring_invoices; ?></span> <span class="right badge"><?php echo $num_recurring; ?></span>
<?php } ?> <?php } ?>
</p> </p>
</a> </a>

View File

@@ -5,4 +5,4 @@
* It is used in conjunction with database_updates.php * It is used in conjunction with database_updates.php
*/ */
DEFINE("LATEST_DATABASE_VERSION", "2.1.2"); DEFINE("LATEST_DATABASE_VERSION", "1.8.4");

View File

@@ -33,7 +33,7 @@ if (str_contains(basename($_SERVER["PHP_SELF"]), "admin_")) { ?>
<script src="plugins/clipboardjs/clipboard.min.js"></script> <script src="plugins/clipboardjs/clipboard.min.js"></script>
<script src="js/keepalive.js"></script> <script src="js/keepalive.js"></script>
<script src="plugins/DataTables/datatables.min.js"></script> <script src="plugins/DataTables/datatables.min.js"></script>
<script src="plugins/intl-tel-input/js/intlTelInput.min.js"></script>
<!-- AdminLTE App --> <!-- AdminLTE App -->
<script src="plugins/adminlte/js/adminlte.min.js"></script> <script src="plugins/adminlte/js/adminlte.min.js"></script>

View File

@@ -10,7 +10,7 @@ $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('ticket_id') AS nu
$num_active_tickets = $row['num']; $num_active_tickets = $row['num'];
// Recurring Ticket Count // Recurring Ticket Count
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('recurring_ticket_id') AS num FROM recurring_tickets LEFT JOIN clients ON client_id = recurring_ticket_client_id WHERE 1 = 1 $access_permission_query")); $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('scheduled_ticket_id') AS num FROM scheduled_tickets LEFT JOIN clients ON client_id = scheduled_ticket_client_id WHERE 1 = 1 $access_permission_query"));
$num_recurring_tickets = $row['num']; $num_recurring_tickets = $row['num'];
// Active Project Count // Active Project Count
@@ -22,7 +22,7 @@ $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('invoice_id') AS n
$num_open_invoices = $row['num']; $num_open_invoices = $row['num'];
// Recurring Invoice Count // Recurring Invoice Count
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('recurring_invoice_id') AS num FROM recurring_invoices WHERE recurring_invoice_archived_at IS NULL")); $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('recurring_id') AS num FROM recurring WHERE recurring_archived_at IS NULL"));
$num_recurring_invoices = $row['num']; $num_recurring_invoices = $row['num'];
// Open Quotes Count // Open Quotes Count

View File

@@ -39,7 +39,6 @@ header("X-Frame-Options: DENY");
<link href='plugins/daterangepicker/daterangepicker.css' rel='stylesheet' /> <link href='plugins/daterangepicker/daterangepicker.css' rel='stylesheet' />
<link href="plugins/toastr/toastr.min.css" rel="stylesheet"> <link href="plugins/toastr/toastr.min.css" rel="stylesheet">
<link href="plugins/DataTables/datatables.min.css" rel="stylesheet"> <link href="plugins/DataTables/datatables.min.css" rel="stylesheet">
<link href="plugins/intl-tel-input/css/intlTelInput.min.css" rel="stylesheet">
<!-- CSS to allow regular button to show as block button in mobile response view using the class btn-responsive --> <!-- CSS to allow regular button to show as block button in mobile response view using the class btn-responsive -->
<link href="css/itflow_custom.css" rel="stylesheet"> <link href="css/itflow_custom.css" rel="stylesheet">

View File

@@ -61,11 +61,9 @@ if (isset($_GET['client_id'])) {
$contact_name = nullable_htmlentities($row['contact_name']); $contact_name = nullable_htmlentities($row['contact_name']);
$contact_title = nullable_htmlentities($row['contact_title']); $contact_title = nullable_htmlentities($row['contact_title']);
$contact_email = nullable_htmlentities($row['contact_email']); $contact_email = nullable_htmlentities($row['contact_email']);
$contact_phone_country_code = nullable_htmlentities($row['contact_phone_country_code']); $contact_phone = formatPhoneNumber($row['contact_phone']);
$contact_phone = nullable_htmlentities(formatPhoneNumber($row['contact_phone'], $contact_phone_country_code));
$contact_extension = nullable_htmlentities($row['contact_extension']); $contact_extension = nullable_htmlentities($row['contact_extension']);
$contact_mobile_country_code = nullable_htmlentities($row['contact_mobile_country_code']); $contact_mobile = formatPhoneNumber($row['contact_mobile']);
$contact_mobile = nullable_htmlentities(formatPhoneNumber($row['contact_mobile'], $contact_mobile_country_code));
$contact_primary = intval($row['contact_primary']); $contact_primary = intval($row['contact_primary']);
$location_id = intval($row['location_id']); $location_id = intval($row['location_id']);
$location_name = nullable_htmlentities($row['location_name']); $location_name = nullable_htmlentities($row['location_name']);
@@ -74,8 +72,7 @@ if (isset($_GET['client_id'])) {
$location_state = nullable_htmlentities($row['location_state']); $location_state = nullable_htmlentities($row['location_state']);
$location_zip = nullable_htmlentities($row['location_zip']); $location_zip = nullable_htmlentities($row['location_zip']);
$location_country = nullable_htmlentities($row['location_country']); $location_country = nullable_htmlentities($row['location_country']);
$location_phone_country_code = nullable_htmlentities($row['location_phone_country_code']); $location_phone = formatPhoneNumber($row['location_phone']);
$location_phone = nullable_htmlentities(formatPhoneNumber($row['location_phone'], $location_phone_country_code));
$location_primary = intval($row['location_primary']); $location_primary = intval($row['location_primary']);
// Tab Title // No Sanitizing needed // Tab Title // No Sanitizing needed
@@ -118,13 +115,13 @@ if (isset($_GET['client_id'])) {
$balance = $invoice_amounts - $amount_paid; $balance = $invoice_amounts - $amount_paid;
//Get Monthly Recurring Total //Get Monthly Recurring Total
$sql_recurring_monthly_total = mysqli_query($mysqli, "SELECT SUM(recurring_invoice_amount) AS recurring_monthly_total FROM recurring_invoices WHERE recurring_invoice_status = 1 AND recurring_invoice_frequency = 'month' AND recurring_invoice_client_id = $client_id"); $sql_recurring_monthly_total = mysqli_query($mysqli, "SELECT SUM(recurring_amount) AS recurring_monthly_total FROM recurring WHERE recurring_status = 1 AND recurring_frequency = 'month' AND recurring_client_id = $client_id");
$row = mysqli_fetch_array($sql_recurring_monthly_total); $row = mysqli_fetch_array($sql_recurring_monthly_total);
$recurring_monthly_total = floatval($row['recurring_monthly_total']); $recurring_monthly_total = floatval($row['recurring_monthly_total']);
//Get Yearly Recurring Total //Get Yearly Recurring Total
$sql_recurring_yearly_total = mysqli_query($mysqli, "SELECT SUM(recurring_invoice_amount) AS recurring_yearly_total FROM recurring_invoices WHERE recurring_invoice_status = 1 AND recurring_invoice_frequency = 'year' AND recurring_invoice_client_id = $client_id"); $sql_recurring_yearly_total = mysqli_query($mysqli, "SELECT SUM(recurring_amount) AS recurring_yearly_total FROM recurring WHERE recurring_status = 1 AND recurring_frequency = 'year' AND recurring_client_id = $client_id");
$row = mysqli_fetch_array($sql_recurring_yearly_total); $row = mysqli_fetch_array($sql_recurring_yearly_total);
$recurring_yearly_total = floatval($row['recurring_yearly_total']) / 12; $recurring_yearly_total = floatval($row['recurring_yearly_total']) / 12;
@@ -148,12 +145,8 @@ if (isset($_GET['client_id'])) {
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('ticket_id') AS num FROM tickets WHERE ticket_archived_at IS NULL AND ticket_closed_at IS NOT NULL AND ticket_client_id = $client_id")); $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('ticket_id') AS num FROM tickets WHERE ticket_archived_at IS NULL AND ticket_closed_at IS NOT NULL AND ticket_client_id = $client_id"));
$num_closed_tickets = $row['num']; $num_closed_tickets = $row['num'];
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('recurring_ticket_id') AS num FROM recurring_tickets WHERE recurring_ticket_client_id = $client_id")); $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('scheduled_ticket_id') AS num FROM scheduled_tickets WHERE scheduled_ticket_client_id = $client_id"));
$num_recurring_tickets = $row['num']; $num_scheduled_tickets = $row['num'];
// Active Project Count
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('project_id') AS num FROM projects WHERE project_archived_at IS NULL AND project_completed_at IS NULL AND project_client_id = $client_id"));
$num_active_projects = $row['num'];
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('service_id') AS num FROM services WHERE service_client_id = $client_id")); $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('service_id') AS num FROM services WHERE service_client_id = $client_id"));
$num_services = $row['num']; $num_services = $row['num'];
@@ -161,8 +154,8 @@ if (isset($_GET['client_id'])) {
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('vendor_id') AS num FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id AND vendor_template = 0")); $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('vendor_id') AS num FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id AND vendor_template = 0"));
$num_vendors = $row['num']; $num_vendors = $row['num'];
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('credential_id') AS num FROM credentials WHERE credential_archived_at IS NULL AND credential_client_id = $client_id")); $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('login_id') AS num FROM logins WHERE login_archived_at IS NULL AND login_client_id = $client_id"));
$num_credentials = $row['num']; $num_logins = $row['num'];
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('network_id') AS num FROM networks WHERE network_archived_at IS NULL AND network_client_id = $client_id")); $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('network_id') AS num FROM networks WHERE network_archived_at IS NULL AND network_client_id = $client_id"));
$num_networks = $row['num']; $num_networks = $row['num'];
@@ -203,8 +196,8 @@ if (isset($_GET['client_id'])) {
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('quote_id') AS num FROM quotes WHERE quote_archived_at IS NULL AND quote_client_id = $client_id")); $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('quote_id') AS num FROM quotes WHERE quote_archived_at IS NULL AND quote_client_id = $client_id"));
$num_quotes = $row['num']; $num_quotes = $row['num'];
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('recurring_invoice_id') AS num FROM recurring_invoices WHERE recurring_invoice_archived_at IS NULL AND recurring_invoice_client_id = $client_id")); $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"));
$num_recurring_invoices = $row['num']; $num_recurring = $row['num'];
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('payment_id') AS num FROM payments, invoices WHERE payment_invoice_id = invoice_id AND invoice_client_id = $client_id")); $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('payment_id') AS num FROM payments, invoices WHERE payment_invoice_id = invoice_id AND invoice_client_id = $client_id"));
$num_payments = $row['num']; $num_payments = $row['num'];
@@ -215,26 +208,26 @@ if (isset($_GET['client_id'])) {
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('document_id') AS num FROM documents WHERE document_archived_at IS NULL AND document_client_id = $client_id")); $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('document_id') AS num FROM documents WHERE document_archived_at IS NULL AND document_client_id = $client_id"));
$num_documents = $row['num']; $num_documents = $row['num'];
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('event_id') AS num FROM calendar_events WHERE event_client_id = $client_id")); $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('event_id') AS num FROM events WHERE event_client_id = $client_id"));
$num_calendar_events = $row['num']; $num_events = $row['num'];
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('trip_id') AS num FROM trips WHERE trip_archived_at IS NULL AND trip_client_id = $client_id")); $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('trip_id') AS num FROM trips WHERE trip_archived_at IS NULL AND trip_client_id = $client_id"));
$num_trips = $row['num']; $num_trips = $row['num'];
// Expiring Items // Expiring Items
// Count Domains Expiring within 45 Days // Count Domains Expiring within 90 Days
$row = mysqli_fetch_assoc(mysqli_query( $row = mysqli_fetch_assoc(mysqli_query(
$mysqli, $mysqli,
"SELECT COUNT('domain_id') AS num FROM domains "SELECT COUNT('domain_id') AS num FROM domains
WHERE domain_client_id = $client_id WHERE domain_client_id = $client_id
AND domain_expire IS NOT NULL AND domain_expire IS NOT NULL
AND domain_expire < CURRENT_DATE + INTERVAL 45 DAY AND domain_expire < CURRENT_DATE + INTERVAL 90 DAY
AND domain_archived_at IS NULL" AND domain_archived_at IS NULL"
)); ));
$num_domains_expiring_warning= intval($row['num']); $num_domains_expiring = intval($row['num']);
// Count Domains Expired or within 7 days // Count Domains Expired or within 14 days
$row = mysqli_fetch_assoc(mysqli_query( $row = mysqli_fetch_assoc(mysqli_query(
$mysqli, $mysqli,
"SELECT COUNT('domain_id') AS num FROM domains "SELECT COUNT('domain_id') AS num FROM domains
@@ -242,24 +235,24 @@ if (isset($_GET['client_id'])) {
AND domain_expire IS NOT NULL AND domain_expire IS NOT NULL
AND ( AND (
domain_expire < CURRENT_DATE domain_expire < CURRENT_DATE
OR domain_expire < CURRENT_DATE + INTERVAL 7 DAY OR domain_expire < CURRENT_DATE + INTERVAL 14 DAY
) )
AND domain_archived_at IS NULL" AND domain_archived_at IS NULL"
)); ));
$num_domains_urgent = intval($row['num']); $num_domains_expired = intval($row['num']);
// Count Certificates Expiring within 7 Days // Count Certificates Expiring within 90 Days
$row = mysqli_fetch_assoc(mysqli_query( $row = mysqli_fetch_assoc(mysqli_query(
$mysqli, $mysqli,
"SELECT COUNT('certificate_id') AS num FROM certificates "SELECT COUNT('certificate_id') AS num FROM certificates
WHERE certificate_client_id = $client_id WHERE certificate_client_id = $client_id
AND certificate_expire IS NOT NULL AND certificate_expire IS NOT NULL
AND certificate_expire < CURRENT_DATE + INTERVAL 7 DAY AND certificate_expire < CURRENT_DATE + INTERVAL 90 DAY
AND certificate_archived_at IS NULL" AND certificate_archived_at IS NULL"
)); ));
$num_certificates_expiring = intval($row['num']); $num_certificates_expiring = intval($row['num']);
// Count Certificates Expired or within 7 days // Count Certificates Expired or within 14 days
$row = mysqli_fetch_assoc(mysqli_query( $row = mysqli_fetch_assoc(mysqli_query(
$mysqli, $mysqli,
"SELECT COUNT('certificate_id') AS num FROM certificates "SELECT COUNT('certificate_id') AS num FROM certificates
@@ -267,7 +260,7 @@ if (isset($_GET['client_id'])) {
AND certificate_expire IS NOT NULL AND certificate_expire IS NOT NULL
AND ( AND (
certificate_expire < CURRENT_DATE certificate_expire < CURRENT_DATE
OR certificate_expire < CURRENT_DATE + INTERVAL 1 DAY OR certificate_expire < CURRENT_DATE + INTERVAL 14 DAY
) )
AND certificate_archived_at IS NULL" AND certificate_archived_at IS NULL"
)); ));
@@ -279,7 +272,7 @@ if (isset($_GET['client_id'])) {
"SELECT COUNT('software_id') AS num FROM software "SELECT COUNT('software_id') AS num FROM software
WHERE software_client_id = $client_id WHERE software_client_id = $client_id
AND software_expire IS NOT NULL AND software_expire IS NOT NULL
AND software_expire < CURRENT_DATE + INTERVAL 45 DAY AND software_expire < CURRENT_DATE + INTERVAL 90 DAY
AND software_archived_at IS NULL" AND software_archived_at IS NULL"
)); ));
$num_software_expiring = intval($row['num']); $num_software_expiring = intval($row['num']);
@@ -292,7 +285,7 @@ if (isset($_GET['client_id'])) {
AND software_expire IS NOT NULL AND software_expire IS NOT NULL
AND ( AND (
software_expire < CURRENT_DATE software_expire < CURRENT_DATE
OR software_expire < CURRENT_DATE + INTERVAL 7 DAY OR software_expire < CURRENT_DATE + INTERVAL 14 DAY
) )
AND software_archived_at IS NULL" AND software_archived_at IS NULL"
)); ));

View File

@@ -96,13 +96,6 @@
<p>Tickets by Client</p> <p>Tickets by Client</p>
</a> </a>
</li> </li>
<li class="nav-item">
<a href="report_time_by_tech.php" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "report_time_by_tech.php") { echo "active"; } ?>">
<i class="nav-icon fas fa-life-ring"></i>
<p>Time by Technician</p>
</a>
</li>
<?php } ?> <?php } ?>
<?php if (lookupUserPermission("module_credential") >= 1) { ?> <?php if (lookupUserPermission("module_credential") >= 1) { ?>
<li class="nav-item"> <li class="nav-item">

View File

@@ -54,11 +54,9 @@ if (isset($_GET['invoice_id'])) {
$location_state = nullable_htmlentities($row['location_state']); $location_state = nullable_htmlentities($row['location_state']);
$location_zip = nullable_htmlentities($row['location_zip']); $location_zip = nullable_htmlentities($row['location_zip']);
$contact_email = nullable_htmlentities($row['contact_email']); $contact_email = nullable_htmlentities($row['contact_email']);
$contact_phone_country_code = nullable_htmlentities($row['contact_phone_country_code']); $contact_phone = formatPhoneNumber($row['contact_phone']);
$contact_phone = nullable_htmlentities(formatPhoneNumber($row['contact_phone'], $contact_phone_country_code));
$contact_extension = nullable_htmlentities($row['contact_extension']); $contact_extension = nullable_htmlentities($row['contact_extension']);
$contact_mobile_country_code = nullable_htmlentities($row['contact_mobile_country_code']); $contact_mobile = formatPhoneNumber($row['contact_mobile']);
$contact_mobile = nullable_htmlentities(formatPhoneNumber($row['contact_mobile'], $contact_mobile_country_code));
$client_website = nullable_htmlentities($row['client_website']); $client_website = nullable_htmlentities($row['client_website']);
$client_currency_code = nullable_htmlentities($row['client_currency_code']); $client_currency_code = nullable_htmlentities($row['client_currency_code']);
$client_net_terms = intval($row['client_net_terms']); $client_net_terms = intval($row['client_net_terms']);
@@ -79,8 +77,7 @@ if (isset($_GET['invoice_id'])) {
$company_city = nullable_htmlentities($row['company_city']); $company_city = nullable_htmlentities($row['company_city']);
$company_state = nullable_htmlentities($row['company_state']); $company_state = nullable_htmlentities($row['company_state']);
$company_zip = nullable_htmlentities($row['company_zip']); $company_zip = nullable_htmlentities($row['company_zip']);
$company_phone_country_code = nullable_htmlentities($row['company_phone_country_code']); $company_phone = formatPhoneNumber($row['company_phone']);
$company_phone = nullable_htmlentities(formatPhoneNumber($row['company_phone'], $company_phone_country_code));
$company_email = nullable_htmlentities($row['company_email']); $company_email = nullable_htmlentities($row['company_email']);
$company_website = nullable_htmlentities($row['company_website']); $company_website = nullable_htmlentities($row['company_website']);
$company_logo = nullable_htmlentities($row['company_logo']); $company_logo = nullable_htmlentities($row['company_logo']);
@@ -745,13 +742,6 @@ require_once "includes/footer.php";
style: 'invoiceNumber', style: 'invoiceNumber',
width: '*' width: '*'
}, },
<?php if ($invoice_status == "Paid") { ?>
{
text: 'PAID',
style: 'invoicePaid',
width: '*'
},
<?php } ?>
], ],
], ],
}, },
@@ -1041,14 +1031,6 @@ require_once "includes/footer.php";
fontSize: 14, fontSize: 14,
alignment: 'right' alignment: 'right'
}, },
// Invoice Paid
invoicePaid: {
fontSize: 13,
bold: true,
margin: [0,5,0,0],
alignment: 'right',
color: 'green'
},
// Billing Headers // Billing Headers
invoiceBillingTitle: { invoiceBillingTitle: {
fontSize: 14, fontSize: 14,

View File

@@ -33,7 +33,7 @@ $draft_count = $row['num'];
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('invoice_id') AS num FROM invoices WHERE invoice_status = 'Cancelled' $client_query")); $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('invoice_id') AS num FROM invoices WHERE invoice_status = 'Cancelled' $client_query"));
$cancelled_count = $row['num']; $cancelled_count = $row['num'];
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('invoice_id') AS num FROM invoices WHERE invoice_status NOT LIKE 'Draft' AND invoice_status NOT LIKE 'Paid' AND invoice_status NOT LIKE 'Cancelled' AND invoice_status NOT LIKE 'Non-Billable' AND invoice_due < CURDATE() $client_query")); $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('invoice_id') AS num FROM invoices WHERE invoice_status NOT LIKE 'Draft' AND invoice_status NOT LIKE 'Paid' AND invoice_status NOT LIKE 'Cancelled' AND invoice_due < CURDATE() $client_query"));
$overdue_count = $row['num']; $overdue_count = $row['num'];
$sql_total_draft_amount = mysqli_query($mysqli, "SELECT SUM(invoice_amount) AS total_draft_amount FROM invoices WHERE invoice_status = 'Draft' $client_query"); $sql_total_draft_amount = mysqli_query($mysqli, "SELECT SUM(invoice_amount) AS total_draft_amount FROM invoices WHERE invoice_status = 'Draft' $client_query");
@@ -180,16 +180,9 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-8"> <div class="col-sm-8">
<?php if ($client_url) { ?> <div class="btn-group float-right">
<div class="float-right">
<div class="btn-group float-right">
<?php if ($balance > 0) { ?>
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#addBulkPaymentModal"><i class="fa fa-credit-card mr-2"></i>Batch Payment</button>
<?php } ?>
</div>
</div> </div>
<?php } ?>
</div> </div>
</div> </div>
<div class="collapse mt-3 <?php if (!empty($_GET['dtf']) || $_GET['canned_date'] !== "custom" ) { echo "show"; } ?>" id="advancedFilter"> <div class="collapse mt-3 <?php if (!empty($_GET['dtf']) || $_GET['canned_date'] !== "custom" ) { echo "show"; } ?>" id="advancedFilter">
@@ -387,6 +380,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<?php <?php
require_once "modals/invoice_add_modal.php"; require_once "modals/invoice_add_modal.php";
if ($client_url) { require_once "modals/invoice_payment_add_bulk_modal.php"; }
require_once "modals/invoice_export_modal.php"; require_once "modals/invoice_export_modal.php";
require_once "includes/footer.php"; require_once "includes/footer.php";

View File

@@ -1,5 +1,5 @@
document.getElementById('rewordButton').addEventListener('click', function() { document.getElementById('rewordButton').addEventListener('click', function() {
var textInput = this.closest('form').querySelector('textarea'); var textInput = document.getElementById('textInput');
var ticketDescription = document.getElementById('ticketDescription'); var ticketDescription = document.getElementById('ticketDescription');
var rewordButton = document.getElementById('rewordButton'); var rewordButton = document.getElementById('rewordButton');
var undoButton = document.getElementById('undoButton'); var undoButton = document.getElementById('undoButton');

View File

@@ -27,6 +27,7 @@ $(document).on('click', '[data-toggle="ajax-modal"]', function (e) {
method: 'GET', method: 'GET',
data: { id: ajaxId }, data: { id: ajaxId },
dataType: 'json', dataType: 'json',
cache: false, // Prevent caching if necessary
success: function (response) { success: function (response) {
if (response.error) { if (response.error) {
alert(response.error); alert(response.error);
@@ -41,7 +42,7 @@ $(document).on('click', '[data-toggle="ajax-modal"]', function (e) {
// Build the modal HTML using the returned title and content. // Build the modal HTML using the returned title and content.
var modalHtml = var modalHtml =
'<div class="modal fade" id="' + modalId + '" tabindex="-1">' + '<div class="modal text-sm" id="' + modalId + '" tabindex="-1">' +
' <div class="modal-dialog modal-'+ modalSize +'">' + ' <div class="modal-dialog modal-'+ modalSize +'">' +
' <div class="modal-content bg-dark">' ' <div class="modal-content bg-dark">'
+ response.content + + response.content +
@@ -50,7 +51,7 @@ $(document).on('click', '[data-toggle="ajax-modal"]', function (e) {
'</div>'; '</div>';
// Append the modal to the body and show it. // Append the modal to the body and show it.
$('.content-wrapper').append(modalHtml); $('body').append(modalHtml);
var $modal = $('#' + modalId); var $modal = $('#' + modalId);
$modal.modal('show'); $modal.modal('show');

Some files were not shown because too many files have changed in this diff Show More